llvm.org GIT mirror llvm / 9bc243b
Remove llvm-upgrade and update tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47784 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 12 years ago
40 changed file(s) with 624 addition(s) and 705 deletion(s). Raw diff Collapse all Expand all
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %X = global int 4, align 16
4 @X = global i32 4, align 16 ; [#uses=0]
55
6 int *%test() align 32 {
7 %X = alloca int, align 4
8 %Y = alloca int, uint 42, align 16
9 %Z = alloca int, align 0
10 ret int *%X
6 define i32* @test() align 32 {
7 %X = alloca i32, align 4 ; [#uses=1]
8 %Y = alloca i32, i32 42, align 16 ; [#uses=0]
9 %Z = alloca i32 ; [#uses=0]
10 ret i32* %X
1111 }
1212
13 int *%test2() {
14 %X = malloc int, align 4
15 %Y = malloc int, uint 42, align 16
16 %Z = malloc int, align 0
17 %T = malloc int, align 256
18 ret int *%X
13 define i32* @test2() {
14 %X = malloc i32, align 4 ; [#uses=1]
15 %Y = malloc i32, i32 42, align 16 ; [#uses=0]
16 %Z = malloc i32 ; [#uses=0]
17 %T = malloc i32, align 256 ; [#uses=0]
18 ret i32* %X
1919 }
20
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
3
4 implementation
53
64 ; Test "stripped" format where nothing is symbolic... this is how the bytecode
75 ; format looks anyways (except for negative vs positive offsets)...
86 ;
9 void "void"(int, int) ; Def %0, %1
10 begin
11 add int 0, 0 ; Def 2
12 sub int 0, 4 ; Def 3
13 br label %1
147
15 add int %0, %1 ; Def 4
16 sub int %4, %3 ; Def 5
17 setle int %5, %2 ; Def 0 - bool plane
18 br bool %0, label %2, label %1
8 define void @void(i32, i32) {
9 add i32 0, 0 ; :3 [#uses=2]
10 sub i32 0, 4 ; :4 [#uses=2]
11 br label %5
1912
20 add int %0, %1 ; Def 6
21 sub int %4, %3 ; Def 7
22 setle int %7, %2 ; Def 1 - bool plane
23 ret void
24 end
13 ;
14 add i32 %0, %1 ; :6 [#uses=2]
15 sub i32 %6, %4 ; :7 [#uses=1]
16 icmp sle i32 %7, %3 ; :8 [#uses=1]
17 br i1 %8, label %9, label %5
18
19 ;
20 add i32 %0, %1 ; :10 [#uses=0]
21 sub i32 %6, %4 ; :11 [#uses=1]
22 icmp sle i32 %11, %3 ; :12 [#uses=0]
23 ret void
24 }
2525
2626 ; This function always returns zero
27 int "zarro"()
28 begin
27 define i32 @zarro() {
2928 Startup:
30 ret int 0
31 end
29 ret i32 0
30 }
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 fastcc void %foo() {
5 ret void
4 define fastcc void @foo() {
5 ret void
66 }
77
8 coldcc void %bar() {
9 call fastcc void %foo()
10 ret void
8 define coldcc void @bar() {
9 call fastcc void @foo( )
10 ret void
1111 }
1212
13 csretcc void %structret({sbyte}* %P) {
14 call csretcc void %structret({sbyte}* %P)
15 ret void
13 define void @structret({ i8 }* sret %P) {
14 call void @structret( { i8 }* sret %P )
15 ret void
1616 }
1717
18
19 cc0 void %foo2() {
20 ret void
18 define void @foo2() {
19 ret void
2120 }
2221
23 coldcc void %bar2() {
24 call fastcc void %foo()
25 ret void
22 define coldcc void @bar2() {
23 call fastcc void @foo( )
24 ret void
2625 }
2726
28 cc42 void %bar3() {
29 invoke fastcc void %foo() to label %Ok unwind label %U
30 Ok:
31 ret void
32 U:
33 unwind
27 define cc42 void @bar3() {
28 invoke fastcc void @foo( )
29 to label %Ok unwind label %U
30
31 Ok: ; preds = %0
32 ret void
33
34 U: ; preds = %0
35 unwind
3436 }
3537
38 define void @bar4() {
39 call cc42 void @bar( )
40 invoke cc42 void @bar3( )
41 to label %Ok unwind label %U
3642
37 void %bar4() {
38 call cc42 void %bar()
39 invoke cc42 void %bar3() to label %Ok unwind label %U
40 Ok:
41 ret void
42 U:
43 unwind
43 Ok: ; preds = %0
44 ret void
45
46 U: ; preds = %0
47 unwind
4448 }
4549
46
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %FunTy = type int(int)
4 %FunTy = type i32 (i32)
55
6 declare int "test"(int) ; Test forward declaration merging
6 declare i32 @test(i32) ; Test forward declaration merging
77
8 implementation
9
10 void "invoke"(%FunTy *%x) {
11 %foo = call %FunTy* %x(int 123)
12 %foo2 = tail call %FunTy* %x(int 123)
13 ret void
8 define void @invoke(%FunTy* %x) {
9 %foo = call i32 %x( i32 123 ) ; [#uses=0]
10 %foo2 = tail call i32 %x( i32 123 ) ; [#uses=0]
11 ret void
1412 }
1513
16 int "main"(int %argc) ; TODO: , sbyte **argv, sbyte **envp)
17 begin
18 %retval = call int (int) *%test(int %argc)
19 %two = add int %retval, %retval
20 %retval2 = invoke int %test(int %argc)
21 to label %Next except label %Error
22 Next:
23 %two2 = add int %two, %retval2
24 call void %invoke (%FunTy* %test)
25 ret int %two2
26 Error:
27 ret int -1
28 end
14 define i32 @main(i32 %argc) {
15 %retval = call i32 @test( i32 %argc ) ; [#uses=2]
16 %two = add i32 %retval, %retval ; [#uses=1]
17 %retval2 = invoke i32 @test( i32 %argc )
18 to label %Next unwind label %Error ; [#uses=1]
2919
30 int "test"(int %i0)
31 begin
32 ret int %i0
33 end
20 Next: ; preds = %0
21 %two2 = add i32 %two, %retval2 ; [#uses=1]
22 call void @invoke( %FunTy* @test )
23 ret i32 %two2
24
25 Error: ; preds = %0
26 ret i32 -1
27 }
28
29 define i32 @test(i32 %i0) {
30 ret i32 %i0
31 }
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 short "FunFunc"(long %x, sbyte %z)
5 begin
6 bb0: ;;
7 %cast110 = cast sbyte %z to short ;;:(signed operands)
8 %cast10 = cast long %x to short ;;
9 %reg109 = add short %cast110, %cast10 ;;
10 ret short %reg109 ;;
11 end
4 define i16 @FunFunc(i64 %x, i8 %z) {
5 bb0:
6 %cast110 = sext i8 %z to i16 ; [#uses=1]
7 %cast10 = trunc i64 %x to i16 ; [#uses=1]
8 %reg109 = add i16 %cast110, %cast10 ; [#uses=1]
9 ret i16 %reg109
10 }
1211
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 implementation
4 ;; This is an irreducible flow graph
5 define void @irreducible(i1 %cond) {
6 br i1 %cond, label %X, label %Y
57
6 ;; This is an irreducible flow graph
8 X: ; preds = %Y, %0
9 br label %Y
10
11 Y: ; preds = %X, %0
12 br label %X
13 }
14
15 ;; This is a pair of loops that share the same header
16 define void @sharedheader(i1 %cond) {
17 br label %A
18
19 A: ; preds = %Y, %X, %0
20 br i1 %cond, label %X, label %Y
21
22 X: ; preds = %A
23 br label %A
24
25 Y: ; preds = %A
26 br label %A
27 }
728
829
9 void "irreducible"(bool %cond)
10 begin
11 br bool %cond, label %X, label %Y
30 ;; This is a simple nested loop
31 define void @nested(i1 %cond1, i1 %cond2, i1 %cond3) {
32 br label %Loop1
1233
13 X:
14 br label %Y
15 Y:
16 br label %X
17 end
34 Loop1: ; preds = %L2Exit, %0
35 br label %Loop2
1836
19 ;; This is a pair of loops that share the same header
37 Loop2: ; preds = %L3Exit, %Loop1
38 br label %Loop3
2039
21 void "sharedheader"(bool %cond)
22 begin
23 br label %A
24 A:
25 br bool %cond, label %X, label %Y
40 Loop3: ; preds = %Loop3, %Loop2
41 br i1 %cond3, label %Loop3, label %L3Exit
2642
27 X:
28 br label %A
29 Y:
30 br label %A
31 end
43 L3Exit: ; preds = %Loop3
44 br i1 %cond2, label %Loop2, label %L2Exit
3245
33 ;; This is a simple nested loop
34 void "nested"(bool %cond1, bool %cond2, bool %cond3)
35 begin
36 br label %Loop1
46 L2Exit: ; preds = %L3Exit
47 br i1 %cond1, label %Loop1, label %L1Exit
3748
38 Loop1:
39 br label %Loop2
49 L1Exit: ; preds = %L2Exit
50 ret void
51 }
4052
41 Loop2:
42 br label %Loop3
43
44 Loop3:
45 br bool %cond3, label %Loop3, label %L3Exit
46
47 L3Exit:
48 br bool %cond2, label %Loop2, label %L2Exit
49
50 L2Exit:
51 br bool %cond1, label %Loop1, label %L1Exit
52
53 L1Exit:
54 ret void
55 end
56
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
99 ;; Test constant cast expressions
1010 ;;-------------------------------
1111
12 global ulong u0x00001 ; hexadecimal unsigned integer constants
13 global long s0x0012312 ; hexadecimal signed integer constants
12 global i64 u0x00001 ; hexadecimal unsigned integer constants
13 global i64 s0x0012312 ; hexadecimal signed integer constants
1414
15 %t2 = global int* %t1 ;; Forward reference without cast
16 %t3 = global uint* cast (int* %t1 to uint*) ;; Forward reference with cast
17 %t1 = global int 4 ;; int* %0
18 %t4 = global int** cast (uint** %t3 to int**) ;; Cast of a previous cast
19 %t5 = global uint** %t3 ;; Reference to a previous cast
20 %t6 = global int*** %t4 ;; Different ref. to a previous cast
21 %t7 = global float* cast (int 12345678 to float*) ;; Cast ordinary value to ptr
22 %t9 = global int cast (float cast (int 8 to float) to int) ;; Nested cast expression
15 @t2 = global i32* @t1 ;; Forward reference without cast
16 @t3 = global i32* bitcast (i32* @t1 to i32*) ;; Forward reference with cast
17 @t1 = global i32 4 ;; i32* @0
18 @t4 = global i32** bitcast (i32** @t3 to i32**) ;; Cast of a previous cast
19 @t5 = global i32** @t3 ;; Reference to a previous cast
20 @t6 = global i32*** @t4 ;; Different ref. to a previous cast
21 @t7 = global float* inttoptr (i32 12345678 to float*) ;; Cast ordinary value to ptr
22 @t9 = global i32 bitcast (float bitcast (i32 8 to float) to i32) ;; Nested cast expression
2323
24 global int* cast (float* %0 to int*) ;; Forward numeric reference
25 global float* %0 ;; Duplicate forward numeric reference
24 global i32* bitcast (float* @4 to i32*) ;; Forward numeric reference
25 global float* @4 ;; Duplicate forward numeric reference
2626 global float 0.0
2727
2828
3030 ;; Test constant getelementpr expressions for arrays
3131 ;;---------------------------------------------------
3232
33 %array = constant [2 x int] [ int 12, int 52 ]
34 %arrayPtr = global int* getelementptr ([2 x int]* %array, long 0, long 0) ;; int* &%array[0][0]
35 %arrayPtr5 = global int** getelementptr (int** %arrayPtr, long 5) ;; int* &%arrayPtr[5]
33 @array = constant [2 x i32] [ i32 12, i32 52 ]
34 @arrayPtr = global i32* getelementptr ([2 x i32]* @array, i64 0, i64 0) ;; i32* &@array[0][0]
35 @arrayPtr5 = global i32** getelementptr (i32** @arrayPtr, i64 5) ;; i32* &@arrayPtr[5]
3636
37 %somestr = constant [11x sbyte] c"hello world"
38 %char5 = global sbyte* getelementptr([11x sbyte]* %somestr, long 0, long 5)
37 @somestr = constant [11x i8] c"hello world"
38 @char5 = global i8* getelementptr([11x i8]* @somestr, i64 0, i64 5)
3939
4040 ;; cast of getelementptr
41 %char8a = global int* cast (sbyte* getelementptr([11x sbyte]* %somestr, long 0, long 8) to int*)
41 @char8a = global i32* bitcast (i8* getelementptr([11x i8]* @somestr, i64 0, i64 8) to i32*)
4242
4343 ;; getelementptr containing casts
44 %char8b = global sbyte* getelementptr([11x sbyte]* %somestr, long cast (ubyte 0 to long), long cast (sbyte 8 to long))
44 @char8b = global i8* getelementptr([11x i8]* @somestr, i64 sext (i8 0 to i64), i64 sext (i8 8 to i64))
4545
4646 ;;-------------------------------------------------------
4747 ;; TODO: Test constant getelementpr expressions for structures
4848 ;;-------------------------------------------------------
4949
50 %SType = type { int , {float, {ubyte} }, ulong } ;; struct containing struct
51 %SAType = type { int , {[2x float], ulong} } ;; struct containing array
50 %SType = type { i32 , {float, {i8} }, i64 } ;; struct containing struct
51 %SAType = type { i32 , {[2x float], i64} } ;; struct containing array
5252
53 %S1 = global %SType* null ;; Global initialized to NULL
54 %S2c = constant %SType { int 1, {float,{ubyte}} {float 2.0, {ubyte} {ubyte 3}}, ulong 4}
53 @S1 = global %SType* null ;; Global initialized to NULL
54 @S2c = constant %SType { i32 1, {float,{i8}} {float 2.0, {i8} {i8 3}}, i64 4}
5555
56 %S3c = constant %SAType { int 1, {[2x float], ulong} {[2x float] [float 2.0, float 3.0], ulong 4} }
56 @S3c = constant %SAType { i32 1, {[2x float], i64} {[2x float] [float 2.0, float 3.0], i64 4} }
5757
58 %S1ptr = global %SType** %S1 ;; Ref. to global S1
59 %S2 = global %SType* %S2c ;; Ref. to constant S2
60 %S3 = global %SAType* %S3c ;; Ref. to constant S3
58 @S1ptr = global %SType** @S1 ;; Ref. to global S1
59 @S2 = global %SType* @S2c ;; Ref. to constant S2
60 @S3 = global %SAType* @S3c ;; Ref. to constant S3
6161
62 ;; Pointer to float (**%S1).1.0
63 %S1fld1a = global float* getelementptr (%SType* %S2c, long 0, uint 1, uint 0)
62 ;; Pointer to float (**@S1).1.0
63 @S1fld1a = global float* getelementptr (%SType* @S2c, i64 0, i32 1, i32 0)
6464 ;; Another ptr to the same!
65 %S1fld1b = global float* getelementptr (%SType* %S2c, long 0, uint 1, uint 0)
65 @S1fld1b = global float* getelementptr (%SType* @S2c, i64 0, i32 1, i32 0)
6666
67 %S1fld1bptr = global float** %S1fld1b ;; Ref. to previous pointer
67 @S1fld1bptr = global float** @S1fld1b ;; Ref. to previous pointer
6868
69 ;; Pointer to ubyte (**%S2).1.1.0
70 %S2fld3 = global ubyte* getelementptr (%SType* %S2c, long 0, uint 1, uint 1, uint 0)
69 ;; Pointer to i8 (**@S2).1.1.0
70 @S2fld3 = global i8* getelementptr (%SType* @S2c, i64 0, i32 1, i32 1, i32 0)
7171
72 ;; Pointer to float (**%S2).1.0[0]
73 ;%S3fld3 = global float* getelementptr (%SAType** %S3, long 0, long 0, uint 1, uint 0, long 0)
72 ;; Pointer to float (**@S2).1.0[0]
73 ;@S3fld3 = global float* getelementptr (%SAType** @S3, i64 0, i64 0, i32 1, i32 0, i64 0)
7474
7575 ;;---------------------------------------------------------
7676 ;; TODO: Test constant expressions for unary and binary operators
7777 ;;---------------------------------------------------------
7878
7979 ;;---------------------------------------------------
80
81 implementation
82
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
99 ;
1010
1111
12 %t3 = global int * %t1 ;; Forward reference
13 %t1 = global int 4
14 %t4 = global int ** %t3 ;; reference to reference
12 @t3 = global i32* @t1 ;; Forward reference
13 @t1 = global i32 4
14 @t4 = global i32** @t3 ;; reference to reference
1515
16 %t2 = global int * %t1
16 @t2 = global i32* @t1
1717
18 global float * %0 ;; Forward numeric reference
19 global float * %0 ;; Duplicate forward numeric reference
18 global float * @2 ;; Forward numeric reference
19 global float * @2 ;; Duplicate forward numeric reference
2020 global float 0.0
21 global float * %0 ;; Numeric reference
21 global float * @2 ;; Numeric reference
2222
2323
24 %fptr = global void() * %f ;; Forward ref method defn
25 declare void "f"() ;; External method
24 @fptr = global void() * @f ;; Forward ref method defn
25 declare void @f() ;; External method
2626
27 %sptr1 = global [11x sbyte]* %somestr ;; Forward ref to a constant
28 %somestr = constant [11x sbyte] c"hello world"
29 %sptr2 = global [11x sbyte]* %somestr
27 @sptr1 = global [11x i8]* @somestr ;; Forward ref to a constant
28 @somestr = constant [11x i8] c"hello world"
29 @sptr2 = global [11x i8]* @somestr
3030
31 implementation
32
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 define i32 @foo() {
5 br label %"foo`~!@#$%^&*()-_=+{}[]\\\\|;:',<.>/?"
46
5 int %foo() {
6 br label "foo`~!@#$%^&*()-_=+{}[]\\|;:',<.>/?"
7 "foo`~!@#$%^&*()-_=+{}[]\\|;:',<.>/?":
8 ret int 17
7 "foo`~!@#$%^&*()-_=+{}[]\\\\|;:',<.>/?": ; preds = %0
8 ret i32 17
99 }
10
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > t1.ll
11 ; RUN: llvm-as t1.ll -o - | llvm-dis > t2.ll
22 ; RUN: diff t1.ll t2.ll
33
4 %F1 = global float 0x4010000000000000
5 %D1 = global double 0x4010000000000000
4 @F1 = global float 0x4010000000000000
5 @D1 = global double 0x4010000000000000
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis | not grep bitcast
0 ; RUN: llvm-as < %s | llvm-dis | not grep bitcast
11
2 int %test1() {
3 ret int bitcast(float 0x400D9999A0000000 to int)
2 define i32 @test1() {
3 ret i32 bitcast(float 0x400D9999A0000000 to i32)
44 }
55
6 float %test2() {
7 ret float bitcast(int 17 to float)
6 define float @test2() {
7 ret float bitcast(i32 17 to float)
88 }
99
10 long %test3() {
11 ret long bitcast (double 0x400921FB4D12D84A to long)
10 define i64 @test3() {
11 ret i64 bitcast (double 0x400921FB4D12D84A to i64)
1212 }
1313
14 double %test4() {
15 ret double bitcast (long 42 to double)
14 define double @test4() {
15 ret double bitcast (i64 42 to double)
1616 }
1717
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %myty = type int
5 %myfn = type float (int,double,uint,short)
6 type int(%myfn*)
7 type int(int)
8 type int(int(int)*)
4 %myty = type i32
5 %myfn = type float (i32,double,i32,i16)
6 type i32(%myfn*)
7 type i32(i32)
8 type i32(i32(i32)*)
99
10 %thisfuncty = type int (int) *
11 implementation
10 %thisfuncty = type i32 (i32) *
1211
13 declare void %F(%thisfuncty, %thisfuncty, %thisfuncty)
12 declare void @F(%thisfuncty, %thisfuncty, %thisfuncty)
1413
15 ; This function always returns zero
16 int %zarro(int %Func)
17 begin
14 define i32 @zarro(i32 %Func) {
1815 Startup:
19 add int 0, 10
20 ret int 0
21 end
16 add i32 0, 10 ; :0 [#uses=0]
17 ret i32 0
18 }
2219
23 int %test(int)
24 begin
25 call void %F(%thisfuncty %zarro, %thisfuncty %test, %thisfuncty %foozball)
26 ret int 0
27 end
20 define i32 @test(i32) {
21 call void @F( %thisfuncty @zarro, %thisfuncty @test, %thisfuncty @foozball )
22 ret i32 0
23 }
2824
29 int %foozball(int)
30 begin
31 ret int 0
32 end
25 define i32 @foozball(i32) {
26 ret i32 0
27 }
3328
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %X = global int 4, section "foo", align 16
4 @X = global i32 4, section "foo", align 16 ; [#uses=0]
55
6 void %test() section "bar" {
7 ret void
6 define void @test() section "bar" {
7 ret void
88 }
99
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
44 ; Test forward references and redefinitions of globals
55
6 %A = global int* %B
7 %B = global int 7
6 @A = global i32* @B ; [#uses=0]
7 @B = global i32 7 ; [#uses=1]
88
9 declare void %X()
9 declare void @X()
1010
11 declare void %X()
11 declare void @X()
1212
13 void %X() {
13 define void @X() {
1414 ret void
1515 }
1616
17 declare void %X()
17 declare void @X()
+0
-6
test/Feature/globalredefinition2.ll less more
None ; Test that redefinitions of globals produces an error in llvm-upgrade
1 ; RUN: llvm-upgrade < %s -o /dev/null -f |& grep \
2 ; RUN: "Renaming global variable 'B' to.*linkage errors"
3
4 %B = global int 7
5 %B = global int 7
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 @MyVar = external global i32 ; [#uses=1]
5 @MyIntList = external global { \2*, i32 } ; <{ \2*, i32 }*> [#uses=1]
6 external global i32 ; :0 [#uses=0]
7 @AConst = constant i32 123 ; [#uses=0]
8 @AString = constant [4 x i8] c"test" ; <[4 x i8]*> [#uses=0]
9 @ZeroInit = global { [100 x i32], [40 x float] } zeroinitializer ; <{ [100 x i32], [40 x float] }*> [#uses=0]
410
5 %MyVar = uninitialized global int
6 %MyIntList = uninitialized global { \2 *, int }
7 external global int ; int*:0
11 define i32 @foo(i32 %blah) {
12 store i32 5, i32* @MyVar
13 %idx = getelementptr { \2*, i32 }* @MyIntList, i64 0, i32 1 ; [#uses=1]
14 store i32 12, i32* %idx
15 ret i32 %blah
16 }
817
9 %AConst = constant int 123
10
11 %AString = constant [4 x ubyte] c"test"
12
13 %ZeroInit = global { [100 x int ], [40 x float ] } { [100 x int] zeroinitializer,
14 [40 x float] zeroinitializer }
15
16 implementation
17
18 int "foo"(int %blah)
19 begin
20 store int 5, int *%MyVar
21 %idx = getelementptr { \2 *, int } * %MyIntList, long 0, uint 1
22 store int 12, int* %idx
23 ret int %blah
24 end
25
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 implementation
4 declare i32 @atoi(i8*)
55
6 declare int "atoi"(sbyte *)
6 define i64 @fib(i64 %n) {
7 icmp ult i64 %n, 2 ; :1 [#uses=1]
8 br i1 %1, label %BaseCase, label %RecurseCase
79
8 ulong "fib"(ulong %n)
9 begin
10 setlt ulong %n, 2 ; {bool}:0
11 br bool %0, label %BaseCase, label %RecurseCase
10 BaseCase: ; preds = %0
11 ret i64 1
1212
13 BaseCase:
14 ret ulong 1
13 RecurseCase: ; preds = %0
14 %n2 = sub i64 %n, 2 ; [#uses=1]
15 %n1 = sub i64 %n, 1 ; [#uses=1]
16 %f2 = call i64 @fib( i64 %n2 ) ; [#uses=1]
17 %f1 = call i64 @fib( i64 %n1 ) ; [#uses=1]
18 %result = add i64 %f2, %f1 ; [#uses=1]
19 ret i64 %result
20 }
1521
16 RecurseCase:
17 %n2 = sub ulong %n, 2
18 %n1 = sub ulong %n, 1
19 %f2 = call ulong(ulong) * %fib(ulong %n2)
20 %f1 = call ulong(ulong) * %fib(ulong %n1)
21 %result = add ulong %f2, %f1
22 ret ulong %result
23 end
22 define i64 @realmain(i32 %argc, i8** %argv) {
23 ;
24 icmp eq i32 %argc, 2 ; :1 [#uses=1]
25 br i1 %1, label %HasArg, label %Continue
2426
25 ulong "realmain"(int %argc, sbyte ** %argv)
26 begin
27 seteq int %argc, 2 ; {bool}:0
28 br bool %0, label %HasArg, label %Continue
29 HasArg:
30 ; %n1 = atoi(argv[1])
31 %n1 = add int 1, 1
32 br label %Continue
27 HasArg: ; preds = %0
28 %n1 = add i32 1, 1 ; [#uses=1]
29 br label %Continue
3330
34 Continue:
35 %n = phi int [%n1, %HasArg], [1, %0]
36 %N = cast int %n to ulong
37 %F = call ulong(ulong) *%fib(ulong %N)
38 ret ulong %F
39 end
31 Continue: ; preds = %HasArg, %0
32 %n = phi i32 [ %n1, %HasArg ], [ 1, %0 ] ; [#uses=1]
33 %N = sext i32 %n to i64 ; [#uses=1]
34 %F = call i64 @fib( i64 %N ) ; [#uses=1]
35 ret i64 %F
36 }
4037
41 ulong "trampoline"(ulong %n, ulong(ulong)* %fibfunc)
42 begin
43 %F = call ulong(ulong) *%fibfunc(ulong %n)
44 ret ulong %F
45 end
38 define i64 @trampoline(i64 %n, i64 (i64)* %fibfunc) {
39 %F = call i64 %fibfunc( i64 %n ) ; [#uses=1]
40 ret i64 %F
41 }
4642
47 int "main"()
48 begin
49 %Result = call ulong %trampoline(ulong 10, ulong(ulong) *%fib)
50 %Result = cast ulong %Result to int
51 ret int %Result
52 end
43 define i32 @main() {
44 %Result = call i64 @trampoline( i64 10, i64 (i64)* @fib ) ; [#uses=1]
45 %Result.upgrd.1 = trunc i64 %Result to i32 ; [#uses=1]
46 ret i32 %Result.upgrd.1
47 }
5348
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 implementation
4 define i64 @test(i64 %X) {
5 ret i64 %X
6 }
57
6 ulong "test"(ulong %X)
7 begin
8 ret ulong %X
9 end
8 define i64 @fib(i64 %n) {
9 ;
10 %T = icmp ult i64 %n, 2 ; [#uses=1]
11 br i1 %T, label %BaseCase, label %RecurseCase
1012
11 ulong "fib"(ulong %n)
12 begin
13 %T = setlt ulong %n, 2 ; {bool}:0
14 br bool %T, label %BaseCase, label %RecurseCase
13 RecurseCase: ; preds = %0
14 %result = call i64 @test( i64 %n ) ; [#uses=0]
15 br label %BaseCase
1516
16 RecurseCase:
17 %result = call ulong %test(ulong %n)
18 br label %BaseCase
17 BaseCase: ; preds = %RecurseCase, %0
18 %X = phi i64 [ 1, %0 ], [ 2, %RecurseCase ] ; [#uses=1]
19 ret i64 %X
20 }
1921
20 BaseCase:
21 %X = phi ulong [1, %0], [2, %RecurseCase]
22 ret ulong %X
23 end
24
None ; RUN: llvm-upgrade %s -o - | llvm-as -o /dev/null -f
1 ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > t1.ll
21 ; RUN: llvm-as t1.ll -o - | llvm-dis > t2.ll
32 ; RUN: diff t1.ll t2.ll
4
53
64 module asm "this is an inline asm block"
75 module asm "this is another inline asm block"
86
9 int %test() {
10 %X = call int asm "tricky here $0, $1", "=r,r"(int 4)
11 call void asm sideeffect "eieio", ""()
12 ret int %X
7 define i32 @test() {
8 %X = call i32 asm "tricky here $0, $1", "=r,r"( i32 4 ) ; [#uses=1]
9 call void asm sideeffect "eieio", ""( )
10 ret i32 %X
1311 }
12
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 uint %test_extractelement(<4 x uint> %V) {
5 %R = extractelement <4 x uint> %V, uint 1
6 ret uint %R
4 define i32 @test_extractelement(<4 x i32> %V) {
5 %R = extractelement <4 x i32> %V, i32 1 ; [#uses=1]
6 ret i32 %R
77 }
88
9 <4 x uint> %test_insertelement(<4 x uint> %V) {
10 %R = insertelement <4 x uint> %V, uint 0, uint 0
11 ret <4 x uint> %R
9 define <4 x i32> @test_insertelement(<4 x i32> %V) {
10 %R = insertelement <4 x i32> %V, i32 0, i32 0 ; <<4 x i32>> [#uses=1]
11 ret <4 x i32> %R
1212 }
1313
14 <4 x uint> %test_shufflevector_u(<4 x uint> %V) {
15 %R = shufflevector <4 x uint> %V, <4 x uint> %V,
16 <4 x uint> < uint 1, uint undef, uint 7, uint 2>
17 ret <4 x uint> %R
14 define <4 x i32> @test_shufflevector_u(<4 x i32> %V) {
15 %R = shufflevector <4 x i32> %V, <4 x i32> %V, <4 x i32> < i32 1, i32 undef, i32 7, i32 2 > ; <<4 x i32>> [#uses=1]
16 ret <4 x i32> %R
1817 }
1918
20 <4 x float> %test_shufflevector_f(<4 x float> %V) {
21 %R = shufflevector <4 x float> %V, <4 x float> undef,
22 <4 x uint> < uint 1, uint undef, uint 7, uint 2>
19 define <4 x float> @test_shufflevector_f(<4 x float> %V) {
20 %R = shufflevector <4 x float> %V, <4 x float> undef, <4 x i32> < i32 1, i32 undef, i32 7, i32 2 > ; <<4 x float>> [#uses=1]
2321 ret <4 x float> %R
2422 }
23
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 declare i1 @llvm.isunordered.f32(float, float)
45
5 declare bool %llvm.isunordered.f32(float,float)
6 declare bool %llvm.isunordered.f64(double,double)
6 declare i1 @llvm.isunordered.f64(double, double)
77
8 declare void %llvm.prefetch(sbyte*, uint, uint)
8 declare void @llvm.prefetch(i8*, i32, i32)
99
10 declare uint %llvm.ctpop.i8(ubyte)
11 declare uint %llvm.ctpop.i16(ushort)
12 declare uint %llvm.ctpop.i32(uint)
13 declare uint %llvm.ctpop.i64(ulong)
10 declare i32 @llvm.ctpop.i8(i8)
1411
15 declare uint %llvm.cttz.i8(ubyte)
16 declare uint %llvm.cttz.i16(ushort)
17 declare uint %llvm.cttz.i32(uint)
18 declare uint %llvm.cttz.i64(ulong)
12 declare i32 @llvm.ctpop.i16(i16)
1913
20 declare uint %llvm.ctlz.i8(ubyte)
21 declare uint %llvm.ctlz.i16(ushort)
22 declare uint %llvm.ctlz.i32(uint)
23 declare uint %llvm.ctlz.i64(ulong)
14 declare i32 @llvm.ctpop.i32(i32)
2415
25 declare float %llvm.sqrt.f32(float)
26 declare double %llvm.sqrt.f64(double)
16 declare i32 @llvm.ctpop.i64(i64)
2717
28 implementation
18 declare i32 @llvm.cttz.i8(i8)
19
20 declare i32 @llvm.cttz.i16(i16)
21
22 declare i32 @llvm.cttz.i32(i32)
23
24 declare i32 @llvm.cttz.i64(i64)
25
26 declare i32 @llvm.ctlz.i8(i8)
27
28 declare i32 @llvm.ctlz.i16(i16)
29
30 declare i32 @llvm.ctlz.i32(i32)
31
32 declare i32 @llvm.ctlz.i64(i64)
33
34 declare float @llvm.sqrt.f32(float)
35
36 declare double @llvm.sqrt.f64(double)
2937
3038 ; Test llvm intrinsics
3139 ;
32 void %libm() {
33 call bool %llvm.isunordered.f32(float 1.0, float 2.0)
34 call bool %llvm.isunordered.f64(double 3.0, double 4.0)
35
36 call void %llvm.prefetch(sbyte* null, uint 1, uint 3)
37
38 call float %llvm.sqrt.f32(float 5.0)
39 call double %llvm.sqrt.f64(double 6.0)
40
41 call uint %llvm.ctpop.i8(ubyte 10)
42 call uint %llvm.ctpop.i16(ushort 11)
43 call uint %llvm.ctpop.i32(uint 12)
44 call uint %llvm.ctpop.i64(ulong 13)
45
46 call uint %llvm.ctlz.i8(ubyte 14)
47 call uint %llvm.ctlz.i16(ushort 15)
48 call uint %llvm.ctlz.i32(uint 16)
49 call uint %llvm.ctlz.i64(ulong 17)
50
51 call uint %llvm.cttz.i8(ubyte 18)
52 call uint %llvm.cttz.i16(ushort 19)
53 call uint %llvm.cttz.i32(uint 20)
54 call uint %llvm.cttz.i64(ulong 21)
55 ret void
40 define void @libm() {
41 fcmp uno float 1.000000e+00, 2.000000e+00 ; :1 [#uses=0]
42 fcmp uno double 3.000000e+00, 4.000000e+00 ; :2 [#uses=0]
43 call void @llvm.prefetch( i8* null, i32 1, i32 3 )
44 call float @llvm.sqrt.f32( float 5.000000e+00 ) ; :3 [#uses=0]
45 call double @llvm.sqrt.f64( double 6.000000e+00 ) ; :4 [#uses=0]
46 call i32 @llvm.ctpop.i8( i8 10 ) ; :5 [#uses=0]
47 call i32 @llvm.ctpop.i16( i16 11 ) ; :6 [#uses=0]
48 call i32 @llvm.ctpop.i32( i32 12 ) ; :7 [#uses=0]
49 call i32 @llvm.ctpop.i64( i64 13 ) ; :8 [#uses=0]
50 call i32 @llvm.ctlz.i8( i8 14 ) ; :9 [#uses=0]
51 call i32 @llvm.ctlz.i16( i16 15 ) ; :10 [#uses=0]
52 call i32 @llvm.ctlz.i32( i32 16 ) ; :11 [#uses=0]
53 call i32 @llvm.ctlz.i64( i64 17 ) ; :12 [#uses=0]
54 call i32 @llvm.cttz.i8( i8 18 ) ; :13 [#uses=0]
55 call i32 @llvm.cttz.i16( i16 19 ) ; :14 [#uses=0]
56 call i32 @llvm.cttz.i32( i32 20 ) ; :15 [#uses=0]
57 call i32 @llvm.cttz.i64( i64 21 ) ; :16 [#uses=0]
58 ret void
5659 }
5760
5861 ; FIXME: test ALL the intrinsics in this file.
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
55 ; and recursive types. Oh my.
66 ;
77
8 %SQ1 = type { int }
8 %SQ1 = type { i32 }
99 %ITy = type opaque
1010 %SQ2 = type { %ITy }
11 %ITy = type int
11 %ITy = type i32
1212
1313
1414 %CCC = type { \2* }
2222
2323 ; Test simple opaque type resolution...
2424 %intty = type opaque
25 %intty = type int
25 %intty = type i32
2626
2727 ; Perform a simple forward reference...
28 %ty1 = type { %ty2, int }
28 %ty1 = type { %ty2, i32 }
2929 %ty2 = type float
3030
3131 ; Do a recursive type...
5454 %Y1 = type { { \3 * }, \2 * }
5555 %Z1 = type { { \3 * }, [12x\3] *, { { { \5 * } } } }
5656
57 implementation
58
59
60
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %foo1 = uninitialized global <4 x float>;
5 %foo2 = uninitialized global <2 x int>;
4 @foo1 = external global <4 x float> ; <<4 x float>*> [#uses=2]
5 @foo2 = external global <2 x i32> ; <<2 x i32>*> [#uses=2]
66
7 implementation ; Functions:
8
9 void %main()
10 {
11 store <4 x float> , <4 x float>* %foo1
12 store <2 x int> , <2 x int>* %foo2
13 %l1 = load <4 x float>* %foo1
14 %l2 = load <2 x int>* %foo2
7 define void @main() {
8 store <4 x float> < float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00 >, <4 x float>* @foo1
9 store <2 x i32> < i32 4, i32 4 >, <2 x i32>* @foo2
10 %l1 = load <4 x float>* @foo1 ; <<4 x float>> [#uses=0]
11 %l2 = load <2 x i32>* @foo2 ; <<2 x i32>> [#uses=0]
1512 ret void
1613 }
14
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4
5 target endian = little
6 target pointersize = 32
4 target datalayout = "e-p:32:32"
75 target triple = "proc-vend-sys"
86 deplibs = [ "m", "c" ]
9
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 implementation
4 declare i32 @bar(i32)
55
6 declare int "bar"(int %in)
6 define i32 @foo(i32 %blah) {
7 %xx = call i32 @bar( i32 %blah ) ; [#uses=1]
8 ret i32 %xx
9 }
710
8 int "foo"(int %blah)
9 begin
10 %xx = call int %bar(int %blah)
11 ret int %xx
12 end
13
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
3636 ; if (FindData(MyList, 700)) foundIt();
3737 ; }
3838
39 %list = type { %list*, int }
39 %list = type { %list*, i32 }
4040
41 declare sbyte *"malloc"(uint)
41 declare i8* @malloc(i32)
4242
43 ;;**********************
44 implementation
45 ;;**********************
43 define void @InsertIntoListTail(%list** %L, i32 %Data) {
44 bb1:
45 %reg116 = load %list** %L ; <%list*> [#uses=1]
46 %cast1004 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
47 %cond1000 = icmp eq %list* %reg116, %cast1004 ; [#uses=1]
48 br i1 %cond1000, label %bb3, label %bb2
4649
47 void "InsertIntoListTail"(%list** %L, int %Data)
48 begin
49 bb1:
50 %reg116 = load %list** %L ;;<%list*>
51 %cast1004 = cast ulong 0 to %list* ;;<%list*>
52 %cond1000 = seteq %list* %reg116, %cast1004 ;;
53 br bool %cond1000, label %bb3, label %bb2
50 bb2: ; preds = %bb2, %bb1
51 %reg117 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ; <%list**> [#uses=1]
52 %cast1010 = bitcast %list** %reg117 to %list*** ; <%list***> [#uses=1]
53 %reg118 = load %list*** %cast1010 ; <%list**> [#uses=3]
54 %reg109 = load %list** %reg118 ; <%list*> [#uses=1]
55 %cast1005 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
56 %cond1001 = icmp ne %list* %reg109, %cast1005 ; [#uses=1]
57 br i1 %cond1001, label %bb2, label %bb3
5458
55 bb2:
56 %reg117 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ;;<%list**>
57 %cast1010 = cast %list** %reg117 to %list*** ;;<%list***>
58 %reg118 = load %list*** %cast1010 ;;<%list**>
59 %reg109 = load %list** %reg118 ;;<%list*>
60 %cast1005 = cast ulong 0 to %list* ;;<%list*>
61 %cond1001 = setne %list* %reg109, %cast1005 ;;
62 br bool %cond1001, label %bb2, label %bb3
59 bb3: ; preds = %bb2, %bb1
60 %reg119 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ; <%list**> [#uses=1]
61 %cast1006 = bitcast %list** %reg119 to i8** ; [#uses=1]
62 %reg111 = call i8* @malloc( i32 16 ) ; [#uses=3]
63 store i8* %reg111, i8** %cast1006
64 %reg111.upgrd.1 = ptrtoint i8* %reg111 to i64 ; [#uses=1]
65 %reg1002 = add i64 %reg111.upgrd.1, 8 ; [#uses=1]
66 %reg1002.upgrd.2 = inttoptr i64 %reg1002 to i8* ; [#uses=1]
67 %cast1008 = bitcast i8* %reg1002.upgrd.2 to i32* ; [#uses=1]
68 store i32 %Data, i32* %cast1008
69 %cast1003 = inttoptr i64 0 to i64* ; [#uses=1]
70 %cast1009 = bitcast i8* %reg111 to i64** ; [#uses=1]
71 store i64* %cast1003, i64** %cast1009
72 ret void
73 }
6374
64 bb3:
65 %reg119 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ;;<%list**>
66 %cast1006 = cast %list** %reg119 to sbyte** ;;
67 %reg111 = call sbyte* %malloc(uint 16) ;;
68 store sbyte* %reg111, sbyte** %cast1006 ;;
69 %reg111 = cast sbyte* %reg111 to ulong
70 %reg1002 = add ulong %reg111, 8
71 %reg1002 = cast ulong %reg1002 to sbyte* ;;
72 %cast1008 = cast sbyte* %reg1002 to int* ;;
73 store int %Data, int* %cast1008 ;;
74 %cast1003 = cast ulong 0 to ulong* ;;
75 %cast1009 = cast sbyte* %reg111 to ulong** ;;
76 store ulong* %cast1003, ulong** %cast1009 ;;
77 ret void
78 end
79
80 %list* "FindData"(%list* %L, int %Data)
81 begin
75 define %list* @FindData(%list* %L, i32 %Data) {
8276 bb1:
8377 br label %bb2
8478
85 bb2:
86 %reg115 = phi %list* [ %reg116, %bb6 ], [ %L, %bb1 ] ;;<%list*>
87 %cast1014 = cast ulong 0 to %list* ;;<%list*>
88 %cond1011 = setne %list* %reg115, %cast1014 ;;
89 br bool %cond1011, label %bb4, label %bb3
79 bb2: ; preds = %bb6, %bb1
80 %reg115 = phi %list* [ %reg116, %bb6 ], [ %L, %bb1 ] ; <%list*> [#uses=4]
81 %cast1014 = inttoptr i64 0 to %list* ; <%list*> [#uses=1]
82 %cond1011 = icmp ne %list* %reg115, %cast1014 ; [#uses=1]
83 br i1 %cond1011, label %bb4, label %bb3
9084
91 bb3:
85 bb3: ; preds = %bb2
9286 ret %list* null
9387
94 bb4:
95 %idx = getelementptr %list* %reg115, long 0, uint 1 ;;
96 %reg111 = load int* %idx
97 %cond1013 = setne int %reg111, %Data ;;
98 br bool %cond1013, label %bb6, label %bb5
88 bb4: ; preds = %bb2
89 %idx = getelementptr %list* %reg115, i64 0, i32 1 ; [#uses=1]
90 %reg111 = load i32* %idx ; [#uses=1]
91 %cond1013 = icmp ne i32 %reg111, %Data ; [#uses=1]
92 br i1 %cond1013, label %bb6, label %bb5
9993
100 bb5:
94 bb5: ; preds = %bb4
10195 ret %list* %reg115
10296
103 bb6:
104 %idx2 = getelementptr %list* %reg115, long 0, uint 0 ;;<%list*>
105 %reg116 = load %list** %idx2
97 bb6: ; preds = %bb4
98 %idx2 = getelementptr %list* %reg115, i64 0, i32 0 ; <%list**> [#uses=1]
99 %reg116 = load %list** %idx2 ; <%list*> [#uses=1]
106100 br label %bb2
107 end
101 }
102
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %FunTy = type int(int)
4 %FunTy = type i32 (i32)
55
6 implementation
6 define void @invoke(%FunTy* %x) {
7 %foo = call i32 %x( i32 123 ) ; [#uses=0]
8 ret void
9 }
710
8 void "invoke"(%FunTy *%x)
9 begin
10 %foo = call %FunTy* %x(int 123)
11 ret void
12 end
11 define i32 @main(i32 %argc, i8** %argv, i8** %envp) {
12 %retval = call i32 @test( i32 %argc ) ; [#uses=2]
13 %two = add i32 %retval, %retval ; [#uses=1]
14 %retval2 = call i32 @test( i32 %argc ) ; [#uses=1]
15 %two2 = add i32 %two, %retval2 ; [#uses=1]
16 call void @invoke( %FunTy* @test )
17 ret i32 %two2
18 }
1319
14 int "main"(int %argc, sbyte **%argv, sbyte **%envp)
15 begin
16 %retval = call int (int) *%test(int %argc)
17 %two = add int %retval, %retval
18 %retval2 = call int %test(int %argc)
20 define i32 @test(i32 %i0) {
21 ret i32 %i0
22 }
1923
20 %two2 = add int %two, %retval2
21 call void %invoke (%FunTy* %test)
22 ret int %two2
23 end
24
25 int "test"(int %i0)
26 begin
27 ret int %i0
28 end
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %x = type int
4 %x = type i32
55
6 implementation
6 define i32 @foo(i32 %in) {
7 label:
8 ret i32 2
9 }
710
8 int "foo"(int %in)
9 begin
10 label:
11 ret int 2
12 end
13
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4
5 implementation
6
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %inners = type {float, {ubyte } }
5 %struct = type { int , {float, {ubyte } } , ulong }
4 %inners = type { float, { i8 } }
5 %struct = type { i32, %inners, i64 }
66
7 implementation
7 define i32 @testfunction(i32 %i0, i32 %j0) {
8 alloca i8, i32 5 ; :1 [#uses=0]
9 %ptr = alloca i32 ; [#uses=2]
10 store i32 3, i32* %ptr
11 %val = load i32* %ptr ; [#uses=0]
12 %sptr = alloca %struct ; <%struct*> [#uses=2]
13 %nsptr = getelementptr %struct* %sptr, i64 0, i32 1 ; <%inners*> [#uses=1]
14 %ubsptr = getelementptr %inners* %nsptr, i64 0, i32 1 ; <{ i8 }*> [#uses=1]
15 %idx = getelementptr { i8 }* %ubsptr, i64 0, i32 0 ; [#uses=1]
16 store i8 4, i8* %idx
17 %fptr = getelementptr %struct* %sptr, i64 0, i32 1, i32 0 ; [#uses=1]
18 store float 4.000000e+00, float* %fptr
19 ret i32 3
20 }
821
9 int %testfunction(int %i0, int %j0)
10 begin
11 alloca ubyte, uint 5
12 %ptr = alloca int ; yields {int*}:ptr
13 store int 3, int* %ptr ; yields {void}
14 %val = load int* %ptr ; yields {int}:val = int %3
15
16 %sptr = alloca %struct ; yields {%struct*}:sptr
17 %nsptr = getelementptr %struct * %sptr, long 0, uint 1 ; yields {inners*}:nsptr
18 %ubsptr = getelementptr %inners * %nsptr, long 0, uint 1 ; yields {{ubyte}*}:ubsptr
19 %idx = getelementptr {ubyte} * %ubsptr, long 0, uint 0
20 store ubyte 4, ubyte* %idx
21
22 %fptr = getelementptr %struct * %sptr, long 0, uint 1, uint 0 ; yields {float*}:fptr
23 store float 4.0, float * %fptr
24
25 ret int 3
26 end
27
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %somestr = constant [11x sbyte] c"hello world"
5 %array = constant [2 x int] [ int 12, int 52 ]
6 constant { int, int } { int 4, int 3 }
4 @somestr = constant [11 x i8] c"hello world" ; <[11 x i8]*> [#uses=1]
5 @array = constant [2 x i32] [ i32 12, i32 52 ] ; <[2 x i32]*> [#uses=1]
6 constant { i32, i32 } { i32 4, i32 3 } ; <{ i32, i32 }*>:0 [#uses=0]
77
8 implementation
9
10 [2 x int]* %testfunction(int %i0, int %j0)
11 begin
12 ret [2x int]* %array
13 end
14
15 sbyte* %otherfunc(int, double)
16 begin
17 %somestr = getelementptr [11x sbyte]* %somestr, long 0, long 0
18 ret sbyte* %somestr
19 end
20
21 sbyte* %yetanotherfunc(int, double)
22 begin
23 ret sbyte* null ; Test null
24 end
25
26 uint %negativeUnsigned() {
27 ret uint -1
8 define [2 x i32]* @testfunction(i32 %i0, i32 %j0) {
9 ret [2 x i32]* @array
2810 }
2911
30 int %largeSigned() {
31 ret int 3900000000
12 define i8* @otherfunc(i32, double) {
13 %somestr = getelementptr [11 x i8]* @somestr, i64 0, i64 0 ; [#uses=1]
14 ret i8* %somestr
3215 }
16
17 define i8* @yetanotherfunc(i32, double) {
18 ret i8* null
19 }
20
21 define i32 @negativeUnsigned() {
22 ret i32 -1
23 }
24
25 define i32 @largeSigned() {
26 ret i32 -394967296
27 }
28
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 implementation
4 define i32 @simpleAdd(i32 %i0, i32 %j0) {
5 %t1 = xor i32 %i0, %j0 ; [#uses=1]
6 %t2 = or i32 %i0, %j0 ; [#uses=1]
7 %t3 = and i32 %t1, %t2 ; [#uses=1]
8 ret i32 %t3
9 }
510
6 int "simpleAdd"(int %i0, int %j0)
7 begin
8 %t1 = xor int %i0, %j0
9 %t2 = or int %i0, %j0
10 %t3 = and int %t1, %t2
11 ret int %t3
12 end
13
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %struct = type { int , {float, {ubyte } } , ulong }
5 %complexty = type {int, {[4 x sbyte *], float}, double}
64
7 implementation
5 %complexty = type { i32, { [4 x i8*], float }, double }
6 %struct = type { i32, { float, { i8 } }, i64 }
87
9 int "main"()
10 begin
11 call int %testfunction(long 0, long 1)
12 ret int 0
13 end
8 define i32 @main() {
9 call i32 @testfunction( i64 0, i64 1 ) ; :1 [#uses=0]
10 ret i32 0
11 }
1412
15 int "testfunction"(long %i0, long %j0)
16 begin
17 %array0 = malloc [4 x ubyte] ; yields {[4 x ubyte]*}:array0
18 %size = add uint 2, 2 ; yields {uint}:size = uint %4
19 %array1 = malloc ubyte, uint 4 ; yields {ubyte*}:array1
20 %array2 = malloc ubyte, uint %size ; yields {ubyte*}:array2
13 define i32 @testfunction(i64 %i0, i64 %j0) {
14 %array0 = malloc [4 x i8] ; <[4 x i8]*> [#uses=2]
15 %size = add i32 2, 2 ; [#uses=1]
16 %array1 = malloc i8, i32 4 ; [#uses=1]
17 %array2 = malloc i8, i32 %size ; [#uses=1]
18 %idx = getelementptr [4 x i8]* %array0, i64 0, i64 2 ; [#uses=1]
19 store i8 123, i8* %idx
20 free [4 x i8]* %array0
21 free i8* %array1
22 free i8* %array2
23 %aa = alloca %complexty, i32 5 ; <%complexty*> [#uses=1]
24 %idx2 = getelementptr %complexty* %aa, i64 %i0, i32 1, i32 0, i64 %j0 ; [#uses=1]
25 store i8* null, i8** %idx2
26 %ptr = alloca i32 ; [#uses=2]
27 store i32 3, i32* %ptr
28 %val = load i32* %ptr ; [#uses=0]
29 %sptr = alloca %struct ; <%struct*> [#uses=1]
30 %ubsptr = getelementptr %struct* %sptr, i64 0, i32 1, i32 1 ; <{ i8 }*> [#uses=1]
31 %idx3 = getelementptr { i8 }* %ubsptr, i64 0, i32 0 ; [#uses=1]
32 store i8 4, i8* %idx3
33 ret i32 3
34 }
2135
22 %idx = getelementptr [4 x ubyte]* %array0, long 0, long 2
23 store ubyte 123, ubyte* %idx
24 free [4x ubyte]* %array0
25 free ubyte* %array1
26 free ubyte* %array2
27
28
29 %aa = alloca %complexty, uint 5
30 %idx2 = getelementptr %complexty* %aa, long %i0, uint 1, uint 0, long %j0
31 store sbyte *null, sbyte** %idx2
32
33 %ptr = alloca int ; yields {int*}:ptr
34 store int 3, int* %ptr ; yields {void}
35 %val = load int* %ptr ; yields {int}:val = int %3
36
37 %sptr = alloca %struct ; yields {%struct*}:sptr
38 %ubsptr = getelementptr %struct * %sptr, long 0, uint 1, uint 1 ; yields {{ubyte}*}:ubsptr
39 %idx3 = getelementptr {ubyte} * %ubsptr, long 0, uint 0
40 store ubyte 4, ubyte* %idx3
41
42 ret int 3
43 end
44
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 %int = type int
4 %int = type i32
55
6 implementation
6 define i32 @squared(i32 %i0) {
7 switch i32 %i0, label %Default [
8 i32 1, label %Case1
9 i32 2, label %Case2
10 i32 4, label %Case4
11 ]
712
8 int "squared"(%int %i0)
9 begin
10 switch int %i0, label %Default [
11 int 1, label %Case1
12 int 2, label %Case2
13 int 4, label %Case4 ]
13 Default: ; preds = %0
14 ret i32 -1
1415
15 Default:
16 ret int -1 ; Unrecognized input value
16 Case1: ; preds = %0
17 ret i32 1
1718
18 Case1:
19 ret int 1
20 Case2:
21 ret int 4
22 Case4:
23 ret int 16
24 end
19 Case2: ; preds = %0
20 ret i32 4
21
22 Case4: ; preds = %0
23 ret i32 16
24 }
25
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 implementation
54
6 declare int "printf"(sbyte*, ...) ;; Prototype for: int __builtin_printf(const char*, ...)
5 declare i32 @printf(i8*, ...) ;; Prototype for: int __builtin_printf(const char*, ...)
76
8 int "testvarar"()
9 begin
10 call int(sbyte*, ...) *%printf(sbyte * null, int 12, sbyte 42);
11 ret int %0
12 end
7 define i32 @testvarar() {
8 call i32 (i8*, ...)* @printf( i8* null, i32 12, i8 42 ) ; :1 [#uses=1]
9 ret i32 %1
10 }
1311
14
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 @X = global i32 undef ; [#uses=0]
45
5 %X = global int undef
6 declare i32 @atoi(i8*)
67
7 implementation
8
9 declare int "atoi"(sbyte *)
10
11 int %test() {
12 ret int undef
8 define i32 @test() {
9 ret i32 undef
1310 }
1411
15 int %test2() {
16 %X = add int undef, 1
17 ret int %X
12 define i32 @test2() {
13 %X = add i32 undef, 1 ; [#uses=1]
14 ret i32 %X
1815 }
16
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
4 declare void @bar()
45
5 implementation
6
7 declare void %bar()
8
9 int %foo() { ;; Calling this function has undefined behavior
10 unreachable
6 define i32 @foo() {
7 unreachable
118 }
129
13 double %xyz() {
14 call void %bar()
15 unreachable ;; Bar must not return.
10 define double @xyz() {
11 call void @bar( )
12 unreachable
1613 }
14
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
44 ; Demonstrate all of the variable argument handling intrinsic functions plus
55 ; the va_arg instruction.
66
7 implementation
8 declare void %llvm.va_start(sbyte** %ap)
9 declare void %llvm.va_copy(sbyte** %aq, sbyte** %ap)
10 declare void %llvm.va_end(sbyte** %ap)
7 declare void @llvm.va_start(i8*)
118
12 int %test(int %X, ...) {
13 %ap = alloca sbyte*
14 call void %llvm.va_start(sbyte** %ap)
15 %tmp = va_arg sbyte** %ap, int
9 declare void @llvm.va_copy(i8*, i8*)
1610
17 %aq = alloca sbyte*
18 call void %llvm.va_copy(sbyte** %aq, sbyte** %ap)
19 call void %llvm.va_end(sbyte** %aq)
20
21 call void %llvm.va_end(sbyte** %ap)
22 ret int %tmp
11 declare void @llvm.va_end(i8*)
12
13 define i32 @test(i32 %X, ...) {
14 %ap = alloca i8* ; [#uses=4]
15 %va.upgrd.1 = bitcast i8** %ap to i8* ; [#uses=1]
16 call void @llvm.va_start( i8* %va.upgrd.1 )
17 %tmp = va_arg i8** %ap, i32 ; [#uses=1]
18 %aq = alloca i8* ; [#uses=2]
19 %va0.upgrd.2 = bitcast i8** %aq to i8* ; [#uses=1]
20 %va1.upgrd.3 = bitcast i8** %ap to i8* ; [#uses=1]
21 call void @llvm.va_copy( i8* %va0.upgrd.2, i8* %va1.upgrd.3 )
22 %va.upgrd.4 = bitcast i8** %aq to i8* ; [#uses=1]
23 call void @llvm.va_end( i8* %va.upgrd.4 )
24 %va.upgrd.5 = bitcast i8** %ap to i8* ; [#uses=1]
25 call void @llvm.va_end( i8* %va.upgrd.5 )
26 ret i32 %tmp
2327 }
28
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
44 ; Demonstrate all of the variable argument handling intrinsic functions plus
55 ; the va_arg instruction.
66
7 implementation ; Functions:
8 declare void %llvm.va_start(sbyte**)
9 declare void %llvm.va_copy(sbyte**, sbyte*)
10 declare void %llvm.va_end(sbyte**)
7 declare void @llvm.va_start(i8*)
118
12 int %test(int %X, ...) {
9 declare void @llvm.va_copy(i8*, i8*)
10
11 declare void @llvm.va_end(i8*)
12
13 define i32 @test(i32 %X, ...) {
1314 ; Allocate two va_list items. On this target, va_list is of type sbyte*
14 %ap = alloca sbyte* ; [#uses=4]
15 %aq = alloca sbyte* ; [#uses=2]
15 %ap = alloca i8* ; [#uses=4]
16 %aq = alloca i8* ; [#uses=2]
1617
1718 ; Initialize variable argument processing
18 call void %llvm.va_start(sbyte** %ap)
19 %va.upgrd.1 = bitcast i8** %ap to i8* ; [#uses=1]
20 call void @llvm.va_start( i8* %va.upgrd.1 )
1921
2022 ; Read a single integer argument
21 %tmp = va_arg sbyte** %ap, int ; > [#uses=1]
23 %tmp = va_arg i8** %ap, i32 ; > [#uses=1]
2224
2325 ; Demonstrate usage of llvm.va_copy and llvm_va_end
24 %apv = load sbyte** %ap ; [#uses=1]
25 call void %llvm.va_copy(sbyte** %aq, sbyte* %apv)
26 call void %llvm.va_end(sbyte** %aq)
26 %apv = load i8** %ap ; [#uses=1]
27 %va0.upgrd.2 = bitcast i8** %aq to i8* ; [#uses=1]
28 %va1.upgrd.3 = bitcast i8* %apv to i8* ; [#uses=1]
29 call void @llvm.va_copy( i8* %va0.upgrd.2, i8* %va1.upgrd.3 )
30 %va.upgrd.4 = bitcast i8** %aq to i8* ; [#uses=1]
31 call void @llvm.va_end( i8* %va.upgrd.4 )
2732
2833 ; Stop processing of arguments.
29 call void %llvm.va_end(sbyte** %ap)
30 ret int %tmp
31
34 %va.upgrd.5 = bitcast i8** %ap to i8* ; [#uses=1]
35 call void @llvm.va_end( i8* %va.upgrd.5 )
36 ret i32 %tmp
3237 }
None ; RUN: llvm-upgrade < %s | llvm-as | llvm-dis > %t1.ll
0 ; RUN: llvm-as < %s | llvm-dis > %t1.ll
11 ; RUN: llvm-as %t1.ll -o - | llvm-dis > %t2.ll
22 ; RUN: diff %t1.ll %t2.ll
33
44 ; Test using double quotes to form names that are not legal in the % form
5
6 "&^ " = type { int }
7 "%.*+ foo" = global "&^ " { int 5 }
8 "0" = global float 0.0 ; This CANNOT be %0
9 "\03foo" = global float 0x3FB99999A0000000 ; Make sure funny char gets round trip
5 %"&^ " = type { i32 }
6 @"%.*+ foo" = global %"&^ " { i32 5 }
7 @"0" = global float 0.000000e+00 ; This CANNOT be %0
8 @"\\03foo" = global float 0x3FB99999A0000000 ; Make sure funny char gets round trip