Author: Timm Bäder Date: 2023-02-03T15:40:25+01:00 New Revision: 60dcc70e48fa9814a4e0d5e12856bc88b7f927eb
URL: https://github.com/llvm/llvm-project/commit/60dcc70e48fa9814a4e0d5e12856bc88b7f927eb DIFF: https://github.com/llvm/llvm-project/commit/60dcc70e48fa9814a4e0d5e12856bc88b7f927eb.diff LOG: [clang][Interp] Only generate disassembly in debug builds With the current set of opcodes, this saves 3460 lines in the generated Opcodes.inc in release builds (-17%). Differential Revision: https://reviews.llvm.org/D142694 Added: Modified: clang/lib/AST/Interp/Disasm.cpp clang/utils/TableGen/ClangOpcodesEmitter.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp index 1c95782536fba..aa07c0d7b8159 100644 --- a/clang/lib/AST/Interp/Disasm.cpp +++ b/clang/lib/AST/Interp/Disasm.cpp @@ -34,6 +34,7 @@ template <typename T> inline T ReadArg(Program &P, CodePtr &OpPC) { LLVM_DUMP_METHOD void Function::dump() const { dump(llvm::errs()); } LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const { +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) if (F) { if (const auto *MD = dyn_cast<CXXMethodDecl>(F)) OS << MD->getParent()->getDeclName() << "::"; @@ -64,6 +65,7 @@ LLVM_DUMP_METHOD void Function::dump(llvm::raw_ostream &OS) const { #undef GET_DISASM } } +#endif } LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); } diff --git a/clang/utils/TableGen/ClangOpcodesEmitter.cpp b/clang/utils/TableGen/ClangOpcodesEmitter.cpp index aa012233c46ee..c4992ef7d25b7 100644 --- a/clang/utils/TableGen/ClangOpcodesEmitter.cpp +++ b/clang/utils/TableGen/ClangOpcodesEmitter.cpp @@ -161,6 +161,7 @@ void ClangOpcodesEmitter::EmitInterp(raw_ostream &OS, StringRef N, Record *R) { } void ClangOpcodesEmitter::EmitDisasm(raw_ostream &OS, StringRef N, Record *R) { +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) OS << "#ifdef GET_DISASM\n"; Enumerate(R, N, [R, &OS](ArrayRef<Record *>, const Twine &ID) { OS << "case OP_" << ID << ":\n"; @@ -176,6 +177,7 @@ void ClangOpcodesEmitter::EmitDisasm(raw_ostream &OS, StringRef N, Record *R) { OS << " continue;\n"; }); OS << "#endif\n"; +#endif } void ClangOpcodesEmitter::EmitEmitter(raw_ostream &OS, StringRef N, Record *R) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits