[llvm-commits] [dragonegg] r165127 - in /dragonegg/trunk: src/Convert.cpp test/validator/c++/CallReturnAlignment.cpp
Duncan Sands
baldrick at free.fr
Wed Oct 3 09:25:57 PDT 2012
Author: baldrick
Date: Wed Oct 3 11:25:57 2012
New Revision: 165127
URL: http://llvm.org/viewvc/llvm-project?rev=165127&view=rev
Log:
Compute alignment correctly when extracting part of a struct returned by a
function call.
Added:
dragonegg/trunk/test/validator/c++/CallReturnAlignment.cpp
Modified:
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=165127&r1=165126&r2=165127&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed Oct 3 11:25:57 2012
@@ -3464,6 +3464,7 @@
// pointer and storing into it. The store does not necessarily start at the
// beginning of the aggregate (x86-64).
Value *Ptr = DestLoc->Ptr;
+ unsigned Align = DestLoc->getAlignment();
// AggTy - The type of the aggregate being stored to.
Type *AggTy = cast<PointerType>(Ptr->getType())->getElementType();
// MaxStoreSize - The maximum number of bytes we can store without overflowing
@@ -3474,6 +3475,7 @@
Ptr = Builder.CreateGEP(Ptr,
ConstantInt::get(TD.getIntPtrType(Context), Client.Offset),
flag_verbose_asm ? "ro" : "");
+ Align = MinAlign(Align, Client.Offset);
MaxStoreSize -= Client.Offset;
}
assert(MaxStoreSize > 0 && "Storing off end of aggregate?");
@@ -3494,8 +3496,7 @@
// Store the integer rather than the call result to the aggregate.
}
Ptr = Builder.CreateBitCast(Ptr, PointerType::getUnqual(Val->getType()));
- Builder.CreateAlignedStore(Val, Ptr, DestLoc->getAlignment(),
- DestLoc->Volatile);
+ Builder.CreateAlignedStore(Val, Ptr, Align, DestLoc->Volatile);
return 0;
}
Added: dragonegg/trunk/test/validator/c++/CallReturnAlignment.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/c%2B%2B/CallReturnAlignment.cpp?rev=165127&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/c++/CallReturnAlignment.cpp (added)
+++ dragonegg/trunk/test/validator/c++/CallReturnAlignment.cpp Wed Oct 3 11:25:57 2012
@@ -0,0 +1,18 @@
+// RUN: %dragonegg %s -O2 -march=native -fplugin-arg-dragonegg-llvm-ir-optimize=0 -S -o - | FileCheck %s
+
+struct base {};
+
+struct child1 : base {
+ void* P;
+};
+
+class child2 : base {
+ child1 C;
+};
+
+child2 bar();
+bool foo() {
+// CHECK: foo
+ child2 D = bar();
+// CHECK-NOT: store {{.*}}, align 16
+}
More information about the llvm-commits
mailing list