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
This commit is contained in:
Eli Friedman 2013-06-11 01:08:22 +00:00
parent f0168de936
commit 61f615af81
2 changed files with 11 additions and 2 deletions

View File

@ -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;
}

View File

@ -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);
}