[llvm] [llvm-exegesis] Debug generated disassembly (PR #142540)
Sjoerd Meijer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 05:47:23 PDT 2025
================
@@ -588,6 +594,99 @@ class SubProcessFunctionExecutorImpl
const std::optional<int> BenchmarkProcessCPU;
};
#endif // __linux__
+
+// Helper function to print generated assembly snippets
+void printGeneratedAssembly(
+ const std::vector<std::pair<std::string, std::pair<uint64_t, std::string>>>
+ &Instructions,
+ bool Preview, size_t PreviewFirst = 10, size_t PreviewLast = 3) {
+ dbgs() << "```\n";
+ size_t N = Instructions.size();
+ // Print first "PreviewFirst" lines or all if less
+ for (size_t i = 0; i < std::min(size_t(PreviewFirst), N); ++i) {
+ dbgs() << format_hex_no_prefix(Instructions[i].second.first, 0) << ":\t"
+ << Instructions[i].second.second << Instructions[i].first << '\n';
+ }
+ if (N > (PreviewFirst + PreviewLast)) {
+ if (Preview) {
+ dbgs() << "...\t(" << (N - PreviewFirst - PreviewLast)
----------------
sjoerdmeijer wrote:
So yeah, debug vs. release builds had me confused earlier. I guess this debug stream is available even in non-Debug mode, but does it make sense to use `outs()` instead? I see that being used elsewhere, and guess that is the slightly more appropriate output stream for this?
https://github.com/llvm/llvm-project/pull/142540
More information about the llvm-commits
mailing list