diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2011-05-26 00:10:27 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2011-05-26 00:10:27 +0000 |
| commit | df96819daf5555cc4e3ecef96d09b0397da8ccae (patch) | |
| tree | 5ea50f0cb8bd965287f30f7d31b8b5954a870a18 /clang/lib/CodeGen/CGCall.cpp | |
| parent | 25d5745cc5db8ce0da4ed5e3b20587800ae15b65 (diff) | |
| download | bcm5719-llvm-df96819daf5555cc4e3ecef96d09b0397da8ccae.tar.gz bcm5719-llvm-df96819daf5555cc4e3ecef96d09b0397da8ccae.zip | |
Skip extra copy from aggregate where it isn't necessary; rdar://problem/8139919 . This shouldn't make much of a difference at -O3, but should substantially reduce the number of generated memcpy's at -O0.
Originally r130717, but was backed out due to an ObjC regression.
llvm-svn: 132102
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 4c9f3d467a1..712ae89a488 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1189,6 +1189,15 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, return args.add(EmitReferenceBindingToExpr(E, /*InitializedDecl=*/0), type); + if (hasAggregateLLVMType(type) && isa<ImplicitCastExpr>(E) && + cast<CastExpr>(E)->getCastKind() == CK_LValueToRValue) { + LValue L = EmitLValue(cast<CastExpr>(E)->getSubExpr()); + assert(L.isSimple()); + args.add(RValue::getAggregate(L.getAddress(), L.isVolatileQualified()), + type, /*NeedsCopy*/true); + return; + } + args.add(EmitAnyExprToTemp(E), type); } @@ -1254,6 +1263,10 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, Alignment, I->Ty); else StoreComplexToAddr(RV.getComplexVal(), Args.back(), false); + } else if (I->NeedsCopy && !ArgInfo.getIndirectByVal()) { + Args.push_back(CreateMemTemp(I->Ty)); + EmitAggregateCopy(Args.back(), RV.getAggregateAddr(), I->Ty, + RV.isVolatileQualified()); } else { Args.push_back(RV.getAggregateAddr()); } |

