[cfe-commits] r132223 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CodeGen/string-literal.c

Eli Friedman eli.friedman at gmail.com
Fri May 27 15:13:20 PDT 2011


Author: efriedma
Date: Fri May 27 17:13:20 2011
New Revision: 132223

URL: http://llvm.org/viewvc/llvm-project?rev=132223&view=rev
Log:
Match llvm-gcc's string literals alignment by forcing alignment on string literals to 1.  This can significantly impact the size of the string data, and as far as I know, the alignment doesn't help performance.  rdar://9078969 .


Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/test/CodeGen/string-literal.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=132223&r1=132222&r2=132223&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri May 27 17:13:20 2011
@@ -1899,6 +1899,7 @@
     new llvm::GlobalVariable(CGM.getModule(), C->getType(), constant,
                              llvm::GlobalValue::PrivateLinkage,
                              C, GlobalName);
+  GV->setAlignment(1);
   GV->setUnnamedAddr(true);
   return GV;
 }

Modified: cfe/trunk/test/CodeGen/string-literal.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/string-literal.c?rev=132223&r1=132222&r2=132223&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/string-literal.c (original)
+++ cfe/trunk/test/CodeGen/string-literal.c Fri May 27 17:13:20 2011
@@ -8,9 +8,9 @@
   // CHECK: internal 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"
+  // CHECK: private unnamed_addr constant [12 x i8] c"A\00\00\00B\00\00\00\00\00\00\00", align 1
   void *foo = L"AB";
 
-  // CHECK: private unnamed_addr constant [12 x i8] c"4\12\00\00\0B\F0\10\00\00\00\00\00"
+  // CHECK: private unnamed_addr constant [12 x i8] c"4\12\00\00\0B\F0\10\00\00\00\00\00", align 1
   void *bar = L"\u1234\U0010F00B";
 }





More information about the cfe-commits mailing list