Skip to content

Commit f614a47

Browse files
committed
wip
1 parent bba8dfe commit f614a47

File tree

1 file changed

+9
-35
lines changed

1 file changed

+9
-35
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,22 +1295,6 @@ struct FunctionStackPoisoner : public InstVisitor<FunctionStackPoisoner> {
12951295

12961296
} // end anonymous namespace
12971297

1298-
static void DisableSanitizerForAllCalledFunctions(Function *F, CallGraph &CG) {
1299-
if (F->hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
1300-
return;
1301-
F->addFnAttr(Attribute::DisableSanitizerInstrumentation);
1302-
1303-
CallGraphNode *CGN = CG[F];
1304-
if (!CGN)
1305-
return;
1306-
for (auto &CallRecord : *CGN) {
1307-
CallGraphNode *CalleeNode = CallRecord.second;
1308-
Function *CalleeFunction = CalleeNode->getFunction();
1309-
if (CalleeFunction)
1310-
DisableSanitizerForAllCalledFunctions(CalleeFunction, CG);
1311-
}
1312-
}
1313-
13141298
static StringMap<GlobalVariable *> GlobalStringMap;
13151299

13161300
static GlobalVariable *GetOrCreateGlobalString(Module &M, StringRef Name,
@@ -1334,7 +1318,6 @@ static GlobalVariable *GetOrCreateGlobalString(Module &M, StringRef Name,
13341318
static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM) {
13351319
SmallVector<Function *> SpirFixupKernels;
13361320
SmallVector<Constant *, 8> SpirKernelsMetadata;
1337-
CallGraph CG(M);
13381321

13391322
auto DL = M.getDataLayout();
13401323
Type *IntptrTy = DL.getIntPtrType(M.getContext());
@@ -1353,25 +1336,14 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM) {
13531336
auto *KernelNameGV = GetOrCreateGlobalString(M, "__asan_kernel", KernelName,
13541337
kSpirOffloadGlobalAS);
13551338

1356-
bool IsKernelFixup = true;
1357-
bool IsESIMDKernel = F.hasMetadata("sycl_explicit_simd");
1358-
1359-
// FIXME: ESIMD kernel doesn't support noinline functions, so we can't
1360-
// support sanitizer for it
1361-
if (IsESIMDKernel || !F.hasFnAttribute(Attribute::SanitizeAddress) ||
1339+
if (!F.hasFnAttribute(Attribute::SanitizeAddress) ||
13621340
F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
1363-
IsKernelFixup = false;
1341+
continue;
13641342

1365-
if (IsKernelFixup) {
1366-
SpirFixupKernels.emplace_back(&F);
1367-
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
1368-
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
1369-
ConstantInt::get(IntptrTy, KernelName.size())));
1370-
} else {
1371-
F.removeFnAttr(Attribute::SanitizeAddress);
1372-
if (IsESIMDKernel)
1373-
DisableSanitizerForAllCalledFunctions(&F, CG);
1374-
}
1343+
SpirFixupKernels.emplace_back(&F);
1344+
SpirKernelsMetadata.emplace_back(ConstantStruct::get(
1345+
StructTy, ConstantExpr::getPointerCast(KernelNameGV, IntptrTy),
1346+
ConstantInt::get(IntptrTy, KernelName.size())));
13751347
}
13761348

13771349
// Create global variable to record spirv kernels' information
@@ -1540,10 +1512,12 @@ PreservedAnalyses AddressSanitizerPass::run(Module &M,
15401512

15411513
if (Triple(M.getTargetTriple()).isSPIROrSPIRV()) {
15421514
ExtendSpirKernelArgs(M, FAM);
1515+
Modified = true;
1516+
15431517
// FIXME: W/A skip instrumentation if this module has ESIMD
15441518
for (auto &F : M) {
15451519
if (F.hasMetadata("sycl_explicit_simd"))
1546-
return PreservedAnalyses::all();
1520+
return PreservedAnalyses::none();
15471521
}
15481522
}
15491523

0 commit comments

Comments
 (0)