llvm.org GIT mirror llvm / bbf3052
[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 Mandeep Singh Grang 1 year, 10 months ago
16 changed file(s) with 37 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
413413 def int_localrecover : Intrinsic<[llvm_ptr_ty],
414414 [llvm_ptr_ty, llvm_ptr_ty, llvm_i32_ty],
415415 [IntrNoMem]>;
416
417 // Given the frame pointer passed into an SEH filter function, returns a
418 // pointer to the local variable area suitable for use with llvm.localrecover.
419 def int_eh_recoverfp : Intrinsic<[llvm_ptr_ty],
420 [llvm_ptr_ty, llvm_ptr_ty],
421 [IntrNoMem]>;
422
416423 // Note: we treat stacksave/stackrestore as writemem because we don't otherwise
417424 // model their dependencies on allocas.
418425 def int_stacksave : Intrinsic<[llvm_ptr_ty]>,
2626
2727 // Marks the EH guard slot node created in LLVM IR prior to code generation.
2828 def int_x86_seh_ehguard : Intrinsic<[], [llvm_ptr_ty], []>;
29
30 // Given a pointer to the end of an EH registration object, returns the true
31 // parent frame address that can be used with llvm.localrecover.
32 def int_x86_seh_recoverfp : Intrinsic<[llvm_ptr_ty],
33 [llvm_ptr_ty, llvm_ptr_ty],
34 [IntrNoMem]>;
3529 }
3630
3731 //===----------------------------------------------------------------------===//
545545 };
546546
547547 // Emit a label assignment with the SEH frame offset so we can use it for
548 // llvm.x86.seh.recoverfp.
548 // llvm.eh.recoverfp.
549549 StringRef FLinkageName =
550550 GlobalValue::dropLLVMManglingEscape(MF->getFunction().getName());
551551 MCSymbol *ParentFrameOffset =
6767 const MachineFunction *MF, const WinEHFuncInfo &FuncInfo,
6868 SmallVectorImpl> &IPToStateTable);
6969
70 /// Emits the label used with llvm.x86.seh.recoverfp, which is used by
70 /// Emits the label used with llvm.eh.recoverfp, which is used by
7171 /// outlined funclets.
7272 void emitEHRegistrationOffsetLabel(const WinEHFuncInfo &FuncInfo,
7373 StringRef FLinkageName);
543543 NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::thread_pointer);
544544 return true;
545545 }
546 if (Name == "x86.seh.recoverfp") {
547 NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_recoverfp);
548 return true;
549 }
546550 break;
547551 }
548552
2225922259 return DAG.getNode(X86ISD::Wrapper, dl, VT, Result);
2226022260 }
2226122261
22262 case Intrinsic::x86_seh_recoverfp: {
22262 case Intrinsic::eh_recoverfp: {
2226322263 SDValue FnOp = Op.getOperand(1);
2226422264 SDValue IncomingFPOp = Op.getOperand(2);
2226522265 GlobalAddressSDNode *GSD = dyn_cast(FnOp);
2226622266 auto *Fn = dyn_cast_or_null(GSD ? GSD->getGlobal() : nullptr);
2226722267 if (!Fn)
2226822268 report_fatal_error(
22269 "llvm.x86.seh.recoverfp must take a function as the first argument");
22269 "llvm.eh.recoverfp must take a function as the first argument");
2227022270 return recoverFramePointer(DAG, Fn, IncomingFPOp);
2227122271 }
2227222272
179179 define internal i32 @"\01?filt$0@0@required_state_store@@"() {
180180 entry:
181181 %0 = tail call i8* @llvm.frameaddress(i32 1)
182 %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %0)
182 %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %0)
183183 %2 = tail call i8* @llvm.localrecover(i8* bitcast (void (i1)* @required_state_store to i8*), i8* %1, i32 0)
184184 %__exception_code = bitcast i8* %2 to i32*
185185 %3 = getelementptr inbounds i8, i8* %0, i32 -20
202202
203203 declare i8* @llvm.frameaddress(i32)
204204
205 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
205 declare i8* @llvm.eh.recoverfp(i8*, i8*)
206206
207207 declare i8* @llvm.localrecover(i8*, i8*, i32)
208208
1111 declare i8* @llvm.frameaddress(i32)
1212 declare i8* @llvm.localrecover(i8*, i8*, i32)
1313 declare void @llvm.localescape(...)
14 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
14 declare i8* @llvm.eh.recoverfp(i8*, i8*)
1515
1616 define i32 @main() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
1717 entry:
3636 define internal i32 @"filt$main"() {
3737 entry:
3838 %ebp = tail call i8* @llvm.frameaddress(i32 1)
39 %parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
39 %parentfp = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
4040 %code.i8 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %parentfp, i32 0)
4141 %__exceptioncode = bitcast i8* %code.i8 to i32*
4242 %info.addr = getelementptr inbounds i8, i8* %ebp, i32 -20
0 ; RUN: llc -mtriple=i686-windows-msvc < %s | FileCheck %s
11
2 ; Mostly make sure that llvm.x86.seh.recoverfp doesn't crash if the parent
2 ; Mostly make sure that llvm.eh.recoverfp doesn't crash if the parent
33 ; function lacks a personality.
44
55 declare i8* @llvm.frameaddress(i32)
6 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
6 declare i8* @llvm.eh.recoverfp(i8*, i8*)
77
88 define i32 @main() {
99 entry:
1313 define internal i32 @"filt$main"() {
1414 entry:
1515 %ebp = tail call i8* @llvm.frameaddress(i32 1)
16 %parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
16 %parentfp = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
1717 %info.addr = getelementptr inbounds i8, i8* %ebp, i32 -20
1818 %0 = bitcast i8* %info.addr to i32***
1919 %1 = load i32**, i32*** %0, align 4
3737 define internal i32 @"\01?filt$0@0@f@@"() #1 {
3838 entry:
3939 %0 = tail call i8* @llvm.frameaddress(i32 1)
40 %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @f to i8*), i8* %0)
40 %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @f to i8*), i8* %0)
4141 %2 = tail call i8* @llvm.localrecover(i8* bitcast (void ()* @f to i8*), i8* %1, i32 0)
4242 %__exception_code = bitcast i8* %2 to i32*
4343 %3 = getelementptr inbounds i8, i8* %0, i32 -20
5454 declare i8* @llvm.frameaddress(i32) #2
5555
5656 ; Function Attrs: nounwind readnone
57 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) #2
57 declare i8* @llvm.eh.recoverfp(i8*, i8*) #2
5858
5959 ; Function Attrs: nounwind readnone
6060 declare i8* @llvm.localrecover(i8*, i8*, i32) #2
1111 declare i8* @llvm.frameaddress(i32)
1212 declare i8* @llvm.localrecover(i8*, i8*, i32)
1313 declare void @llvm.localescape(...)
14 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
14 declare i8* @llvm.eh.recoverfp(i8*, i8*)
1515
1616 define i32 @main() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
1717 entry:
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
5252 define internal i32 @try_except_filter_catchall() #0 {
5353 entry:
5454 %0 = call i8* @llvm.frameaddress(i32 1)
55 %1 = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @try_except to i8*), i8* %0)
55 %1 = call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @try_except to i8*), i8* %0)
5656 %2 = call i8* @llvm.localrecover(i8* bitcast (void ()* @try_except to i8*), i8* %1, i32 0)
5757 %__exception_code = bitcast i8* %2 to i32*
5858 %3 = getelementptr inbounds i8, i8* %0, i32 -20
168168 define internal i32 @nested_exceptions_filter_catchall() #0 {
169169 entry:
170170 %0 = call i8* @llvm.frameaddress(i32 1)
171 %1 = call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @nested_exceptions to i8*), i8* %0)
171 %1 = call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @nested_exceptions to i8*), i8* %0)
172172 %2 = call i8* @llvm.localrecover(i8* bitcast (void ()* @nested_exceptions to i8*), i8* %1, i32 0)
173173 %__exception_code3 = bitcast i8* %2 to i32*
174174 %3 = getelementptr inbounds i8, i8* %0, i32 -20
212212 declare i8* @llvm.frameaddress(i32) #1
213213
214214 ; Function Attrs: nounwind readnone
215 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) #1
215 declare i8* @llvm.eh.recoverfp(i8*, i8*) #1
216216
217217 ; Function Attrs: nounwind readnone
218218 declare i8* @llvm.localrecover(i8*, i8*, i32) #1
215215 define internal i32 @"?filt$0@0@seh@@"() #8 !dbg !74 {
216216 entry:
217217 %0 = tail call i8* @llvm.frameaddress(i32 1)
218 %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (void ()* @seh to i8*), i8* %0)
218 %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (void ()* @seh to i8*), i8* %0)
219219 %2 = tail call i8* @llvm.localrecover(i8* bitcast (void ()* @seh to i8*), i8* %1, i32 0)
220220 %__exception_code = bitcast i8* %2 to i32*
221221 %3 = getelementptr inbounds i8, i8* %0, i32 -20, !dbg !76
232232 declare i8* @llvm.frameaddress(i32) #9
233233
234234 ; Function Attrs: nounwind readnone
235 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*) #9
235 declare i8* @llvm.eh.recoverfp(i8*, i8*) #9
236236
237237 ; Function Attrs: nounwind readnone
238238 declare i8* @llvm.localrecover(i8*, i8*, i32) #9
55
66 declare i32 @llvm.eh.typeid.for(i8*) #2
77 declare i8* @llvm.frameaddress(i32)
8 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
8 declare i8* @llvm.eh.recoverfp(i8*, i8*)
99 declare i8* @llvm.localrecover(i8*, i8*, i32)
1010 declare void @llvm.localescape(...) #1
1111
5555 define internal i32 @"\01?filt$0@0@main@@"() #1 {
5656 entry:
5757 %0 = tail call i8* @llvm.frameaddress(i32 1)
58 %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0)
58 %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0)
5959 %2 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %1, i32 0)
6060 %__exception_code = bitcast i8* %2 to i32*
6161 %3 = getelementptr inbounds i8, i8* %0, i32 -20
66
77 declare i32 @llvm.eh.typeid.for(i8*) #2
88 declare i8* @llvm.frameaddress(i32)
9 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
9 declare i8* @llvm.eh.recoverfp(i8*, i8*)
1010 declare i8* @llvm.localrecover(i8*, i8*, i32)
1111 declare void @llvm.localescape(...) #1
1212
5454 define internal i32 @"\01?filt$0@0@main@@"() #1 {
5555 entry:
5656 %0 = tail call i8* @llvm.frameaddress(i32 1)
57 %1 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0)
57 %1 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %0)
5858 %2 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %1, i32 0)
5959 %__exception_code = bitcast i8* %2 to i32*
6060 %3 = getelementptr inbounds i8, i8* %0, i32 -20
8484
8585 define internal i32 @"\01?filt$0@0@m@@"(i8* %exception_pointers, i8* %frame_pointer) personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
8686 entry:
87 %0 = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @"\01?m@@YAJXZ" to i8*), i8* %frame_pointer)
87 %0 = tail call i8* @llvm.eh.recoverfp(i8* bitcast (i32 ()* @"\01?m@@YAJXZ" to i8*), i8* %frame_pointer)
8888 %1 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @"\01?m@@YAJXZ" to i8*), i8* %0, i32 0)
8989 %2 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @"\01?m@@YAJXZ" to i8*), i8* %0, i32 1)
9090 %status = bitcast i8* %2 to i32*
111111 cleanupret from %9 unwind to caller
112112 }
113113
114 declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
114 declare i8* @llvm.eh.recoverfp(i8*, i8*)
115115 declare i8* @llvm.localrecover(i8*, i8*, i32)
116116 declare i32 @"\01?j@@YAJVf@@JPEAUk@@PEAH@Z"(i8, i32, %struct.k*, i32*) local_unnamed_addr
117117 declare i32 @__C_specific_handler(...)