Skip to content

Commit b46211b

Browse files
committed
[ORC] Add minimal-throw-catch.ll regression test for lli -jit-mode=orc.
We already had a -jit-mode=orc-lazy regression test for this, but it should work equally well in non-lazy mode.
1 parent e649b38 commit b46211b

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
; REQUIRES: x86_64-apple
2+
; RUN: lli -jit-kind=orc-lazy %s
3+
;
4+
; Basic correctness testing for eh-frame processing and registration.
5+
6+
@_ZTIi = external constant ptr
7+
8+
declare ptr @__cxa_allocate_exception(i64)
9+
declare void @__cxa_throw(ptr, ptr, ptr)
10+
11+
declare i32 @__gxx_personality_v0(...)
12+
declare i32 @llvm.eh.typeid.for(ptr)
13+
declare ptr @__cxa_begin_catch(ptr)
14+
declare void @__cxa_end_catch()
15+
16+
define void @explode() {
17+
entry:
18+
%exception = tail call ptr @__cxa_allocate_exception(i64 4)
19+
store i32 42, ptr %exception, align 16
20+
tail call void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null)
21+
unreachable
22+
}
23+
24+
define i32 @main(i32 %argc, ptr %argv) personality ptr @__gxx_personality_v0 {
25+
entry:
26+
invoke void @explode()
27+
to label %return unwind label %lpad
28+
29+
lpad:
30+
%0 = landingpad { ptr, i32 }
31+
catch ptr @_ZTIi
32+
%1 = extractvalue { ptr, i32 } %0, 1
33+
%2 = tail call i32 @llvm.eh.typeid.for(ptr @_ZTIi)
34+
%matches = icmp eq i32 %1, %2
35+
br i1 %matches, label %catch, label %eh.resume
36+
37+
catch:
38+
%3 = extractvalue { ptr, i32 } %0, 0
39+
%4 = tail call ptr @__cxa_begin_catch(ptr %3)
40+
%5 = load i32, ptr %4, align 4
41+
%cmp = icmp ne i32 %5, 42
42+
%cond = zext i1 %cmp to i32
43+
tail call void @__cxa_end_catch()
44+
br label %return
45+
46+
return:
47+
%retval.0 = phi i32 [ %cond, %catch ], [ 2, %entry ]
48+
ret i32 %retval.0
49+
50+
eh.resume:
51+
resume { ptr, i32 } %0
52+
}

llvm/test/ExecutionEngine/OrcLazy/minimal-throw-catch.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
;
44
; Basic correctness testing for eh-frame processing and registration.
55

6-
source_filename = "minimal-throw-catch.cpp"
7-
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
8-
target triple = "x86_64-apple-macosx10.14.0"
9-
106
@_ZTIi = external constant ptr
117

128
declare ptr @__cxa_allocate_exception(i64)

0 commit comments

Comments
 (0)