summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2013-06-11 01:08:22 +0000
committerEli Friedman <eli.friedman@gmail.com>2013-06-11 01:08:22 +0000
commit61f615af81993a3d63a9d09adacb00cc84a02888 (patch)
tree8999f1c83944c3d99aa28f71ec4b7d182d7434e1 /clang
parentf0168de936ec39f043a801f474fd063e533827ed (diff)
downloadbcm5719-llvm-61f615af81993a3d63a9d09adacb00cc84a02888.tar.gz
bcm5719-llvm-61f615af81993a3d63a9d09adacb00cc84a02888.zip
Fix a FIXME in a testcase about packed structs and calls I left around
while fixing a related bug. The fix here was simpler than I thought it would be. Fixes <rdar://problem/10530444>. llvm-svn: 183718
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp11
-rw-r--r--clang/test/CodeGen/packed-nest-unpacked.c2
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a53283eb143..77a43a2fc4a 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2022,7 +2022,16 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
cast<CastExpr>(E)->getCastKind() == CK_LValueToRValue) {
LValue L = EmitLValue(cast<CastExpr>(E)->getSubExpr());
assert(L.isSimple());
- args.add(L.asAggregateRValue(), type, /*NeedsCopy*/true);
+ if (L.getAlignment() >= getContext().getTypeAlignInChars(type)) {
+ args.add(L.asAggregateRValue(), type, /*NeedsCopy*/true);
+ } else {
+ // We can't represent a misaligned lvalue in the CallArgList, so copy
+ // to an aligned temporary now.
+ llvm::Value *tmp = CreateMemTemp(type);
+ EmitAggregateCopy(tmp, L.getAddress(), type, L.isVolatile(),
+ L.getAlignment());
+ args.add(RValue::getAggregate(tmp), type);
+ }
return;
}
diff --git a/clang/test/CodeGen/packed-nest-unpacked.c b/clang/test/CodeGen/packed-nest-unpacked.c
index 7f486c99987..393174196f4 100644
--- a/clang/test/CodeGen/packed-nest-unpacked.c
+++ b/clang/test/CodeGen/packed-nest-unpacked.c
@@ -28,7 +28,7 @@ void test3(struct X a) {
// <rdar://problem/10530444>
void test4() {
// CHECK: @test4
- // FIXME: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false)
f(g.y);
}
OpenPOWER on IntegriCloud