diff options
Diffstat (limited to 'test/ExecutionEngine')
40 files changed, 1011 insertions, 0 deletions
diff --git a/test/ExecutionEngine/2002-12-16-ArgTest.ll b/test/ExecutionEngine/2002-12-16-ArgTest.ll new file mode 100644 index 0000000..4ef1439 --- /dev/null +++ b/test/ExecutionEngine/2002-12-16-ArgTest.ll @@ -0,0 +1,47 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +%.LC0 = internal global [10 x sbyte] c"argc: %d\0A\00" + +implementation ; Functions: + +declare int %puts(sbyte*) + +void %getoptions(int* %argc) { +bb0: ; No predecessors! + ret void +} + +declare int %printf(sbyte*, ...) + +int %main(int %argc, sbyte** %argv) { +bb0: ; No predecessors! + call int (sbyte*, ...)* %printf( sbyte* getelementptr ([10 x sbyte]* %.LC0, long 0, long 0), int %argc) + %cast224 = cast sbyte** %argv to sbyte* ; <sbyte*> [#uses=1] + %local = alloca sbyte* ; <sbyte**> [#uses=3] + store sbyte* %cast224, sbyte** %local + %cond226 = setle int %argc, 0 ; <bool> [#uses=1] + br bool %cond226, label %bb3, label %bb2 + +bb2: ; preds = %bb2, %bb0 + %cann-indvar = phi int [ 0, %bb0 ], [ %add1-indvar, %bb2 ] ; <int> [#uses=2] + %add1-indvar = add int %cann-indvar, 1 ; <int> [#uses=2] + %cann-indvar-idxcast = cast int %cann-indvar to long ; <long> [#uses=1] + ;%reg115 = load sbyte** %local ; <sbyte*> [#uses=1] + ;%cann-indvar-idxcast-scale = mul long %cann-indvar-idxcast, 8 ; <long> [#uses=1] + ;%reg232 = getelementptr sbyte* %reg115, long %cann-indvar-idxcast-scale ; <sbyte*> [#uses=1] + ;%cast235 = cast sbyte* %reg232 to sbyte** ; <sbyte**> [#uses=1] + %CT = cast sbyte** %local to sbyte*** + %reg115 = load sbyte*** %CT + %cast235 = getelementptr sbyte** %reg115, long %cann-indvar-idxcast + + %reg117 = load sbyte** %cast235 ; <sbyte*> [#uses=1] + %reg236 = call int %puts( sbyte* %reg117 ) ; <int> [#uses=0] + %cond239 = setlt int %add1-indvar, %argc ; <bool> [#uses=1] + br bool %cond239, label %bb2, label %bb3 + +bb3: ; preds = %bb2, %bb0 + %cast243 = cast sbyte** %local to int* ; <int*> [#uses=1] + call void %getoptions( int* %cast243 ) + ret int 0 +} diff --git a/test/ExecutionEngine/2003-01-04-ArgumentBug.ll b/test/ExecutionEngine/2003-01-04-ArgumentBug.ll new file mode 100644 index 0000000..218154f --- /dev/null +++ b/test/ExecutionEngine/2003-01-04-ArgumentBug.ll @@ -0,0 +1,16 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +implementation ; Functions: + +int %foo(int %X, int %Y, double %A) { + %cond212 = setne double %A, 1.000000e+00 ; <bool> [#uses=1] + %cast110 = cast bool %cond212 to int ; <int> [#uses=1] + ret int %cast110 +} + +int %main() { + %reg212 = call int %foo( int 0, int 1, double 1.000000e+00 ) ; <int> [#uses=1] + ret int %reg212 +} diff --git a/test/ExecutionEngine/2003-01-04-LoopTest.ll b/test/ExecutionEngine/2003-01-04-LoopTest.ll new file mode 100644 index 0000000..f70928a --- /dev/null +++ b/test/ExecutionEngine/2003-01-04-LoopTest.ll @@ -0,0 +1,25 @@ +; RUN: llvm-upgrade < %s | llvm-as -o %t.bc -f +; RUN: lli %t.bc > /dev/null + +implementation + +int %main() { + call int %mylog(int 4) + ret int 0 +} + +internal int %mylog(int %num) { +bb0: ; No predecessors! + br label %bb2 + +bb2: + %reg112 = phi int [ 10, %bb2 ], [ 1, %bb0 ] + %cann-indvar = phi int [ %cann-indvar, %bb2 ], [0, %bb0] + %reg114 = add int %reg112, 1 + %cond222 = setlt int %reg114, %num + br bool %cond222, label %bb2, label %bb3 + +bb3: ; preds = %bb2, %bb0 + ret int %reg114 +} + diff --git a/test/ExecutionEngine/2003-01-04-PhiTest.ll b/test/ExecutionEngine/2003-01-04-PhiTest.ll new file mode 100644 index 0000000..45af830 --- /dev/null +++ b/test/ExecutionEngine/2003-01-04-PhiTest.ll @@ -0,0 +1,11 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +int %main() { + br label %Loop +Loop: + %X = phi int [0, %0], [1, %Loop] + br bool true, label %Out, label %Loop +Out: + ret int %X +} diff --git a/test/ExecutionEngine/2003-01-09-SARTest.ll b/test/ExecutionEngine/2003-01-09-SARTest.ll new file mode 100644 index 0000000..73f2900 --- /dev/null +++ b/test/ExecutionEngine/2003-01-09-SARTest.ll @@ -0,0 +1,11 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; We were accidentally inverting the signedness of right shifts. Whoops. + +int %main() { + %X = shr int -1, ubyte 16 + %Y = shr int %X, ubyte 16 + %Z = add int %Y, 1 + ret int %Z +} diff --git a/test/ExecutionEngine/2003-01-10-FUCOM.ll b/test/ExecutionEngine/2003-01-10-FUCOM.ll new file mode 100644 index 0000000..4209df9 --- /dev/null +++ b/test/ExecutionEngine/2003-01-10-FUCOM.ll @@ -0,0 +1,11 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +int %main() { + %X = add double 0.0, 1.0 + %Y = sub double 0.0, 1.0 + %Z = seteq double %X, %Y + add double %Y, 0.0 + ret int 0 +} diff --git a/test/ExecutionEngine/2003-01-15-AlignmentTest.ll b/test/ExecutionEngine/2003-01-15-AlignmentTest.ll new file mode 100644 index 0000000..e9ffd90 --- /dev/null +++ b/test/ExecutionEngine/2003-01-15-AlignmentTest.ll @@ -0,0 +1,19 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +int %bar(sbyte* %X) { + %P = alloca double ; pointer should be 4 byte aligned! + %R = cast double* %P to int + %A = and int %R, 3 + ret int %A +} + +int %main() { + %SP = alloca sbyte + %X = add uint 0, 0 + alloca sbyte, uint %X + + call int %bar(sbyte* %SP) + ret int %0 +} diff --git a/test/ExecutionEngine/2003-05-06-LivenessClobber.llx b/test/ExecutionEngine/2003-05-06-LivenessClobber.llx new file mode 100644 index 0000000..ea3f14b --- /dev/null +++ b/test/ExecutionEngine/2003-05-06-LivenessClobber.llx @@ -0,0 +1,20 @@ +; This testcase shoudl return with an exit code of 1. +; +; RUN: llvm-upgrade < %s | llvm-as | not lli + +%test = global long 0 +implementation + + +internal long %test() { + %tmp.0 = load long* %test ; <long> [#uses=1] + %tmp.1 = add long %tmp.0, 1 ; <long> [#uses=1] + ret long %tmp.1 +} + +int %main() { + %L = call long %test() + %I = cast long %L to int + ret int %I +} + diff --git a/test/ExecutionEngine/2003-05-07-ArgumentTest.llx b/test/ExecutionEngine/2003-05-07-ArgumentTest.llx new file mode 100644 index 0000000..e5dd04e --- /dev/null +++ b/test/ExecutionEngine/2003-05-07-ArgumentTest.llx @@ -0,0 +1,13 @@ +; RUN: llvm-upgrade < %s | llvm-as | lli - test + +implementation + +declare int %puts(sbyte*) + +int %main(int %argc.1, sbyte** %argv.1) { + %tmp.5 = getelementptr sbyte** %argv.1, long 1 ; <sbyte**> [#uses=1] + %tmp.6 = load sbyte** %tmp.5 ; <sbyte*> [#uses=1] + %tmp.0 = call int %puts( sbyte* %tmp.6 ) ; <int> [#uses=0] + ret int 0 +} + diff --git a/test/ExecutionEngine/2003-05-11-PHIRegAllocBug.ll b/test/ExecutionEngine/2003-05-11-PHIRegAllocBug.ll new file mode 100644 index 0000000..1d9ba77 --- /dev/null +++ b/test/ExecutionEngine/2003-05-11-PHIRegAllocBug.ll @@ -0,0 +1,18 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +target endian = little +target pointersize = 32 + +implementation + +int %main() { +entry: + br label %endif +then: + br label %endif +endif: + %x = phi uint [ 4, %entry ], [ 27, %then ] + %result = phi int [ 32, %then ], [ 0, %entry ] + ret int 0 +} diff --git a/test/ExecutionEngine/2003-06-04-bzip2-bug.ll b/test/ExecutionEngine/2003-06-04-bzip2-bug.ll new file mode 100644 index 0000000..cd237c3 --- /dev/null +++ b/test/ExecutionEngine/2003-06-04-bzip2-bug.ll @@ -0,0 +1,22 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; Testcase distilled from 256.bzip2. + +target endian = little +target pointersize = 32 + +int %main() { +entry: + br label %loopentry.0 + +loopentry.0: + %h.0 = phi int [ %tmp.2, %loopentry.0 ], [ -1, %entry ] + %tmp.2 = add int %h.0, 1 + %tmp.4 = setne int %tmp.2, 0 + br bool %tmp.4, label %loopentry.0, label %loopentry.1 + +loopentry.1: + %h.1 = phi int [ %tmp.2, %loopentry.0 ] + ret int %h.1 +} diff --git a/test/ExecutionEngine/2003-06-05-PHIBug.ll b/test/ExecutionEngine/2003-06-05-PHIBug.ll new file mode 100644 index 0000000..8c1aaba --- /dev/null +++ b/test/ExecutionEngine/2003-06-05-PHIBug.ll @@ -0,0 +1,19 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; Testcase distilled from 256.bzip2. + +target endian = little +target pointersize = 32 + +int %main() { +entry: + %X = add int 1, -1 + br label %Next + +Next: + %A = phi int [ %X, %entry ] + %B = phi int [ %X, %entry ] + %C = phi int [ %X, %entry ] + ret int %C +} diff --git a/test/ExecutionEngine/2003-08-15-AllocaAssertion.ll b/test/ExecutionEngine/2003-08-15-AllocaAssertion.ll new file mode 100644 index 0000000..adc8220 --- /dev/null +++ b/test/ExecutionEngine/2003-08-15-AllocaAssertion.ll @@ -0,0 +1,12 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; This testcase failed to work because two variable sized allocas confused the +; local register allocator. + +int %main(uint %X) { + %A = alloca uint, uint %X + + %B = alloca float, uint %X + ret int 0 +} diff --git a/test/ExecutionEngine/2003-08-21-EnvironmentTest.ll b/test/ExecutionEngine/2003-08-21-EnvironmentTest.ll new file mode 100644 index 0000000..21e87ca --- /dev/null +++ b/test/ExecutionEngine/2003-08-21-EnvironmentTest.ll @@ -0,0 +1,23 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; +; Regression Test: EnvironmentTest.ll +; +; Description: +; This is a regression test that verifies that the JIT passes the +; environment to the main() function. +; + +implementation + +declare uint %strlen(sbyte*) + +int %main(int %argc.1, sbyte** %argv.1, sbyte** %envp.1) { + %tmp.2 = load sbyte** %envp.1 + %tmp.3 = call uint %strlen( sbyte* %tmp.2 ) + %T = seteq uint %tmp.3, 0 + %R = cast bool %T to int + ret int %R +} + diff --git a/test/ExecutionEngine/2003-08-23-RegisterAllocatePhysReg.ll b/test/ExecutionEngine/2003-08-23-RegisterAllocatePhysReg.ll new file mode 100644 index 0000000..4d1d045 --- /dev/null +++ b/test/ExecutionEngine/2003-08-23-RegisterAllocatePhysReg.ll @@ -0,0 +1,33 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; This testcase exposes a bug in the local register allocator where it runs out +; of registers (due to too many overlapping live ranges), but then attempts to +; use the ESP register (which is not allocatable) to hold a value. + +int %main(uint %A) { + %Ap2 = alloca uint, uint %A ; ESP gets used again... + %B = add uint %A, 1 ; Produce lots of overlapping live ranges + %C = add uint %A, 2 + %D = add uint %A, 3 + %E = add uint %A, 4 + %F = add uint %A, 5 + %G = add uint %A, 6 + %H = add uint %A, 7 + %I = add uint %A, 8 + %J = add uint %A, 9 + %K = add uint %A, 10 + + store uint %A, uint *%Ap2 ; Uses of all of the values + store uint %B, uint *%Ap2 + store uint %C, uint *%Ap2 + store uint %D, uint *%Ap2 + store uint %E, uint *%Ap2 + store uint %F, uint *%Ap2 + store uint %G, uint *%Ap2 + store uint %H, uint *%Ap2 + store uint %I, uint *%Ap2 + store uint %J, uint *%Ap2 + store uint %K, uint *%Ap2 + ret int 0 +} diff --git a/test/ExecutionEngine/2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll b/test/ExecutionEngine/2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll new file mode 100644 index 0000000..b2700e1 --- /dev/null +++ b/test/ExecutionEngine/2003-10-18-PHINode-ConstantExpr-CondCode-Failure.ll @@ -0,0 +1,30 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +%A = global int 0 + +int %main() { + %Ret = call int %test(bool true, int 0) + ret int %Ret +} + +int %test(bool %c, int %A) { + br bool %c, label %Taken1, label %NotTaken + +Cont: + %V = phi int [0, %NotTaken], + [ sub (int cast (int* %A to int), int 1234), %Taken1] + ret int 0 + +NotTaken: + br label %Cont + +Taken1: + %B = seteq int %A, 0 + ; Code got inserted here, breaking the condition code. + br bool %B, label %Cont, label %ExitError + +ExitError: + ret int 12 + +} diff --git a/test/ExecutionEngine/2004-12-04-LazyCompileFuncs.ll b/test/ExecutionEngine/2004-12-04-LazyCompileFuncs.ll new file mode 100644 index 0000000..e266be9 --- /dev/null +++ b/test/ExecutionEngine/2004-12-04-LazyCompileFuncs.ll @@ -0,0 +1,33 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli -debug-only=jit %t.bc |& not grep {Finished CodeGen of .*Function: F} + +%.str_1 = internal constant [7 x sbyte] c"IN F!\0A\00" ; <[7 x sbyte]*> [#uses=1] +%.str_2 = internal constant [7 x sbyte] c"IN G!\0A\00" ; <[7 x sbyte]*> [#uses=1] +%Ptrs = internal constant [2 x void (...)*] [ void (...)* cast (void ()* %F to void (...)*), void (...)* cast (void ()* %G to void (...)*) ] ; <[2 x void (...)*]*> [#uses=1] + +implementation ; Functions: + +declare int %printf(sbyte*, ...) + +internal void %F() { +entry: + %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([7 x sbyte]* %.str_1, int 0, int 0) ) ; <int> [#uses=0] + ret void +} + +internal void %G() { +entry: + %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([7 x sbyte]* %.str_2, int 0, int 0) ) ; <int> [#uses=0] + ret void +} + +int %main(int %argc, sbyte** %argv) { +entry: + %tmp.3 = and int %argc, 1 ; <int> [#uses=1] + %tmp.4 = getelementptr [2 x void (...)*]* %Ptrs, int 0, int %tmp.3 ; <void (...)**> [#uses=1] + %tmp.5 = load void (...)** %tmp.4 ; <void (...)*> [#uses=1] + %tmp.5_c = cast void (...)* %tmp.5 to void ()* ; <void ()*> [#uses=1] + call void %tmp.5_c( ) + ret int undef +} + diff --git a/test/ExecutionEngine/2005-12-02-TailCallBug.ll b/test/ExecutionEngine/2005-12-02-TailCallBug.ll new file mode 100644 index 0000000..447f49e --- /dev/null +++ b/test/ExecutionEngine/2005-12-02-TailCallBug.ll @@ -0,0 +1,21 @@ +; PR672 +; RUN: llvm-upgrade < %s | llvm-as | lli + +int %main(){ + %f = cast int (int, int*, int)* %check_tail to int* + %res = tail call fastcc int %check_tail( int 10, int* %f,int 10) + ret int %res +} +fastcc int %check_tail(int %x, int* %f, int %g) { + %tmp1 = setgt int %x, 0 + br bool %tmp1, label %if-then, label %if-else + +if-then: + %fun_ptr = cast int* %f to int(int, int*, int)* + %arg1 = add int %x, -1 + %res = tail call fastcc int %fun_ptr( int %arg1, int * %f, int %g) + ret int %res + +if-else: + ret int %x +} diff --git a/test/ExecutionEngine/2007-05-12-APInt-Shl.ll b/test/ExecutionEngine/2007-05-12-APInt-Shl.ll new file mode 100644 index 0000000..cbea407 --- /dev/null +++ b/test/ExecutionEngine/2007-05-12-APInt-Shl.ll @@ -0,0 +1,30 @@ +; RUN: llvm-as %s -f -o %t.bc +; RUN: lli -force-interpreter=true %t.bc | tee %t.out | grep 10 + +; Test that APInt shift left works when bitwidth > 64 and shiftamt == 0 + +declare i32 @putchar(i32) + +define void @putBit(i65 %x, i65 %bitnum) { + %tmp1 = shl i65 1, %bitnum + %tmp2 = and i65 %x, %tmp1 + %cond = icmp ne i65 %tmp2, 0 + br i1 %cond, label %cond_true, label %cond_false + +cond_true: + call i32 @putchar(i32 49) + br label %cond_next + +cond_false: + call i32 @putchar(i32 48) + br label %cond_next + +cond_next: + ret void +} + +define i32 @main() { + call void @putBit(i65 1, i65 0) + call void @putBit(i65 0, i65 0) + ret i32 0 +} diff --git a/test/ExecutionEngine/dg.exp b/test/ExecutionEngine/dg.exp new file mode 100644 index 0000000..879685c --- /dev/null +++ b/test/ExecutionEngine/dg.exp @@ -0,0 +1,3 @@ +load_lib llvm.exp + +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]] diff --git a/test/ExecutionEngine/fpbitcast.ll b/test/ExecutionEngine/fpbitcast.ll new file mode 100644 index 0000000..34ca129 --- /dev/null +++ b/test/ExecutionEngine/fpbitcast.ll @@ -0,0 +1,21 @@ +; RUN: llvm-as < %s > %t.bc +; RUN: lli -force-interpreter=true %t.bc | grep 40091eb8 +; +define i32 @test(double %x) { +entry: + %x46.i = bitcast double %x to i64 + %tmp343.i = lshr i64 %x46.i, 32 + %tmp344.i = trunc i64 %tmp343.i to i32 + ret i32 %tmp344.i +} + +define i32 @main() +{ + %res = call i32 @test(double 3.14) + %ptr = getelementptr [4 x i8]* @format, i32 0, i32 0 + call i32 (i8*,...)* @printf(i8* %ptr, i32 %res) + ret i32 0 +} + +declare i32 @printf(i8*, ...) +@format = internal constant [4 x i8] c"%x\0A\00" diff --git a/test/ExecutionEngine/hello.ll b/test/ExecutionEngine/hello.ll new file mode 100644 index 0000000..ea2f9a4 --- /dev/null +++ b/test/ExecutionEngine/hello.ll @@ -0,0 +1,14 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +%.LC0 = internal global [12 x sbyte] c"Hello World\00" + +implementation + +declare int %puts(sbyte*) + +int %main() { + %reg210 = call int %puts( sbyte* getelementptr ([12 x sbyte]* %.LC0, long 0, long 0) ) + ret int 0 +} + diff --git a/test/ExecutionEngine/hello2.ll b/test/ExecutionEngine/hello2.ll new file mode 100644 index 0000000..b186c52 --- /dev/null +++ b/test/ExecutionEngine/hello2.ll @@ -0,0 +1,22 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +%X = global int 7 +%msg = internal global [13 x sbyte] c"Hello World\0A\00" + + +implementation + +declare void %printf([13 x sbyte]*,...) + +void %bar() { + call void([13 x sbyte]*,...)* %printf([13 x sbyte]* %msg) + ret void +} + +int %main() { + call void %bar() + ret int 0 +} + diff --git a/test/ExecutionEngine/simplesttest.ll b/test/ExecutionEngine/simplesttest.ll new file mode 100644 index 0000000..1f578d2 --- /dev/null +++ b/test/ExecutionEngine/simplesttest.ll @@ -0,0 +1,10 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +implementation + +int %main() { + ret int 0 +} + diff --git a/test/ExecutionEngine/simpletest.ll b/test/ExecutionEngine/simpletest.ll new file mode 100644 index 0000000..68b7044 --- /dev/null +++ b/test/ExecutionEngine/simpletest.ll @@ -0,0 +1,12 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +implementation + +int %bar() { ret int 0 } + +int %main() { + %r = call int %bar() + ret int %r +} + diff --git a/test/ExecutionEngine/test-arith.ll b/test/ExecutionEngine/test-arith.ll new file mode 100644 index 0000000..49d85af --- /dev/null +++ b/test/ExecutionEngine/test-arith.ll @@ -0,0 +1,38 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +int %main() { + %A = add sbyte 0, 12 + %B = sub sbyte %A, 1 + %C = mul sbyte %B, %B + %D = div sbyte %C, %C + %E = rem sbyte %D, %D + %F = div ubyte 5, 6 + %G = rem ubyte 6, 5 + + %A = add short 0, 12 + %B = sub short %A, 1 + %C = mul short %B, %B + %D = div short %C, %C + %E = rem short %D, %D + %F = div ushort 5, 6 + %G = rem uint 6, 5 + + %A = add int 0, 12 + %B = sub int %A, 1 + %C = mul int %B, %B + %D = div int %C, %C + %E = rem int %D, %D + %F = div uint 5, 6 + %G1 = rem uint 6, 5 + + %A = add long 0, 12 + %B = sub long %A, 1 + %C = mul long %B, %B + %D = div long %C, %C + %E = rem long %D, %D + %F = div ulong 5, 6 + %G = rem ulong 6, 5 + + ret int 0 +} diff --git a/test/ExecutionEngine/test-branch.ll b/test/ExecutionEngine/test-branch.ll new file mode 100644 index 0000000..649319b --- /dev/null +++ b/test/ExecutionEngine/test-branch.ll @@ -0,0 +1,12 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; test unconditional branch +int %main() { + br label %Test +Test: + %X = seteq int 0, 4 + br bool %X, label %Test, label %Label +Label: + ret int 0 +} diff --git a/test/ExecutionEngine/test-call.ll b/test/ExecutionEngine/test-call.ll new file mode 100644 index 0000000..23e4f14 --- /dev/null +++ b/test/ExecutionEngine/test-call.ll @@ -0,0 +1,22 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +declare void %exit(int) + +int %test(sbyte %C, short %S) { + %X = cast short %S to ubyte + %Y = cast ubyte %X to int + ret int %Y +} + +void %FP(void(int) * %F) { + %X = call int %test(sbyte 123, short 1024) + call void %F(int %X) + ret void +} + +int %main() { + call void %FP(void(int)* %exit) + ret int 1 +} diff --git a/test/ExecutionEngine/test-cast.ll b/test/ExecutionEngine/test-cast.ll new file mode 100644 index 0000000..97e7157 --- /dev/null +++ b/test/ExecutionEngine/test-cast.ll @@ -0,0 +1,136 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +int %foo() { + ret int 0 +} + +int %main() { + ; cast bool to ... + cast bool true to bool + cast bool true to ubyte + cast bool true to sbyte + cast bool true to short + cast bool true to ushort + cast bool true to int + cast bool true to uint + cast bool true to long + cast bool true to ulong + cast bool true to float + cast bool true to double + + ; cast sbyte to ... + cast sbyte 0 to bool + cast sbyte 1 to bool + cast sbyte 0 to sbyte + cast sbyte -1 to ubyte + cast sbyte 4 to short + cast sbyte 4 to ushort + cast sbyte 4 to long + cast sbyte 4 to ulong + cast sbyte 4 to float + cast sbyte 4 to double + + ; cast ubyte to ... + cast ubyte 0 to bool + cast ubyte 1 to bool + cast ubyte 0 to sbyte + cast ubyte 1 to ubyte + cast ubyte 4 to short + cast ubyte 4 to ushort + cast ubyte 4 to long + cast ubyte 4 to ulong + cast ubyte 0 to float + cast ubyte 0 to double + + ; cast short to ... + cast short 1 to bool + cast short -1 to sbyte + cast short 255 to ubyte + cast short 0 to short + cast short 0 to ushort + cast short 0 to long + cast short 0 to ulong + cast short 0 to float + cast short 0 to double + + ; cast ushort to ... + cast ushort 1 to bool + cast ushort 1 to sbyte + cast ushort 255 to ubyte + cast ushort 0 to short + cast ushort 0 to ushort + cast ushort 0 to long + cast ushort 0 to ulong + cast ushort 0 to float + cast ushort 0 to double + + ; cast int to ... + cast int 6 to bool + cast int -6 to sbyte + cast int 6 to ubyte + cast int 6 to short + cast int 0 to int + cast int 0 to long + cast int 0 to ulong + cast int 0 to float + cast int 0 to double + + ; cast uint to ... + cast uint 6 to bool + cast uint 7 to sbyte + cast uint 8 to ubyte + cast uint 9 to short + cast uint 10 to int + cast uint 0 to long + cast uint 0 to ulong + cast uint 0 to float + cast uint 0 to double + + ; cast long to ... + cast long 0 to bool + cast long 0 to sbyte + cast long 0 to ubyte + cast long 0 to short + cast long 0 to ushort + cast long 0 to int + cast long 0 to uint + cast long 0 to long + cast long 0 to ulong + cast long 0 to float + cast long 0 to double + + ; cast ulong to ... + cast ulong 1 to bool + cast ulong 1 to sbyte + cast ulong 1 to ubyte + cast ulong 1 to short + cast ulong 1 to ushort + cast ulong 1 to int + cast ulong 1 to uint + cast ulong 1 to long + cast ulong 1 to ulong + cast ulong 1 to float + cast ulong 0 to double + + ; cast float to ... + ;cast float 0.0 to bool + cast float 0.0 to float + cast float 0.0 to double + + ; cast double to ... + ;cast double 0.0 to bool + cast double 0.0 to sbyte + cast double 0.0 to ubyte + cast double 0.0 to short + cast double 0.0 to ushort + cast double 0.0 to int + cast double 0.0 to uint + cast double 0.0 to long + ;cast double 0.0 to ulong + cast double 0.0 to float + cast double 0.0 to double + + ret int 0 +} diff --git a/test/ExecutionEngine/test-constantexpr.ll b/test/ExecutionEngine/test-constantexpr.ll new file mode 100644 index 0000000..1ee7e14 --- /dev/null +++ b/test/ExecutionEngine/test-constantexpr.ll @@ -0,0 +1,14 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; This tests to make sure that we can evaluate weird constant expressions +%A = global int 5 +%B = global int 6 + +implementation + +int %main() { + %A = or bool false, setlt (int* %A, int* %B) ; Which is lower in memory? + ret int 0 +} + diff --git a/test/ExecutionEngine/test-fp.ll b/test/ExecutionEngine/test-fp.ll new file mode 100644 index 0000000..1ee29b5 --- /dev/null +++ b/test/ExecutionEngine/test-fp.ll @@ -0,0 +1,24 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +double %test(double* %DP, double %Arg) { + %D = load double* %DP + %V = add double %D, 1.0 + %W = sub double %V, %V + %X = mul double %W, %W + %Y = div double %X, %X + %Z = rem double %Y, %Y + %Z1 = div double %Z, %W + %Q = add double %Z, %Arg + %R = cast double %Q to double + store double %R, double* %DP + ret double %Z +} + +int %main() { + %X = alloca double + store double 0.0, double* %X + call double %test(double* %X, double 2.0) + ret int 0 +} diff --git a/test/ExecutionEngine/test-loadstore.ll b/test/ExecutionEngine/test-loadstore.ll new file mode 100644 index 0000000..8a4b793 --- /dev/null +++ b/test/ExecutionEngine/test-loadstore.ll @@ -0,0 +1,37 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +void %test(sbyte* %P, short* %P, int* %P, long* %P) { + %V = load sbyte* %P + store sbyte %V, sbyte* %P + + %V = load short* %P + store short %V, short* %P + + %V = load int* %P + store int %V, int* %P + + %V = load long* %P + store long %V, long* %P + + ret void +} + +uint %varalloca(uint %Size) { + %X = alloca uint, uint %Size ;; Variable sized alloca + store uint %Size, uint* %X + %Y = load uint* %X + ret uint %Y +} + +int %main() { + %A = alloca sbyte + %B = alloca short + %C = alloca int + %D = alloca long + call void %test(sbyte* %A, short* %B, int* %C, long* %D) + call uint %varalloca(uint 7) + + ret int 0 +} diff --git a/test/ExecutionEngine/test-logical.ll b/test/ExecutionEngine/test-logical.ll new file mode 100644 index 0000000..86af2e2 --- /dev/null +++ b/test/ExecutionEngine/test-logical.ll @@ -0,0 +1,23 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +int %main() { + %A = and sbyte 4, 8 + %B = or sbyte %A, 7 + %C = xor sbyte %B, %A + + %A = and short 4, 8 + %B = or short %A, 7 + %C = xor short %B, %A + + %A = and int 4, 8 + %B = or int %A, 7 + %C = xor int %B, %A + + %A = and long 4, 8 + %B = or long %A, 7 + %C = xor long %B, %A + + ret int 0 +} diff --git a/test/ExecutionEngine/test-loop.ll b/test/ExecutionEngine/test-loop.ll new file mode 100644 index 0000000..79ffbd2 --- /dev/null +++ b/test/ExecutionEngine/test-loop.ll @@ -0,0 +1,13 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +int %main() { + br label %Loop +Loop: + %I = phi int [0, %0], [%i2, %Loop] + %i2 = add int %I, 1 + %C = seteq int %i2, 10 + br bool %C, label %Out, label %Loop +Out: + ret int 0 +} diff --git a/test/ExecutionEngine/test-malloc.ll b/test/ExecutionEngine/test-malloc.ll new file mode 100644 index 0000000..7a7f245 --- /dev/null +++ b/test/ExecutionEngine/test-malloc.ll @@ -0,0 +1,14 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +int %main() { + %X = malloc int ; constant size + %Y = malloc int, uint 100 ; constant size + %u = add uint 1, 2 + %Z = malloc int, uint %u ; variable size + free int* %X + free int* %Y + free int* %Z + ret int 0 +} diff --git a/test/ExecutionEngine/test-phi.ll b/test/ExecutionEngine/test-phi.ll new file mode 100644 index 0000000..e50cbad --- /dev/null +++ b/test/ExecutionEngine/test-phi.ll @@ -0,0 +1,32 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; test phi node + +%Y = global int 6 + +void %blah(int *%X) { + br label %T +T: + phi int* [%X, %0], [%Y, %Dead] + ret void +Dead: + br label %T +} + +int %test(bool %C) { + br bool %C, label %T, label %T +T: + %X = phi int [123, %0], [123, %0] + ret int %X +} + +int %main() { + br label %Test +Test: + %X = phi int [0, %0], [%Y, %Dead] + ret int %X +Dead: + %Y = shr int 12, ubyte 4 + br label %Test +} diff --git a/test/ExecutionEngine/test-ret.ll b/test/ExecutionEngine/test-ret.ll new file mode 100644 index 0000000..e206912 --- /dev/null +++ b/test/ExecutionEngine/test-ret.ll @@ -0,0 +1,16 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; test return instructions + +void %test1() { ret void } +sbyte %test2() { ret sbyte 1 } +ubyte %test3() { ret ubyte 1 } +short %test4() { ret short -1 } +ushort %test5() { ret ushort 65535 } +int %main() { ret int 0 } +uint %test6() { ret uint 4 } +long %test7() { ret long 0 } +ulong %test8() { ret ulong 0 } +float %test9() { ret float 1.0 } +double %test10() { ret double 2.0 } diff --git a/test/ExecutionEngine/test-setcond-fp.ll b/test/ExecutionEngine/test-setcond-fp.ll new file mode 100644 index 0000000..3f54d6f --- /dev/null +++ b/test/ExecutionEngine/test-setcond-fp.ll @@ -0,0 +1,23 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +int %main() { + %double1 = add double 0.0, 0.0 + %double2 = add double 0.0, 0.0 + %float1 = add float 0.0, 0.0 + %float2 = add float 0.0, 0.0 + %test49 = seteq float %float1, %float2 + %test50 = setge float %float1, %float2 + %test51 = setgt float %float1, %float2 + %test52 = setle float %float1, %float2 + %test53 = setlt float %float1, %float2 + %test54 = setne float %float1, %float2 + %test55 = seteq double %double1, %double2 + %test56 = setge double %double1, %double2 + %test57 = setgt double %double1, %double2 + %test58 = setle double %double1, %double2 + %test59 = setlt double %double1, %double2 + %test60 = setne double %double1, %double2 + ret int 0 +} diff --git a/test/ExecutionEngine/test-setcond-int.ll b/test/ExecutionEngine/test-setcond-int.ll new file mode 100644 index 0000000..db5b48b --- /dev/null +++ b/test/ExecutionEngine/test-setcond-int.ll @@ -0,0 +1,71 @@ +; RUN: llvm-upgrade < %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + + +int %main() { + %int1 = add int 0, 0 + %int2 = add int 0, 0 + %long1 = add long 0, 0 + %long2 = add long 0, 0 + %sbyte1 = add sbyte 0, 0 + %sbyte2 = add sbyte 0, 0 + %short1 = add short 0, 0 + %short2 = add short 0, 0 + %ubyte1 = add ubyte 0, 0 + %ubyte2 = add ubyte 0, 0 + %uint1 = add uint 0, 0 + %uint2 = add uint 0, 0 + %ulong1 = add ulong 0, 0 + %ulong2 = add ulong 0, 0 + %ushort1 = add ushort 0, 0 + %ushort2 = add ushort 0, 0 + %test1 = seteq ubyte %ubyte1, %ubyte2 + %test2 = setge ubyte %ubyte1, %ubyte2 + %test3 = setgt ubyte %ubyte1, %ubyte2 + %test4 = setle ubyte %ubyte1, %ubyte2 + %test5 = setlt ubyte %ubyte1, %ubyte2 + %test6 = setne ubyte %ubyte1, %ubyte2 + %test7 = seteq ushort %ushort1, %ushort2 + %test8 = setge ushort %ushort1, %ushort2 + %test9 = setgt ushort %ushort1, %ushort2 + %test10 = setle ushort %ushort1, %ushort2 + %test11 = setlt ushort %ushort1, %ushort2 + %test12 = setne ushort %ushort1, %ushort2 + %test13 = seteq uint %uint1, %uint2 + %test14 = setge uint %uint1, %uint2 + %test15 = setgt uint %uint1, %uint2 + %test16 = setle uint %uint1, %uint2 + %test17 = setlt uint %uint1, %uint2 + %test18 = setne uint %uint1, %uint2 + %test19 = seteq ulong %ulong1, %ulong2 + %test20 = setge ulong %ulong1, %ulong2 + %test21 = setgt ulong %ulong1, %ulong2 + %test22 = setle ulong %ulong1, %ulong2 + %test23 = setlt ulong %ulong1, %ulong2 + %test24 = setne ulong %ulong1, %ulong2 + %test25 = seteq sbyte %sbyte1, %sbyte2 + %test26 = setge sbyte %sbyte1, %sbyte2 + %test27 = setgt sbyte %sbyte1, %sbyte2 + %test28 = setle sbyte %sbyte1, %sbyte2 + %test29 = setlt sbyte %sbyte1, %sbyte2 + %test30 = setne sbyte %sbyte1, %sbyte2 + %test31 = seteq short %short1, %short2 + %test32 = setge short %short1, %short2 + %test33 = setgt short %short1, %short2 + %test34 = setle short %short1, %short2 + %test35 = setlt short %short1, %short2 + %test36 = setne short %short1, %short2 + %test37 = seteq int %int1, %int2 + %test38 = setge int %int1, %int2 + %test39 = setgt int %int1, %int2 + %test40 = setle int %int1, %int2 + %test41 = setlt int %int1, %int2 + %test42 = setne int %int1, %int2 + %test43 = seteq long %long1, %long2 + %test44 = setge long %long1, %long2 + %test45 = setgt long %long1, %long2 + %test46 = setle long %long1, %long2 + %test47 = setlt long %long1, %long2 + %test48 = setne long %long1, %long2 + ret int 0 +} diff --git a/test/ExecutionEngine/test-shift.ll b/test/ExecutionEngine/test-shift.ll new file mode 100644 index 0000000..2549f34 --- /dev/null +++ b/test/ExecutionEngine/test-shift.ll @@ -0,0 +1,40 @@ +; RUN: llvm-upgrade %s | llvm-as -f -o %t.bc +; RUN: lli %t.bc > /dev/null + +; test shifts +int %main() { + %shamt = add ubyte 0, 1 + + ; Left shifts... + %t1.s = shl int 1, ubyte %shamt + %t2.s = shl int 1, ubyte 4 + + %t1 = shl uint 1, ubyte %shamt + %t2 = shl uint 1, ubyte 5 + + ;%t1 = shl long 1, ubyte %shamt + %t2.s = shl long 1, ubyte 4 + + ;%t1 = shl ulong 1, ubyte %shamt + %t2 = shl ulong 1, ubyte 5 + + ; Right shifts... + %tr1.s = shr int 1, ubyte %shamt + %tr2.s = shr int 1, ubyte 4 + + %tr1 = shr uint 1, ubyte %shamt + %tr2 = shr uint 1, ubyte 5 + + ;%tr1 = shr long 1, ubyte %shamt + %tr1.l = shr long 1, ubyte 4 + %tr2.l = shr long 1, ubyte %shamt + %tr3.l = shl long 1, ubyte 4 + %tr4.l = shl long 1, ubyte %shamt + + ;%t1 = shr ulong 1, ubyte %shamt + %tr1.u = shr ulong 1, ubyte 5 + %tr2.u = shr ulong 1, ubyte %shamt + %tr3.u = shl ulong 1, ubyte 5 + %tr4.u = shl ulong 1, ubyte %shamt + ret int 0 +} |