diff --git a/llvm/test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll b/llvm/test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll --- a/llvm/test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll +++ b/llvm/test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll @@ -1,7 +1,9 @@ -; RUN: opt < %s -ipconstprop -S | grep "ret i32 %r" +; RUN: opt < %s -ipconstprop -S | FileCheck %s ; Should not propagate the result of a weak function. ; PR2411 +; CHECK: ret i32 %r + define weak i32 @foo() nounwind { entry: ret i32 1 diff --git a/llvm/test/Transforms/IPConstantProp/2009-09-24-byval-ptr.ll b/llvm/test/Transforms/IPConstantProp/2009-09-24-byval-ptr.ll --- a/llvm/test/Transforms/IPConstantProp/2009-09-24-byval-ptr.ll +++ b/llvm/test/Transforms/IPConstantProp/2009-09-24-byval-ptr.ll @@ -21,10 +21,10 @@ entry: %0 = getelementptr %struct.MYstr, %struct.MYstr* %u, i32 0, i32 1 ; [#uses=1] %1 = load i32, i32* %0 -; CHECK: load i32, i32* getelementptr inbounds (%struct.MYstr, %struct.MYstr* @mystr, i32 0, i32 1) +; CHECK: %struct.MYstr* @mystr, i{{..}} 0, i32 1 %2 = getelementptr %struct.MYstr, %struct.MYstr* %u, i32 0, i32 0 ; [#uses=1] %3 = load i8, i8* %2 -; CHECK: load i8, i8* getelementptr inbounds (%struct.MYstr, %struct.MYstr* @mystr, i32 0, i32 0) +; CHECK: %struct.MYstr* @mystr, i{{..}} 0, i32 0 %4 = zext i8 %3 to i32 %5 = add i32 %4, %1 ret i32 %5 @@ -34,7 +34,7 @@ entry: call void @vfu1(%struct.MYstr* byval align 4 @mystr) nounwind %result = call i32 @vfu2(%struct.MYstr* byval align 4 @mystr) nounwind - +; CHECK: ret i32 %result ret i32 %result } diff --git a/llvm/test/Transforms/IPConstantProp/PR16052.ll b/llvm/test/Transforms/IPConstantProp/PR16052.ll --- a/llvm/test/Transforms/IPConstantProp/PR16052.ll +++ b/llvm/test/Transforms/IPConstantProp/PR16052.ll @@ -1,9 +1,15 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes ; RUN: opt < %s -S -ipsccp | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" define i64 @fn2() { +; CHECK-LABEL: define {{[^@]+}}@fn2() +; CHECK-NEXT: entry: +; CHECK-NEXT: [[CALL2:%.*]] = call i64 @fn1(i64 undef) +; CHECK-NEXT: ret i64 [[CALL2]] +; entry: %conv = sext i32 undef to i64 %div = sdiv i64 8, %conv @@ -11,16 +17,15 @@ ret i64 %call2 } -; CHECK-DAG: define i64 @fn2( -; CHECK: %[[CALL:.*]] = call i64 @fn1(i64 undef) - define internal i64 @fn1(i64 %p1) { +; CHECK-LABEL: define {{[^@]+}}@fn1 +; CHECK-SAME: (i64 [[P1:%.*]]) +; CHECK-NEXT: entry: +; CHECK-NEXT: [[COND:%.*]] = select i1 undef, i64 undef, i64 undef +; CHECK-NEXT: ret i64 [[COND]] +; entry: %tobool = icmp ne i64 %p1, 0 %cond = select i1 %tobool, i64 %p1, i64 %p1 ret i64 %cond } - -; CHECK-DAG: define internal i64 @fn1( -; CHECK: %[[SEL:.*]] = select i1 undef, i64 undef, i64 undef -; CHECK: ret i64 %[[SEL]] diff --git a/llvm/test/Transforms/IPConstantProp/PR26044.ll b/llvm/test/Transforms/IPConstantProp/PR26044.ll --- a/llvm/test/Transforms/IPConstantProp/PR26044.ll +++ b/llvm/test/Transforms/IPConstantProp/PR26044.ll @@ -1,8 +1,20 @@ -; RUN: opt < %s -S -ipsccp | FileCheck %s +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes +; RUN: opt < %s -S -ipsccp | FileCheck %s --check-prefixes=IPSCCP target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" -define void @fn2() { +define void @fn2(i32* %P) { +; IPSCCP-LABEL: define {{[^@]+}}@fn2 +; IPSCCP-SAME: (i32* [[P:%.*]]) +; IPSCCP-NEXT: entry: +; IPSCCP-NEXT: br label [[IF_END:%.*]] +; IPSCCP: for.cond1: +; IPSCCP-NEXT: br i1 false, label [[IF_END]], label [[IF_END]] +; IPSCCP: if.end: +; IPSCCP-NEXT: [[CALL:%.*]] = call i32 @fn1(i32 undef) +; IPSCCP-NEXT: store i32 [[CALL]], i32* [[P]] +; IPSCCP-NEXT: br label [[FOR_COND1:%.*]] +; entry: br label %if.end @@ -13,17 +25,36 @@ %e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ] %0 = load i32, i32* %e.2, align 4 %call = call i32 @fn1(i32 %0) + store i32 %call, i32* %P br label %for.cond1 } define internal i32 @fn1(i32 %p1) { +; IPSCCP-LABEL: define {{[^@]+}}@fn1 +; IPSCCP-SAME: (i32 [[P1:%.*]]) +; IPSCCP-NEXT: entry: +; IPSCCP-NEXT: [[COND:%.*]] = select i1 undef, i32 undef, i32 undef +; IPSCCP-NEXT: ret i32 [[COND]] +; entry: %tobool = icmp ne i32 %p1, 0 %cond = select i1 %tobool, i32 %p1, i32 %p1 ret i32 %cond } -define void @fn_no_null_opt() #0 { +define void @fn_no_null_opt(i32* %P) #0 { +; IPSCCP-LABEL: define {{[^@]+}}@fn_no_null_opt +; IPSCCP-SAME: (i32* [[P:%.*]]) +; IPSCCP-NEXT: entry: +; IPSCCP-NEXT: br label [[IF_END:%.*]] +; IPSCCP: for.cond1: +; IPSCCP-NEXT: br i1 false, label [[IF_END]], label [[IF_END]] +; IPSCCP: if.end: +; IPSCCP-NEXT: [[TMP0:%.*]] = load i32, i32* null, align 4 +; IPSCCP-NEXT: [[CALL:%.*]] = call i32 @fn0(i32 [[TMP0]]) +; IPSCCP-NEXT: store i32 [[CALL]], i32* [[P]] +; IPSCCP-NEXT: br label [[FOR_COND1:%.*]] +; entry: br label %if.end @@ -34,10 +65,18 @@ %e.2 = phi i32* [ undef, %entry ], [ null, %for.cond1 ], [ null, %for.cond1 ] %0 = load i32, i32* %e.2, align 4 %call = call i32 @fn0(i32 %0) + store i32 %call, i32* %P br label %for.cond1 } define internal i32 @fn0(i32 %p1) { +; IPSCCP-LABEL: define {{[^@]+}}@fn0 +; IPSCCP-SAME: (i32 [[P1:%.*]]) +; IPSCCP-NEXT: entry: +; IPSCCP-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[P1]], 0 +; IPSCCP-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], i32 [[P1]], i32 [[P1]] +; IPSCCP-NEXT: ret i32 [[COND]] +; entry: %tobool = icmp ne i32 %p1, 0 %cond = select i1 %tobool, i32 %p1, i32 %p1 @@ -45,18 +84,3 @@ } attributes #0 = { "null-pointer-is-valid"="true" } - -; CHECK-LABEL: define void @fn2( -; CHECK: call i32 @fn1(i32 undef) - -; CHECK-LABEL: define internal i32 @fn1( -; CHECK:%[[COND:.*]] = select i1 undef, i32 undef, i32 undef -; CHECK: ret i32 %[[COND]] - -; CHECK-LABEL: define void @fn_no_null_opt( -; CHECK: call i32 @fn0(i32 %0) - -; CHECK-LABEL: define internal i32 @fn0( -; CHECK:%[[TOBOOL:.*]] = icmp ne i32 %p1, 0 -; CHECK:%[[COND:.*]] = select i1 %[[TOBOOL]], i32 %p1, i32 %p1 -; CHECK: ret i32 %[[COND]] diff --git a/llvm/test/Transforms/IPConstantProp/recursion.ll b/llvm/test/Transforms/IPConstantProp/recursion.ll --- a/llvm/test/Transforms/IPConstantProp/recursion.ll +++ b/llvm/test/Transforms/IPConstantProp/recursion.ll @@ -1,4 +1,7 @@ -; RUN: opt < %s -ipconstprop -deadargelim -S | not grep %X +; RUN: opt < %s -ipconstprop -deadargelim -S | FileCheck %s + +; CHECK-NOT: %X + define internal i32 @foo(i32 %X) { %Y = call i32 @foo( i32 %X ) ; [#uses=1] %Z = add i32 %Y, 1 ; [#uses=1] diff --git a/llvm/test/Transforms/IPConstantProp/return-constant.ll b/llvm/test/Transforms/IPConstantProp/return-constant.ll --- a/llvm/test/Transforms/IPConstantProp/return-constant.ll +++ b/llvm/test/Transforms/IPConstantProp/return-constant.ll @@ -1,4 +1,9 @@ -; RUN: opt < %s -ipconstprop -instcombine -S | grep "ret i1 true" | count 2 +; RUN: opt < %s -ipconstprop -instcombine -S | FileCheck %s + +; CHECK: ret i1 true +; CHECK: ret i1 true +; CHECK-NOT: ret i1 true + define internal i32 @foo(i1 %C) { br i1 %C, label %T, label %F diff --git a/llvm/test/Transforms/IPConstantProp/return-constants.ll b/llvm/test/Transforms/IPConstantProp/return-constants.ll --- a/llvm/test/Transforms/IPConstantProp/return-constants.ll +++ b/llvm/test/Transforms/IPConstantProp/return-constants.ll @@ -1,8 +1,9 @@ -; RUN: opt < %s -ipconstprop -S > %t +; RUN: opt < %s -ipconstprop -S | FileCheck %s + ;; Check that the 21 constants got propagated properly -; RUN: cat %t | grep "%M = add i32 21, 21" +; CHECK: %M = add i32 21, 21 ;; Check that the second return values didn't get propagated -; RUN: cat %t | grep "%N = add i32 %B, %D" +; CHECK: %N = add i32 %B, %D %0 = type { i32, i32 } diff --git a/llvm/test/Transforms/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll b/llvm/test/Transforms/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll --- a/llvm/test/Transforms/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll +++ b/llvm/test/Transforms/IPConstantProp/solve-after-each-resolving-undefs-for-function.ll @@ -3,12 +3,15 @@ ; CHECK-LABEL: @testf( ; CHECK: ret i32 undef ; -define internal i32 @testf() { +define internal i32 @testf(i1 %c) { entry: + br i1 %c, label %if.cond, label %if.end + +if.cond: br i1 undef, label %if.then, label %if.end if.then: ; preds = %entry, %if.then - br label %if.end + ret i32 11 if.end: ; preds = %if.then1, %entry ret i32 10 @@ -17,12 +20,12 @@ ; CHECK-LABEL: @test1( ; CHECK: ret i32 undef ; -define internal i32 @test1() { +define internal i32 @test1(i1 %c) { entry: br label %if.then if.then: ; preds = %entry, %if.then - %call = call i32 @testf() + %call = call i32 @testf(i1 %c) %res = icmp eq i32 %call, 10 br i1 %res, label %ret1, label %ret2 @@ -34,10 +37,10 @@ } ; CHECK-LABEL: @main( -; CHECK-NEXT: %res = call i32 @test1() +; CHECK-NEXT: %res = call i32 @test1( ; CHECK-NEXT: ret i32 99 ; -define i32 @main() { - %res = call i32 @test1() +define i32 @main(i1 %c) { + %res = call i32 @test1(i1 %c) ret i32 %res } diff --git a/llvm/test/Transforms/IPConstantProp/user-with-multiple-uses.ll b/llvm/test/Transforms/IPConstantProp/user-with-multiple-uses.ll --- a/llvm/test/Transforms/IPConstantProp/user-with-multiple-uses.ll +++ b/llvm/test/Transforms/IPConstantProp/user-with-multiple-uses.ll @@ -28,6 +28,3 @@ return: ret i32 0 } - -; CHECK: attributes #0 = { noreturn nounwind } -; CHECK: attributes #1 = { nounwind }