Skip to content

Commit f57c921

Browse files
authored
[DeviceSanitizer] Change "TargetTriple.isSPIR()" to "TargetTriple.isSPIROrSPIRV()" in AddressSanitizer.cpp (#14413)
SYCL is going to switch to SPIR-V backend soon, this PR changed "TargetTriple.isSPIR()" to "TargetTriple.isSPIROrSPIRV()" to improve compatibility
1 parent 9d4b5ef commit f57c921

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ PreservedAnalyses AddressSanitizerPass::run(Module &M,
14091409
const StackSafetyGlobalInfo *const SSGI =
14101410
ClUseStackSafety ? &MAM.getResult<StackSafetyGlobalAnalysis>(M) : nullptr;
14111411

1412-
if (Triple(M.getTargetTriple()).isSPIR()) {
1412+
if (Triple(M.getTargetTriple()).isSPIROrSPIRV()) {
14131413
bool HasESIMDKernel = false;
14141414

14151415
// ESIMD kernel doesn't support noinline functions, so we can't
@@ -1565,7 +1565,7 @@ void AddressSanitizer::AppendDebugInfoToArgs(Instruction *InsertBefore,
15651565

15661566
Value *AddressSanitizer::memToShadow(Value *Shadow, IRBuilder<> &IRB,
15671567
uint32_t AddressSpace) {
1568-
if (TargetTriple.isSPIR()) {
1568+
if (TargetTriple.isSPIROrSPIRV()) {
15691569
return IRB.CreateCall(
15701570
AsanMemToShadow,
15711571
{Shadow, ConstantInt::get(IRB.getInt32Ty(), AddressSpace)},
@@ -1718,7 +1718,7 @@ bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
17181718

17191719
bool AddressSanitizer::ignoreAccess(Instruction *Inst, Value *Ptr) {
17201720
// SPIR has its own rules to filter the instrument accesses
1721-
if (TargetTriple.isSPIR()) {
1721+
if (TargetTriple.isSPIROrSPIRV()) {
17221722
if (isUnsupportedSPIRAccess(Ptr, Inst->getFunction()))
17231723
return true;
17241724
} else {
@@ -2212,7 +2212,7 @@ void AddressSanitizer::instrumentAddress(Instruction *OrigIns,
22122212
Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
22132213
if (UseCalls) {
22142214
if (Exp == 0) {
2215-
if (TargetTriple.isSPIR()) {
2215+
if (TargetTriple.isSPIROrSPIRV()) {
22162216
SmallVector<Value *, 5> Args;
22172217
Args.push_back(AddrLong);
22182218
AppendDebugInfoToArgs(InsertBefore, Addr, Args);
@@ -2294,7 +2294,7 @@ void AddressSanitizer::instrumentUnusualSizeOrAlignment(
22942294
Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
22952295
if (UseCalls) {
22962296
if (Exp == 0) {
2297-
if (TargetTriple.isSPIR()) {
2297+
if (TargetTriple.isSPIROrSPIRV()) {
22982298
SmallVector<Value *, 6> Args;
22992299
Args.push_back(AddrLong);
23002300
Args.push_back(Size);
@@ -3126,7 +3126,7 @@ bool ModuleAddressSanitizer::instrumentModule(Module &M) {
31263126
}
31273127
}
31283128

3129-
if (TargetTriple.isSPIR()) {
3129+
if (TargetTriple.isSPIROrSPIRV()) {
31303130
// Add module metadata "device.sanitizer" for sycl-post-link
31313131
LLVMContext &Ctx = M.getContext();
31323132
auto *MD = M.getOrInsertNamedMetadata("device.sanitizer");
@@ -3189,7 +3189,7 @@ void AddressSanitizer::initializeCallbacks(Module &M, const TargetLibraryInfo *T
31893189
// unsigned int line,
31903190
// char* func
31913191
// )
3192-
if (TargetTriple.isSPIR()) {
3192+
if (TargetTriple.isSPIROrSPIRV()) {
31933193
auto *Int8PtrTy =
31943194
Type::getInt8Ty(*C)->getPointerTo(kSpirOffloadConstantAS);
31953195

@@ -3250,7 +3250,7 @@ void AddressSanitizer::initializeCallbacks(Module &M, const TargetLibraryInfo *T
32503250
AsanShadowGlobal = M.getOrInsertGlobal("__asan_shadow",
32513251
ArrayType::get(IRB.getInt8Ty(), 0));
32523252

3253-
if (TargetTriple.isSPIR()) {
3253+
if (TargetTriple.isSPIROrSPIRV()) {
32543254
// __asan_set_shadow_static_local(
32553255
// uptr ptr,
32563256
// size_t size,
@@ -3375,7 +3375,7 @@ bool AddressSanitizer::instrumentFunction(Function &F,
33753375
if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false;
33763376
if (F.getName().starts_with("__asan_")) return false;
33773377

3378-
if (TargetTriple.isSPIR()) {
3378+
if (TargetTriple.isSPIROrSPIRV()) {
33793379
if (F.getName().contains("__sycl_service_kernel__"))
33803380
return false;
33813381
// Skip referenced-indirectly function as we insert access to shared local
@@ -3471,7 +3471,7 @@ bool AddressSanitizer::instrumentFunction(Function &F,
34713471
NoReturnCalls.push_back(CB);
34723472
}
34733473
if (CallInst *CI = dyn_cast<CallInst>(&Inst)) {
3474-
if (TargetTriple.isSPIR() && CI->getCalledFunction() &&
3474+
if (TargetTriple.isSPIROrSPIRV() && CI->getCalledFunction() &&
34753475
CI->getCalledFunction()->getCallingConv() ==
34763476
llvm::CallingConv::SPIR_FUNC &&
34773477
CI->getCalledFunction()->getName() ==
@@ -3501,7 +3501,7 @@ bool AddressSanitizer::instrumentFunction(Function &F,
35013501
F.getParent()->getDataLayout(), RTCI);
35023502
FunctionModified = true;
35033503
}
3504-
if (TargetTriple.isSPIR()) {
3504+
if (TargetTriple.isSPIROrSPIRV()) {
35053505
for (auto *CI : SyclAllocateLocalMemoryCalls) {
35063506
instrumentSyclStaticLocalMemory(CI);
35073507
FunctionModified = true;
@@ -4027,7 +4027,7 @@ void FunctionStackPoisoner::processStaticAllocas() {
40274027
// The left-most redzone has enough space for at least 4 pointers.
40284028
Value *BasePlus0 = IRB.CreateIntToPtr(LocalStackBase, IntptrPtrTy);
40294029
// SPIRV doesn't use the following metadata
4030-
if (!TargetTriple.isSPIR()) {
4030+
if (!TargetTriple.isSPIROrSPIRV()) {
40314031
// Write the Magic value to redzone[0].
40324032
IRB.CreateStore(ConstantInt::get(IntptrTy, kCurrentStackFrameMagic),
40334033
BasePlus0);

0 commit comments

Comments
 (0)