Skip to content

Commit

Permalink
[DeviceSAN] Fix kernel name addressspace (#16425)
Browse files Browse the repository at this point in the history
Fix llvm-spirv: Invalid SPIR-V module: Casts from private/local/global
address space are allowed only to generic
  • Loading branch information
AllanZyne authored Dec 19, 2024
1 parent 7a4a978 commit ef4d66a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM,

auto KernelName = F.getName();
auto *KernelNameGV = GetOrCreateGlobalString(
M, "__asan_kernel", KernelName, kSpirOffloadGlobalAS);
M, "__asan_kernel", KernelName, kSpirOffloadConstantAS);
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
ConstantInt::get(IntptrTy, KernelName.size())));
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ Constant *getOrCreateGlobalString(Module &M, StringRef Name, StringRef Value,
static void extendSpirKernelArgs(Module &M) {
SmallVector<Constant *, 8> SpirKernelsMetadata;

auto DL = M.getDataLayout();
const auto &DL = M.getDataLayout();
Type *IntptrTy = DL.getIntPtrType(M.getContext());

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

auto KernelName = F.getName();
auto *KernelNameGV = getOrCreateGlobalString(M, "__msan_kernel", KernelName,
kSpirOffloadGlobalAS);
kSpirOffloadConstantAS);
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
ConstantInt::get(IntptrTy, KernelName.size())));
Expand Down

0 comments on commit ef4d66a

Please sign in to comment.