Skip to content

Commit

Permalink
Merge branch 'main' into vkd1
Browse files Browse the repository at this point in the history
  • Loading branch information
vdonaldson authored Dec 5, 2024
2 parents 14a4472 + 32b821c commit e1fb4ca
Show file tree
Hide file tree
Showing 44 changed files with 314 additions and 1,440 deletions.
1 change: 1 addition & 0 deletions clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,7 @@ void MicrosoftCXXNameMangler::mangleFloat(llvm::APFloat Number) {
case APFloat::S_x87DoubleExtended: Out << 'X'; break;
case APFloat::S_IEEEquad: Out << 'Y'; break;
case APFloat::S_PPCDoubleDouble: Out << 'Z'; break;
case APFloat::S_PPCDoubleDoubleLegacy:
case APFloat::S_Float8E5M2:
case APFloat::S_Float8E4M3:
case APFloat::S_Float8E4M3FN:
Expand Down
30 changes: 15 additions & 15 deletions clang/lib/Driver/ToolChains/Fuchsia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,19 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
addLinkerCompressDebugSectionsOption(ToolChain, Args, CmdArgs);
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);

// Sample these options first so they are claimed even under -nostdlib et al.
bool NoLibc = Args.hasArg(options::OPT_nolibc);
bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
!Args.hasArg(options::OPT_static);
bool Pthreads = Args.hasArg(options::OPT_pthread, options::OPT_pthreads);
bool SplitStack = Args.hasArg(options::OPT_fsplit_stack);
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
if (Args.hasArg(options::OPT_static))
CmdArgs.push_back("-Bdynamic");

