[cfe-commits] r86650 - in /cfe/trunk/lib/CodeGen: CGVtable.cpp CodeGenFunction.h
Mike Stump
mrs at apple.com
Mon Nov 9 18:30:51 PST 2009
Author: mrs
Date: Mon Nov 9 20:30:51 2009
New Revision: 86650
URL: http://llvm.org/viewvc/llvm-project?rev=86650&view=rev
Log:
Be sure to clear out VCall when we clear out VCalls.
Start implementing VTTs. WIP.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=86650&r1=86649&r2=86650&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Mon Nov 9 20:30:51 2009
@@ -433,6 +433,7 @@
i != e; ++i)
methods[InsertionPoint++] = wrap((0?600:0) + *i);
VCalls.clear();
+ VCall.clear();
}
Index_t end(const CXXRecordDecl *RD, const ASTRecordLayout &Layout,
@@ -700,6 +701,8 @@
// then the vtables for all the virtual bases.
b.GenerateVtableForVBases(RD);
+ //GenerateVTT(RD);
+
llvm::Constant *C;
llvm::ArrayType *type = llvm::ArrayType::get(Ptr8Ty, methods.size());
C = llvm::ConstantArray::get(type, methods);
@@ -711,3 +714,39 @@
AddressPoint*LLVMPointerWidth/8));
return vtable;
}
+
+class VTTBuilder {
+ /// Inits - The list of values built for the VTT.
+ std::vector<llvm::Constant *> &Inits;
+ /// Class - The most derived class that this vtable is being built for.
+ const CXXRecordDecl *Class;
+ CodeGenModule &CGM; // Per-module state.
+
+public:
+ VTTBuilder(std::vector<llvm::Constant *> &inits, const CXXRecordDecl *c,
+ CodeGenModule &cgm) : Inits(inits), Class(c), CGM(cgm) {
+ }
+};
+
+llvm::Value *CodeGenFunction::GenerateVTT(const CXXRecordDecl *RD) {
+ llvm::SmallString<256> OutName;
+ llvm::raw_svector_ostream Out(OutName);
+ mangleCXXVTT(CGM.getMangleContext(), RD, Out);
+
+ llvm::GlobalVariable::LinkageTypes linktype;
+ linktype = llvm::GlobalValue::LinkOnceODRLinkage;
+ std::vector<llvm::Constant *> inits;
+ llvm::Type *Ptr8Ty=llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext),0);
+
+ VTTBuilder b(inits, RD, CGM);
+
+ D1(printf("vtt %s\n", RD->getNameAsCString()));
+
+ llvm::Constant *C;
+ llvm::ArrayType *type = llvm::ArrayType::get(Ptr8Ty, inits.size());
+ C = llvm::ConstantArray::get(type, inits);
+ llvm::Value *vtt = new llvm::GlobalVariable(CGM.getModule(), type, true,
+ linktype, C, Out.str());
+ vtt = Builder.CreateBitCast(vtt, Ptr8Ty);
+ return vtt;
+}
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=86650&r1=86649&r2=86650&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Nov 9 20:30:51 2009
@@ -384,6 +384,9 @@
/// GenerateVtable - Generate the vtable for the given type.
llvm::Value *GenerateVtable(const CXXRecordDecl *RD);
+ /// GenerateVTT - Generate the VTT for the given type.
+ llvm::Value *GenerateVTT(const CXXRecordDecl *RD);
+
/// DynamicTypeAdjust - Do the non-virtual and virtual adjustments on an
/// object pointer to alter the dynamic type of the pointer. Used by
/// GenerateCovariantThunk for building thunks.
More information about the cfe-commits
mailing list