junaire created this revision. junaire added a reviewer: v.g.vassilev. Herald added a project: All. junaire requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Also move MangleCtx when moving some lazy emission states in CodeGenModule. Without this patch clang-repl hits an invalid address access when passing `-Xcc -O2` flag. Signed-off-by: Jun Zhang <j...@junz.org> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D130420 Files: clang/lib/CodeGen/CGCXXABI.h clang/lib/CodeGen/CodeGenModule.cpp clang/test/Interpreter/execute.cpp Index: clang/test/Interpreter/execute.cpp =================================================================== --- clang/test/Interpreter/execute.cpp +++ clang/test/Interpreter/execute.cpp @@ -5,6 +5,7 @@ // UNSUPPORTED: system-aix // CHECK-DRIVER: i = 10 // RUN: cat %s | clang-repl | FileCheck %s +// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s extern "C" int printf(const char *, ...); int i = 42; auto r1 = printf("i = %d\n", i); Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -7000,4 +7000,6 @@ "Still have (unmerged) EmittedDeferredDecls deferred decls"); NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls); + + NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx); } Index: clang/lib/CodeGen/CGCXXABI.h =================================================================== --- clang/lib/CodeGen/CGCXXABI.h +++ clang/lib/CodeGen/CGCXXABI.h @@ -41,6 +41,8 @@ /// Implements C++ ABI-specific code generation functions. class CGCXXABI { + friend class CodeGenModule; + protected: CodeGenModule &CGM; std::unique_ptr<MangleContext> MangleCtx;
Index: clang/test/Interpreter/execute.cpp =================================================================== --- clang/test/Interpreter/execute.cpp +++ clang/test/Interpreter/execute.cpp @@ -5,6 +5,7 @@ // UNSUPPORTED: system-aix // CHECK-DRIVER: i = 10 // RUN: cat %s | clang-repl | FileCheck %s +// RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s extern "C" int printf(const char *, ...); int i = 42; auto r1 = printf("i = %d\n", i); Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -7000,4 +7000,6 @@ "Still have (unmerged) EmittedDeferredDecls deferred decls"); NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls); + + NewBuilder->ABI->MangleCtx = std::move(ABI->MangleCtx); } Index: clang/lib/CodeGen/CGCXXABI.h =================================================================== --- clang/lib/CodeGen/CGCXXABI.h +++ clang/lib/CodeGen/CGCXXABI.h @@ -41,6 +41,8 @@ /// Implements C++ ABI-specific code generation functions. class CGCXXABI { + friend class CodeGenModule; + protected: CodeGenModule &CGM; std::unique_ptr<MangleContext> MangleCtx;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits