aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGVTables.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-05-21 17:55:12 +0000
committerDouglas Gregor <dgregor@apple.com>2010-05-21 17:55:12 +0000
commit663218b576d8d79dea546c5726d7c90c216b1358 (patch)
treea657d68dbb932f265df66f6b213ba39e73457c68 /lib/CodeGen/CGVTables.cpp
parentb4eae116b036bd34a1d1dffc9b76ddcad72825ee (diff)
When generating the call arguments in a thunk to call the thunkee, do
not make copies non-POD arguments or arguments passed by reference: just copy the pointers directly. This eliminates another source of the dreaded memcpy-of-non-PODs. Fixes PR7188. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGVTables.cpp')
-rw-r--r--lib/CodeGen/CGVTables.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp
index 3c9b45ba8c..b66b9f8493 100644
--- a/lib/CodeGen/CGVTables.cpp
+++ b/lib/CodeGen/CGVTables.cpp
@@ -2642,9 +2642,15 @@ void CodeGenFunction::GenerateThunk(llvm::Function *Fn, GlobalDecl GD,
ParmVarDecl *Param = *I;
QualType ArgType = Param->getType();
- // FIXME: Declaring a DeclRefExpr on the stack is kinda icky.
- DeclRefExpr ArgExpr(Param, ArgType.getNonReferenceType(), SourceLocation());
- CallArgs.push_back(std::make_pair(EmitCallArg(&ArgExpr, ArgType), ArgType));
+ // Load the argument corresponding to this parameter.
+ RValue Arg;
+ if (ArgType->isReferenceType() ||
+ (hasAggregateLLVMType(ArgType) && !ArgType->isAnyComplexType()))
+ Arg = RValue::get(Builder.CreateLoad(LocalDeclMap[Param]));
+ else
+ Arg = RValue::get(EmitLoadOfScalar(LocalDeclMap[Param], false, ArgType));
+
+ CallArgs.push_back(std::make_pair(Arg, ArgType));
}
// Get our callee.