diff options
Diffstat (limited to 'test/Transforms/ArgumentPromotion')
-rw-r--r-- | test/Transforms/ArgumentPromotion/basictest.ll | 32 | ||||
-rw-r--r-- | test/Transforms/ArgumentPromotion/byval-2.ll | 37 | ||||
-rw-r--r-- | test/Transforms/ArgumentPromotion/byval.ll | 33 | ||||
-rw-r--r-- | test/Transforms/ArgumentPromotion/dbg.ll | 22 |
4 files changed, 80 insertions, 44 deletions
diff --git a/test/Transforms/ArgumentPromotion/basictest.ll b/test/Transforms/ArgumentPromotion/basictest.ll index d3d21fc..8f78b98 100644 --- a/test/Transforms/ArgumentPromotion/basictest.ll +++ b/test/Transforms/ArgumentPromotion/basictest.ll @@ -1,23 +1,29 @@ -; RUN: opt < %s -basicaa -argpromotion -mem2reg -S | not grep alloca +; RUN: opt < %s -basicaa -argpromotion -mem2reg -S | FileCheck %s target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" + define internal i32 @test(i32* %X, i32* %Y) { - %A = load i32* %X ; <i32> [#uses=1] - %B = load i32* %Y ; <i32> [#uses=1] - %C = add i32 %A, %B ; <i32> [#uses=1] - ret i32 %C +; CHECK-LABEL: define internal i32 @test(i32 %X.val, i32 %Y.val) + %A = load i32* %X + %B = load i32* %Y + %C = add i32 %A, %B + ret i32 %C } define internal i32 @caller(i32* %B) { - %A = alloca i32 ; <i32*> [#uses=2] - store i32 1, i32* %A - %C = call i32 @test( i32* %A, i32* %B ) ; <i32> [#uses=1] - ret i32 %C +; CHECK-LABEL: define internal i32 @caller(i32 %B.val1) + %A = alloca i32 + store i32 1, i32* %A + %C = call i32 @test(i32* %A, i32* %B) +; CHECK: call i32 @test(i32 1, i32 %B.val1) + ret i32 %C } define i32 @callercaller() { - %B = alloca i32 ; <i32*> [#uses=2] - store i32 2, i32* %B - %X = call i32 @caller( i32* %B ) ; <i32> [#uses=1] - ret i32 %X +; CHECK-LABEL: define i32 @callercaller() + %B = alloca i32 + store i32 2, i32* %B + %X = call i32 @caller(i32* %B) +; CHECK: call i32 @caller(i32 2) + ret i32 %X } diff --git a/test/Transforms/ArgumentPromotion/byval-2.ll b/test/Transforms/ArgumentPromotion/byval-2.ll index 368c689..b412f5e 100644 --- a/test/Transforms/ArgumentPromotion/byval-2.ll +++ b/test/Transforms/ArgumentPromotion/byval-2.ll @@ -1,26 +1,31 @@ -; RUN: opt < %s -argpromotion -S | grep -F "i32* byval" | count 2 -; Argpromote + scalarrepl should change this to passing the two integers by value. +; RUN: opt < %s -argpromotion -S | FileCheck %s - %struct.ss = type { i32, i64 } +; Arg promotion eliminates the struct argument. +; FIXME: Should it eliminate the i32* argument? + +%struct.ss = type { i32, i64 } define internal void @f(%struct.ss* byval %b, i32* byval %X) nounwind { +; CHECK-LABEL: define internal void @f(i32 %b.0, i64 %b.1, i32* byval %X) entry: - %tmp = getelementptr %struct.ss* %b, i32 0, i32 0 - %tmp1 = load i32* %tmp, align 4 - %tmp2 = add i32 %tmp1, 1 - store i32 %tmp2, i32* %tmp, align 4 + %tmp = getelementptr %struct.ss* %b, i32 0, i32 0 + %tmp1 = load i32* %tmp, align 4 + %tmp2 = add i32 %tmp1, 1 + store i32 %tmp2, i32* %tmp, align 4 - store i32 0, i32* %X - ret void + store i32 0, i32* %X + ret void } define i32 @test(i32* %X) { +; CHECK-LABEL: define i32 @test entry: - %S = alloca %struct.ss ; <%struct.ss*> [#uses=4] - %tmp1 = getelementptr %struct.ss* %S, i32 0, i32 0 ; <i32*> [#uses=1] - store i32 1, i32* %tmp1, align 8 - %tmp4 = getelementptr %struct.ss* %S, i32 0, i32 1 ; <i64*> [#uses=1] - store i64 2, i64* %tmp4, align 4 - call void @f( %struct.ss* byval %S, i32* byval %X) - ret i32 0 + %S = alloca %struct.ss + %tmp1 = getelementptr %struct.ss* %S, i32 0, i32 0 + store i32 1, i32* %tmp1, align 8 + %tmp4 = getelementptr %struct.ss* %S, i32 0, i32 1 + store i64 2, i64* %tmp4, align 4 + call void @f( %struct.ss* byval %S, i32* byval %X) +; CHECK: call void @f(i32 %{{.*}}, i64 %{{.*}}, i32* byval %{{.*}}) + ret i32 0 } diff --git a/test/Transforms/ArgumentPromotion/byval.ll b/test/Transforms/ArgumentPromotion/byval.ll index 44b26fc..27305e9 100644 --- a/test/Transforms/ArgumentPromotion/byval.ll +++ b/test/Transforms/ArgumentPromotion/byval.ll @@ -1,25 +1,28 @@ -; RUN: opt < %s -argpromotion -scalarrepl -S | not grep load +; RUN: opt < %s -argpromotion -S | FileCheck %s + target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" -; Argpromote + scalarrepl should change this to passing the two integers by value. - %struct.ss = type { i32, i64 } +%struct.ss = type { i32, i64 } define internal void @f(%struct.ss* byval %b) nounwind { +; CHECK-LABEL: define internal void @f(i32 %b.0, i64 %b.1) entry: - %tmp = getelementptr %struct.ss* %b, i32 0, i32 0 ; <i32*> [#uses=2] - %tmp1 = load i32* %tmp, align 4 ; <i32> [#uses=1] - %tmp2 = add i32 %tmp1, 1 ; <i32> [#uses=1] - store i32 %tmp2, i32* %tmp, align 4 - ret void + %tmp = getelementptr %struct.ss* %b, i32 0, i32 0 ; <i32*> [#uses=2] + %tmp1 = load i32* %tmp, align 4 ; <i32> [#uses=1] + %tmp2 = add i32 %tmp1, 1 ; <i32> [#uses=1] + store i32 %tmp2, i32* %tmp, align 4 + ret void } define i32 @main() nounwind { +; CHECK-LABEL: define i32 @main entry: - %S = alloca %struct.ss ; <%struct.ss*> [#uses=4] - %tmp1 = getelementptr %struct.ss* %S, i32 0, i32 0 ; <i32*> [#uses=1] - store i32 1, i32* %tmp1, align 8 - %tmp4 = getelementptr %struct.ss* %S, i32 0, i32 1 ; <i64*> [#uses=1] - store i64 2, i64* %tmp4, align 4 - call void @f( %struct.ss* byval %S ) nounwind - ret i32 0 + %S = alloca %struct.ss ; <%struct.ss*> [#uses=4] + %tmp1 = getelementptr %struct.ss* %S, i32 0, i32 0 ; <i32*> [#uses=1] + store i32 1, i32* %tmp1, align 8 + %tmp4 = getelementptr %struct.ss* %S, i32 0, i32 1 ; <i64*> [#uses=1] + store i64 2, i64* %tmp4, align 4 + call void @f( %struct.ss* byval %S ) nounwind +; CHECK: call void @f(i32 %{{.*}}, i64 %{{.*}}) + ret i32 0 } diff --git a/test/Transforms/ArgumentPromotion/dbg.ll b/test/Transforms/ArgumentPromotion/dbg.ll new file mode 100644 index 0000000..70503af --- /dev/null +++ b/test/Transforms/ArgumentPromotion/dbg.ll @@ -0,0 +1,22 @@ +; RUN: opt < %s -argpromotion -S | FileCheck %s +; CHECK: call void @test(), !dbg [[DBG_LOC:![0-9]]] +; CHECK: [[TEST_FN:.*]] = {{.*}} void ()* @test +; CHECK: [[DBG_LOC]] = metadata !{i32 8, i32 0, metadata [[TEST_FN]], null} + +define internal void @test(i32* %X) { + ret void +} + +define void @caller() { + call void @test(i32* null), !dbg !1 + ret void +} + +!llvm.module.flags = !{!0} +!llvm.dbg.cu = !{!3} + +!0 = metadata !{i32 2, metadata !"Debug Info Version", i32 1} +!1 = metadata !{i32 8, i32 0, metadata !2, null} +!2 = metadata !{i32 786478, null, null, metadata !"test", metadata !"test", metadata !"", i32 3, null, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32*)* @test, null, null, null, i32 3} +!3 = metadata !{i32 786449, null, i32 4, metadata !"clang version 3.5.0 ", i1 false, metadata !"", i32 0, null, null, metadata !4, null, null, metadata !"", i32 2} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/blaikie/dev/scratch/pr20038/reduce/<stdin>] [DW_LANG_C_plus_plus] +!4 = metadata !{metadata !2} |