Skip to content

Commit 0d32bec

Browse files
authored
Merge branch 'main' into cfgsimplify
2 parents 0117763 + 3d596ad commit 0d32bec

File tree

76 files changed

+1478
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1478
-143
lines changed

clang/lib/CodeGen/CGPointerAuth.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,10 @@ CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key,
440440
IntegerDiscriminator = llvm::ConstantInt::get(Int64Ty, 0);
441441
}
442442

443-
return llvm::ConstantPtrAuth::get(Pointer,
444-
llvm::ConstantInt::get(Int32Ty, Key),
445-
IntegerDiscriminator, AddressDiscriminator);
443+
return llvm::ConstantPtrAuth::get(
444+
Pointer, llvm::ConstantInt::get(Int32Ty, Key), IntegerDiscriminator,
445+
AddressDiscriminator,
446+
/*DeactivationSymbol=*/llvm::Constant::getNullValue(DefaultPtrTy));
446447
}
447448

448449
/// Does a given PointerAuthScheme require us to sign a value

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
922922
if (IsX86_64 || IsMIPS64 || IsAArch64 || IsPowerPC64 || IsSystemZ ||
923923
IsLoongArch64 || IsRISCV64)
924924
Res |= SanitizerKind::Thread;
925-
if (IsX86_64 || IsAArch64 || IsSystemZ)
925+
if (IsX86_64 || IsAArch64)
926926
Res |= SanitizerKind::Type;
927927
if (IsX86_64 || IsSystemZ || IsPowerPC64)
928928
Res |= SanitizerKind::KernelMemory;

clang/test/Driver/hip-spirv-backend-opt.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,58 @@
44

55
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
66
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
7-
// RUN: -use-spirv-backend --offload-device-only -S \
7+
// RUN: -use-spirv-backend --offload-device-only -S -no-canonical-prefixes \
88
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-TEXTUAL
99

1010
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
1111
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
12-
// RUN: -use-spirv-backend --offload-device-only \
12+
// RUN: -use-spirv-backend --offload-device-only -no-canonical-prefixes \
1313
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BINARY
1414

1515
// The new driver's behavior is to emit LLVM IR for --offload-device-only and -fgpu-rdc (independently of SPIR-V).
1616
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
1717
// RUN: -### -nogpuinc -nogpulib -x hip %s -save-temps \
18-
// RUN: -use-spirv-backend --offload-device-only -S -fgpu-rdc \
18+
// RUN: -use-spirv-backend --offload-device-only -S -fgpu-rdc -no-canonical-prefixes \
1919
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-LL,CHECK-FGPU-RDC
2020

2121
// The new driver's behavior is to emit LLVM IR for --offload-device-only and -fgpu-rdc (independently of SPIR-V).
2222
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
2323
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
24-
// RUN: -use-spirv-backend --offload-device-only -fgpu-rdc \
24+
// RUN: -use-spirv-backend --offload-device-only -fgpu-rdc -no-canonical-prefixes \
2525
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-FGPU-RDC
2626

2727
// --offload-device-only is always unset --- testing interactions with -S and -fgpu-rdc
2828

2929
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
3030
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
31-
// RUN: -use-spirv-backend -S -fgpu-rdc \
31+
// RUN: -use-spirv-backend -S -fgpu-rdc -no-canonical-prefixes \
3232
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-FGPU-RDC
3333

3434
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
3535
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
36-
// RUN: -use-spirv-backend -S \
36+
// RUN: -use-spirv-backend -S -no-canonical-prefixes \
3737
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC
3838

3939
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
4040
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
41-
// RUN: -use-spirv-backend -fgpu-rdc \
41+
// RUN: -use-spirv-backend -fgpu-rdc -no-canonical-prefixes \
4242
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-CLANG-LINKER-WRAPPER
4343

4444
// RUN: %clang --offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
4545
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
46-
// RUN: -use-spirv-backend \
46+
// RUN: -use-spirv-backend -no-canonical-prefixes \
4747
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-CLANG-LINKER-WRAPPER
4848

