diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 87594f71b26ec..4a54b2040154d 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -263,12 +263,7 @@ static llvm::FunctionCallee getPersonalityFn(CodeGenModule &CGM, static llvm::Constant *getOpaquePersonalityFn(CodeGenModule &CGM, const EHPersonality &Personality) { llvm::FunctionCallee Fn = getPersonalityFn(CGM, Personality); - llvm::PointerType* Int8PtrTy = llvm::PointerType::get( - llvm::Type::getInt8Ty(CGM.getLLVMContext()), - CGM.getDataLayout().getProgramAddressSpace()); - - return llvm::ConstantExpr::getBitCast(cast(Fn.getCallee()), - Int8PtrTy); + return cast(Fn.getCallee()); } /// Check whether a landingpad instruction only uses C++ features. @@ -1838,13 +1833,11 @@ Address CodeGenFunction::recoverAddrOfEscapedLocal(CodeGenFunction &ParentCGF, auto InsertPair = ParentCGF.EscapedLocals.insert( std::make_pair(ParentAlloca, ParentCGF.EscapedLocals.size())); int FrameEscapeIdx = InsertPair.first->second; - // call i8* @llvm.localrecover(i8* bitcast(@parentFn), i8* %fp, i32 N) + // call ptr @llvm.localrecover(ptr @parentFn, ptr %fp, i32 N) llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration( &CGM.getModule(), llvm::Intrinsic::localrecover); - llvm::Constant *ParentI8Fn = - llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy); RecoverCall = Builder.CreateCall( - FrameRecoverFn, {ParentI8Fn, ParentFP, + FrameRecoverFn, {ParentCGF.CurFn, ParentFP, llvm::ConstantInt::get(Int32Ty, FrameEscapeIdx)}); } else { @@ -1907,9 +1900,7 @@ void CodeGenFunction::EmitCapturedLocals(CodeGenFunction &ParentCGF, // since finally funclets recover the parent FP for us. llvm::Function *RecoverFPIntrin = CGM.getIntrinsic(llvm::Intrinsic::eh_recoverfp); - llvm::Constant *ParentI8Fn = - llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy); - ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentI8Fn, EntryFP}); + ParentFP = Builder.CreateCall(RecoverFPIntrin, {ParentCGF.CurFn, EntryFP}); // if the parent is a _finally, the passed-in ParentFP is the FP // of parent _finally, not Establisher's FP (FP of outermost function). @@ -1937,19 +1928,15 @@ void CodeGenFunction::EmitCapturedLocals(CodeGenFunction &ParentCGF, int FrameEscapeIdx = InsertPair.first->second; // an example of a filter's prolog:: - // %0 = call i8* @llvm.eh.recoverfp(bitcast(@"?fin$0@0@main@@"),..) - // %1 = call i8* @llvm.localrecover(bitcast(@"?fin$0@0@main@@"),..) - // %2 = bitcast i8* %1 to i8** - // %3 = load i8*, i8* *%2, align 8 - // ==> %3 is the frame-pointer of outermost host function + // %0 = call ptr @llvm.eh.recoverfp(@"?fin$0@0@main@@",..) + // %1 = call ptr @llvm.localrecover(@"?fin$0@0@main@@",..) + // %2 = load ptr, ptr %1, align 8 + // ==> %2 is the frame-pointer of outermost host function llvm::Function *FrameRecoverFn = llvm::Intrinsic::getDeclaration( &CGM.getModule(), llvm::Intrinsic::localrecover); - llvm::Constant *ParentI8Fn = - llvm::ConstantExpr::getBitCast(ParentCGF.CurFn, Int8PtrTy); ParentFP = Builder.CreateCall( - FrameRecoverFn, {ParentI8Fn, ParentFP, + FrameRecoverFn, {ParentCGF.CurFn, ParentFP, llvm::ConstantInt::get(Int32Ty, FrameEscapeIdx)}); - ParentFP = Builder.CreateBitCast(ParentFP, CGM.VoidPtrPtrTy); ParentFP = Builder.CreateLoad( Address(ParentFP, CGM.VoidPtrTy, getPointerAlign())); } @@ -2206,9 +2193,7 @@ void CodeGenFunction::EnterSEHTryStmt(const SEHTryStmt &S) { // in place of the RTTI typeinfo global that C++ EH uses. llvm::Function *FilterFunc = HelperCGF.GenerateSEHFilterFunction(*this, *Except); - llvm::Constant *OpaqueFunc = - llvm::ConstantExpr::getBitCast(FilterFunc, Int8PtrTy); - CatchScope->setHandler(0, OpaqueFunc, createBasicBlock("__except.ret")); + CatchScope->setHandler(0, FilterFunc, createBasicBlock("__except.ret")); } void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {