Skip to content

Commit 6841b84

Browse files
AllanZyneKornevNikita
authored andcommitted
[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 45c5577 commit 6841b84

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
@@ -746,7 +746,7 @@ Constant *getOrCreateGlobalString(Module &M, StringRef Name, StringRef Value,
746746
static void extendSpirKernelArgs(Module &M) {
747747
SmallVector<Constant *, 8> SpirKernelsMetadata;
748748

749-
auto DL = M.getDataLayout();
749+
const auto &DL = M.getDataLayout();
750750
Type *IntptrTy = DL.getIntPtrType(M.getContext());
751751

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

765765
auto KernelName = F.getName();
766766
auto *KernelNameGV = getOrCreateGlobalString(M, "__msan_kernel", KernelName,
767-
kSpirOffloadGlobalAS);
767+
kSpirOffloadConstantAS);
768768
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
769769
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
770770
ConstantInt::get(IntptrTy, KernelName.size())));

0 commit comments

Comments
 (0)