[PATCH] D34444: Teach codegen to work in incremental processing mode.

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 22 06:27:46 PDT 2017


v.g.vassilev updated this revision to Diff 103565.
v.g.vassilev added a comment.

Bring back the initial state of this patch. I accidentally uploaded a wrong patch here, instead of its dependee...


https://reviews.llvm.org/D34444

Files:
  include/clang/CodeGen/ModuleBuilder.h
  lib/CodeGen/ModuleBuilder.cpp


Index: lib/CodeGen/ModuleBuilder.cpp
===================================================================
--- lib/CodeGen/ModuleBuilder.cpp
+++ lib/CodeGen/ModuleBuilder.cpp
@@ -119,6 +119,14 @@
       return Builder->GetAddrOfGlobal(global, ForDefinition_t(isForDefinition));
     }
 
+    llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext& C,
+                              const CodeGenOptions& CGO) {
+      assert(!M && "Replacing existing Module?");
+      M.reset(new llvm::Module(ModuleName, C));
+      Initialize(*Ctx);
+      return M.get();
+    }
+
     void Initialize(ASTContext &Context) override {
       Ctx = &Context;
 
@@ -317,6 +325,11 @@
            ->GetAddrOfGlobal(global, isForDefinition);
 }
 
+llvm::Module *CodeGenerator::StartModule(const std::string& ModuleName,
+                                         llvm::LLVMContext& C) {
+   return static_cast<CodeGeneratorImpl*>(this)->StartModule(ModuleName, C);
+}
+
 CodeGenerator *clang::CreateLLVMCodeGen(
     DiagnosticsEngine &Diags, llvm::StringRef ModuleName,
     const HeaderSearchOptions &HeaderSearchOpts,
Index: include/clang/CodeGen/ModuleBuilder.h
===================================================================
--- include/clang/CodeGen/ModuleBuilder.h
+++ include/clang/CodeGen/ModuleBuilder.h
@@ -84,6 +84,11 @@
   ///   code generator will schedule the entity for emission if a
   ///   definition has been registered with this code generator.
   llvm::Constant *GetAddrOfGlobal(GlobalDecl decl, bool isForDefinition);
+
+  /// Create a new \c llvm::Module after calling HandleTranslationUnit. This
+  /// enable codegen in interactive processing environments.
+  llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext& C,
+                            const CodeGenOptions& CGO);
 };
 
 /// CreateLLVMCodeGen - Create a CodeGenerator instance.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34444.103565.patch
Type: text/x-patch
Size: 1882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170622/d5f3a838/attachment.bin>


More information about the cfe-commits mailing list