diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-01-19 16:32:21 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-01-19 16:32:21 +0000 |
commit | c4440e3e307fb696146c08c127c53300a982fe82 (patch) | |
tree | 98655770283e3e6cdb07b1892b925d7db9fffbbc /test | |
parent | 348c975cb89c0f92e2114d021388334c711292b5 (diff) | |
download | external_llvm-c4440e3e307fb696146c08c127c53300a982fe82.zip external_llvm-c4440e3e307fb696146c08c127c53300a982fe82.tar.gz external_llvm-c4440e3e307fb696146c08c127c53300a982fe82.tar.bz2 |
Add unnamed_addr when we can show that address of a global is not used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
6 files changed, 61 insertions, 7 deletions
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 cfc9f30..5b06fea 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 global .*align 16} -; RUN: opt < %s -globalopt -S | grep {@G.1 = internal global .*align 8} -; RUN: opt < %s -globalopt -S | grep {@G.2 = internal 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-03-07-PromotePtrToBool.ll b/test/Transforms/GlobalOpt/2009-03-07-PromotePtrToBool.ll index e024fc2..d645ce4 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 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-MallocSingleStoreToGlobalVar.ll b/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll index c43565a..b73f62b 100644 --- a/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll +++ b/test/Transforms/GlobalOpt/2009-11-16-MallocSingleStoreToGlobalVar.ll @@ -8,7 +8,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3 target triple = "x86_64-apple-darwin10.0" @TOP = internal global i64* null ; <i64**> [#uses=2] -; CHECK: @TOP = internal global i64* null +; CHECK: @TOP = internal unnamed_addr global i64* null @channelColumns = internal global i64 0 ; <i64*> [#uses=2] ; Derived from @DescribeChannel() in yacr2 diff --git a/test/Transforms/GlobalOpt/globalsra-unknown-index.ll b/test/Transforms/GlobalOpt/globalsra-unknown-index.ll index 9397a12..1e0db6a 100644 --- a/test/Transforms/GlobalOpt/globalsra-unknown-index.ll +++ b/test/Transforms/GlobalOpt/globalsra-unknown-index.ll @@ -1,5 +1,5 @@ ; RUN: opt < %s -globalopt -S > %t -; RUN: grep {@Y = internal 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 diff --git a/test/Transforms/GlobalOpt/memcpy.ll b/test/Transforms/GlobalOpt/memcpy.ll index 335f5ec..8f063a2 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 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/unnamed-addr.ll b/test/Transforms/GlobalOpt/unnamed-addr.ll new file mode 100644 index 0000000..be02821 --- /dev/null +++ b/test/Transforms/GlobalOpt/unnamed-addr.ll @@ -0,0 +1,54 @@ +; RUN: opt %s -globalopt -S | FileCheck %s + +@a = internal global i32 0, align 4 +@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 + +; 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 + +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 + ret i1 %cmp +} + +define void @baz(i32 %x) { +entry: + store i32 %x, i32* @a, align 4 + store i32 %x, i32* @b, align 4 + store i32 %x, i32* @c, align 4 + ret void +} + +define i32 @foo(i32* %x) nounwind readnone optsize ssp { +entry: + %cmp = icmp eq i32* %x, @a + %conv = zext i1 %cmp to i32 + ret i32 %conv +} + +define i32 @bar() { +entry: + switch i64 ptrtoint (i32* @b to i64), label %sw.epilog [ + i64 1, label %return + i64 0, label %return + ] + +sw.epilog: + ret i32 0 + +return: + ret i32 1 +} + +define i32 @zed() { +entry: + %tmp1 = load i32* @c, align 4 + ret i32 %tmp1 +} |