summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-06-30 22:46:59 +0000
committerReid Kleckner <reid@kleckner.net>2015-06-30 22:46:59 +0000
commit399a2fe400912313eafdb7ff3b6e17b439887e9d (patch)
tree556f40456637c0e60c51ae07819490a2bf7d4b7d /llvm/test
parenta5812a215bd90c320221b4d33bdf2767f4ec7077 (diff)
downloadbcm5719-llvm-399a2fe400912313eafdb7ff3b6e17b439887e9d.tar.gz
bcm5719-llvm-399a2fe400912313eafdb7ff3b6e17b439887e9d.zip
[SEH] Add new intrinsics for recovering and restoring parent frames
The incoming EBP value established by the runtime is actually a pointer to the end of the EH registration object, and not the true parent function frame pointer. Clang doesn't need llvm.x86.seh.exceptioninfo anymore because we know that the exception info pointer is at a fixed offset from this incoming EBP. The llvm.x86.seh.recoverfp intrinsic takes an EBP value provided by the EH runtime and returns a pointer that is usable with llvm.framerecover. The llvm.x86.seh.restoreframe intrinsic is inserted by the 32-bit specific preparation pass in blocks targetted by the EH runtime. It re-establishes any physical registers used by the parent function to address the stack, such as the frame, base, and stack pointers. Neither of these intrinsics correctly handle stack realignment prologues yet, but it's possible to add that later. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D10848 llvm-svn: 241125
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/seh-catch-all-win32.ll29
-rw-r--r--llvm/test/CodeGen/X86/seh-safe-div-win32.ll46
2 files changed, 44 insertions, 31 deletions
diff --git a/llvm/test/CodeGen/X86/seh-catch-all-win32.ll b/llvm/test/CodeGen/X86/seh-catch-all-win32.ll
index 28b0bca962e..423b9914e99 100644
--- a/llvm/test/CodeGen/X86/seh-catch-all-win32.ll
+++ b/llvm/test/CodeGen/X86/seh-catch-all-win32.ll
@@ -12,7 +12,7 @@ declare i32 @llvm.eh.typeid.for(i8*)
declare i8* @llvm.frameaddress(i32)
declare i8* @llvm.framerecover(i8*, i8*, i32)
declare void @llvm.frameescape(...)
-declare i8* @llvm.x86.seh.exceptioninfo(i8*, i8*)
+declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
define i32 @main() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
entry:
@@ -43,14 +43,16 @@ eh.resume: ; preds = %lpad
define internal i32 @"filt$main"() {
entry:
- %0 = tail call i8* @llvm.frameaddress(i32 1)
- %1 = tail call i8* @llvm.framerecover(i8* bitcast (i32 ()* @main to i8*), i8* %0, i32 0)
- %__exceptioncode = bitcast i8* %1 to i32*
- %2 = tail call i8* @llvm.x86.seh.exceptioninfo(i8* bitcast (i32 ()* @main to i8*), i8* %0)
- %3 = bitcast i8* %2 to i32**
- %4 = load i32*, i32** %3, align 4
- %5 = load i32, i32* %4, align 4
- store i32 %5, i32* %__exceptioncode, align 4
+ %ebp = tail call i8* @llvm.frameaddress(i32 1)
+ %parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
+ %code.i8 = tail call i8* @llvm.framerecover(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
+ %0 = bitcast i8* %info.addr to i32***
+ %1 = load i32**, i32*** %0, align 4
+ %2 = load i32*, i32** %1, align 4
+ %3 = load i32, i32* %2, align 4
+ store i32 %3, i32* %__exceptioncode, align 4
ret i32 1
}
@@ -76,10 +78,17 @@ entry:
; CHECK: calll _printf
; CHECK: .section .xdata,"dr"
+; CHECK: Lmain$parent_frame_offset = Lmain$frame_escape_1
; CHECK: L__ehtable$main
; CHECK-NEXT: .long -1
; CHECK-NEXT: .long _filt$main
; CHECK-NEXT: .long Ltmp{{[0-9]+}}
; CHECK-LABEL: _filt$main:
-; CHECK: movl
+; CHECK: pushl %ebp
+; CHECK: movl %esp, %ebp
+; CHECK: movl (%ebp), %[[oldebp:[a-z]+]]
+; CHECK: movl -20(%[[oldebp]]), %[[ehinfo:[a-z]+]]
+; CHECK: movl (%[[ehinfo]]), %[[ehrec:[a-z]+]]
+; CHECK: movl (%[[ehrec]]), %[[ehcode:[a-z]+]]
+; CHECK: movl %[[ehcode]], {{.*}}(%{{.*}})
diff --git a/llvm/test/CodeGen/X86/seh-safe-div-win32.ll b/llvm/test/CodeGen/X86/seh-safe-div-win32.ll
index 0f76ec07a6b..b1bcde2c7ff 100644
--- a/llvm/test/CodeGen/X86/seh-safe-div-win32.ll
+++ b/llvm/test/CodeGen/X86/seh-safe-div-win32.ll
@@ -122,27 +122,30 @@ entry:
; ...
; } EXCEPTION_RECORD;
-; FIXME: Use llvm.eh.exceptioninfo for this.
-declare i32 @safe_div_filt0()
-declare i32 @safe_div_filt1()
-; define i32 @safe_div_filt0() {
-; %eh_ptrs_c = bitcast i8* %eh_ptrs to i32**
-; %eh_rec = load i32*, i32** %eh_ptrs_c
-; %eh_code = load i32, i32* %eh_rec
-; ; EXCEPTION_ACCESS_VIOLATION = 0xC0000005
-; %cmp = icmp eq i32 %eh_code, 3221225477
-; %filt.res = zext i1 %cmp to i32
-; ret i32 %filt.res
-; }
-; define i32 @safe_div_filt1() {
-; %eh_ptrs_c = bitcast i8* %eh_ptrs to i32**
-; %eh_rec = load i32*, i32** %eh_ptrs_c
-; %eh_code = load i32, i32* %eh_rec
-; ; EXCEPTION_INT_DIVIDE_BY_ZERO = 0xC0000094
-; %cmp = icmp eq i32 %eh_code, 3221225620
-; %filt.res = zext i1 %cmp to i32
-; ret i32 %filt.res
-; }
+define i32 @safe_div_filt0() {
+ %ebp = call i8* @llvm.frameaddress(i32 1)
+ %eh_ptrs.addr.i8 = getelementptr inbounds i8, i8* %ebp, i32 -20
+ %eh_ptrs.addr = bitcast i8* %eh_ptrs.addr.i8 to i32***
+ %eh_ptrs = load i32**, i32*** %eh_ptrs.addr
+ %eh_rec = load i32*, i32** %eh_ptrs
+ %eh_code = load i32, i32* %eh_rec
+ ; EXCEPTION_ACCESS_VIOLATION = 0xC0000005
+ %cmp = icmp eq i32 %eh_code, 3221225477
+ %filt.res = zext i1 %cmp to i32
+ ret i32 %filt.res
+}
+define i32 @safe_div_filt1() {
+ %ebp = call i8* @llvm.frameaddress(i32 1)
+ %eh_ptrs.addr.i8 = getelementptr inbounds i8, i8* %ebp, i32 -20
+ %eh_ptrs.addr = bitcast i8* %eh_ptrs.addr.i8 to i32***
+ %eh_ptrs = load i32**, i32*** %eh_ptrs.addr
+ %eh_rec = load i32*, i32** %eh_ptrs
+ %eh_code = load i32, i32* %eh_rec
+ ; EXCEPTION_INT_DIVIDE_BY_ZERO = 0xC0000094
+ %cmp = icmp eq i32 %eh_code, 3221225620
+ %filt.res = zext i1 %cmp to i32
+ ret i32 %filt.res
+}
@str_result = internal constant [21 x i8] c"safe_div result: %d\0A\00"
@@ -170,3 +173,4 @@ declare i32 @llvm.eh.typeid.for(i8*) readnone nounwind
declare void @puts(i8*)
declare void @printf(i8*, ...)
declare void @abort()
+declare i8* @llvm.frameaddress(i32)
OpenPOWER on IntegriCloud