[cfe-commits] r143645 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp test/CodeGen/align-param.c

Eli Friedman eli.friedman at gmail.com
Thu Nov 3 13:31:28 PDT 2011


Author: efriedma
Date: Thu Nov  3 15:31:28 2011
New Revision: 143645

URL: http://llvm.org/viewvc/llvm-project?rev=143645&view=rev
Log:
Fix the alignment on scalar parameter variables so that it matches what the AST thinks it should be.  Per report on cfe-dev.


Added:
    cfe/trunk/test/CodeGen/align-param.c
Modified:
    cfe/trunk/lib/CodeGen/CGDecl.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=143645&r1=143644&r2=143645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Thu Nov  3 15:31:28 2011
@@ -1442,7 +1442,10 @@
     DeclPtr = Arg;
   } else {
     // Otherwise, create a temporary to hold the value.
-    DeclPtr = CreateMemTemp(Ty, D.getName() + ".addr");
+    llvm::AllocaInst *Alloc = CreateTempAlloca(ConvertTypeForMem(Ty),
+                                               D.getName() + ".addr");
+    Alloc->setAlignment(getContext().getDeclAlign(&D).getQuantity());
+    DeclPtr = Alloc;
 
     bool doStore = true;
 

Added: cfe/trunk/test/CodeGen/align-param.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/align-param.c?rev=143645&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/align-param.c (added)
+++ cfe/trunk/test/CodeGen/align-param.c Thu Nov  3 15:31:28 2011
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-apple-macosx10.7.2 < %s | FileCheck %s
+
+// The preferred alignment for a long long on x86-32 is 8; make sure the
+// alloca for x uses that alignment.
+int test (long long x) {
+  return (int)x;
+}
+// CHECK: define i32 @test
+// CHECK: alloca i64, align 8





More information about the cfe-commits mailing list