Skip to content
This repository was archived by the owner on Oct 24, 2019. It is now read-only.

Commit bbf3052

Browse files
author
Mandeep Singh Grang
committed
[EH] Rename llvm.x86.seh.recoverfp intrinsic to llvm.eh.recoverfp
Summary: Make recoverfp intrinsic target-independent so that it can be implemented for AArch64, etc. Refer D53541 for the context. Clang counterpart D56748. Reviewers: rnk, efriedma Reviewed By: rnk, efriedma Subscribers: javed.absar, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D56747 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351281 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 1b044af commit bbf3052

File tree

16 files changed

+37
-32
lines changed

16 files changed

+37
-32
lines changed

include/llvm/IR/Intrinsics.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,13 @@ def int_localescape : Intrinsic<[], [llvm_vararg_ty]>;
414414
def int_localrecover : Intrinsic<[llvm_ptr_ty],
415415
[llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
416416
[IntrNoMem]>;
417+
418+
// Given the frame pointer passed into an SEH filter function, returns a
419+
// pointer to the local variable area suitable for use with llvm.localrecover.
420+
def int_eh_recoverfp : Intrinsic<[llvm_ptr_ty],
421+
[llvm_ptr_ty, llvm_ptr_ty],
422+
[IntrNoMem]>;
423+
417424
// Note: we treat stacksave/stackrestore as writemem because we don't otherwise
418425
// model their dependencies on allocas.
419426
def int_stacksave : Intrinsic<[llvm_ptr_ty]>,

include/llvm/IR/IntrinsicsX86.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ let TargetPrefix = "x86" in {
2727

2828
// Marks the EH guard slot node created in LLVM IR prior to code generation.
2929
def int_x86_seh_ehguard : Intrinsic<[], [llvm_ptr_ty], []>;
30-
31-
// Given a pointer to the end of an EH registration object, returns the true
32-
// parent frame address that can be used with llvm.localrecover.
33-
def int_x86_seh_recoverfp : Intrinsic<[llvm_ptr_ty],
34-
[llvm_ptr_ty, llvm_ptr_ty],
35-
[IntrNoMem]>;
3630
}
3731

3832
//===----------------------------------------------------------------------===//

lib/CodeGen/AsmPrinter/WinException.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ void WinException::emitCSpecificHandlerTable(const MachineFunction *MF) {
546546
};
547547

548548
// Emit a label assignment with the SEH frame offset so we can use it for
549-
// llvm.x86.seh.recoverfp.
549+
// llvm.eh.recoverfp.
550550
StringRef FLinkageName =
551551
GlobalValue::dropLLVMManglingEscape(MF->getFunction().getName());
552552
MCSymbol *ParentFrameOffset =

lib/CodeGen/AsmPrinter/WinException.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class LLVM_LIBRARY_VISIBILITY WinException : public EHStreamer {
6868
const MachineFunction *MF, const WinEHFuncInfo &FuncInfo,
6969
SmallVectorImpl<std::pair<const MCExpr *, int>> &IPToStateTable);
7070

71-
/// Emits the label used with llvm.x86.seh.recoverfp, which is used by
71+
/// Emits the label used with llvm.eh.recoverfp, which is used by
7272
/// outlined funclets.
7373
void emitEHRegistrationOffsetLabel(const WinEHFuncInfo &FuncInfo,
7474
StringRef FLinkageName);

lib/IR/AutoUpgrade.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
544544
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::thread_pointer);
545545
return true;
546546
}
547+
if (Name == "x86.seh.recoverfp") {
548+
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_recoverfp);
549+
return true;
550+
}
547551
break;
548552
}
549553

lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22260,14 +22260,14 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
2226022260
return DAG.getNode(X86ISD::Wrapper, dl, VT, Result);
2226122261
}
2226222262

22263-
case Intrinsic::x86_seh_recoverfp: {
22263+
case Intrinsic::eh_recoverfp: {
2226422264
SDValue FnOp = Op.getOperand(1);
2226522265
SDValue IncomingFPOp = Op.getOperand(2);
2226622266
GlobalAddressSDNode *GSD = dyn_cast<GlobalAddressSDNode>(FnOp);
2226722267
auto *Fn = dyn_cast_or_null<Function>(GSD ? GSD->getGlobal() : nullptr);
2226822268
if (!Fn)
2226922269
report_fatal_error(
22270-
"llvm.x86.seh.recoverfp must take a function as the first argument");
22270+
"llvm.eh.recoverfp must take a function as the first argument");
2227122271
return recoverFramePointer(DAG, Fn, IncomingFPOp);
2227222272
}
2227322273

