aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
diff options
context:
space:
mode:
authorJameson Nash <vtjnash@gmail.com>2020-11-03 08:54:51 -0500
committerJameson Nash <vtjnash@gmail.com>2020-11-03 10:02:09 -0500
commita0ad066ce490ba34f259dd0fc8ad5810bd92dc3d (patch)
treed600989a4f78fdb5e39366b3017387060be11d88 /llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
parent97e8da45f9459ce9334c2d387ada7d2cde9625f4 (diff)
downloadllvm-a0ad066ce490ba34f259dd0fc8ad5810bd92dc3d.zip
llvm-a0ad066ce490ba34f259dd0fc8ad5810bd92dc3d.tar.gz
llvm-a0ad066ce490ba34f259dd0fc8ad5810bd92dc3d.tar.bz2
make the AsmPrinterHandler array public
This lets external consumers customize the output, similar to how AssemblyAnnotationWriter lets the caller define callbacks when printing IR. The array of handlers already existed, this just cleans up the code so that it can be exposed publically. Replaces https://reviews.llvm.org/D74158 Differential Revision: https://reviews.llvm.org/D89613
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index 9d963a3..68a4bfb 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -91,6 +91,11 @@ DbgVariableLocation::extractFromMachineInstruction(
DebugHandlerBase::DebugHandlerBase(AsmPrinter *A) : Asm(A), MMI(Asm->MMI) {}
+void DebugHandlerBase::beginModule(Module *M) {
+ if (M->debug_compile_units().empty())
+ Asm = nullptr;
+}
+
// Each LexicalScope has first instruction and last instruction to mark
// beginning and end of a scope respectively. Create an inverse map that list
// scopes starts (and ends) with an instruction. One instruction may start (or
@@ -324,7 +329,7 @@ void DebugHandlerBase::beginFunction(const MachineFunction *MF) {
}
void DebugHandlerBase::beginInstruction(const MachineInstr *MI) {
- if (!MMI->hasDebugInfo())
+ if (!Asm || !MMI->hasDebugInfo())
return;
assert(CurMI == nullptr);
@@ -350,7 +355,7 @@ void DebugHandlerBase::beginInstruction(const MachineInstr *MI) {
}
void DebugHandlerBase::endInstruction() {
- if (!MMI->hasDebugInfo())
+ if (!Asm || !MMI->hasDebugInfo())
return;
assert(CurMI != nullptr);
@@ -382,7 +387,7 @@ void DebugHandlerBase::endInstruction() {
}
void DebugHandlerBase::endFunction(const MachineFunction *MF) {
- if (hasDebugInfo(MMI, MF))
+ if (Asm && hasDebugInfo(MMI, MF))
endFunctionImpl(MF);
DbgValues.clear();
DbgLabels.clear();