Skip to content

Commit a093598

Browse files
committed
Revert "Fix __cfi_check not aligned to 4k on relocatable files with no executable code"
This reverts commit c7cacb2. Broken tests.
1 parent 6239227 commit a093598

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3445,12 +3445,14 @@ void CodeGenFunction::EmitCfiCheckStub() {
34453445
llvm::Function *F = llvm::Function::Create(
34463446
llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false),
34473447
llvm::GlobalValue::WeakAnyLinkage, "__cfi_check", M);
3448-
F->setAlignment(llvm::Align(4096));
34493448
CGM.setDSOLocal(F);
34503449
llvm::BasicBlock *BB = llvm::BasicBlock::Create(Ctx, "entry", F);
3451-
// CrossDSOCFI pass is not executed if there is no executable code.
3452-
SmallVector<llvm::Value*> Args{F->getArg(2), F->getArg(1)};
3453-
llvm::CallInst::Create(M->getFunction("__cfi_check_fail"), Args, "", BB);
3450+
// FIXME: consider emitting an intrinsic call like
3451+
// call void @llvm.cfi_check(i64 %0, i8* %1, i8* %2)
3452+
// which can be lowered in CrossDSOCFI pass to the actual contents of
3453+
// __cfi_check. This would allow inlining of __cfi_check calls.
3454+
llvm::CallInst::Create(
3455+
llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB);
34543456
llvm::ReturnInst::Create(Ctx, nullptr, BB);
34553457
}
34563458

@@ -3544,6 +3546,9 @@ void CodeGenFunction::EmitCfiCheckFail() {
35443546
}
35453547

35463548
FinishFunction();
3549+
// The only reference to this function will be created during LTO link.
3550+
// Make sure it survives until then.
3551+
CGM.addUsedGlobal(F);
35473552
}
35483553

35493554
void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {

clang/test/CodeGen/cfi-cross-dso-align.c

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)