[llvm] [BOLT] Add a printing function for MCInst (PR #67225)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 23 01:22:30 PDT 2023
https://github.com/llongint created https://github.com/llvm/llvm-project/pull/67225
In GDB debugging, obtaining the assembly representation of MCInst is more intuitive.
>From 419ac62348c3cd7b35ecf967097470a416366bf1 Mon Sep 17 00:00:00 2001
From: hezuoqiang <hezuoqiang2 at huawei.com>
Date: Sat, 23 Sep 2023 13:23:16 +0800
Subject: [PATCH] [BOLT] Add a printing function for MCInst
In GDB debugging, obtaining the assembly representation of MCInst is
more intuitive.
---
bolt/include/bolt/Core/BinaryFunction.h | 3 +++
bolt/lib/Core/BinaryFunction.cpp | 7 +++++++
2 files changed, 10 insertions(+)
diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index dea1d55b15026e4..44cf966c65d3e18 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -1532,6 +1532,9 @@ class BinaryFunction {
/// Note: this doesn't take function splitting into account.
bool isForwardCall(const MCSymbol *CalleeSymbol) const;
+ /// Dump the assembly representation of MCInst to debug output.
+ void dump(const MCInst &Inst) const;
+
/// Dump function information to debug output. If \p PrintInstructions
/// is true - include instruction disassembly.
void dump() const;
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index 6cf1cfb50a9c12c..73ef9d0c3f8b806 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -389,6 +389,13 @@ bool BinaryFunction::isForwardCall(const MCSymbol *CalleeSymbol) const {
}
}
+void BinaryFunction::dump(const MCInst &Inst) const {
+ if (!BC.InstPrinter)
+ return;
+ BC.InstPrinter->printInst(&Inst, 0, "", *BC.STI, dbgs());
+ dbgs() << "\n";
+}
+
void BinaryFunction::dump() const {
// getDynoStats calls FunctionLayout::updateLayoutIndices and
// BasicBlock::analyzeBranch. The former cannot be const, but should be
More information about the llvm-commits
mailing list