[cfe-commits] r85852 - /cfe/trunk/lib/CodeGen/CGCXX.cpp
Mike Stump
mrs at apple.com
Mon Nov 2 18:12:59 PST 2009
Author: mrs
Date: Mon Nov 2 20:12:59 2009
New Revision: 85852
URL: http://llvm.org/viewvc/llvm-project?rev=85852&view=rev
Log:
Add virtual adjustments for this for thunks.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=85852&r1=85851&r2=85852&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Mon Nov 2 20:12:59 2009
@@ -737,9 +737,38 @@
StartFunction(FD, ResultType, Fn, Args, SourceLocation());
// generate body
- llvm::Value *Callee = CGM.GetAddrOfFunction(MD);
+ const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
+ const llvm::Type *Ty =
+ CGM.getTypes().GetFunctionType(CGM.getTypes().getFunctionInfo(MD),
+ FPT->isVariadic());
+ llvm::Value *Callee = CGM.GetAddrOfFunction(MD, Ty);
CallArgList CallArgs;
+ QualType ArgType = MD->getThisType(getContext());
+ llvm::Value *Arg = Builder.CreateLoad(LocalDeclMap[ThisDecl], "this");
+ if (v_t) {
+ const llvm::Type *OrigTy = Arg->getType();
+ // FIXME: Add this adjustments
+ const llvm::Type *PtrDiffTy =
+ ConvertType(getContext().getPointerDiffType());
+ llvm::Type *Ptr8Ty, *PtrPtr8Ty, *PtrPtrDiffTy;
+ Ptr8Ty = llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
+ PtrPtr8Ty = llvm::PointerType::get(Ptr8Ty, 0);
+ PtrPtrDiffTy = llvm::PointerType::get(PtrDiffTy, 0);
+ llvm::Value *ThisVal = Builder.CreateBitCast(Arg, Ptr8Ty);
+ Arg = Builder.CreateBitCast(Arg, PtrPtrDiffTy->getPointerTo());
+ Arg = Builder.CreateLoad(Arg, "vtable");
+ llvm::Value *VTablePtr = Arg;
+ assert(v_t % (LLVMPointerWidth/8) == 0 && "vtable entry unaligned");
+ v_t /= LLVMPointerWidth/8;
+ Arg = Builder.CreateConstInBoundsGEP1_64(VTablePtr, v_t);
+ Arg = Builder.CreateLoad(Arg);
+ Arg = Builder.CreateGEP(ThisVal, Arg);
+ Arg = Builder.CreateBitCast(Arg, OrigTy);
+ }
+ // FIXME: Add this non-virtual adjustment
+ CallArgs.push_back(std::make_pair(RValue::get(Arg), ArgType));
+
for (FunctionDecl::param_const_iterator i = MD->param_begin(),
e = MD->param_end();
i != e; ++i) {
@@ -748,7 +777,6 @@
// llvm::Value *Arg = CGF.GetAddrOfLocalVar(Dst);
Expr *Arg = new (getContext()) DeclRefExpr(D, ArgType, SourceLocation());
- // FIXME: Add this adjustments
CallArgs.push_back(std::make_pair(EmitCallArg(Arg, ArgType), ArgType));
}
More information about the cfe-commits
mailing list