4949
// RUN: %clang --no-offload-new-driver --target=x86_64-unknown-linux-gnu --offload-arch=amdgcnspirv \
5050
// RUN: -nogpuinc -nogpulib -### -x hip %s -save-temps \
51-
// RUN: -use-spirv-backend \
51+
// RUN: -use-spirv-backend -no-canonical-prefixes \
5252
// RUN: 2>&1 | FileCheck %s --check-prefixes=CHECK-SPIRV-TRANSLATOR,CHECK-SPIRV-BACKEND-BC,CHECK-SPIRV-BACKEND-BINARY-EQ-TRIPLE
5353

5454
// CHECK-SPIRV-TRANSLATOR-NOT: "{{.*llvm-spirv.*}}"
55-
// CHECK-SPIRV-BACKEND-TEXTUAL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-S"
56-
// CHECK-SPIRV-BACKEND-BINARY: "{{.*}}clang{{.*}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-obj"
57-
// CHECK-SPIRV-BACKEND-BC: "{{.*}}clang{{.*}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-llvm-bc"
58-
// CHECK-SPIRV-BACKEND-LL: "{{.*}}clang{{.*}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-llvm"
59-
// CHECK-SPIRV-BACKEND-BINARY-EQ-TRIPLE: "{{.*}}clang{{.*}}" "-cc1" {{.*}}"-triple=spirv64-amd-amdhsa" {{.*}}"-emit-obj"
55+
// CHECK-SPIRV-BACKEND-TEXTUAL: "{{.*clang(\.exe)?}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-S"
56+
// CHECK-SPIRV-BACKEND-BINARY: "{{.*clang(\.exe)?}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-obj"
57+
// CHECK-SPIRV-BACKEND-BC: "{{.*clang(\.exe)?}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-llvm-bc"
58+
// CHECK-SPIRV-BACKEND-LL: "{{.*clang(\.exe)?}}" "-cc1" "-triple" "spirv64-amd-amdhsa" {{.*}} "-emit-llvm"
59+
// CHECK-SPIRV-BACKEND-BINARY-EQ-TRIPLE: "{{.*clang(\.exe)?}}" "-cc1" {{.*}}"-triple=spirv64-amd-amdhsa" {{.*}}"-emit-obj"
6060
// CHECK-FGPU-RDC-SAME: {{.*}} "-fgpu-rdc"
6161
// CHECK-CLANG-LINKER-WRAPPER: "{{.*}}clang-linker-wrapper" "--should-extract=amdgcnspirv" {{.*}} "--device-compiler=spirv64-amd-amdhsa=-use-spirv-backend"

compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ else()
8989
set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X}
9090
${LOONGARCH64} ${RISCV64})
9191
endif()
92-
set(ALL_TYSAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${S390X})
92+
set(ALL_TYSAN_SUPPORTED_ARCH ${X86_64} ${ARM64})
9393
set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${RISCV64}
9494
${MIPS32} ${MIPS64} ${PPC64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
9595
${LOONGARCH64})

compiler-rt/lib/tysan/tysan_platform.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ struct Mapping48 {
4545
static const uptr kPtrShift = 3;
4646
};
4747
#define TYSAN_RUNTIME_VMA 1
48-
#elif defined(__s390x__)
49-
struct Mapping {
50-
static const uptr kShadowAddr = 0x080000000000ULL;
51-
static const uptr kAppAddr = 0x460000000000ULL;
52-
static const uptr kAppMemMsk = ~0xC00000000000ULL;
53-
};
5448
#else
5549
#error "TySan not supported for this platform!"
5650
#endif

flang-rt/lib/cuda/allocator.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
#include "flang/Runtime/CUDA/common.h"
2020
#include "flang/Support/Fortran.h"
2121

