Skip to content

Commit 2e08e44

Browse files
committed
nit
1 parent 1aa7a67 commit 2e08e44

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

libdevice/sanitizer_utils.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ constexpr size_t AlignMask(size_t n) { return n - 1; }
667667
///
668668
/// ASAN Load/Store Report Built-ins
669669
///
670+
/// NOTE:
671+
/// if __AsanLaunchInfo equals 0, the sanitizer is disabled for this launch
672+
///
670673

671674
#define ASAN_REPORT_ERROR_BASE(type, is_write, size, as) \
672675
DEVICE_EXTERN_C_NOINLINE void __asan_##type##size##_as##as( \

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,15 +1332,15 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM) {
13321332
if (F.getCallingConv() != CallingConv::SPIR_KERNEL)
13331333
continue;
13341334

1335-
auto KernelName = F.getName();
1336-
auto *KernelNameGV = GetOrCreateGlobalString(M, "__asan_kernel", KernelName,
1337-
kSpirOffloadGlobalAS);
1338-
13391335
if (!F.hasFnAttribute(Attribute::SanitizeAddress) ||
13401336
F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
13411337
continue;
13421338

13431339
SpirFixupKernels.emplace_back(&F);
1340+
1341+
auto KernelName = F.getName();
1342+
auto *KernelNameGV = GetOrCreateGlobalString(M, "__asan_kernel", KernelName,
1343+
kSpirOffloadGlobalAS);
13441344
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
13451345
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
13461346
ConstantInt::get(IntptrTy, KernelName.size())));
@@ -1528,10 +1528,8 @@ PreservedAnalyses AddressSanitizerPass::run(Module &M,
15281528
Options.UseAfterScope, Options.UseAfterReturn);
15291529
const TargetLibraryInfo &TLI = FAM.getResult<TargetLibraryAnalysis>(F);
15301530
Modified |= FunctionSanitizer.instrumentFunction(F, &TLI);
1531-
if (F.getCallingConv() == CallingConv::SPIR_KERNEL) {
1531+
if (F.getCallingConv() == CallingConv::SPIR_KERNEL)
15321532
FunctionSanitizer.instrumentInitAsanLaunchInfo(F, &TLI);
1533-
Modified = true;
1534-
}
15351533
}
15361534
Modified |= ModuleSanitizer.instrumentModule();
15371535
if (!Modified)
@@ -1829,6 +1827,8 @@ void AddressSanitizer::instrumentInitAsanLaunchInfo(
18291827
return;
18301828
}
18311829
}
1830+
// FIXME: if the initial value of "__AsanLaunchInfo" is zero, we'll not need
1831+
// this step
18321832
initializeCallbacks(TLI);
18331833
IRB.CreateStore(
18341834
ConstantPointerNull::get(IntptrTy->getPointerTo(kSpirOffloadGlobalAS)),

0 commit comments

Comments
 (0)