aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/ModuleBuilder.cpp
diff options
context:
space:
mode:
authorJun Zhang <jun@junz.org>2022-06-18 19:53:11 +0800
committerJun Zhang <jun@junz.org>2022-06-18 20:27:21 +0800
commitcd64a427efa0baaf1bb7ae624d4301908afc07f7 (patch)
tree4cce22c0582ec202f26a324e4663b99794c124b8 /clang/lib/CodeGen/ModuleBuilder.cpp
parent3ea1422362c619c8ea7cba3e92aa716fa0c0cc5e (diff)
downloadllvm-cd64a427efa0baaf1bb7ae624d4301908afc07f7.zip
llvm-cd64a427efa0baaf1bb7ae624d4301908afc07f7.tar.gz
llvm-cd64a427efa0baaf1bb7ae624d4301908afc07f7.tar.bz2
Reland "[CodeGen] Keep track info of lazy-emitted symbols in ModuleBuilder"
This reverts commits: d3ddc251acae631bf5ab4da13878f7e8b5b5a451 d90eecff5c9e7e9f8263de6cd72d70322400829f It turned out there're some options turned on that leaks the memory intentionally, which fires the asan builds after the patch being applied. The issue has been fixed in 7bc00ce5cd41aad5fd0775f58c8e85a0a8d9ee56, so reland it. Below is the original commit message: 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>
Diffstat (limited to 'clang/lib/CodeGen/ModuleBuilder.cpp')
-rw-r--r--clang/lib/CodeGen/ModuleBuilder.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/ModuleBuilder.cpp b/clang/lib/CodeGen/ModuleBuilder.cpp
index 50b7fd8..8e97a29 100644
--- a/clang/lib/CodeGen/ModuleBuilder.cpp
+++ b/clang/lib/CodeGen/ModuleBuilder.cpp
@@ -134,7 +134,14 @@ namespace {
llvm::LLVMContext &C) {
assert(!M && "Replacing existing Module?");
M.reset(new llvm::Module(ExpandModuleName(ModuleName, CodeGenOpts), C));
+
+ std::unique_ptr<CodeGenModule> OldBuilder = std::move(Builder);
+
Initialize(*Ctx);
+
+ if (OldBuilder)
+ OldBuilder->moveLazyEmissionStates(Builder.get());
+
return M.get();
}