if (D.CCCIsCXX()) {
if (ToolChain.ShouldLinkCXXStdlib(Args)) {
bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
!Args.hasArg(options::OPT_static);
CmdArgs.push_back("--push-state");
CmdArgs.push_back("--as-needed");
if (OnlyLibstdcxxStatic)
Expand All @@ -188,14 +192,13 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,

AddRunTimeLibs(ToolChain, D, CmdArgs, Args);

if (Args.hasArg(options::OPT_pthread) ||
Args.hasArg(options::OPT_pthreads))
if (Pthreads)
CmdArgs.push_back("-lpthread");

if (Args.hasArg(options::OPT_fsplit_stack))
if (SplitStack)
CmdArgs.push_back("--wrap=pthread_create");

if (!Args.hasArg(options::OPT_nolibc))
if (!NoLibc)
CmdArgs.push_back("-lc");
}

Expand Down Expand Up @@ -229,7 +232,7 @@ void fuchsia::StaticLibTool::ConstructJob(Compilation &C, const JobAction &JA,

for (const auto &II : Inputs) {
if (II.isFilename()) {
CmdArgs.push_back(II.getFilename());
CmdArgs.push_back(II.getFilename());
}
}

Expand Down Expand Up @@ -343,16 +346,14 @@ std::string Fuchsia::ComputeEffectiveClangTriple(const ArgList &Args,
return Triple.str();
}

Tool *Fuchsia::buildLinker() const {
return new tools::fuchsia::Linker(*this);
}
Tool *Fuchsia::buildLinker() const { return new tools::fuchsia::Linker(*this); }

Tool *Fuchsia::buildStaticLibTool() const {
return new tools::fuchsia::StaticLibTool(*this);
}

ToolChain::RuntimeLibType Fuchsia::GetRuntimeLibType(
const ArgList &Args) const {
ToolChain::RuntimeLibType
Fuchsia::GetRuntimeLibType(const ArgList &Args) const {
if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) {
StringRef Value = A->getValue();
if (Value != "compiler-rt")
Expand All @@ -363,13 +364,12 @@ ToolChain::RuntimeLibType Fuchsia::GetRuntimeLibType(
return ToolChain::RLT_CompilerRT;
}

ToolChain::CXXStdlibType
Fuchsia::GetCXXStdlibType(const ArgList &Args) const {
ToolChain::CXXStdlibType Fuchsia::GetCXXStdlibType(const ArgList &Args) const {
if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
StringRef Value = A->getValue();
if (Value != "libc++")
getDriver().Diag(diag::err_drv_invalid_stdlib_name)
<< A->getAsString(Args);
<< A->getAsString(Args);
}

return ToolChain::CST_Libcxx;
Expand Down
2 changes: 1 addition & 1 deletion clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ __global__ void kernel4(struct S s) {
// CHECK-SPIRV-NEXT: ret void
//
// OPT-LABEL: define dso_local amdgpu_kernel void @_Z7kernel5P1S(
// OPT-SAME: ptr addrspace(1) nocapture noundef readonly [[S_COERCE:%.*]]) local_unnamed_addr #[[ATTR3:[0-9]+]] {
// OPT-SAME: ptr addrspace(1) nocapture noundef readonly [[S_COERCE:%.*]]) local_unnamed_addr #[[ATTR2]] {
// OPT-NEXT: [[ENTRY:.*:]]
// OPT-NEXT: [[TMP0:%.*]] = load ptr, ptr addrspace(1) [[S_COERCE]], align 8
// OPT-NEXT: [[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/fuchsia.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,9 @@
// RUN: %clang --target=riscv64-unknown-fuchsia -mno-relax -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=RISCV64-FLAGS %s
// RISCV64-FLAGS: "-X" "--no-relax"

// RUN: %clang -### %s --target=x86_64-unknown-fuchsia 2>&1 \
// RUN: -nostdlib -nolibc \
// RUN: | FileCheck %s -check-prefix=CHECK-NOSTDLIB-NOLIBC
// CHECK-NOSTDLIB-NOLIBC-NOT: "warning:"
// CHECK-NOSTDLIB-NOLIBC-NOT: "error:"
2 changes: 1 addition & 1 deletion flang/test/Evaluate/fold-ieee.f90
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module m
logical, parameter :: test_sn_all = ieee_support_subnormal()
logical, parameter :: test_sn_4 = ieee_support_subnormal(1.)
logical, parameter :: test_sn_8 = ieee_support_subnormal(1.d0)
! logical, parameter :: test_uc_all = .not. ieee_support_underflow_control() ! varies by architecture
! logical, parameter :: test_uc_all = .not. ieee_support_underflow_control()
! logical, parameter :: test_uc_4 = ieee_support_underflow_control(1.)
! logical, parameter :: test_uc_8 = ieee_support_underflow_control(1.d0)
end
2 changes: 1 addition & 1 deletion libc/docs/fenv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Macros
:align: center
:header-rows: 1

* - Function
* - Macro
- Implemented
- C23 Standard Section
- POSIX.1-2017 Standard Section
Expand Down
33 changes: 30 additions & 3 deletions libc/docs/setjmp.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
.. include:: check.rst

setjmp.h Functions
==================
========
setjmp.h
========

Macros
======

.. list-table::
:widths: auto
:align: center
:header-rows: 1

* - Macro
- Implemented
- C23 Standard Section
- POSIX.1-2017 Standard Section
* - __STDC_VERSION_SETJMP_H__
-
- 7.13.2
-

Functions
=========

.. list-table::
:widths: auto
Expand All @@ -10,7 +31,13 @@ setjmp.h Functions

* - Function
- Implemented
- Standard
- C23 Standard Section
- POSIX.1-2017 Standard Section
* - longjmp
- |check|
- 7.13.2.1
-
* - setjmp
- |check|
- 7.13.1.1
-
2 changes: 1 addition & 1 deletion libc/docs/signal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Macros
:align: center
:header-rows: 1

* - Function
* - Macro
- Implemented
- C23 Standard Section
- POSIX.1-2017 Standard Section
Expand Down
2 changes: 1 addition & 1 deletion libc/docs/stdbit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Macros
:align: center
:header-rows: 1

* - Function
* - Macro
- Implemented
- C23 Standard Section
- POSIX.1-2017 Standard Section
Expand Down
2 changes: 1 addition & 1 deletion libc/docs/threads.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Macros
:align: center
:header-rows: 1

* - Function
* - Macro
- Implemented
- C23 Standard Section
- POSIX.1-2017 Standard Section
Expand Down
8 changes: 4 additions & 4 deletions libc/utils/docgen/docgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ def load_api(header: Header) -> Dict:
return json.loads(api)


def print_tbl_dir():
def print_tbl_dir(name):
print(
f"""
.. list-table::
:widths: auto
:align: center
:header-rows: 1
* - Function
* - {name}
- Implemented
- C23 Standard Section
- POSIX.1-2017 Standard Section"""
Expand All @@ -112,7 +112,7 @@ def print_functions_rst(header: Header, functions: Dict):
print(tbl_hdr)
print("=" * len(tbl_hdr))

print_tbl_dir()
print_tbl_dir("Function")

for name in sorted(functions.keys()):
print(f" * - {name}")
Expand All @@ -138,7 +138,7 @@ def print_macros_rst(header: Header, macros: Dict):
print(tbl_hdr)
print("=" * len(tbl_hdr))

print_tbl_dir()
print_tbl_dir("Macro")

for name in sorted(macros.keys()):
print(f" * - {name}")
Expand Down
10 changes: 5 additions & 5 deletions libc/utils/docgen/setjmp.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"macros": {
"__STDC_VERSION_SETJMP_H__": {
"defined": "7.13.2"
},
"setjmp": {
"defined": "7.13.1.1"
"c-definition": "7.13.2"
}
},
"functions": {
"setjmp": {
"c-definition": "7.13.1.1"
},
"longjmp": {
"defined": "7.13.2.1"
"c-definition": "7.13.2.1"
}
}
}
1 change: 0 additions & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUAttributes.def
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ AMDGPU_ATTRIBUTE(WORKITEM_ID_Z, "amdgpu-no-workitem-id-z")
AMDGPU_ATTRIBUTE(LDS_KERNEL_ID, "amdgpu-no-lds-kernel-id")
AMDGPU_ATTRIBUTE(DEFAULT_QUEUE, "amdgpu-no-default-queue")
AMDGPU_ATTRIBUTE(COMPLETION_ACTION, "amdgpu-no-completion-action")
AMDGPU_ATTRIBUTE(FLAT_SCRATCH_INIT, "amdgpu-no-flat-scratch-init")

#undef AMDGPU_ATTRIBUTE
74 changes: 0 additions & 74 deletions llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,18 +260,6 @@ class AMDGPUInformationCache : public InformationCache {
return !HasAperture && (Access & ADDR_SPACE_CAST);
}

bool checkConstForAddrSpaceCastFromPrivate(const Constant *C) {
SmallPtrSet<const Constant *, 8> Visited;
uint8_t Access = getConstantAccess(C, Visited);

if (Access & ADDR_SPACE_CAST)
if (const auto *CE = dyn_cast<ConstantExpr>(C))
if (CE->getOperand(0)->getType()->getPointerAddressSpace() ==
AMDGPUAS::PRIVATE_ADDRESS)
return true;
return false;
}

private:
/// Used to determine if the Constant needs the queue pointer.
DenseMap<const Constant *, uint8_t> ConstantStatus;
Expand Down Expand Up @@ -536,9 +524,6 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
if (isAssumed(COMPLETION_ACTION) && funcRetrievesCompletionAction(A, COV))
removeAssumedBits(COMPLETION_ACTION);

if (isAssumed(FLAT_SCRATCH_INIT) && needFlatScratchInit(A))
removeAssumedBits(FLAT_SCRATCH_INIT);

return getAssumed() != OrigAssumed ? ChangeStatus::CHANGED
: ChangeStatus::UNCHANGED;
}
Expand Down Expand Up @@ -697,65 +682,6 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
return !A.checkForAllCallLikeInstructions(DoesNotRetrieve, *this,
UsedAssumedInformation);
}

// Returns true if FlatScratchInit is needed, i.e., no-flat-scratch-init is
// not to be set.
bool needFlatScratchInit(Attributor &A) {
assert(isAssumed(FLAT_SCRATCH_INIT)); // only called if the bit is still set

// Check all AddrSpaceCast instructions. FlatScratchInit is needed if
// there is a cast from PRIVATE_ADDRESS.
auto AddrSpaceCastNotFromPrivate = [](Instruction &I) {
return cast<AddrSpaceCastInst>(I).getSrcAddressSpace() !=
AMDGPUAS::PRIVATE_ADDRESS;
};

bool UsedAssumedInformation = false;
if (!A.checkForAllInstructions(AddrSpaceCastNotFromPrivate, *this,
{Instruction::AddrSpaceCast},
UsedAssumedInformation))
return true;

// Check for addrSpaceCast from PRIVATE_ADDRESS in constant expressions
auto &InfoCache = static_cast<AMDGPUInformationCache &>(A.getInfoCache());

Function *F = getAssociatedFunction();
for (Instruction &I : instructions(F)) {
for (const Use &U : I.operands()) {
if (const auto *C = dyn_cast<Constant>(U)) {
if (InfoCache.checkConstForAddrSpaceCastFromPrivate(C))
return true;
}
}
}

// Finally check callees.

// This is called on each callee; false means callee shouldn't have
// no-flat-scratch-init.
auto CheckForNoFlatScratchInit = [&](Instruction &I) {
const auto &CB = cast<CallBase>(I);
const Function *Callee = CB.getCalledFunction();

// Callee == 0 for inline asm or indirect call with known callees.
// In the latter case, updateImpl() already checked the callees and we
// know their FLAT_SCRATCH_INIT bit is set.
// If function has indirect call with unknown callees, the bit is
// already removed in updateImpl() and execution won't reach here.
if (!Callee)
return true;

return Callee->getIntrinsicID() !=
Intrinsic::amdgcn_addrspacecast_nonnull;
};

UsedAssumedInformation = false;
// If any callee is false (i.e. need FlatScratchInit),
// checkForAllCallLikeInstructions returns false, in which case this
// function returns true.
return !A.checkForAllCallLikeInstructions(CheckForNoFlatScratchInit, *this,
UsedAssumedInformation);
}
};

AAAMDAttributes &AAAMDAttributes::createForPosition(const IRPosition &IRP,
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/AMDGPU/addrspacecast-constantexpr.ll
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ attributes #1 = { nounwind }
; AKF_HSA: attributes #[[ATTR1]] = { nounwind }
;.
; ATTRIBUTOR_HSA: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
; ATTRIBUTOR_HSA: attributes #[[ATTR1]] = { nounwind "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
; ATTRIBUTOR_HSA: attributes #[[ATTR2]] = { nounwind "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
; ATTRIBUTOR_HSA: attributes #[[ATTR3]] = { nounwind "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "amdgpu-waves-per-eu"="4,10" "uniform-work-group-size"="false" }
; ATTRIBUTOR_HSA: attributes #[[ATTR1]] = { nounwind "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
; ATTRIBUTOR_HSA: attributes #[[ATTR2]] = { nounwind "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "uniform-work-group-size"="false" }
; ATTRIBUTOR_HSA: attributes #[[ATTR3]] = { nounwind "amdgpu-no-agpr" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "amdgpu-waves-per-eu"="4,10" "uniform-work-group-size"="false" }
;.
; AKF_HSA: [[META0:![0-9]+]] = !{i32 1, !"amdhsa_code_object_version", i32 500}
;.
Expand Down
Loading

0 comments on commit e1fb4ca

Please sign in to comment.