Skip to content

Commit 9e90027

Browse files
committed
[CGException] Remove no-op ptr-to-ptr bitcasts (NFC)
Opaque ptr cleanup effort (NFC).
1 parent ad91473 commit 9e90027

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

clang/lib/CodeGen/CGException.cpp

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,7 @@ static llvm::FunctionCallee getPersonalityFn(CodeGenModule &CGM,
263263
static llvm::Constant *getOpaquePersonalityFn(CodeGenModule &CGM,
264264
const EHPersonality &Personality) {
265265
llvm::FunctionCallee Fn = getPersonalityFn(CGM, Personality);
266-
llvm::PointerType* Int8PtrTy = llvm::PointerType::get(
267-
llvm::Type::getInt8Ty(CGM.getLLVMContext()),
268-
CGM.getDataLayout().getProgramAddressSpace());
269-
270-
return llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(Fn.getCallee()),
271-
Int8PtrTy);
266+
return cast<llvm::Constant>(Fn.getCallee());
272267
}
273268

274269
/// Check whether a landingpad instruction only uses C++ features.
@@ -1838,13 +1833,11 @@ Address CodeGenFunction::recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF,
18381833
auto InsertPair = ParentCGF.EscapedLocals.insert(
18391834
std::make_pair(ParentAlloca, ParentCGF.EscapedLocals.size()));
18401835
int FrameEscapeIdx = InsertPair.first->second;
1841-
// call i8* @llvm.localrecover(i8* bitcast(@parentFn), i8* %fp, i32 N)
1836+
// call ptr @llvm.localrecover(ptr @parentFn, ptr %fp, i32 N)
18421837
llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration(
18431838
&CGM.getModule(), llvm::Intrinsic::localrecover);
1844-
llvm::Constant *ParentI8Fn =
1845-
llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
18461839
RecoverCall = Builder.CreateCall(
1847-
FrameRecoverFn, {ParentI8Fn, ParentFP,
1840+
FrameRecoverFn, {ParentCGF.CurFn, ParentFP,
18481841
llvm::ConstantInt::get(Int32Ty, FrameEscapeIdx)});
18491842

18501843
} else {
@@ -1907,9 +1900,7 @@ void CodeGenFunction::EmitCapturedLocals(CodeGenFunction &ParentCGF,
19071900
// since finally funclets recover the parent FP for us.
19081901
llvm::Function *RecoverFPIntrin =
19091902
CGM.getIntrinsic(llvm::Intrinsic::eh_recoverfp);
1910-
llvm::Constant *ParentI8Fn =
1911-
llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
1912-
ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP});
1903+
ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentCGF.CurFn, EntryFP});
19131904

19141905
// if the parent is a _finally, the passed-in ParentFP is the FP
19151906
// of parent _finally, not Establisher's FP (FP of outermost function).
@@ -1937,19 +1928,15 @@ void CodeGenFunction::EmitCapturedLocals(CodeGenFunction &ParentCGF,
19371928
int FrameEscapeIdx = InsertPair.first->second;
19381929

19391930
// an example of a filter's prolog::
1940-
// %0 = call i8* @llvm.eh.recoverfp(bitcast(@"?fin$0@0@main@@"),..)
1941-
// %1 = call i8* @llvm.localrecover(bitcast(@"?fin$0@0@main@@"),..)
1942-
// %2 = bitcast i8* %1 to i8**
1943-
// %3 = load i8*, i8* *%2, align 8
1944-
// ==> %3 is the frame-pointer of outermost host function
1931+
// %0 = call ptr @llvm.eh.recoverfp(@"?fin$0@0@main@@",..)
1932+
// %1 = call ptr @llvm.localrecover(@"?fin$0@0@main@@",..)
1933+
// %2 = load ptr, ptr %1, align 8
1934+
// ==> %2 is the frame-pointer of outermost host function
19451935
llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration(
19461936
&CGM.getModule(), llvm::Intrinsic::localrecover);
1947-
llvm::Constant *ParentI8Fn =
1948-
llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy);
19491937
ParentFP = Builder.CreateCall(
1950-
FrameRecoverFn, {ParentI8Fn, ParentFP,
1938+
FrameRecoverFn, {ParentCGF.CurFn, ParentFP,
19511939
llvm::ConstantInt::get(Int32Ty, FrameEscapeIdx)});
1952-
ParentFP = Builder.CreateBitCast(ParentFP, CGM.VoidPtrPtrTy);
19531940
ParentFP = Builder.CreateLoad(
19541941
Address(ParentFP, CGM.VoidPtrTy, getPointerAlign()));
19551942
}
@@ -2206,9 +2193,7 @@ void CodeGenFunction::EnterSEHTryStmt(const SEHTryStmt &S) {
22062193
// in place of the RTTI typeinfo global that C++ EH uses.
22072194
llvm::Function *FilterFunc =
22082195
HelperCGF.GenerateSEHFilterFunction(*this, *Except);
2209-
llvm::Constant *OpaqueFunc =
2210-
llvm::ConstantExpr::getBitCast(FilterFunc, Int8PtrTy);
2211-
CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except.ret"));
2196+
CatchScope->setHandler(0, FilterFunc, createBasicBlock("__except.ret"));
22122197
}
22132198

22142199
void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {

0 commit comments

Comments
 (0)