aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/CGVTables.cpp12
-rw-r--r--test/CodeGenCXX/thunks.cpp45
2 files changed, 54 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.
diff --git a/test/CodeGenCXX/thunks.cpp b/test/CodeGenCXX/thunks.cpp
index 8144770763..b6e18e6e01 100644
--- a/test/CodeGenCXX/thunks.cpp
+++ b/test/CodeGenCXX/thunks.cpp
@@ -173,6 +173,51 @@ namespace Test6 {
X Thunks::f() { return X(); }
}
+namespace Test7 {
+ // PR7188
+ struct X {
+ X();
+ X(const X&);
+ X &operator=(const X&);
+ ~X();
+ };
+
+ struct Small { short s; };
+ struct Large {
+ char array[1024];
+ };
+
+ class A {
+ protected:
+ virtual void foo() = 0;
+ };
+
+ class B : public A {
+ protected:
+ virtual void bar() = 0;
+ };
+
+ class C : public A {
+ protected:
+ virtual void baz(X, X&, _Complex float, Small, Small&, Large) = 0;
+ };
+
+ class D : public B,
+ public C {
+
+ void foo() {}
+ void bar() {}
+ void baz(X, X&, _Complex float, Small, Small&, Large);
+ };
+
+ void D::baz(X, X&, _Complex float, Small, Small&, Large) { }
+
+ // CHECK: define void @_ZThn8_N5Test71D3bazENS_1XERS1_CfNS_5SmallERS4_NS_5LargeE(
+ // CHECK-NOT: memcpy
+ // CHECK: ret void
+ void testD() { D d; }
+}
+
// This is from Test5:
// CHECK: define linkonce_odr void @_ZTv0_n24_N5Test51B1fEv
// CHECK: define internal void @_ZThn8_N12_GLOBAL__N_11C1fEv(