Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2532,10 +2532,12 @@ AsanShadowGlobal = M.getOrInsertGlobal("__asan_shadow", ArrayType::get(IRB.getInt8Ty(), 0)); - AMDGPUAddressShared = M.getOrInsertFunction( - kAMDGPUAddressSharedName, IRB.getInt1Ty(), IRB.getInt8PtrTy()); - AMDGPUAddressPrivate = M.getOrInsertFunction( - kAMDGPUAddressPrivateName, IRB.getInt1Ty(), IRB.getInt8PtrTy()); + if (TargetTriple.isAMDGPU()) { + AMDGPUAddressShared = M.getOrInsertFunction( + kAMDGPUAddressSharedName, IRB.getInt1Ty(), IRB.getInt8PtrTy()); + AMDGPUAddressPrivate = M.getOrInsertFunction( + kAMDGPUAddressPrivateName, IRB.getInt1Ty(), IRB.getInt8PtrTy()); + } } bool AddressSanitizer::maybeInsertAsanInitAtFunctionEntry(Function &F) { Index: llvm/test/Instrumentation/AddressSanitizer/basic.ll =================================================================== --- llvm/test/Instrumentation/AddressSanitizer/basic.ll +++ llvm/test/Instrumentation/AddressSanitizer/basic.ll @@ -187,6 +187,11 @@ ret void } +; CHECK: declare void @__asan_handle_no_return() +; CHECK-NOT: declare i1 @llvm.amdgcn.is.private +; CHECK-NOT: declare i1 @llvm.amdgcn.is.shared +; CHECK: declare void @__asan_init() + ;; ctor/dtor have the nounwind attribute. See uwtable.ll, they additionally have ;; the uwtable attribute with the module flag "uwtable". ; CHECK: define internal void @asan.module_ctor() #[[#ATTR:]] {{(comdat )?}}{