From: Rafael Espindola Date: Thu, 29 Mar 2018 22:08:01 +0000 (+0000) Subject: Set dso_local on cfi_slowpath. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c828ac533bb785c90b83fee1958fe11678f4f8c6;p=clang Set dso_local on cfi_slowpath. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328836 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 36e7da85cc..2ca3756da3 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -2975,6 +2975,7 @@ void CodeGenFunction::EmitCfiSlowPathCheck( bool WithDiag = !CGM.getCodeGenOpts().SanitizeTrap.has(Kind); llvm::CallInst *CheckCall; + llvm::Constant *SlowPathFn; if (WithDiag) { llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs); auto *InfoPtr = @@ -2983,20 +2984,20 @@ void CodeGenFunction::EmitCfiSlowPathCheck( InfoPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); CGM.getSanitizerMetadata()->disableSanitizerForGlobal(InfoPtr); - llvm::Constant *SlowPathDiagFn = CGM.getModule().getOrInsertFunction( + SlowPathFn = CGM.getModule().getOrInsertFunction( "__cfi_slowpath_diag", llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false)); CheckCall = Builder.CreateCall( - SlowPathDiagFn, - {TypeId, Ptr, Builder.CreateBitCast(InfoPtr, Int8PtrTy)}); + SlowPathFn, {TypeId, Ptr, Builder.CreateBitCast(InfoPtr, Int8PtrTy)}); } else { - llvm::Constant *SlowPathFn = CGM.getModule().getOrInsertFunction( + SlowPathFn = CGM.getModule().getOrInsertFunction( "__cfi_slowpath", llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy}, false)); CheckCall = Builder.CreateCall(SlowPathFn, {TypeId, Ptr}); } + CGM.setDSOLocal(cast(SlowPathFn->stripPointerCasts())); CheckCall->setDoesNotThrow(); EmitBlock(Cont); diff --git a/test/CodeGen/cfi-icall-cross-dso.c b/test/CodeGen/cfi-icall-cross-dso.c index 4fe4ba7b58..1df20aa1c8 100644 --- a/test/CodeGen/cfi-icall-cross-dso.c +++ b/test/CodeGen/cfi-icall-cross-dso.c @@ -39,6 +39,11 @@ // MS-DIAG: call void @__cfi_slowpath_diag(i64 4195979634929632483, i8* %{{.*}}, {{.*}}@[[DATA]]{{.*}}) {{.*}}, !nosanitize // MS-TRAP: call void @__cfi_slowpath(i64 4195979634929632483, i8* %{{.*}}) {{.*}}, !nosanitize +// ITANIUM-DIAG: declare void @__cfi_slowpath_diag( +// ITANIUM-TRAP: declare void @__cfi_slowpath( +// MS-DIAG: declare dso_local void @__cfi_slowpath_diag( +// MS-TRAP: declare dso_local void @__cfi_slowpath( + void caller(void (*f)()) { f(); }