[PATCH] D142694: [clang][Interp] Only generate disassembly in debug builds
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 27 00:19:05 PST 2023
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()); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142694.492655.patch
Type: text/x-patch
Size: 1322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230127/66c47547/attachment.bin>
More information about the cfe-commits
mailing list