junaire updated this revision to Diff 433965. junaire added a comment. remove `EmittedDeferredDecls`
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D126781/new/ https://reviews.llvm.org/D126781 Files: clang/lib/CodeGen/CodeGenModule.h clang/lib/CodeGen/ModuleBuilder.cpp clang/test/Interpreter/execute.cpp Index: clang/test/Interpreter/execute.cpp =================================================================== --- clang/test/Interpreter/execute.cpp +++ clang/test/Interpreter/execute.cpp @@ -13,4 +13,8 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast<unsigned long long>(s.m)); // CHECK-NEXT: S[f=1.000000, m=0x0] + +inline int foo() { return 42; } +int r3 = foo(); + quit Index: clang/lib/CodeGen/ModuleBuilder.cpp =================================================================== --- clang/lib/CodeGen/ModuleBuilder.cpp +++ clang/lib/CodeGen/ModuleBuilder.cpp @@ -133,8 +133,37 @@ llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C) { assert(!M && "Replacing existing Module?"); + + std::unique_ptr<CodeGen::CodeGenModule> OldBuilder; + OldBuilder.swap(Builder); + M.reset(new llvm::Module(ExpandModuleName(ModuleName, CodeGenOpts), C)); Initialize(*Ctx); + + assert(OldBuilder->getDeferredDeclsToEmit().empty() && + "Should have emitted all decls deferred to emit."); + assert(Builder->getDeferredDecls().empty() && + "Newly created module should not have deferred decls"); + + Builder->getDeferredDecls().swap(OldBuilder->getDeferredDecls()); + + assert(Builder->getDeferredVTables().empty() && + "Newly created module should not have deferred vtables"); + + Builder->getDeferredVTables().swap(OldBuilder->getDeferredVTables()); + + assert(Builder->getMangledDeclNames().empty() && + "Newly created module should not have mangled decl names"); + assert(Builder->getManglings().empty() && + "Newly created module should not have manglings"); + + Builder->getManglings() = std::move(OldBuilder->getManglings()); + + assert(OldBuilder->getWeakRefReferences().empty() && + "Not all WeakRefRefs have been applied"); + + Builder->getTBAA().swap(OldBuilder->getTBAA()); + return M.get(); } Index: clang/lib/CodeGen/CodeGenModule.h =================================================================== --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -1477,6 +1477,36 @@ void printPostfixForExternalizedDecl(llvm::raw_ostream &OS, const Decl *D) const; + llvm::SmallPtrSetImpl<clang::Module *> &getEmittedDeferredDecls() { + return EmittedModuleInitializers; + } + + llvm::DenseMap<StringRef, GlobalDecl> &getDeferredDecls() { + return DeferredDecls; + } + + std::vector<GlobalDecl> &getDeferredDeclsToEmit() { + return DeferredDeclsToEmit; + } + + std::vector<const CXXRecordDecl *> &getDeferredVTables() { + return DeferredVTables; + } + + llvm::MapVector<GlobalDecl, StringRef> &getMangledDeclNames() { + return MangledDeclNames; + } + + llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> &getManglings() { + return Manglings; + } + + llvm::SmallPtrSetImpl<llvm::GlobalValue *> &getWeakRefReferences() { + return WeakRefReferences; + } + + std::unique_ptr<CodeGenTBAA> &getTBAA() { return TBAA; } + private: llvm::Constant *GetOrCreateLLVMFunction( StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,
Index: clang/test/Interpreter/execute.cpp =================================================================== --- clang/test/Interpreter/execute.cpp +++ clang/test/Interpreter/execute.cpp @@ -13,4 +13,8 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast<unsigned long long>(s.m)); // CHECK-NEXT: S[f=1.000000, m=0x0] + +inline int foo() { return 42; } +int r3 = foo(); + quit Index: clang/lib/CodeGen/ModuleBuilder.cpp =================================================================== --- clang/lib/CodeGen/ModuleBuilder.cpp +++ clang/lib/CodeGen/ModuleBuilder.cpp @@ -133,8 +133,37 @@ llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C) { assert(!M && "Replacing existing Module?"); + + std::unique_ptr<CodeGen::CodeGenModule> OldBuilder; + OldBuilder.swap(Builder); + M.reset(new llvm::Module(ExpandModuleName(ModuleName, CodeGenOpts), C)); Initialize(*Ctx); + + assert(OldBuilder->getDeferredDeclsToEmit().empty() && + "Should have emitted all decls deferred to emit."); + assert(Builder->getDeferredDecls().empty() && + "Newly created module should not have deferred decls"); + + Builder->getDeferredDecls().swap(OldBuilder->getDeferredDecls()); + + assert(Builder->getDeferredVTables().empty() && + "Newly created module should not have deferred vtables"); + + Builder->getDeferredVTables().swap(OldBuilder->getDeferredVTables()); + + assert(Builder->getMangledDeclNames().empty() && + "Newly created module should not have mangled decl names"); + assert(Builder->getManglings().empty() && + "Newly created module should not have manglings"); + + Builder->getManglings() = std::move(OldBuilder->getManglings()); + + assert(OldBuilder->getWeakRefReferences().empty() && + "Not all WeakRefRefs have been applied"); + + Builder->getTBAA().swap(OldBuilder->getTBAA()); + return M.get(); } Index: clang/lib/CodeGen/CodeGenModule.h =================================================================== --- clang/lib/CodeGen/CodeGenModule.h +++ clang/lib/CodeGen/CodeGenModule.h @@ -1477,6 +1477,36 @@ void printPostfixForExternalizedDecl(llvm::raw_ostream &OS, const Decl *D) const; + llvm::SmallPtrSetImpl<clang::Module *> &getEmittedDeferredDecls() { + return EmittedModuleInitializers; + } + + llvm::DenseMap<StringRef, GlobalDecl> &getDeferredDecls() { + return DeferredDecls; + } + + std::vector<GlobalDecl> &getDeferredDeclsToEmit() { + return DeferredDeclsToEmit; + } + + std::vector<const CXXRecordDecl *> &getDeferredVTables() { + return DeferredVTables; + } + + llvm::MapVector<GlobalDecl, StringRef> &getMangledDeclNames() { + return MangledDeclNames; + } + + llvm::StringMap<GlobalDecl, llvm::BumpPtrAllocator> &getManglings() { + return Manglings; + } + + llvm::SmallPtrSetImpl<llvm::GlobalValue *> &getWeakRefReferences() { + return WeakRefReferences; + } + + std::unique_ptr<CodeGenTBAA> &getTBAA() { return TBAA; } + private: llvm::Constant *GetOrCreateLLVMFunction( StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits