diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-21 17:55:12 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-21 17:55:12 +0000 |
commit | c5871f07f0f9eda682beb425b3e509b311ef1856 (patch) | |
tree | 10b8993169de7e7610a6f65fa570959b1e1a9c15 /clang/lib/CodeGen | |
parent | fb41aaefeb6f744f77bfd0d17790246577b51f9f (diff) | |
download | bcm5719-llvm-c5871f07f0f9eda682beb425b3e509b311ef1856.tar.gz bcm5719-llvm-c5871f07f0f9eda682beb425b3e509b311ef1856.zip |
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.
llvm-svn: 104327
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGVTables.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 3c9b45ba8c1..b66b9f84933 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/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. |