llvm.org GIT mirror llvm / 7147946
don't have i386-specific tests in CodeGen/Generic, PR6601. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98508 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
37 changed file(s) with 389 addition(s) and 419 deletion(s). Raw diff Collapse all Expand all
+0
-95
test/CodeGen/Generic/2007-02-16-BranchFold.ll less more
None ; PR 1200
1 ; RUN: llc < %s -enable-tail-merge=0 | not grep jmp
2
3 ; ModuleID = ''
4 target datalayout = "e-p:32:32"
5 target triple = "i686-apple-darwin8"
6 %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }
7 %struct.Index_Map = type { i32, %struct.item_set** }
8 %struct.Item = type { [4 x i16], %struct.rule* }
9 %struct.__sFILEX = type opaque
10 %struct.__sbuf = type { i8*, i32 }
11 %struct.dimension = type { i16*, %struct.Index_Map, %struct.mapping*, i32, %struct.plankMap* }
12 %struct.item_set = type { i32, i32, %struct.operator*, [2 x %struct.item_set*], %struct.item_set*, i16*, %struct.Item*, %struct.Item* }
13 %struct.list = type { i8*, %struct.list* }
14 %struct.mapping = type { %struct.list**, i32, i32, i32, %struct.item_set** }
15 %struct.nonterminal = type { i8*, i32, i32, i32, %struct.plankMap*, %struct.rule* }
16 %struct.operator = type { i8*, i8, i32, i32, i32, i32, %struct.table* }
17 %struct.pattern = type { %struct.nonterminal*, %struct.operator*, [2 x %struct.nonterminal*] }
18 %struct.plank = type { i8*, %struct.list*, i32 }
19 %struct.plankMap = type { %struct.list*, i32, %struct.stateMap* }
20 %struct.rule = type { [4 x i16], i32, i32, i32, %struct.nonterminal*, %struct.pattern*, i8 }
21 %struct.stateMap = type { i8*, %struct.plank*, i32, i16* }
22 %struct.table = type { %struct.operator*, %struct.list*, i16*, [2 x %struct.dimension*], %struct.item_set** }
23 @outfile = external global %struct.FILE* ; <%struct.FILE**> [#uses=1]
24 @str1 = external global [11 x i8] ; <[11 x i8]*> [#uses=1]
25
26 declare i32 @fprintf(%struct.FILE*, i8*, ...)
27
28 define i16 @main_bb_2E_i9_2E_i_2E_i932_2E_ce(%struct.list* %l_addr.01.0.i2.i.i929, %struct.operator** %tmp66.i62.i.out) {
29 newFuncRoot:
30 br label %bb.i9.i.i932.ce
31
32 NewDefault: ; preds = %LeafBlock, %LeafBlock1, %LeafBlock2, %LeafBlock3
33 br label %bb36.i.i.exitStub
34
35 bb36.i.i.exitStub: ; preds = %NewDefault
36 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
37 ret i16 0
38
39 bb.i14.i.exitStub: ; preds = %LeafBlock
40 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
41 ret i16 1
42
43 bb12.i.i935.exitStub: ; preds = %LeafBlock1
44 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
45 ret i16 2
46
47 bb20.i.i937.exitStub: ; preds = %LeafBlock2
48 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
49 ret i16 3
50
51 bb28.i.i938.exitStub: ; preds = %LeafBlock3
52 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
53 ret i16 4
54
55 bb.i9.i.i932.ce: ; preds = %newFuncRoot
56 %tmp1.i3.i.i930 = getelementptr %struct.list* %l_addr.01.0.i2.i.i929, i32 0, i32 0 ; [#uses=1]
57 %tmp2.i4.i.i931 = load i8** %tmp1.i3.i.i930 ; [#uses=1]
58 %tmp66.i62.i = bitcast i8* %tmp2.i4.i.i931 to %struct.operator* ; <%struct.operator*> [#uses=7]
59 %tmp1.i6.i = getelementptr %struct.operator* %tmp66.i62.i, i32 0, i32 2 ; [#uses=1]
60 %tmp2.i7.i = load i32* %tmp1.i6.i ; [#uses=1]
61 %tmp3.i8.i = load %struct.FILE** @outfile ; <%struct.FILE*> [#uses=1]
62 %tmp5.i9.i = call i32 (%struct.FILE*, i8*, ...)* @fprintf( %struct.FILE* %tmp3.i8.i, i8* getelementptr ([11 x i8]* @str1, i32 0, i32 0), i32 %tmp2.i7.i ) ; [#uses=0]
63 %tmp7.i10.i = getelementptr %struct.operator* %tmp66.i62.i, i32 0, i32 5 ; [#uses=1]
64 %tmp8.i11.i = load i32* %tmp7.i10.i ; [#uses=7]
65 br label %NodeBlock5
66
67 NodeBlock5: ; preds = %bb.i9.i.i932.ce
68 icmp slt i32 %tmp8.i11.i, 1 ; :0 [#uses=1]
69 br i1 %0, label %NodeBlock, label %NodeBlock4
70
71 NodeBlock4: ; preds = %NodeBlock5
72 icmp slt i32 %tmp8.i11.i, 2 ; :1 [#uses=1]
73 br i1 %1, label %LeafBlock2, label %LeafBlock3
74
75 LeafBlock3: ; preds = %NodeBlock4
76 icmp eq i32 %tmp8.i11.i, 2 ; :2 [#uses=1]
77 br i1 %2, label %bb28.i.i938.exitStub, label %NewDefault
78
79 LeafBlock2: ; preds = %NodeBlock4
80 icmp eq i32 %tmp8.i11.i, 1 ; :3 [#uses=1]
81 br i1 %3, label %bb20.i.i937.exitStub, label %NewDefault
82
83 NodeBlock: ; preds = %NodeBlock5
84 icmp slt i32 %tmp8.i11.i, 0 ; :4 [#uses=1]
85 br i1 %4, label %LeafBlock, label %LeafBlock1
86
87 LeafBlock1: ; preds = %NodeBlock
88 icmp eq i32 %tmp8.i11.i, 0 ; :5 [#uses=1]
89 br i1 %5, label %bb12.i.i935.exitStub, label %NewDefault
90
91 LeafBlock: ; preds = %NodeBlock
92 icmp eq i32 %tmp8.i11.i, -1 ; :6 [#uses=1]
93 br i1 %6, label %bb.i14.i.exitStub, label %NewDefault
94 }
0 ; RUN: llc < %s -O0
11 ; PR 1323
22
3 ; ModuleID = 'test.bc'
4 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
5 target triple = "i686-apple-darwin8"
63 %struct.comp = type { i8*, i32, i8*, [3 x i8], i32 }
74
85 define void @regbranch() {
+0
-35
test/CodeGen/Generic/2007-05-05-Personality.ll less more
None ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -enable-eh -o - | grep zPL
1
2 @error = external global i8 ; [#uses=2]
3
4 define void @_ada_x() {
5 entry:
6 invoke void @raise( )
7 to label %eh_then unwind label %unwind
8
9 unwind: ; preds = %entry
10 %eh_ptr = tail call i8* @llvm.eh.exception( ) ; [#uses=2]
11 %eh_select = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector.i32( i8* %eh_ptr, i8* bitcast (i32 (...)* @__gnat_eh_personality to i8*), i8* @error ) ; [#uses=1]
12 %eh_typeid = tail call i32 @llvm.eh.typeid.for.i32( i8* @error ) ; [#uses=1]
13 %tmp2 = icmp eq i32 %eh_select, %eh_typeid ; [#uses=1]
14 br i1 %tmp2, label %eh_then, label %Unwind
15
16 eh_then: ; preds = %unwind, %entry
17 ret void
18
19 Unwind: ; preds = %unwind
20 tail call i32 (...)* @_Unwind_Resume( i8* %eh_ptr ) ; :0 [#uses=0]
21 unreachable
22 }
23
24 declare void @raise()
25
26 declare i8* @llvm.eh.exception()
27
28 declare i32 @llvm.eh.selector.i32(i8*, i8*, ...)
29
30 declare i32 @llvm.eh.typeid.for.i32(i8*)
31
32 declare i32 @__gnat_eh_personality(...)
33
34 declare i32 @_Unwind_Resume(...)
0 ; RUN: llc < %s -o -
11
2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
3 target triple = "i686-pc-linux-gnu"
42 %struct.RETURN = type { i32, i32 }
53 %struct.ada__finalization__controlled = type { %struct.system__finalization_root__root_controlled }
64 %struct.ada__streams__root_stream_type = type { %struct.ada__tags__dispatch_table* }
0 ; RUN: llc < %s -enable-eh
1
2 target triple = "i686-pc-linux-gnu"
31
42 define fastcc void @bc__support__high_resolution_time__initialize_clock_rate() {
53 entry:
0 ; RUN: llc < %s -enable-eh
11 ; PR1833
22
3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
4 target triple = "i686-pc-linux-gnu"
53 %struct.__class_type_info_pseudo = type { %struct.__type_info_pseudo }
64 %struct.__type_info_pseudo = type { i8*, i8* }
75 @_ZTI2e1 = external constant %struct.__class_type_info_pseudo ; <%struct.__class_type_info_pseudo*> [#uses=1]
0 ; RUN: llc < %s
11 ; PR2603
2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
3 target triple = "i386-pc-linux-gnu"
42 %struct.A = type { i8 }
53 %struct.B = type { i8, [1 x i8] }
64 @Foo = constant %struct.A { i8 ptrtoint (i8* getelementptr ([1 x i8]* inttoptr (i32 17 to [1 x i8]*), i32 0, i32 -16) to i8) } ; <%struct.A*> [#uses=0]
0 ; RUN: llc < %s
11 ; PR5495
2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
3 target triple = "i386-pc-linux-gnu"
42
53 %"struct.std::__ctype_abstract_base" = type { %"struct.std::locale::facet" }
64 %"struct.std::basic_ios >" = type { %"struct.std::ios_base", %"struct.std::basic_ostream >"*, i8, i8, %"struct.std::basic_streambuf >"*, %"struct.std::ctype"*, %"struct.std::__ctype_abstract_base"*, %"struct.std::__ctype_abstract_base"* }
+0
-53
test/CodeGen/Generic/GC/alloc_loop.ll less more
None ; RUN: llc < %s
1
2
3 declare i8* @llvm_gc_allocate(i32)
4 declare void @llvm_gc_initialize(i32)
5
6 declare void @llvm.gcroot(i8**, i8*)
7 declare void @llvm.gcwrite(i8*, i8*, i8**)
8
9 define i32 @main() gc "shadow-stack" {
10 entry:
11 %A = alloca i8*
12 %B = alloca i8**
13
14 call void @llvm_gc_initialize(i32 1048576) ; Start with 1MB heap
15
16 ;; void *A;
17 call void @llvm.gcroot(i8** %A, i8* null)
18
19 ;; A = gcalloc(10);
20 %Aptr = call i8* @llvm_gc_allocate(i32 10)
21 store i8* %Aptr, i8** %A
22
23 ;; void **B;
24 %tmp.1 = bitcast i8*** %B to i8**
25 call void @llvm.gcroot(i8** %tmp.1, i8* null)
26
27 ;; B = gcalloc(4);
28 %B.upgrd.1 = call i8* @llvm_gc_allocate(i32 8)
29 %tmp.2 = bitcast i8* %B.upgrd.1 to i8**
30 store i8** %tmp.2, i8*** %B
31
32 ;; *B = A;
33 %B.1 = load i8*** %B
34 %A.1 = load i8** %A
35 call void @llvm.gcwrite(i8* %A.1, i8* %B.upgrd.1, i8** %B.1)
36
37 br label %AllocLoop
38
39 AllocLoop:
40 %i = phi i32 [ 0, %entry ], [ %indvar.next, %AllocLoop ]
41 ;; Allocated mem: allocated memory is immediately dead.
42 call i8* @llvm_gc_allocate(i32 100)
43
44 %indvar.next = add i32 %i, 1
45 %exitcond = icmp eq i32 %indvar.next, 10000000
46 br i1 %exitcond, label %Exit, label %AllocLoop
47
48 Exit:
49 ret i32 0
50 }
51
52 declare void @__main()
+0
-19
test/CodeGen/Generic/GC/argpromotion.ll less more
None ; RUN: opt < %s -argpromotion
1
2 declare void @llvm.gcroot(i8**, i8*)
3
4 define i32 @g() {
5 entry:
6 %var = alloca i32
7 store i32 1, i32* %var
8 %x = call i32 @f(i32* %var)
9 ret i32 %x
10 }
11
12 define internal i32 @f(i32* %xp) gc "example" {
13 entry:
14 %var = alloca i8*
15 call void @llvm.gcroot(i8** %var, i8* null)
16 %x = load i32* %xp
17 ret i32 %x
18 }
+0
-13
test/CodeGen/Generic/GC/badreadproto.ll less more
None ; RUN: not llvm-as < %s >& /dev/null
1
2 %list = type { i32, %list* }
3
4 ; This usage is invalid now; instead, objects must be bitcast to i8* for input
5 ; to the gc intrinsics.
6 declare %list* @llvm.gcread(%list*, %list**)
7
8 define %list* @tl(%list* %l) gc "example" {
9 %hd.ptr = getelementptr %list* %l, i32 0, i32 0
10 %hd = call %list* @llvm.gcread(%list* %l, %list** %hd.ptr)
11 ret i32 %tmp
12 }
+0
-13
test/CodeGen/Generic/GC/badrootproto.ll less more
None ; RUN: not llvm-as < %s >& /dev/null
1
2 %list = type { i32, %list* }
3 %meta = type opaque
4
5 ; This usage is invalid now; instead, objects must be bitcast to i8* for input
6 ; to the gc intrinsics.
7 declare void @llvm.gcroot(%list*, %meta*)
8
9 define void @root() gc "example" {
10 %x.var = alloca i8*
11 call void @llvm.gcroot(i8** %x.var, %meta* null)
12 }
+0
-22
test/CodeGen/Generic/GC/badwriteproto.ll less more
None ; RUN: not llvm-as < %s >& /dev/null
1
2 %list = type { i32, %list* }
3
4 ; This usage is invalid now; instead, objects must be bitcast to i8* for input
5 ; to the gc intrinsics.
6 declare void @llvm.gcwrite(%list*, %list*, %list**)
7
8 define %list* @cons(i32 %hd, %list* %tl) gc "example" {
9 %tmp = call i8* @gcalloc(i32 bitcast(%list* getelementptr(%list* null, i32 1) to i32))
10 %cell = bitcast i8* %tmp to %list*
11
12 %hd.ptr = getelementptr %list* %cell, i32 0, i32 0
13 store i32 %hd, i32* %hd.ptr
14
15 %tl.ptr = getelementptr %list* %cell, i32 0, i32 0
16 call void @llvm.gcwrite(%list* %tl, %list* %cell, %list** %tl.ptr)
17
18 ret %cell.2
19 }
20
21 declare i8* @gcalloc(i32)
+0
-16
test/CodeGen/Generic/GC/deadargelim.ll less more
None ; RUN: opt < %s -deadargelim
1
2 declare void @llvm.gcroot(i8**, i8*)
3
4 define void @g() {
5 entry:
6 call void @f(i32 0)
7 ret void
8 }
9
10 define internal void @f(i32 %unused) gc "example" {
11 entry:
12 %var = alloca i8*
13 call void @llvm.gcroot(i8** %var, i8* null)
14 ret void
15 }
+0
-3
test/CodeGen/Generic/GC/dg.exp less more
None load_lib llvm.exp
1
2 RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
+0
-10
test/CodeGen/Generic/GC/fat.ll less more
None ; RUN: not llvm-as < %s >& /dev/null
1
2 declare void @llvm.gcroot(i8**, i8*) nounwind
3
4 define void @f() gc "x" {
5 %st = alloca { i8*, i1 } ; <{ i8*, i1 }*> [#uses=1]
6 %st_ptr = bitcast { i8*, i1 }* %st to i8** ; [#uses=1]
7 call void @llvm.gcroot(i8** %st_ptr, i8* null)
8 ret void
9 }
+0
-23
test/CodeGen/Generic/GC/inline.ll less more
None ; RUN: opt < %s -inline -S | grep example
1
2 %IntArray = type { i32, [0 x i32*] }
3
4 declare void @llvm.gcroot(i8**, i8*) nounwind
5
6 define i32 @f() {
7 %x = call i32 @g( ) ; [#uses=1]
8 ret i32 %x
9 }
10
11 define internal i32 @g() gc "example" {
12 %root = alloca i8* ; [#uses=2]
13 call void @llvm.gcroot( i8** %root, i8* null )
14 %obj = call %IntArray* @h( ) ; <%IntArray*> [#uses=2]
15 %obj.2 = bitcast %IntArray* %obj to i8* ; [#uses=1]
16 store i8* %obj.2, i8** %root
17 %Length.ptr = getelementptr %IntArray* %obj, i32 0, i32 0 ; [#uses=1]
18 %Length = load i32* %Length.ptr ; [#uses=1]
19 ret i32 %Length
20 }
21
22 declare %IntArray* @h()
+0
-24
test/CodeGen/Generic/GC/inline2.ll less more
None ; RUN: opt < %s -inline -S | grep sample
1 ; RUN: opt < %s -inline -S | grep example
2
3 %IntArray = type { i32, [0 x i32*] }
4
5 declare void @llvm.gcroot(i8**, i8*) nounwind
6
7 define i32 @f() gc "sample" {
8 %x = call i32 @g( ) ; [#uses=1]
9 ret i32 %x
10 }
11
12 define internal i32 @g() gc "example" {
13 %root = alloca i8* ; [#uses=2]
14 call void @llvm.gcroot( i8** %root, i8* null )
15 %obj = call %IntArray* @h( ) ; <%IntArray*> [#uses=2]
16 %obj.2 = bitcast %IntArray* %obj to i8* ; [#uses=1]
17 store i8* %obj.2, i8** %root
18 %Length.ptr = getelementptr %IntArray* %obj, i32 0, i32 0 ; [#uses=1]
19 %Length = load i32* %Length.ptr ; [#uses=1]
20 ret i32 %Length
21 }
22
23 declare %IntArray* @h()
+0
-11
test/CodeGen/Generic/GC/lower_gcroot.ll less more
None ; RUN: llc < %s
1
2 %Env = type i8*
3
4 define void @.main(%Env) gc "shadow-stack" {
5 %Root = alloca %Env
6 call void @llvm.gcroot( %Env* %Root, %Env null )
7 unreachable
8 }
9
10 declare void @llvm.gcroot(%Env*, %Env)
+0
-10
test/CodeGen/Generic/GC/outside.ll less more
None ; RUN: not llvm-as < %s >& /dev/null
1
2 declare void @llvm.gcroot(i8**, i8*)
3
4 define void @f(i8* %x) {
5 %root = alloca i8*
6 call void @llvm.gcroot(i8** %root, i8* null)
7 store i8* %x, i8** %root
8 ret void
9 }
+0
-17
test/CodeGen/Generic/GC/redundant_init.ll less more
None ; RUN: llc < %s -march=x86 | \
1 ; RUN: ignore grep {movl..0} | count 0
2
3 %struct.obj = type { i8*, %struct.obj* }
4
5 declare void @g() gc "shadow-stack"
6
7 define void @f(i8* %o) gc "shadow-stack" {
8 entry:
9 %root = alloca i8*
10 call void @llvm.gcroot(i8** %root, i8* null)
11 store i8* %o, i8** %root
12 call void @g()
13 ret void
14 }
15
16 declare void @llvm.gcroot(i8**, i8*)
+0
-42
test/CodeGen/Generic/GC/simple_ocaml.ll less more
None ; RUN: llc < %s | grep caml.*__frametable
1 ; RUN: llc < %s -march=x86 | grep {movl .0}
2
3 %struct.obj = type { i8*, %struct.obj* }
4
5 define %struct.obj* @fun(%struct.obj* %head) gc "ocaml" {
6 entry:
7 %gcroot.0 = alloca i8*
8 %gcroot.1 = alloca i8*
9
10 call void @llvm.gcroot(i8** %gcroot.0, i8* null)
11 call void @llvm.gcroot(i8** %gcroot.1, i8* null)
12
13 %local.0 = bitcast i8** %gcroot.0 to %struct.obj**
14 %local.1 = bitcast i8** %gcroot.1 to %struct.obj**
15
16 store %struct.obj* %head, %struct.obj** %local.0
17 br label %bb.loop
18 bb.loop:
19 %t0 = load %struct.obj** %local.0
20 %t1 = getelementptr %struct.obj* %t0, i32 0, i32 1
21 %t2 = bitcast %struct.obj* %t0 to i8*
22 %t3 = bitcast %struct.obj** %t1 to i8**
23 %t4 = call i8* @llvm.gcread(i8* %t2, i8** %t3)
24 %t5 = bitcast i8* %t4 to %struct.obj*
25 %t6 = icmp eq %struct.obj* %t5, null
26 br i1 %t6, label %bb.loop, label %bb.end
27 bb.end:
28 %t7 = malloc %struct.obj
29 store %struct.obj* %t7, %struct.obj** %local.1
30 %t8 = bitcast %struct.obj* %t7 to i8*
31 %t9 = load %struct.obj** %local.0
32 %t10 = getelementptr %struct.obj* %t9, i32 0, i32 1
33 %t11 = bitcast %struct.obj* %t9 to i8*
34 %t12 = bitcast %struct.obj** %t10 to i8**
35 call void @llvm.gcwrite(i8* %t8, i8* %t11, i8** %t12)
36 ret %struct.obj* %t7
37 }
38
39 declare void @llvm.gcroot(i8** %value, i8* %tag)
40 declare void @llvm.gcwrite(i8* %value, i8* %obj, i8** %field)
41 declare i8* @llvm.gcread(i8* %obj, i8** %field)
0 ; PR 1200
1 ; RUN: llc < %s -enable-tail-merge=0 | not grep jmp
2
3 ; ModuleID = ''
4 target datalayout = "e-p:32:32"
5 target triple = "i686-apple-darwin8"
6 %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }
7 %struct.Index_Map = type { i32, %struct.item_set** }
8 %struct.Item = type { [4 x i16], %struct.rule* }
9 %struct.__sFILEX = type opaque
10 %struct.__sbuf = type { i8*, i32 }
11 %struct.dimension = type { i16*, %struct.Index_Map, %struct.mapping*, i32, %struct.plankMap* }
12 %struct.item_set = type { i32, i32, %struct.operator*, [2 x %struct.item_set*], %struct.item_set*, i16*, %struct.Item*, %struct.Item* }
13 %struct.list = type { i8*, %struct.list* }
14 %struct.mapping = type { %struct.list**, i32, i32, i32, %struct.item_set** }
15 %struct.nonterminal = type { i8*, i32, i32, i32, %struct.plankMap*, %struct.rule* }
16 %struct.operator = type { i8*, i8, i32, i32, i32, i32, %struct.table* }
17 %struct.pattern = type { %struct.nonterminal*, %struct.operator*, [2 x %struct.nonterminal*] }
18 %struct.plank = type { i8*, %struct.list*, i32 }
19 %struct.plankMap = type { %struct.list*, i32, %struct.stateMap* }
20 %struct.rule = type { [4 x i16], i32, i32, i32, %struct.nonterminal*, %struct.pattern*, i8 }
21 %struct.stateMap = type { i8*, %struct.plank*, i32, i16* }
22 %struct.table = type { %struct.operator*, %struct.list*, i16*, [2 x %struct.dimension*], %struct.item_set** }
23 @outfile = external global %struct.FILE* ; <%struct.FILE**> [#uses=1]
24 @str1 = external global [11 x i8] ; <[11 x i8]*> [#uses=1]
25
26 declare i32 @fprintf(%struct.FILE*, i8*, ...)
27
28 define i16 @main_bb_2E_i9_2E_i_2E_i932_2E_ce(%struct.list* %l_addr.01.0.i2.i.i929, %struct.operator** %tmp66.i62.i.out) {
29 newFuncRoot:
30 br label %bb.i9.i.i932.ce
31
32 NewDefault: ; preds = %LeafBlock, %LeafBlock1, %LeafBlock2, %LeafBlock3
33 br label %bb36.i.i.exitStub
34
35 bb36.i.i.exitStub: ; preds = %NewDefault
36 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
37 ret i16 0
38
39 bb.i14.i.exitStub: ; preds = %LeafBlock
40 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
41 ret i16 1
42
43 bb12.i.i935.exitStub: ; preds = %LeafBlock1
44 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
45 ret i16 2
46
47 bb20.i.i937.exitStub: ; preds = %LeafBlock2
48 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
49 ret i16 3
50
51 bb28.i.i938.exitStub: ; preds = %LeafBlock3
52 store %struct.operator* %tmp66.i62.i, %struct.operator** %tmp66.i62.i.out
53 ret i16 4
54
55 bb.i9.i.i932.ce: ; preds = %newFuncRoot
56 %tmp1.i3.i.i930 = getelementptr %struct.list* %l_addr.01.0.i2.i.i929, i32 0, i32 0 ; [#uses=1]
57 %tmp2.i4.i.i931 = load i8** %tmp1.i3.i.i930 ; [#uses=1]
58 %tmp66.i62.i = bitcast i8* %tmp2.i4.i.i931 to %struct.operator* ; <%struct.operator*> [#uses=7]
59 %tmp1.i6.i = getelementptr %struct.operator* %tmp66.i62.i, i32 0, i32 2 ; [#uses=1]
60 %tmp2.i7.i = load i32* %tmp1.i6.i ; [#uses=1]
61 %tmp3.i8.i = load %struct.FILE** @outfile ; <%struct.FILE*> [#uses=1]
62 %tmp5.i9.i = call i32 (%struct.FILE*, i8*, ...)* @fprintf( %struct.FILE* %tmp3.i8.i, i8* getelementptr ([11 x i8]* @str1, i32 0, i32 0), i32 %tmp2.i7.i ) ; [#uses=0]
63 %tmp7.i10.i = getelementptr %struct.operator* %tmp66.i62.i, i32 0, i32 5 ; [#uses=1]
64 %tmp8.i11.i = load i32* %tmp7.i10.i ; [#uses=7]
65 br label %NodeBlock5
66
67 NodeBlock5: ; preds = %bb.i9.i.i932.ce
68 icmp slt i32 %tmp8.i11.i, 1 ; :0 [#uses=1]
69 br i1 %0, label %NodeBlock, label %NodeBlock4
70
71 NodeBlock4: ; preds = %NodeBlock5
72 icmp slt i32 %tmp8.i11.i, 2 ; :1 [#uses=1]
73 br i1 %1, label %LeafBlock2, label %LeafBlock3
74
75 LeafBlock3: ; preds = %NodeBlock4
76 icmp eq i32 %tmp8.i11.i, 2 ; :2 [#uses=1]
77 br i1 %2, label %bb28.i.i938.exitStub, label %NewDefault
78
79 LeafBlock2: ; preds = %NodeBlock4
80 icmp eq i32 %tmp8.i11.i, 1 ; :3 [#uses=1]
81 br i1 %3, label %bb20.i.i937.exitStub, label %NewDefault
82
83 NodeBlock: ; preds = %NodeBlock5
84 icmp slt i32 %tmp8.i11.i, 0 ; :4 [#uses=1]
85 br i1 %4, label %LeafBlock, label %LeafBlock1
86
87 LeafBlock1: ; preds = %NodeBlock
88 icmp eq i32 %tmp8.i11.i, 0 ; :5 [#uses=1]
89 br i1 %5, label %bb12.i.i935.exitStub, label %NewDefault
90
91 LeafBlock: ; preds = %NodeBlock
92 icmp eq i32 %tmp8.i11.i, -1 ; :6 [#uses=1]
93 br i1 %6, label %bb.i14.i.exitStub, label %NewDefault
94 }
0 ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -enable-eh -o - | grep zPL
1
2 @error = external global i8 ; [#uses=2]
3
4 define void @_ada_x() {
5 entry:
6 invoke void @raise( )
7 to label %eh_then unwind label %unwind
8
9 unwind: ; preds = %entry
10 %eh_ptr = tail call i8* @llvm.eh.exception( ) ; [#uses=2]
11 %eh_select = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector.i32( i8* %eh_ptr, i8* bitcast (i32 (...)* @__gnat_eh_personality to i8*), i8* @error ) ; [#uses=1]
12 %eh_typeid = tail call i32 @llvm.eh.typeid.for.i32( i8* @error ) ; [#uses=1]
13 %tmp2 = icmp eq i32 %eh_select, %eh_typeid ; [#uses=1]
14 br i1 %tmp2, label %eh_then, label %Unwind
15
16 eh_then: ; preds = %unwind, %entry
17 ret void
18
19 Unwind: ; preds = %unwind
20 tail call i32 (...)* @_Unwind_Resume( i8* %eh_ptr ) ; :0 [#uses=0]
21 unreachable
22 }
23
24 declare void @raise()
25
26 declare i8* @llvm.eh.exception()
27
28 declare i32 @llvm.eh.selector.i32(i8*, i8*, ...)
29
30 declare i32 @llvm.eh.typeid.for.i32(i8*)
31
32 declare i32 @__gnat_eh_personality(...)
33
34 declare i32 @_Unwind_Resume(...)
0 ; RUN: llc < %s
1
2
3 declare i8* @llvm_gc_allocate(i32)
4 declare void @llvm_gc_initialize(i32)
5
6 declare void @llvm.gcroot(i8**, i8*)
7 declare void @llvm.gcwrite(i8*, i8*, i8**)
8
9 define i32 @main() gc "shadow-stack" {
10 entry:
11 %A = alloca i8*
12 %B = alloca i8**
13
14 call void @llvm_gc_initialize(i32 1048576) ; Start with 1MB heap
15
16 ;; void *A;
17 call void @llvm.gcroot(i8** %A, i8* null)
18
19 ;; A = gcalloc(10);
20 %Aptr = call i8* @llvm_gc_allocate(i32 10)
21 store i8* %Aptr, i8** %A
22
23 ;; void **B;
24 %tmp.1 = bitcast i8*** %B to i8**
25 call void @llvm.gcroot(i8** %tmp.1, i8* null)
26
27 ;; B = gcalloc(4);
28 %B.upgrd.1 = call i8* @llvm_gc_allocate(i32 8)
29 %tmp.2 = bitcast i8* %B.upgrd.1 to i8**
30 store i8** %tmp.2, i8*** %B
31
32 ;; *B = A;
33 %B.1 = load i8*** %B
34 %A.1 = load i8** %A
35 call void @llvm.gcwrite(i8* %A.1, i8* %B.upgrd.1, i8** %B.1)
36
37 br label %AllocLoop
38
39 AllocLoop:
40 %i = phi i32 [ 0, %entry ], [ %indvar.next, %AllocLoop ]
41 ;; Allocated mem: allocated memory is immediately dead.
42 call i8* @llvm_gc_allocate(i32 100)
43
44 %indvar.next = add i32 %i, 1
45 %exitcond = icmp eq i32 %indvar.next, 10000000
46 br i1 %exitcond, label %Exit, label %AllocLoop
47
48 Exit:
49 ret i32 0
50 }
51
52 declare void @__main()
0 ; RUN: opt < %s -argpromotion
1
2 declare void @llvm.gcroot(i8**, i8*)
3
4 define i32 @g() {
5 entry:
6 %var = alloca i32
7 store i32 1, i32* %var
8 %x = call i32 @f(i32* %var)
9 ret i32 %x
10 }
11
12 define internal i32 @f(i32* %xp) gc "example" {
13 entry:
14 %var = alloca i8*
15 call void @llvm.gcroot(i8** %var, i8* null)
16 %x = load i32* %xp
17 ret i32 %x
18 }
0 ; RUN: not llvm-as < %s >& /dev/null
1
2 %list = type { i32, %list* }
3
4 ; This usage is invalid now; instead, objects must be bitcast to i8* for input
5 ; to the gc intrinsics.
6 declare %list* @llvm.gcread(%list*, %list**)
7
8 define %list* @tl(%list* %l) gc "example" {
9 %hd.ptr = getelementptr %list* %l, i32 0, i32 0
10 %hd = call %list* @llvm.gcread(%list* %l, %list** %hd.ptr)
11 ret i32 %tmp
12 }
0 ; RUN: not llvm-as < %s >& /dev/null
1
2 %list = type { i32, %list* }
3 %meta = type opaque
4
5 ; This usage is invalid now; instead, objects must be bitcast to i8* for input
6 ; to the gc intrinsics.
7 declare void @llvm.gcroot(%list*, %meta*)
8
9 define void @root() gc "example" {
10 %x.var = alloca i8*
11 call void @llvm.gcroot(i8** %x.var, %meta* null)
12 }
0 ; RUN: not llvm-as < %s >& /dev/null
1
2 %list = type { i32, %list* }
3
4 ; This usage is invalid now; instead, objects must be bitcast to i8* for input
5 ; to the gc intrinsics.
6 declare void @llvm.gcwrite(%list*, %list*, %list**)
7
8 define %list* @cons(i32 %hd, %list* %tl) gc "example" {
9 %tmp = call i8* @gcalloc(i32 bitcast(%list* getelementptr(%list* null, i32 1) to i32))
10 %cell = bitcast i8* %tmp to %list*
11
12 %hd.ptr = getelementptr %list* %cell, i32 0, i32 0
13 store i32 %hd, i32* %hd.ptr
14
15 %tl.ptr = getelementptr %list* %cell, i32 0, i32 0
16 call void @llvm.gcwrite(%list* %tl, %list* %cell, %list** %tl.ptr)
17
18 ret %cell.2
19 }
20
21 declare i8* @gcalloc(i32)
0 ; RUN: opt < %s -deadargelim
1
2 declare void @llvm.gcroot(i8**, i8*)
3
4 define void @g() {
5 entry:
6 call void @f(i32 0)
7 ret void
8 }
9
10 define internal void @f(i32 %unused) gc "example" {
11 entry:
12 %var = alloca i8*
13 call void @llvm.gcroot(i8** %var, i8* null)
14 ret void
15 }
0 load_lib llvm.exp
1
2 RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]]
0 ; RUN: not llvm-as < %s >& /dev/null
1
2 declare void @llvm.gcroot(i8**, i8*) nounwind
3
4 define void @f() gc "x" {
5 %st = alloca { i8*, i1 } ; <{ i8*, i1 }*> [#uses=1]
6 %st_ptr = bitcast { i8*, i1 }* %st to i8** ; [#uses=1]
7 call void @llvm.gcroot(i8** %st_ptr, i8* null)
8 ret void
9 }
0 ; RUN: opt < %s -inline -S | grep example
1
2 %IntArray = type { i32, [0 x i32*] }
3
4 declare void @llvm.gcroot(i8**, i8*) nounwind
5
6 define i32 @f() {
7 %x = call i32 @g( ) ; [#uses=1]
8 ret i32 %x
9 }
10
11 define internal i32 @g() gc "example" {
12 %root = alloca i8* ; [#uses=2]
13 call void @llvm.gcroot( i8** %root, i8* null )
14 %obj = call %IntArray* @h( ) ; <%IntArray*> [#uses=2]
15 %obj.2 = bitcast %IntArray* %obj to i8* ; [#uses=1]
16 store i8* %obj.2, i8** %root
17 %Length.ptr = getelementptr %IntArray* %obj, i32 0, i32 0 ; [#uses=1]
18 %Length = load i32* %Length.ptr ; [#uses=1]
19 ret i32 %Length
20 }
21
22 declare %IntArray* @h()
0 ; RUN: opt < %s -inline -S | grep sample
1 ; RUN: opt < %s -inline -S | grep example
2
3 %IntArray = type { i32, [0 x i32*] }
4
5 declare void @llvm.gcroot(i8**, i8*) nounwind
6
7 define i32 @f() gc "sample" {
8 %x = call i32 @g( ) ; [#uses=1]
9 ret i32 %x
10 }
11
12 define internal i32 @g() gc "example" {
13 %root = alloca i8* ; [#uses=2]
14 call void @llvm.gcroot( i8** %root, i8* null )
15 %obj = call %IntArray* @h( ) ; <%IntArray*> [#uses=2]
16 %obj.2 = bitcast %IntArray* %obj to i8* ; [#uses=1]
17 store i8* %obj.2, i8** %root
18 %Length.ptr = getelementptr %IntArray* %obj, i32 0, i32 0 ; [#uses=1]
19 %Length = load i32* %Length.ptr ; [#uses=1]
20 ret i32 %Length
21 }
22
23 declare %IntArray* @h()
0 ; RUN: llc < %s
1
2 %Env = type i8*
3
4 define void @.main(%Env) gc "shadow-stack" {
5 %Root = alloca %Env
6 call void @llvm.gcroot( %Env* %Root, %Env null )
7 unreachable
8 }
9
10 declare void @llvm.gcroot(%Env*, %Env)
0 ; RUN: not llvm-as < %s >& /dev/null
1
2 declare void @llvm.gcroot(i8**, i8*)
3
4 define void @f(i8* %x) {
5 %root = alloca i8*
6 call void @llvm.gcroot(i8** %root, i8* null)
7 store i8* %x, i8** %root
8 ret void
9 }
0 ; RUN: llc < %s | grep caml.*__frametable
1 ; RUN: llc < %s -march=x86 | grep {movl .0}
2
3 %struct.obj = type { i8*, %struct.obj* }
4
5 define %struct.obj* @fun(%struct.obj* %head) gc "ocaml" {
6 entry:
7 %gcroot.0 = alloca i8*
8 %gcroot.1 = alloca i8*
9
10 call void @llvm.gcroot(i8** %gcroot.0, i8* null)
11 call void @llvm.gcroot(i8** %gcroot.1, i8* null)
12
13 %local.0 = bitcast i8** %gcroot.0 to %struct.obj**
14 %local.1 = bitcast i8** %gcroot.1 to %struct.obj**
15
16 store %struct.obj* %head, %struct.obj** %local.0
17 br label %bb.loop
18 bb.loop:
19 %t0 = load %struct.obj** %local.0
20 %t1 = getelementptr %struct.obj* %t0, i32 0, i32 1
21 %t2 = bitcast %struct.obj* %t0 to i8*
22 %t3 = bitcast %struct.obj** %t1 to i8**
23 %t4 = call i8* @llvm.gcread(i8* %t2, i8** %t3)
24 %t5 = bitcast i8* %t4 to %struct.obj*
25 %t6 = icmp eq %struct.obj* %t5, null
26 br i1 %t6, label %bb.loop, label %bb.end
27 bb.end:
28 %t7 = malloc %struct.obj
29 store %struct.obj* %t7, %struct.obj** %local.1
30 %t8 = bitcast %struct.obj* %t7 to i8*
31 %t9 = load %struct.obj** %local.0
32 %t10 = getelementptr %struct.obj* %t9, i32 0, i32 1
33 %t11 = bitcast %struct.obj* %t9 to i8*
34 %t12 = bitcast %struct.obj** %t10 to i8**
35 call void @llvm.gcwrite(i8* %t8, i8* %t11, i8** %t12)
36 ret %struct.obj* %t7
37 }
38
39 declare void @llvm.gcroot(i8** %value, i8* %tag)
40 declare void @llvm.gcwrite(i8* %value, i8* %obj, i8** %field)
41 declare i8* @llvm.gcread(i8* %obj, i8** %field)