tbaeder created this revision. tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik. Herald added a project: All. tbaeder requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
With the current set of opcodes, this saves 3460 lines in the generated Opcodes.inc in release builds (-17%). The `dump()` code is only used for debugging right now as far as I know (there is nothing equivalent to `-ast-dump`), so only generate this code for debug builds. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D142694 Files: clang/lib/AST/Interp/Disasm.cpp clang/utils/TableGen/ClangOpcodesEmitter.cpp Index: clang/utils/TableGen/ClangOpcodesEmitter.cpp =================================================================== --- clang/utils/TableGen/ClangOpcodesEmitter.cpp +++ clang/utils/TableGen/ClangOpcodesEmitter.cpp @@ -161,6 +161,7 @@ } 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 @@ OS << " continue;\n"; }); OS << "#endif\n"; +#endif } void ClangOpcodesEmitter::EmitEmitter(raw_ostream &OS, StringRef N, Record *R) { Index: clang/lib/AST/Interp/Disasm.cpp =================================================================== --- clang/lib/AST/Interp/Disasm.cpp +++ clang/lib/AST/Interp/Disasm.cpp @@ -34,6 +34,7 @@ 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 @@ #undef GET_DISASM } } +#endif } LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); }
Index: clang/utils/TableGen/ClangOpcodesEmitter.cpp =================================================================== --- clang/utils/TableGen/ClangOpcodesEmitter.cpp +++ clang/utils/TableGen/ClangOpcodesEmitter.cpp @@ -161,6 +161,7 @@ } 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 @@ OS << " continue;\n"; }); OS << "#endif\n"; +#endif } void ClangOpcodesEmitter::EmitEmitter(raw_ostream &OS, StringRef N, Record *R) { Index: clang/lib/AST/Interp/Disasm.cpp =================================================================== --- clang/lib/AST/Interp/Disasm.cpp +++ clang/lib/AST/Interp/Disasm.cpp @@ -34,6 +34,7 @@ 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 @@ #undef GET_DISASM } } +#endif } LLVM_DUMP_METHOD void Program::dump() const { dump(llvm::errs()); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits