[cfe-commits] r143658 - in /cfe/trunk: lib/CodeGen/CGCall.cpp test/CodeGen/align-param.c
Eli Friedman
eli.friedman at gmail.com
Thu Nov 3 14:39:02 PDT 2011
Author: efriedma
Date: Thu Nov 3 16:39:02 2011
New Revision: 143658
URL: http://llvm.org/viewvc/llvm-project?rev=143658&view=rev
Log:
Fix alignment on alloca's for parameters using ABIArgInfo::Expand.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/align-param.c
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=143658&r1=143657&r2=143658&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Nov 3 16:39:02 2011
@@ -1058,10 +1058,11 @@
// If this structure was expanded into multiple arguments then
// we need to create a temporary and reconstruct it from the
// arguments.
- llvm::Value *Temp = CreateMemTemp(Ty, Arg->getName() + ".addr");
- llvm::Function::arg_iterator End =
- ExpandTypeFromArgs(Ty, MakeAddrLValue(Temp, Ty), AI);
- EmitParmDecl(*Arg, Temp, ArgNo);
+ llvm::AllocaInst *Alloca = CreateMemTemp(Ty);
+ Alloca->setAlignment(getContext().getDeclAlign(Arg).getQuantity());
+ LValue LV = MakeAddrLValue(Alloca, Ty, Alloca->getAlignment());
+ llvm::Function::arg_iterator End = ExpandTypeFromArgs(Ty, LV, AI);
+ EmitParmDecl(*Arg, Alloca, ArgNo);
// Name the arguments used in expansion and increment AI.
unsigned Index = 0;
Modified: cfe/trunk/test/CodeGen/align-param.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/align-param.c?rev=143658&r1=143657&r2=143658&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/align-param.c (original)
+++ cfe/trunk/test/CodeGen/align-param.c Thu Nov 3 16:39:02 2011
@@ -7,3 +7,12 @@
}
// CHECK: define i32 @test
// CHECK: alloca i64, align 8
+
+
+// Make sure we honor the aligned attribute.
+struct X { int x,y,z,a; };
+int test2(struct X x __attribute((aligned(16)))) {
+ return x.z;
+}
+// CHECK: define i32 @test2
+// CHECK: alloca %struct.X, align 16
More information about the cfe-commits
mailing list