22-
#include "cuda_runtime.h"
23-
2422
namespace Fortran::runtime::cuda {
2523

2624
struct DeviceAllocation {
@@ -133,6 +131,15 @@ void RTDEF(CUFRegisterAllocator)() {
133131
allocatorRegistry.Register(
134132
kUnifiedAllocatorPos, {&CUFAllocUnified, CUFFreeUnified});
135133
}
134+
135+
cudaStream_t RTDECL(CUFAssociatedGetStream)(void *p) {
136+
int pos = findAllocation(p);
137+
if (pos >= 0) {
138+
cudaStream_t stream = deviceAllocations[pos].stream;
139+
return stream;
140+
}
141+
return nullptr;
142+
}
136143
}
137144

138145
void *CUFAllocPinned(

flang-rt/unittests/Runtime/CUDA/Allocatable.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,54 @@ TEST(AllocatableCUFTest, StreamDeviceAllocatable) {
121121
cudaDeviceSynchronize();
122122
EXPECT_EQ(cudaSuccess, cudaGetLastError());
123123
}
124+
125+
TEST(AllocatableAsyncTest, StreamDeviceAllocatable) {
126+
using Fortran::common::TypeCategory;
127+
RTNAME(CUFRegisterAllocator)();
128+
// REAL(4), DEVICE, ALLOCATABLE :: a(:)
129+
auto a{createAllocatable(TypeCategory::Real, 4)};
130+
a->SetAllocIdx(kDeviceAllocatorPos);
131+
EXPECT_EQ((int)kDeviceAllocatorPos, a->GetAllocIdx());
132+
EXPECT_FALSE(a->HasAddendum());
133+
RTNAME(AllocatableSetBounds)(*a, 0, 1, 10);
134+
135+
cudaStream_t stream;
136+
cudaStreamCreate(&stream);
137+
EXPECT_EQ(cudaSuccess, cudaGetLastError());
138+
139+
RTNAME(AllocatableAllocate)
140+
(*a, /*asyncObject=*/(int64_t *)&stream, /*hasStat=*/false,
141+
/*errMsg=*/nullptr, __FILE__, __LINE__);
142+
EXPECT_TRUE(a->IsAllocated());
143+
cudaDeviceSynchronize();
144+
EXPECT_EQ(cudaSuccess, cudaGetLastError());
145+
cudaStream_t s = RTDECL(CUFAssociatedGetStream)(a->raw().base_addr);
146+
EXPECT_EQ(s, stream);
147+
RTNAME(AllocatableDeallocate)
148+
(*a, /*hasStat=*/false, /*errMsg=*/nullptr, __FILE__, __LINE__);
149+
EXPECT_FALSE(a->IsAllocated());
150+
cudaDeviceSynchronize();
151+
152+
cudaStream_t defaultStream = 0;
153+
RTNAME(AllocatableAllocate)
154+
(*a, /*asyncObject=*/(int64_t *)&defaultStream, /*hasStat=*/false,
155+
/*errMsg=*/nullptr, __FILE__, __LINE__);
156+
EXPECT_TRUE(a->IsAllocated());
157+
cudaDeviceSynchronize();
158+
EXPECT_EQ(cudaSuccess, cudaGetLastError());
159+
cudaStream_t d = RTDECL(CUFAssociatedGetStream)(a->raw().base_addr);
160+
EXPECT_EQ(d, defaultStream);
161+
RTNAME(AllocatableDeallocate)
162+
(*a, /*hasStat=*/false, /*errMsg=*/nullptr, __FILE__, __LINE__);
163+
EXPECT_FALSE(a->IsAllocated());
164+
cudaDeviceSynchronize();
165+
166+
RTNAME(AllocatableAllocate)
167+
(*a, /*asyncObject=*/nullptr, /*hasStat=*/false, /*errMsg=*/nullptr, __FILE__,
168+
__LINE__);
169+
EXPECT_TRUE(a->IsAllocated());
170+
cudaDeviceSynchronize();
171+
EXPECT_EQ(cudaSuccess, cudaGetLastError());
172+
cudaStream_t empty = RTDECL(CUFAssociatedGetStream)(a->raw().base_addr);
173+
EXPECT_EQ(empty, nullptr);
174+
}

flang/include/flang/Runtime/CUDA/allocator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@
1313
#include "flang/Runtime/descriptor-consts.h"
1414
#include "flang/Runtime/entry-names.h"
1515

16+
#include "cuda_runtime.h"
17+
1618
namespace Fortran::runtime::cuda {
1719

1820
extern "C" {
1921

2022
void RTDECL(CUFRegisterAllocator)();
23+
cudaStream_t RTDECL(CUFAssociatedGetStream)(void *);
2124
}
2225

2326
void *CUFAllocPinned(std::size_t, std::int64_t *);

llvm/docs/LangRef.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3234,6 +3234,24 @@ A "convergencectrl" operand bundle is only valid on a ``convergent`` operation.
32343234
When present, the operand bundle must contain exactly one value of token type.
32353235
See the :doc:`ConvergentOperations` document for details.
32363236

3237+
.. _deactivationsymbol:
3238+
3239+
Deactivation Symbol Operand Bundles
3240+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3241+
3242+
A ``"deactivation-symbol"`` operand bundle is valid on the following
3243+
instructions (AArch64 only):
3244+
3245+
- Call to a normal function with ``notail`` attribute and a first argument and
3246+
return value of type ``ptr``.
3247+
- Call to ``llvm.ptrauth.sign`` or ``llvm.ptrauth.auth`` intrinsics.
3248+
3249+
This operand bundle specifies that if the deactivation symbol is defined
3250+
to a valid value for the target, the marked instruction will return the
3251+
value of its first argument instead of calling the specified function
3252+
or intrinsic. This is achieved with ``PATCHINST`` relocations on the
3253+
target instructions (see the AArch64 psABI for details).
3254+
32373255
.. _moduleasm:
32383256

32393257
Module-Level Inline Assembly
@@ -5284,7 +5302,7 @@ need to refer to the actual function body.
52845302
Pointer Authentication Constants
52855303
--------------------------------
52865304

5287-
``ptrauth (ptr CST, i32 KEY[, i64 DISC[, ptr ADDRDISC]?]?)``
5305+
``ptrauth (ptr CST, i32 KEY[, i64 DISC[, ptr ADDRDISC[, ptr DS]?]?]?)``
52885306

52895307
A '``ptrauth``' constant represents a pointer with a cryptographic
52905308
authentication signature embedded into some bits, as described in the
@@ -5313,6 +5331,11 @@ Otherwise, the expression is equivalent to:
53135331
%tmp2 = call i64 @llvm.ptrauth.sign(i64 ptrtoint (ptr CST to i64), i32 KEY, i64 %tmp1)
53145332
%val = inttoptr i64 %tmp2 to ptr
53155333

5334+
If the deactivation symbol operand ``DS`` has a non-null value,
5335+
the semantics are as if a :ref:`deactivation-symbol operand bundle
5336+
<deactivationsymbol>` were added to the ``llvm.ptrauth.sign`` intrinsic
5337+
calls above, with ``DS`` as the only operand.
5338+
53165339
.. _constantexprs:
53175340

53185341
Constant Expressions

llvm/include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ enum ConstantsCodes {
437437
CST_CODE_CE_GEP_WITH_INRANGE = 31, // [opty, flags, range, n x operands]
438438
CST_CODE_CE_GEP = 32, // [opty, flags, n x operands]
439439
CST_CODE_PTRAUTH = 33, // [ptr, key, disc, addrdisc]
440+
CST_CODE_PTRAUTH2 = 34, // [ptr, key, disc, addrdisc,
441+
// deactivation_symbol]
440442
};
441443

442444
/// CastOpcodes - These are values used in the bitcode files to encode which

0 commit comments

Comments
 (0)