test/CodeGen/WinEH/wineh-statenumbering.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ if.end: ; preds = %if.then, %__except.
180180
define internal i32 @"\01?filt$0@0@required_state_store@@"() {
181181
entry:
182182
%0 = tail call i8* @llvm.frameaddress(i32 1)
183-
%1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %0)
183+
%1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %0)
184184
%2 = tail call i8* @llvm.localrecover(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %1, i32 0)
185185
%__exception_code = bitcast i8* %2 to i32*
186186
%3 = getelementptr inbounds i8, i8* %0, i32 -20
@@ -203,7 +203,7 @@ declare i32 @__CxxFrameHandler3(...)
203203

204204
declare i8* @llvm.frameaddress(i32)
205205

206-
declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
206+
declare i8* @llvm.eh.recoverfp(i8*, i8*)
207207

208208
declare i8* @llvm.localrecover(i8*, i8*, i32)
209209

test/CodeGen/X86/seh-catch-all-win32.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ declare i32 @llvm.eh.typeid.for(i8*)
1212
declare i8* @llvm.frameaddress(i32)
1313
declare i8* @llvm.localrecover(i8*, i8*, i32)
1414
declare void @llvm.localescape(...)
15-
declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
15+
declare i8* @llvm.eh.recoverfp(i8*, i8*)
1616

1717
define i32 @main() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
1818
entry:
@@ -37,7 +37,7 @@ __try.cont: ; preds = %entry, %__except
3737
define internal i32 @"filt$main"() {
3838
entry:
3939
%ebp = tail call i8* @llvm.frameaddress(i32 1)
40-
%parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
40+
%parentfp = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
4141
%code.i8 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %parentfp, i32 0)
4242
%__exceptioncode = bitcast i8* %code.i8 to i32*
4343
%info.addr = getelementptr inbounds i8, i8* %ebp, i32 -20

test/CodeGen/X86/seh-filter-no-personality.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
; RUN: llc -mtriple=i686-windows-msvc < %s | FileCheck %s
22

3-
; Mostly make sure that llvm.x86.seh.recoverfp doesn't crash if the parent
3+
; Mostly make sure that llvm.eh.recoverfp doesn't crash if the parent
44
; function lacks a personality.
55

66
declare i8* @llvm.frameaddress(i32)
7-
declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
7+
declare i8* @llvm.eh.recoverfp(i8*, i8*)
88

99
define i32 @main() {
1010
entry:
@@ -14,7 +14,7 @@ entry:
1414
define internal i32 @"filt$main"() {
1515
entry:
1616
%ebp = tail call i8* @llvm.frameaddress(i32 1)
17-
%parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
17+
%parentfp = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
1818
%info.addr = getelementptr inbounds i8, i8* %ebp, i32 -20
1919
%0 = bitcast i8* %info.addr to i32***
2020
%1 = load i32**, i32*** %0, align 4

test/CodeGen/X86/seh-no-invokes.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ __try.cont:
3838
define internal i32 @"\01?filt$0@0@f@@"() #1 {
3939
entry:
4040
%0 = tail call i8* @llvm.frameaddress(i32 1)
41-
%1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @f to i8*), i8* %0)
41+
%1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @f to i8*), i8* %0)
4242
%2 = tail call i8* @llvm.localrecover(i8* bitcast (void ()* @f to i8*), i8* %1, i32 0)
4343
%__exception_code = bitcast i8* %2 to i32*
4444
%3 = getelementptr inbounds i8, i8* %0, i32 -20
@@ -55,7 +55,7 @@ entry:
5555
declare i8* @llvm.frameaddress(i32) #2
5656

5757
; Function Attrs: nounwind readnone
58-
declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) #2
58+
declare i8* @llvm.eh.recoverfp(i8*, i8*) #2
5959

6060
; Function Attrs: nounwind readnone
6161
declare i8* @llvm.localrecover(i8*, i8*, i32) #2

0 commit comments

Comments
 (0)