Skip to content

Commit ef4d66a

Browse files
authored
[DeviceSAN] Fix kernel name addressspace (#16425)
Fix llvm-spirv: Invalid SPIR-V module: Casts from private/local/global address space are allowed only to generic
1 parent 7a4a978 commit ef4d66a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM,
13581358

13591359
auto KernelName = F.getName();
13601360
auto *KernelNameGV = GetOrCreateGlobalString(
1361-
M, "__asan_kernel", KernelName, kSpirOffloadGlobalAS);
1361+
M, "__asan_kernel", KernelName, kSpirOffloadConstantAS);
13621362
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
13631363
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
13641364
ConstantInt::get(IntptrTy, KernelName.size())));

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ Constant *getOrCreateGlobalString(Module &M, StringRef Name, StringRef Value,
763763
static void extendSpirKernelArgs(Module &M) {
764764
SmallVector<Constant *, 8> SpirKernelsMetadata;
765765

766-
auto DL = M.getDataLayout();
766+
const auto &DL = M.getDataLayout();
767767
Type *IntptrTy = DL.getIntPtrType(M.getContext());
768768

769769
// SpirKernelsMetadata only saves fixed kernels, and is described by
@@ -781,7 +781,7 @@ static void extendSpirKernelArgs(Module &M) {
781781

782782
auto KernelName = F.getName();
783783
auto *KernelNameGV = getOrCreateGlobalString(M, "__msan_kernel", KernelName,
784-
kSpirOffloadGlobalAS);
784+
kSpirOffloadConstantAS);
785785
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
786786
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
787787
ConstantInt::get(IntptrTy, KernelName.size())));

0 commit comments

Comments
 (0)