@@ -3431,14 +3431,12 @@ void CodeGenFunction::EmitCfiCheckStub() {
3431
3431
llvm::Function *F = llvm::Function::Create (
3432
3432
llvm::FunctionType::get (VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false ),
3433
3433
llvm::GlobalValue::WeakAnyLinkage, " __cfi_check" , M);
3434
+ F->setAlignment (llvm::Align (4096 ));
3434
3435
CGM.setDSOLocal (F);
3435
3436
llvm::BasicBlock *BB = llvm::BasicBlock::Create (Ctx, " entry" , F);
3436
- // FIXME: consider emitting an intrinsic call like
3437
- // call void @llvm.cfi_check(i64 %0, i8* %1, i8* %2)
3438
- // which can be lowered in CrossDSOCFI pass to the actual contents of
3439
- // __cfi_check. This would allow inlining of __cfi_check calls.
3440
- llvm::CallInst::Create (
3441
- llvm::Intrinsic::getDeclaration (M, llvm::Intrinsic::trap), " " , BB);
3437
+ // CrossDSOCFI pass is not executed if there is no executable code.
3438
+ SmallVector<llvm::Value*> Args{F->getArg (2 ), F->getArg (1 )};
3439
+ llvm::CallInst::Create (M->getFunction (" __cfi_check_fail" ), Args, " " , BB);
3442
3440
llvm::ReturnInst::Create (Ctx, nullptr , BB);
3443
3441
}
3444
3442
@@ -3532,9 +3530,6 @@ void CodeGenFunction::EmitCfiCheckFail() {
3532
3530
}
3533
3531
3534
3532
FinishFunction ();
3535
- // The only reference to this function will be created during LTO link.
3536
- // Make sure it survives until then.
3537
- CGM.addUsedGlobal (F);
3538
3533
}
3539
3534
3540
3535
void CodeGenFunction::EmitUnreachable (SourceLocation Loc) {
0 commit comments