Index: include/llvm/IR/Intrinsics.td =================================================================== --- include/llvm/IR/Intrinsics.td +++ include/llvm/IR/Intrinsics.td @@ -414,6 +414,13 @@ def int_localrecover : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty], [IntrNoMem]>; + +// Given the frame pointer passed into an SEH filter function, returns a +// pointer to the local variable area suitable for use with llvm.localrecover. +def int_eh_recoverfp : Intrinsic<[llvm_ptr_ty], + [llvm_ptr_ty, llvm_ptr_ty], + [IntrNoMem]>; + // Note: we treat stacksave/stackrestore as writemem because we don't otherwise // model their dependencies on allocas. def int_stacksave : Intrinsic<[llvm_ptr_ty]>, Index: include/llvm/IR/IntrinsicsX86.td =================================================================== --- include/llvm/IR/IntrinsicsX86.td +++ include/llvm/IR/IntrinsicsX86.td @@ -27,12 +27,6 @@ // Marks the EH guard slot node created in LLVM IR prior to code generation. def int_x86_seh_ehguard : Intrinsic<[], [llvm_ptr_ty], []>; - - // Given a pointer to the end of an EH registration object, returns the true - // parent frame address that can be used with llvm.localrecover. - def int_x86_seh_recoverfp : Intrinsic<[llvm_ptr_ty], - [llvm_ptr_ty, llvm_ptr_ty], - [IntrNoMem]>; } //===----------------------------------------------------------------------===// Index: lib/CodeGen/AsmPrinter/WinException.h =================================================================== --- lib/CodeGen/AsmPrinter/WinException.h +++ lib/CodeGen/AsmPrinter/WinException.h @@ -68,7 +68,7 @@ const MachineFunction *MF, const WinEHFuncInfo &FuncInfo, SmallVectorImpl> &IPToStateTable); - /// Emits the label used with llvm.x86.seh.recoverfp, which is used by + /// Emits the label used with llvm.eh.recoverfp, which is used by /// outlined funclets. void emitEHRegistrationOffsetLabel(const WinEHFuncInfo &FuncInfo, StringRef FLinkageName); Index: lib/CodeGen/AsmPrinter/WinException.cpp =================================================================== --- lib/CodeGen/AsmPrinter/WinException.cpp +++ lib/CodeGen/AsmPrinter/WinException.cpp @@ -546,7 +546,7 @@ }; // Emit a label assignment with the SEH frame offset so we can use it for - // llvm.x86.seh.recoverfp. + // llvm.eh.recoverfp. StringRef FLinkageName = GlobalValue::dropLLVMManglingEscape(MF->getFunction().getName()); MCSymbol *ParentFrameOffset = Index: lib/IR/AutoUpgrade.cpp =================================================================== --- lib/IR/AutoUpgrade.cpp +++ lib/IR/AutoUpgrade.cpp @@ -544,6 +544,10 @@ NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::thread_pointer); return true; } + if (Name == "x86.seh.recoverfp") { + NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_recoverfp); + return true; + } break; } Index: lib/Target/X86/X86ISelLowering.cpp =================================================================== --- lib/Target/X86/X86ISelLowering.cpp +++ lib/Target/X86/X86ISelLowering.cpp @@ -22260,14 +22260,14 @@ return DAG.getNode(X86ISD::Wrapper, dl, VT, Result); } - case Intrinsic::x86_seh_recoverfp: { + case Intrinsic::eh_recoverfp: { SDValue FnOp = Op.getOperand(1); SDValue IncomingFPOp = Op.getOperand(2); GlobalAddressSDNode *GSD = dyn_cast(FnOp); auto *Fn = dyn_cast_or_null(GSD ? GSD->getGlobal() : nullptr); if (!Fn) report_fatal_error( - "llvm.x86.seh.recoverfp must take a function as the first argument"); + "llvm.eh.recoverfp must take a function as the first argument"); return recoverFramePointer(DAG, Fn, IncomingFPOp); } Index: test/CodeGen/WinEH/wineh-statenumbering.ll =================================================================== --- test/CodeGen/WinEH/wineh-statenumbering.ll +++ test/CodeGen/WinEH/wineh-statenumbering.ll @@ -180,7 +180,7 @@ define internal i32 @"\01?filt$0@0@required_state_store@@"() { entry: %0 = tail call i8* @llvm.frameaddress(i32 1) - %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %0) + %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %0) %2 = tail call i8* @llvm.localrecover(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %1, i32 0) %__exception_code = bitcast i8* %2 to i32* %3 = getelementptr inbounds i8, i8* %0, i32 -20 @@ -203,7 +203,7 @@ declare i8* @llvm.frameaddress(i32) -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) +declare i8* @llvm.eh.recoverfp(i8*, i8*) declare i8* @llvm.localrecover(i8*, i8*, i32) Index: test/CodeGen/X86/seh-catch-all-win32.ll =================================================================== --- test/CodeGen/X86/seh-catch-all-win32.ll +++ test/CodeGen/X86/seh-catch-all-win32.ll @@ -12,7 +12,7 @@ declare i8* @llvm.frameaddress(i32) declare i8* @llvm.localrecover(i8*, i8*, i32) declare void @llvm.localescape(...) -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) +declare i8* @llvm.eh.recoverfp(i8*, i8*) define i32 @main() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) { entry: @@ -37,7 +37,7 @@ define internal i32 @"filt$main"() { entry: %ebp = tail call i8* @llvm.frameaddress(i32 1) - %parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp) + %parentfp = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp) %code.i8 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %parentfp, i32 0) %__exceptioncode = bitcast i8* %code.i8 to i32* %info.addr = getelementptr inbounds i8, i8* %ebp, i32 -20 Index: test/CodeGen/X86/seh-filter-no-personality.ll =================================================================== --- test/CodeGen/X86/seh-filter-no-personality.ll +++ test/CodeGen/X86/seh-filter-no-personality.ll @@ -1,10 +1,10 @@ ; RUN: llc -mtriple=i686-windows-msvc < %s | FileCheck %s -; Mostly make sure that llvm.x86.seh.recoverfp doesn't crash if the parent +; Mostly make sure that llvm.eh.recoverfp doesn't crash if the parent ; function lacks a personality. declare i8* @llvm.frameaddress(i32) -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) +declare i8* @llvm.eh.recoverfp(i8*, i8*) define i32 @main() { entry: @@ -14,7 +14,7 @@ define internal i32 @"filt$main"() { entry: %ebp = tail call i8* @llvm.frameaddress(i32 1) - %parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp) + %parentfp = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp) %info.addr = getelementptr inbounds i8, i8* %ebp, i32 -20 %0 = bitcast i8* %info.addr to i32*** %1 = load i32**, i32*** %0, align 4 Index: test/CodeGen/X86/seh-no-invokes.ll =================================================================== --- test/CodeGen/X86/seh-no-invokes.ll +++ test/CodeGen/X86/seh-no-invokes.ll @@ -38,7 +38,7 @@ define internal i32 @"\01?filt$0@0@f@@"() #1 { entry: %0 = tail call i8* @llvm.frameaddress(i32 1) - %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @f to i8*), i8* %0) + %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @f to i8*), i8* %0) %2 = tail call i8* @llvm.localrecover(i8* bitcast (void ()* @f to i8*), i8* %1, i32 0) %__exception_code = bitcast i8* %2 to i32* %3 = getelementptr inbounds i8, i8* %0, i32 -20 @@ -55,7 +55,7 @@ declare i8* @llvm.frameaddress(i32) #2 ; Function Attrs: nounwind readnone -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) #2 +declare i8* @llvm.eh.recoverfp(i8*, i8*) #2 ; Function Attrs: nounwind readnone declare i8* @llvm.localrecover(i8*, i8*, i32) #2 Index: test/CodeGen/X86/seh-stack-realign.ll =================================================================== --- test/CodeGen/X86/seh-stack-realign.ll +++ test/CodeGen/X86/seh-stack-realign.ll @@ -12,7 +12,7 @@ declare i8* @llvm.frameaddress(i32) declare i8* @llvm.localrecover(i8*, i8*, i32) declare void @llvm.localescape(...) -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) +declare i8* @llvm.eh.recoverfp(i8*, i8*) define i32 @main() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) { entry: @@ -38,7 +38,7 @@ define internal i32 @"filt$main"() { entry: %ebp = tail call i8* @llvm.frameaddress(i32 1) - %parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp) + %parentfp = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp) %code.i8 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %parentfp, i32 0) %__exceptioncode = bitcast i8* %code.i8 to i32* %info.addr = getelementptr inbounds i8, i8* %ebp, i32 -20 Index: test/CodeGen/X86/win32-seh-catchpad.ll =================================================================== --- test/CodeGen/X86/win32-seh-catchpad.ll +++ test/CodeGen/X86/win32-seh-catchpad.ll @@ -53,7 +53,7 @@ define internal i32 @try_except_filter_catchall() #0 { entry: %0 = call i8* @llvm.frameaddress(i32 1) - %1 = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @try_except to i8*), i8* %0) + %1 = call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @try_except to i8*), i8* %0) %2 = call i8* @llvm.localrecover(i8* bitcast (void ()* @try_except to i8*), i8* %1, i32 0) %__exception_code = bitcast i8* %2 to i32* %3 = getelementptr inbounds i8, i8* %0, i32 -20 @@ -169,7 +169,7 @@ define internal i32 @nested_exceptions_filter_catchall() #0 { entry: %0 = call i8* @llvm.frameaddress(i32 1) - %1 = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @nested_exceptions to i8*), i8* %0) + %1 = call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @nested_exceptions to i8*), i8* %0) %2 = call i8* @llvm.localrecover(i8* bitcast (void ()* @nested_exceptions to i8*), i8* %1, i32 0) %__exception_code3 = bitcast i8* %2 to i32* %3 = getelementptr inbounds i8, i8* %0, i32 -20 @@ -213,7 +213,7 @@ declare i8* @llvm.frameaddress(i32) #1 ; Function Attrs: nounwind readnone -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) #1 +declare i8* @llvm.eh.recoverfp(i8*, i8*) #1 ; Function Attrs: nounwind readnone declare i8* @llvm.localrecover(i8*, i8*, i32) #1 Index: test/DebugInfo/COFF/frameproc-flags.ll =================================================================== --- test/DebugInfo/COFF/frameproc-flags.ll +++ test/DebugInfo/COFF/frameproc-flags.ll @@ -216,7 +216,7 @@ define internal i32 @"?filt$0@0@seh@@"() #8 !dbg !74 { entry: %0 = tail call i8* @llvm.frameaddress(i32 1) - %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @seh to i8*), i8* %0) + %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @seh to i8*), i8* %0) %2 = tail call i8* @llvm.localrecover(i8* bitcast (void ()* @seh to i8*), i8* %1, i32 0) %__exception_code = bitcast i8* %2 to i32* %3 = getelementptr inbounds i8, i8* %0, i32 -20, !dbg !76 @@ -233,7 +233,7 @@ declare i8* @llvm.frameaddress(i32) #9 ; Function Attrs: nounwind readnone -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) #9 +declare i8* @llvm.eh.recoverfp(i8*, i8*) #9 ; Function Attrs: nounwind readnone declare i8* @llvm.localrecover(i8*, i8*, i32) #9 Index: test/Instrumentation/AddressSanitizer/localescape.ll =================================================================== --- test/Instrumentation/AddressSanitizer/localescape.ll +++ test/Instrumentation/AddressSanitizer/localescape.ll @@ -6,7 +6,7 @@ declare i32 @llvm.eh.typeid.for(i8*) #2 declare i8* @llvm.frameaddress(i32) -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) +declare i8* @llvm.eh.recoverfp(i8*, i8*) declare i8* @llvm.localrecover(i8*, i8*, i32) declare void @llvm.localescape(...) #1 @@ -56,7 +56,7 @@ define internal i32 @"\01?filt$0@0@main@@"() #1 { entry: %0 = tail call i8* @llvm.frameaddress(i32 1) - %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0) + %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0) %2 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %1, i32 0) %__exception_code = bitcast i8* %2 to i32* %3 = getelementptr inbounds i8, i8* %0, i32 -20 Index: test/Instrumentation/SanitizerCoverage/seh.ll =================================================================== --- test/Instrumentation/SanitizerCoverage/seh.ll +++ test/Instrumentation/SanitizerCoverage/seh.ll @@ -7,7 +7,7 @@ declare i32 @llvm.eh.typeid.for(i8*) #2 declare i8* @llvm.frameaddress(i32) -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) +declare i8* @llvm.eh.recoverfp(i8*, i8*) declare i8* @llvm.localrecover(i8*, i8*, i32) declare void @llvm.localescape(...) #1 @@ -55,7 +55,7 @@ define internal i32 @"\01?filt$0@0@main@@"() #1 { entry: %0 = tail call i8* @llvm.frameaddress(i32 1) - %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0) + %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0) %2 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %1, i32 0) %__exception_code = bitcast i8* %2 to i32* %3 = getelementptr inbounds i8, i8* %0, i32 -20 Index: test/Transforms/LCSSA/avoid-intrinsics-in-catchswitch.ll =================================================================== --- test/Transforms/LCSSA/avoid-intrinsics-in-catchswitch.ll +++ test/Transforms/LCSSA/avoid-intrinsics-in-catchswitch.ll @@ -85,7 +85,7 @@ define internal i32 @"\01?filt$0@0@m@@"(i8* %exception_pointers, i8* %frame_pointer) personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) { entry: - %0 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @"\01?m@@YAJXZ" to i8*), i8* %frame_pointer) + %0 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @"\01?m@@YAJXZ" to i8*), i8* %frame_pointer) %1 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @"\01?m@@YAJXZ" to i8*), i8* %0, i32 0) %2 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @"\01?m@@YAJXZ" to i8*), i8* %0, i32 1) %status = bitcast i8* %2 to i32* @@ -112,7 +112,7 @@ cleanupret from %9 unwind to caller } -declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) +declare i8* @llvm.eh.recoverfp(i8*, i8*) declare i8* @llvm.localrecover(i8*, i8*, i32) declare i32 @"\01?j@@YAJVf@@JPEAUk@@PEAH@Z"(i8, i32, %struct.k*, i32*) local_unnamed_addr declare i32 @__C_specific_handler(...)