[cfe-commits] r132226 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGen/decl.c test/CodeGen/string-literal-short-wstring.c test/CodeGen/string-literal.c

Eli Friedman eli.friedman at gmail.com
Fri May 27 15:32:55 PDT 2011


Author: efriedma
Date: Fri May 27 17:32:55 2011
New Revision: 132226

URL: http://llvm.org/viewvc/llvm-project?rev=132226&view=rev
Log:
Add unnamed_addr to internal globals which are only used as an operand to memcpy. (Spotted by looking at IR.)


Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp
    cfe/trunk/test/CodeGen/decl.c
    cfe/trunk/test/CodeGen/string-literal-short-wstring.c
    cfe/trunk/test/CodeGen/string-literal.c

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=132226&r1=132225&r2=132226&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri May 27 17:32:55 2011
@@ -742,6 +742,7 @@
                                llvm::GlobalValue::InternalLinkage,
                                constant, Name, 0, false, 0);
     GV->setAlignment(alignment.getQuantity());
+    GV->setUnnamedAddr(true);
         
     llvm::Value *SrcPtr = GV;
     if (SrcPtr->getType() != BP)

Modified: cfe/trunk/test/CodeGen/decl.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/decl.c?rev=132226&r1=132225&r2=132226&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/decl.c (original)
+++ cfe/trunk/test/CodeGen/decl.c Fri May 27 17:32:55 2011
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 -w -emit-llvm < %s | FileCheck %s
 
 // CHECK: @test1.x = internal constant [12 x i32] [i32 1
-// CHECK: @test2.x = internal constant [13 x i32] [i32 1,
+// CHECK: @test2.x = internal unnamed_addr constant [13 x i32] [i32 1,
 // CHECK: @test5w = global %0 { i32 2, [4 x i8] undef }
 // CHECK: @test5y = global %union.test5u { double 7.300000e+0{{[0]*}}1 }
 
-// CHECK: @test6.x = internal constant %struct.SelectDest { i8 1, i8 2, i32 3, i32 0 }
+// CHECK: @test6.x = internal unnamed_addr constant %struct.SelectDest { i8 1, i8 2, i32 3, i32 0 }
 
 // CHECK: @test7 = global [2 x %struct.test7s] [%struct.test7s { i32 1, i32 2 }, %struct.test7s { i32 4, i32 0 }]
 

Modified: cfe/trunk/test/CodeGen/string-literal-short-wstring.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/string-literal-short-wstring.c?rev=132226&r1=132225&r2=132226&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/string-literal-short-wstring.c (original)
+++ cfe/trunk/test/CodeGen/string-literal-short-wstring.c Fri May 27 17:32:55 2011
@@ -3,7 +3,7 @@
 
 int main() {
   // This should convert to utf8.
-  // CHECK: internal constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
+  // CHECK: internal unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
   char b[10] = "\u1120\u0220\U00102030";
 
   // CHECK: private unnamed_addr constant [6 x i8] c"A\00B\00\00\00"

Modified: cfe/trunk/test/CodeGen/string-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/string-literal.c?rev=132226&r1=132225&r2=132226&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/string-literal.c (original)
+++ cfe/trunk/test/CodeGen/string-literal.c Fri May 27 17:32:55 2011
@@ -1,11 +1,11 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 
 int main() {
-  // CHECK: internal constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
+  // CHECK: internal unnamed_addr constant [10 x i8] c"abc\00\00\00\00\00\00\00", align 1
   char a[10] = "abc";
 
   // This should convert to utf8.
-  // CHECK: internal constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
+  // CHECK: internal unnamed_addr constant [10 x i8] c"\E1\84\A0\C8\A0\F4\82\80\B0\00", align 1
   char b[10] = "\u1120\u0220\U00102030";
 
   // CHECK: private unnamed_addr constant [12 x i8] c"A\00\00\00B\00\00\00\00\00\00\00", align 1





More information about the cfe-commits mailing list