[cfe-commits] r79366 - /cfe/trunk/lib/CodeGen/CGCXX.cpp

Fariborz Jahanian fjahanian at apple.com
Tue Aug 18 13:53:52 PDT 2009


You may want to rename  ABIBuilder to something more indicative of the  
task at hand.

- Fariborz

On Aug 18, 2009, at 1:50 PM, Mike Stump wrote:

> Author: mrs
> Date: Tue Aug 18 15:50:28 2009
> New Revision: 79366
>
> URL: http://llvm.org/viewvc/llvm-project?rev=79366&view=rev
> Log:
> Split out vtable bulding code into a builder.
>
> 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=79366&r1=79365&r2=79366&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Aug 18 15:50:28 2009
> @@ -703,22 +703,31 @@
>   return Rtti;
> }
>
> -void CodeGenFunction::GenerateVcalls(std::vector<llvm::Constant *>  
> &methods,
> -                                     const CXXRecordDecl *RD,
> -                                     llvm::Type *Ptr8Ty) {
> -  typedef CXXRecordDecl::method_iterator meth_iter;
> -  llvm::Constant *m;
> -
> -  // FIXME: audit order
> -  for (meth_iter mi = RD->method_begin(),
> -         me = RD->method_end(); mi != me; ++mi) {
> -    if (mi->isVirtual()) {
> -      // FIXME: vcall: offset for virtual base for this function
> -      m = llvm::Constant::getNullValue(Ptr8Ty);
> -      methods.push_back(m);
> +class ABIBuilder {
> +  std::vector<llvm::Constant *> &methods;
> +  llvm::Type *Ptr8Ty;
> +  llvm::LLVMContext &VMContext;
> +public:
> +  ABIBuilder(llvm::Module &M, std::vector<llvm::Constant *> &meth)
> +    : methods(meth), VMContext(M.getContext()) {
> +    Ptr8Ty =  
> llvm::PointerType::get(llvm::Type::getInt8Ty(VMContext), 0);
> +  }
> +  void GenerateVcalls(const CXXRecordDecl *RD) {
> +    typedef CXXRecordDecl::method_iterator meth_iter;
> +    llvm::Constant *m;
> +
> +    // FIXME: audit order
> +    for (meth_iter mi = RD->method_begin(),
> +           me = RD->method_end(); mi != me; ++mi) {
> +      if (mi->isVirtual()) {
> +        // FIXME: vcall: offset for virtual base for this function
> +        m = llvm::Constant::getNullValue(Ptr8Ty);
> +        methods.push_back(m);
> +      }
>     }
>   }
> -}
> +
> +};
>
> void CodeGenFunction::GenerateMethods(std::vector<llvm::Constant *>  
> &methods,
>                                       const CXXRecordDecl *RD,
> @@ -807,8 +816,9 @@
>   }
>
>   if (forPrimary || ForVirtualBase) {
> +    ABIBuilder b(CGM.getModule(), methods);
>     // then comes the the vcall offsets for all our functions...
> -    GenerateVcalls(methods, RD, Ptr8Ty);
> +    b.GenerateVcalls(RD);
>   }
>
>   bool Top = true;
> @@ -822,10 +832,6 @@
>                           PrimaryBaseWasVirtual, IndirectPrimary);
>   }
>
> -  // then come the vcall offsets for all our virtual bases.
> -  if (!1 && ForVirtualBase)
> -    GenerateVcalls(methods, RD, Ptr8Ty);
> -
>   if (Top) {
>     int64_t BaseOffset;
>     if (ForVirtualBase) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list