diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2013-06-11 01:08:22 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2013-06-11 01:08:22 +0000 |
| commit | d39083deac93d6580a42ccd5d213aba2bb89cc76 (patch) | |
| tree | b0a0d1c7c4fcd7cdc650b1b974cfba336aa974c4 /lib/CodeGen/CGCall.cpp | |
| parent | 1f01f7c160c06f8290b4f1c203e36b242074c6b1 (diff) | |
| download | clang-d39083deac93d6580a42ccd5d213aba2bb89cc76.tar.gz clang-d39083deac93d6580a42ccd5d213aba2bb89cc76.tar.bz2 clang-d39083deac93d6580a42ccd5d213aba2bb89cc76.tar.xz | |
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>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183718 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCall.cpp')
| -rw-r--r-- | lib/CodeGen/CGCall.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index a53283eb14..77a43a2fc4 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/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; } |
