aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-10-03 14:56:57 +0000
committerAnders Carlsson <andersca@mac.com>2009-10-03 14:56:57 +0000
commit2b3583573ba6b26b605aacaad9a50492fb3d6fe6 (patch)
tree3c646b8e2903a50ce22032e9b5e76171056b8928 /lib/CodeGen/CGCXX.cpp
parentee383163a656a7e8d99efa4e5ee98c705c7fdf89 (diff)
Move some functions from CodeGenFunctions to CodeGenModule so they can be used by CGExprConstant.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83263 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r--lib/CodeGen/CGCXX.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index bf9af9c64d..1ea60eff56 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -1206,23 +1206,27 @@ CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *&This,
const llvm::Type *Ty) {
// FIXME: If we know the dynamic type, we don't have to do a virtual dispatch.
- // FIXME: move to Context
- if (vtableinfo == 0)
- vtableinfo = new VtableInfo(CGM);
-
- VtableInfo::Index_t Idx = vtableinfo->lookup(MD);
-
+ uint64_t Index = CGM.GetVtableIndex(MD);
+
Ty = llvm::PointerType::get(Ty, 0);
Ty = llvm::PointerType::get(Ty, 0);
Ty = llvm::PointerType::get(Ty, 0);
llvm::Value *vtbl = Builder.CreateBitCast(This, Ty);
vtbl = Builder.CreateLoad(vtbl);
llvm::Value *vfn = Builder.CreateConstInBoundsGEP1_64(vtbl,
- Idx, "vfn");
+ Index, "vfn");
vfn = Builder.CreateLoad(vfn);
return vfn;
}
+uint64_t CodeGenModule::GetVtableIndex(const CXXMethodDecl *MD) {
+ // FIXME: move to CodeGenModule.
+ if (vtableinfo == 0)
+ vtableinfo = new VtableInfo(*this);
+
+ return vtableinfo->lookup(MD);
+}
+
/// EmitClassAggrMemberwiseCopy - This routine generates code to copy a class
/// array of objects from SrcValue to DestValue. Copying can be either a bitwise
/// copy or via a copy constructor call.
@@ -1241,7 +1245,7 @@ void CodeGenFunction::EmitClassAggrMemberwiseCopy(llvm::Value *Dest,
"loop.index");
llvm::Value* zeroConstant =
llvm::Constant::getNullValue(llvm::Type::getInt64Ty(VMContext));
- Builder.CreateStore(zeroConstant, IndexPtr, false);
+ Builder.CreateStore(zeroConstant, IndexPtr, false);
// Start the loop with a block that tests the condition.
llvm::BasicBlock *CondBlock = createBasicBlock("for.cond");
llvm::BasicBlock *AfterFor = createBasicBlock("for.end");