Index: lib/CodeGen/CGExpr.cpp =================================================================== --- lib/CodeGen/CGExpr.cpp +++ lib/CodeGen/CGExpr.cpp @@ -3010,6 +3010,7 @@ llvm::Function *F = llvm::Function::Create( llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false), llvm::GlobalValue::WeakAnyLinkage, "__cfi_check", M); + CGM.setDSOLocal(F); llvm::BasicBlock *BB = llvm::BasicBlock::Create(Ctx, "entry", F); // FIXME: consider emitting an intrinsic call like // call void @llvm.cfi_check(i64 %0, i8* %1, i8* %2) Index: test/CodeGen/cfi-icall-cross-dso.c =================================================================== --- test/CodeGen/cfi-icall-cross-dso.c +++ test/CodeGen/cfi-icall-cross-dso.c @@ -66,6 +66,9 @@ inline void foo() {} void bar() { foo(); } +// ITANIUM: define weak void @__cfi_check +// MS: define weak dso_local void @__cfi_check + // CHECK: !{i32 4, !"Cross-DSO CFI", i32 1} // Check that the type entries are correct.