diff options
author | dim <dim@FreeBSD.org> | 2012-08-15 19:34:23 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-08-15 19:34:23 +0000 |
commit | 721c201bd55ffb73cb2ba8d39e0570fa38c44e15 (patch) | |
tree | eacfc83d988e4b9d11114387ae7dc41243f2a363 /test/Transforms/GlobalOpt | |
parent | 2b2816e083a455f7a656ae88b0fd059d1688bb36 (diff) | |
download | FreeBSD-src-721c201bd55ffb73cb2ba8d39e0570fa38c44e15.zip FreeBSD-src-721c201bd55ffb73cb2ba8d39e0570fa38c44e15.tar.gz |
Vendor import of llvm trunk r161861:
http://llvm.org/svn/llvm-project/llvm/trunk@161861
Diffstat (limited to 'test/Transforms/GlobalOpt')
17 files changed, 117 insertions, 22 deletions
diff --git a/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll b/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll index 82abc8fe..7c07d5d 100644 --- a/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll +++ b/test/Transforms/GlobalOpt/2008-01-13-OutOfRangeSROA.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -S | grep {16 x .31 x double.. zeroinitializer} +; RUN: opt < %s -globalopt -S | grep "16 x .31 x double.. zeroinitializer" ; The 'X' indices could be larger than 31. Do not SROA the outer indices of this array. @mm = internal global [16 x [31 x double]] zeroinitializer, align 32 diff --git a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll index 588d5c9..08b2cb1 100644 --- a/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll +++ b/test/Transforms/GlobalOpt/2008-01-29-VolatileGlobal.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -S | grep {load volatile} +; RUN: opt < %s -globalopt -S | grep "load volatile" @t0.1441 = internal global double 0x3FD5555555555555, align 8 ; <double*> [#uses=1] define double @foo() nounwind { diff --git a/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll b/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll index 5b06fea..d58becd 100644 --- a/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll +++ b/test/Transforms/GlobalOpt/2008-04-26-SROA-Global-Align.ll @@ -2,9 +2,9 @@ ; alignments. Elements 0 and 2 must be 16-byte aligned, and element ; 1 must be at least 8 byte aligned (but could be more). -; RUN: opt < %s -globalopt -S | grep {@G.0 = internal unnamed_addr global .*align 16} -; RUN: opt < %s -globalopt -S | grep {@G.1 = internal unnamed_addr global .*align 8} -; RUN: opt < %s -globalopt -S | grep {@G.2 = internal unnamed_addr global .*align 16} +; RUN: opt < %s -globalopt -S | grep "@G.0 = internal unnamed_addr global .*align 16" +; RUN: opt < %s -globalopt -S | grep "@G.1 = internal unnamed_addr global .*align 8" +; RUN: opt < %s -globalopt -S | grep "@G.2 = internal unnamed_addr global .*align 16" ; rdar://5891920 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:32:32-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" diff --git a/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll b/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll index c4b6e52..e76c44d 100644 --- a/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll +++ b/test/Transforms/GlobalOpt/2009-01-13-phi-user.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -S | grep {phi.*@head} +; RUN: opt < %s -globalopt -S | grep "phi.*@head" ; PR3321 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" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/Transforms/GlobalOpt/2009-03-05-dbg.ll b/test/Transforms/GlobalOpt/2009-03-05-dbg.ll index 3154856..0f3efa0 100644 --- a/test/Transforms/GlobalOpt/2009-03-05-dbg.ll +++ b/test/Transforms/GlobalOpt/2009-03-05-dbg.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -stats -disable-output |& grep "1 globalopt - Number of global vars shrunk to booleans" +; RUN: opt < %s -globalopt -stats -disable-output 2>&1 | grep "1 globalopt - Number of global vars shrunk to booleans" @Stop = internal global i32 0 ; <i32*> [#uses=3] diff --git a/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll b/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll index d645ce4..059af1c 100644 --- a/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll +++ b/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -globalopt -S | grep {@X = internal unnamed_addr global i32} +; RUN: opt < %s -globalopt -S | grep "@X = internal unnamed_addr global i32" target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin7" @X = internal global i32* null ; <i32**> [#uses=2] diff --git a/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll index 54e8f90..40862bd 100644 --- a/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll +++ b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll @@ -17,7 +17,7 @@ define void @test() nounwind ssp { %2 = sext i32 %1 to i64 ; <i64> [#uses=1] %3 = mul i64 %2, ptrtoint (%struct.strchartype* getelementptr (%struct.strchartype* null, i64 1) to i64) ; <i64> [#uses=1] %4 = tail call i8* @malloc(i64 %3) ; <i8*> [#uses=1] -; CHECK: call i8* @malloc(i64 +; CHECK-NOT: call i8* @malloc(i64 %5 = bitcast i8* %4 to %struct.strchartype* ; <%struct.strchartype*> [#uses=1] store %struct.strchartype* %5, %struct.strchartype** @chartypes, align 8 ret void diff --git a/test/Transforms/GlobalOpt/2012-05-11-blockaddress.ll b/test/Transforms/GlobalOpt/2012-05-11-blockaddress.ll new file mode 100644 index 0000000..0c58c1a --- /dev/null +++ b/test/Transforms/GlobalOpt/2012-05-11-blockaddress.ll @@ -0,0 +1,16 @@ +; RUN: opt < %s -globalopt -S | FileCheck %s +; Check that the mere presence of a blockaddress doesn't prevent -globalopt +; from promoting @f to fastcc. + +; CHECK: define{{.*}}fastcc{{.*}}@f +define internal i8* @f() { + ret i8* blockaddress(@f, %L1) +L1: + ret i8* null +} + +define void @g() { + ; CHECK: call{{.*}}fastcc{{.*}}@f + %p = call i8* @f() + ret void +} diff --git a/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll b/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll new file mode 100644 index 0000000..a472f10 --- /dev/null +++ b/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll @@ -0,0 +1,49 @@ +; RUN: opt -globalopt -S -o - < %s | FileCheck %s + +@glbl = internal global i8* null + +define void @test1a() { +; CHECK: @test1a +; CHECK-NOT: store +; CHECK-NEXT: ret void + store i8* null, i8** @glbl + ret void +} + +define void @test1b(i8* %p) { +; CHECK: @test1b +; CHECK-NEXT: store +; CHECK-NEXT: ret void + store i8* %p, i8** @glbl + ret void +} + +define void @test2() { +; CHECK: @test2 +; CHECK: alloca i8 + %txt = alloca i8 + call void @foo2(i8* %txt) + %call2 = call i8* @strdup(i8* %txt) + store i8* %call2, i8** @glbl + ret void +} +declare i8* @strdup(i8*) +declare void @foo2(i8*) + +define void @test3() uwtable { +; CHECK: @test3 +; CHECK-NOT: bb1: +; CHECK-NOT: bb2: +; CHECK: invoke + %ptr = invoke i8* @_Znwm(i64 1) + to label %bb1 unwind label %bb2 +bb1: + store i8* %ptr, i8** @glbl + unreachable +bb2: + %tmp1 = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gxx_personality_v0 + cleanup + resume { i8*, i32 } %tmp1 +} +declare i32 @__gxx_personality_v0(i32, i64, i8*, i8*) +declare i8* @_Znwm(i64) diff --git a/test/Transforms/GlobalOpt/constantexpr-dangle.ll b/test/Transforms/GlobalOpt/constantexpr-dangle.ll index 099c607..be13a98 100644 --- a/test/Transforms/GlobalOpt/constantexpr-dangle.ll +++ b/test/Transforms/GlobalOpt/constantexpr-dangle.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -instcombine -globalopt -S | \ -; RUN: grep {internal fastcc float @foo} +; RUN: grep "internal fastcc float @foo" define internal float @foo() { ret float 0.000000e+00 diff --git a/test/Transforms/GlobalOpt/deadglobal.ll b/test/Transforms/GlobalOpt/deadglobal.ll index c8d8e76..cad5a91 100644 --- a/test/Transforms/GlobalOpt/deadglobal.ll +++ b/test/Transforms/GlobalOpt/deadglobal.ll @@ -1,9 +1,25 @@ -; RUN: opt < %s -globalopt -S | not grep internal +; RUN: opt < %s -globalopt -S | FileCheck %s -@G = internal global i32 123 ; <i32*> [#uses=1] +@G1 = internal global i32 123 ; <i32*> [#uses=1] -define void @foo() { - store i32 1, i32* @G +; CHECK-NOT: @G1 +; CHECK: @G2 +; CHECK-NOT: @G3 + +define void @foo1() { +; CHECK: define void @foo +; CHECK-NEXT: ret + store i32 1, i32* @G1 + ret void +} + +@G2 = linkonce_odr constant i32 42 + +define void @foo2() { +; CHECK: define void @foo2 +; CHECK-NEXT: store + store i32 1, i32* @G2 ret void } +@G3 = linkonce_odr constant i32 42 diff --git a/test/Transforms/GlobalOpt/globalsra-unknown-index.ll b/test/Transforms/GlobalOpt/globalsra-unknown-index.ll index 1e0db6a..cc655e9 100644 --- a/test/Transforms/GlobalOpt/globalsra-unknown-index.ll +++ b/test/Transforms/GlobalOpt/globalsra-unknown-index.ll @@ -1,7 +1,7 @@ ; RUN: opt < %s -globalopt -S > %t -; RUN: grep {@Y = internal unnamed_addr global \\\[3 x \[%\]struct.X\\\] zeroinitializer} %t +; RUN: grep "@Y = internal unnamed_addr global \[3 x [%]struct.X\] zeroinitializer" %t ; RUN: grep load %t | count 6 -; RUN: grep {add i32 \[%\]a, \[%\]b} %t | count 3 +; RUN: grep "add i32 [%]a, [%]b" %t | count 3 ; globalopt should not sra the global, because it can't see the index. diff --git a/test/Transforms/GlobalOpt/heap-sra-phi.ll b/test/Transforms/GlobalOpt/heap-sra-phi.ll index 6188e5a..123ad85 100644 --- a/test/Transforms/GlobalOpt/heap-sra-phi.ll +++ b/test/Transforms/GlobalOpt/heap-sra-phi.ll @@ -1,5 +1,5 @@ -; RUN: opt < %s -globalopt -S | grep {tmp.f1 = phi i32. } -; RUN: opt < %s -globalopt -S | grep {tmp.f0 = phi i32. } +; RUN: opt < %s -globalopt -S | grep "tmp.f1 = phi i32. " +; RUN: opt < %s -globalopt -S | grep "tmp.f0 = phi i32. " 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" %struct.foo = type { i32, i32 } diff --git a/test/Transforms/GlobalOpt/integer-bool.ll b/test/Transforms/GlobalOpt/integer-bool.ll index 59403b1..5a34a9c 100644 --- a/test/Transforms/GlobalOpt/integer-bool.ll +++ b/test/Transforms/GlobalOpt/integer-bool.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -globalopt -instcombine | \ -; RUN: llvm-dis | grep {ret i1 true} +; RUN: llvm-dis | grep "ret i1 true" ;; check that global opt turns integers that only hold 0 or 1 into bools. diff --git a/test/Transforms/GlobalOpt/memcpy.ll b/test/Transforms/GlobalOpt/memcpy.ll index 94e07a0..dcfe009 100644 --- a/test/Transforms/GlobalOpt/memcpy.ll +++ b/test/Transforms/GlobalOpt/memcpy.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -globalopt -S | \ -; RUN: grep {G1 = internal unnamed_addr constant} +; RUN: grep "G1 = internal unnamed_addr constant" @G1 = internal global [58 x i8] c"asdlfkajsdlfkajsd;lfkajds;lfkjasd;flkajsd;lkfja;sdlkfjasd\00" ; <[58 x i8]*> [#uses=1] diff --git a/test/Transforms/GlobalOpt/storepointer-compare.ll b/test/Transforms/GlobalOpt/storepointer-compare.ll index 2f5ae86..09e20a8 100644 --- a/test/Transforms/GlobalOpt/storepointer-compare.ll +++ b/test/Transforms/GlobalOpt/storepointer-compare.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -globalopt -S | \ -; RUN: grep {call void @Actual} +; RUN: grep "call void @Actual" ; Check that a comparison does not prevent an indirect call from being made ; direct. The global will still remain, but indirect call elim is still good. diff --git a/test/Transforms/GlobalOpt/unnamed-addr.ll b/test/Transforms/GlobalOpt/unnamed-addr.ll index be02821..ee75058 100644 --- a/test/Transforms/GlobalOpt/unnamed-addr.ll +++ b/test/Transforms/GlobalOpt/unnamed-addr.ll @@ -4,17 +4,31 @@ @b = internal global i32 0, align 4 @c = internal global i32 0, align 4 @d = internal constant [4 x i8] c"foo\00", align 1 +@e = linkonce_odr global i32 0 ; CHECK: @a = internal global i32 0, align 4 ; CHECK: @b = internal global i32 0, align 4 ; CHECK: @c = internal unnamed_addr global i32 0, align 4 ; CHECK: @d = internal unnamed_addr constant [4 x i8] c"foo\00", align 1 +; CHECK: @e = linkonce_odr global i32 0 + +define i32 @get_e() { + %t = load i32* @e + ret i32 %t +} + +define void @set_e(i32 %x) { + store i32 %x, i32* @e + ret void +} define i1 @bah(i64 %i) nounwind readonly optsize ssp { entry: %arrayidx4 = getelementptr inbounds [4 x i8]* @d, i64 0, i64 %i %tmp5 = load i8* %arrayidx4, align 1 - %cmp = icmp eq i8 %tmp5, 42 + %array0 = bitcast [4 x i8]* @d to i8* + %tmp6 = load i8* %array0, align 1 + %cmp = icmp eq i8 %tmp5, %tmp6 ret i1 %cmp } |