]> granicus.if.org Git - clang/commitdiff
Match llvm-gcc's string literals alignment by forcing alignment on string literals...
authorEli Friedman <eli.friedman@gmail.com>
Fri, 27 May 2011 22:13:20 +0000 (22:13 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 27 May 2011 22:13:20 +0000 (22:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132223 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenModule.cpp
test/CodeGen/string-literal.c

index 987ebffd97dcfb7ce16834a41c73be318aed7e61..de11a29f67b7024837adfe346964b2e4bb8bcf5a 100644 (file)
@@ -1899,6 +1899,7 @@ static llvm::Constant *GenerateStringLiteral(llvm::StringRef str,
     new llvm::GlobalVariable(CGM.getModule(), C->getType(), constant,
                              llvm::GlobalValue::PrivateLinkage,
                              C, GlobalName);
+  GV->setAlignment(1);
   GV->setUnnamedAddr(true);
   return GV;
 }
index 6d02b0fdaf95943e76f0ed74baf2633dc6d3d0c9..b5fa345bada973e386ad8418f7e7b907772f6247 100644 (file)
@@ -8,9 +8,9 @@ int main() {
   // 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";
 }