diff options
Diffstat (limited to 'test/Analysis/GlobalsModRef')
-rw-r--r-- | test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll | 4 | ||||
-rw-r--r-- | test/Analysis/GlobalsModRef/aliastest.ll | 7 | ||||
-rw-r--r-- | test/Analysis/GlobalsModRef/chaining-analysis.ll | 6 | ||||
-rw-r--r-- | test/Analysis/GlobalsModRef/indirect-global.ll | 5 | ||||
-rw-r--r-- | test/Analysis/GlobalsModRef/modreftest.ll | 7 | ||||
-rw-r--r-- | test/Analysis/GlobalsModRef/purecse.ll | 8 | ||||
-rw-r--r-- | test/Analysis/GlobalsModRef/volatile-instrs.ll | 34 |
7 files changed, 62 insertions, 9 deletions
diff --git a/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll b/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll index 17ace8a..d51c159 100644 --- a/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll +++ b/test/Analysis/GlobalsModRef/2008-09-03-ReadGlobals.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalsmodref-aa -gvn -S | grep call | count 2 +; RUN: opt < %s -globalsmodref-aa -gvn -S | FileCheck %s @g = internal global i32 0 ; <i32*> [#uses=2] @@ -8,6 +8,8 @@ define i32 @r() { } define i32 @f() { +; CHECK: call i32 @e() +; CHECK: call i32 @e() entry: %tmp = call i32 @e( ) ; <i32> [#uses=1] store i32 %tmp, i32* @g diff --git a/test/Analysis/GlobalsModRef/aliastest.ll b/test/Analysis/GlobalsModRef/aliastest.ll index 75af4dc..4cfed71 100644 --- a/test/Analysis/GlobalsModRef/aliastest.ll +++ b/test/Analysis/GlobalsModRef/aliastest.ll @@ -1,7 +1,12 @@ -; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -S | not grep load +; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -S | FileCheck %s + @X = internal global i32 4 ; <i32*> [#uses=1] define i32 @test(i32* %P) { +; CHECK: @test +; CHECK-NEXT: store i32 7, i32* %P +; CHECK-NEXT: store i32 12, i32* @X +; CHECK-NEXT: ret i32 7 store i32 7, i32* %P store i32 12, i32* @X %V = load i32* %P ; <i32> [#uses=1] diff --git a/test/Analysis/GlobalsModRef/chaining-analysis.ll b/test/Analysis/GlobalsModRef/chaining-analysis.ll index 431b2a6..aeb76e4 100644 --- a/test/Analysis/GlobalsModRef/chaining-analysis.ll +++ b/test/Analysis/GlobalsModRef/chaining-analysis.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -S | not grep load +; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -S | FileCheck %s ; This test requires the use of previous analyses to determine that ; doesnotmodX does not modify X (because 'sin' doesn't). @@ -8,6 +8,10 @@ declare double @sin(double) readnone define i32 @test(i32* %P) { +; CHECK: @test +; CHECK-NEXT: store i32 12, i32* @X +; CHECK-NEXT: call double @doesnotmodX(double 1.000000e+00) +; CHECK-NEXT: ret i32 12 store i32 12, i32* @X call double @doesnotmodX( double 1.000000e+00 ) ; <double>:1 [#uses=0] %V = load i32* @X ; <i32> [#uses=1] diff --git a/test/Analysis/GlobalsModRef/indirect-global.ll b/test/Analysis/GlobalsModRef/indirect-global.ll index 826f55c..48ac6dd 100644 --- a/test/Analysis/GlobalsModRef/indirect-global.ll +++ b/test/Analysis/GlobalsModRef/indirect-global.ll @@ -1,9 +1,7 @@ -; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -instcombine -S | \ -; RUN: grep {ret i32 0} +; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -instcombine -S | FileCheck %s @G = internal global i32* null ; <i32**> [#uses=3] - declare i8* @malloc(i32) define void @test() { %a = call i8* @malloc(i32 4) @@ -13,6 +11,7 @@ define void @test() { } define i32 @test1(i32* %P) { +; CHECK: ret i32 0 %g1 = load i32** @G ; <i32*> [#uses=2] %h1 = load i32* %g1 ; <i32> [#uses=1] store i32 123, i32* %P diff --git a/test/Analysis/GlobalsModRef/modreftest.ll b/test/Analysis/GlobalsModRef/modreftest.ll index 3a02a94a..3eed916 100644 --- a/test/Analysis/GlobalsModRef/modreftest.ll +++ b/test/Analysis/GlobalsModRef/modreftest.ll @@ -1,7 +1,12 @@ -; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -S | not grep load +; RUN: opt < %s -basicaa -globalsmodref-aa -gvn -S | FileCheck %s + @X = internal global i32 4 ; <i32*> [#uses=2] define i32 @test(i32* %P) { +; CHECK: @test +; CHECK-NEXT: store i32 12, i32* @X +; CHECK-NEXT: call void @doesnotmodX() +; CHECK-NEXT: ret i32 12 store i32 12, i32* @X call void @doesnotmodX( ) %V = load i32* @X ; <i32> [#uses=1] diff --git a/test/Analysis/GlobalsModRef/purecse.ll b/test/Analysis/GlobalsModRef/purecse.ll index 994aff8..e030417 100644 --- a/test/Analysis/GlobalsModRef/purecse.ll +++ b/test/Analysis/GlobalsModRef/purecse.ll @@ -1,6 +1,5 @@ ; Test that pure functions are cse'd away -; RUN: opt < %s -globalsmodref-aa -gvn -instcombine | \ -; RUN: llvm-dis | not grep sub +; RUN: opt < %s -globalsmodref-aa -gvn -instcombine -S | FileCheck %s define i32 @pure(i32 %X) { %Y = add i32 %X, 1 ; <i32> [#uses=1] @@ -8,6 +7,8 @@ define i32 @pure(i32 %X) { } define i32 @test1(i32 %X) { +; CHECK: %A = call i32 @pure(i32 %X) +; CHECK-NEXT: ret i32 0 %A = call i32 @pure( i32 %X ) ; <i32> [#uses=1] %B = call i32 @pure( i32 %X ) ; <i32> [#uses=1] %C = sub i32 %A, %B ; <i32> [#uses=1] @@ -15,6 +16,9 @@ define i32 @test1(i32 %X) { } define i32 @test2(i32 %X, i32* %P) { +; CHECK: %A = call i32 @pure(i32 %X) +; CHECK-NEXT: store i32 %X, i32* %P +; CHECK-NEXT: ret i32 0 %A = call i32 @pure( i32 %X ) ; <i32> [#uses=1] store i32 %X, i32* %P ;; Does not invalidate 'pure' call. %B = call i32 @pure( i32 %X ) ; <i32> [#uses=1] diff --git a/test/Analysis/GlobalsModRef/volatile-instrs.ll b/test/Analysis/GlobalsModRef/volatile-instrs.ll new file mode 100644 index 0000000..49bce67 --- /dev/null +++ b/test/Analysis/GlobalsModRef/volatile-instrs.ll @@ -0,0 +1,34 @@ +; RUN: opt < %s -basicaa -dse -S | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.8.0" + +%struct.anon = type { i32, i32, i32 } +@b = global %struct.anon { i32 1, i32 0, i32 0 }, align 4 +@c = common global i32 0, align 4 +@a = common global %struct.anon zeroinitializer, align 4 +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +declare i32 @printf(i8* nocapture, ...) nounwind +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind + + +; Make sure that the initial memcpy call does not go away +; because the volatile load is in the way. PR12899 + +; CHECK: main_entry: +; CHECK-NEXT: tail call void @llvm.memcpy.p0i8.p0i8.i64 + +define i32 @main() nounwind uwtable ssp { +main_entry: + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.anon* @b to i8*), i8* bitcast (%struct.anon* @a to i8*), i64 12, i32 4, i1 false) + %0 = load volatile i32* getelementptr inbounds (%struct.anon* @b, i64 0, i32 0), align 4, !tbaa !0 + store i32 %0, i32* @c, align 4, !tbaa !0 + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.anon* @b to i8*), i8* bitcast (%struct.anon* @a to i8*), i64 12, i32 4, i1 false) nounwind + %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %0) nounwind + ret i32 0 +} + +!0 = metadata !{metadata !"int", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} |