diff options
author | Mike Stump <mrs@apple.com> | 2009-11-04 00:53:51 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-11-04 00:53:51 +0000 |
commit | d0fe5366d4040545d5f72c547ae54e2c21e4cb68 (patch) | |
tree | f87df83d0d7fe12ed41258c1f5dcd195e4112ec5 /lib/CodeGen/CGCXX.cpp | |
parent | 082fb9ae304a25aa6be1f74d9b9720c52a96231e (diff) |
Split out return adjustments in thunks from this adjustment in thunks
so the optimizer can tailcall into the return value adjustment thunk.
This improves codesize for complex hierarchies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85988 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r-- | lib/CodeGen/CGCXX.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index e22670c37b..6dbc53d764 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -779,9 +779,17 @@ llvm::Constant *CodeGenFunction::GenerateCovariantThunk(llvm::Function *Fn, QualType ArgType = MD->getThisType(getContext()); llvm::Value *Arg = Builder.CreateLoad(LocalDeclMap[ThisDecl], "this"); - if (nv_t || v_t) + if (nv_t || v_t) { // Do the this adjustment. + const llvm::Type *OrigTy = Callee->getType(); Arg = DynamicTypeAdjust(Arg, nv_t, v_t); + if (nv_r || v_r) { + Callee = CGM.BuildCovariantThunk(MD, Extern, 0, 0, nv_r, v_r); + Callee = Builder.CreateBitCast(Callee, OrigTy); + nv_r = v_r = 0; + } + } + CallArgs.push_back(std::make_pair(RValue::get(Arg), ArgType)); for (FunctionDecl::param_const_iterator i = MD->param_begin(), @@ -795,7 +803,6 @@ llvm::Constant *CodeGenFunction::GenerateCovariantThunk(llvm::Function *Fn, CallArgs.push_back(std::make_pair(EmitCallArg(Arg, ArgType), ArgType)); } - // FIXME: be sure to call the right function when we thunk to a thunk RValue RV = EmitCall(CGM.getTypes().getFunctionInfo(ResultType, CallArgs), Callee, CallArgs, MD); if (nv_r || v_r) { |