Skip to content

Commit

Permalink
Revert "Fix __cfi_check not aligned to 4k on relocatable files with n…
Browse files Browse the repository at this point in the history
…o executable code"

This reverts commit c7cacb2.

Broken tests.
  • Loading branch information
kongy committed Aug 3, 2023
1 parent 6239227 commit a093598
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
13 changes: 9 additions & 4 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3445,12 +3445,14 @@ void CodeGenFunction::EmitCfiCheckStub() {
llvm::Function *F = llvm::Function::Create(
llvm::FunctionType::get(VoidTy, {Int64Ty, Int8PtrTy, Int8PtrTy}, false),
llvm::GlobalValue::WeakAnyLinkage, "__cfi_check", M);
F->setAlignment(llvm::Align(4096));
CGM.setDSOLocal(F);
llvm::BasicBlock *BB = llvm::BasicBlock::Create(Ctx, "entry", F);
// CrossDSOCFI pass is not executed if there is no executable code.
SmallVector<llvm::Value*> Args{F->getArg(2), F->getArg(1)};
llvm::CallInst::Create(M->getFunction("__cfi_check_fail"), Args, "", BB);
// FIXME: consider emitting an intrinsic call like
// call void @llvm.cfi_check(i64 %0, i8* %1, i8* %2)
// which can be lowered in CrossDSOCFI pass to the actual contents of
// __cfi_check. This would allow inlining of __cfi_check calls.
llvm::CallInst::Create(
llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB);
llvm::ReturnInst::Create(Ctx, nullptr, BB);
}

Expand Down Expand Up @@ -3544,6 +3546,9 @@ void CodeGenFunction::EmitCfiCheckFail() {
}

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

void CodeGenFunction::EmitUnreachable(SourceLocation Loc) {
Expand Down
8 changes: 0 additions & 8 deletions clang/test/CodeGen/cfi-cross-dso-align.c

This file was deleted.

0 comments on commit a093598

Please sign in to comment.