aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorJun Zhang <jun@junz.org>2022-06-09 23:12:21 +0800
committerJun Zhang <jun@junz.org>2022-06-09 23:12:21 +0800
commitb8f9459715815fa055b3e1c5f970c616797dfcfb (patch)
tree938c8aef91feecd03b6c90888a7a9c44015e34a9 /clang/lib/CodeGen/CodeGenModule.h
parent6555558a80589d1c5a1154b92cc3af9495f8f86c (diff)
downloadllvm-b8f9459715815fa055b3e1c5f970c616797dfcfb.zip
llvm-b8f9459715815fa055b3e1c5f970c616797dfcfb.tar.gz
llvm-b8f9459715815fa055b3e1c5f970c616797dfcfb.tar.bz2
[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder
The intent of this patch is to selectively carry some states over to the Builder so we won't lose the information of the previous symbols. This used to be several downstream patches of Cling, it aims to fix errors in Clang Interpreter when trying to use inline functions. Before this patch: clang-repl> inline int foo() { return 42;} clang-repl> int x = foo(); JIT session error: Symbols not found: [ _Z3foov ] error: Failed to materialize symbols: { (main, { x, $.incr_module_1.__inits.0, __orc_init_func.incr_module_1 }) } Co-authored-by: Axel Naumann <Axel.Naumann@cern.ch> Signed-off-by: Jun Zhang <jun@junz.org> Differential Revision: https://reviews.llvm.org/D126781
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 0ac476d..b7c180f 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1477,6 +1477,31 @@ public:
void printPostfixForExternalizedDecl(llvm::raw_ostream &OS,
const Decl *D) const;
+ /// Move some lazily-emitted states to the NewBuilder. This is especially
+ /// essential for the incremental parsing environment like Clang Interpreter,
+ /// because we'll lose all important information after each repl.
+ void moveLazyEmissionStates(CodeGenModule *NewBuilder) {
+ assert(DeferredDeclsToEmit.empty() &&
+ "Should have emitted all decls deferred to emit.");
+ assert(NewBuilder->DeferredDecls.empty() &&
+ "Newly created module should not have deferred decls");
+ NewBuilder->DeferredDecls = std::move(DeferredDecls);
+
+ assert(NewBuilder->DeferredVTables.empty() &&
+ "Newly created module should not have deferred vtables");
+ NewBuilder->DeferredVTables = std::move(DeferredVTables);
+
+ assert(NewBuilder->MangledDeclNames.empty() &&
+ "Newly created module should not have mangled decl names");
+ assert(NewBuilder->Manglings.empty() &&
+ "Newly created module should not have manglings");
+ NewBuilder->Manglings = std::move(Manglings);
+
+ assert(WeakRefReferences.empty() &&
+ "Not all WeakRefRefs have been applied");
+ NewBuilder->TBAA = std::move(TBAA);
+ }
+
private:
llvm::Constant *GetOrCreateLLVMFunction(
StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,