[llvm] 41457bc - [NFC][AsmPrinter] Rework/add comments (#145587)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 25 07:02:05 PDT 2025
Author: Scott Linder
Date: 2025-06-25T10:02:00-04:00
New Revision: 41457bc9d2b58558002a6c1f860b940c99fd62f4
URL: https://github.com/llvm/llvm-project/commit/41457bc9d2b58558002a6c1f860b940c99fd62f4
DIFF: https://github.com/llvm/llvm-project/commit/41457bc9d2b58558002a6c1f860b940c99fd62f4.diff
LOG: [NFC][AsmPrinter] Rework/add comments (#145587)
- Add a comment explaining TrackedRegs cache in handleNewDebugValue
- Remove a comment which is not meaningful since
https://reviews.llvm.org/D4919
- Expand the subject of a comment to match the code it describes
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
index 5442fb15202ea..171fb8394990d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp
@@ -374,6 +374,18 @@ static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV,
DbgValueHistoryMap &HistMap) {
EntryIndex NewIndex;
if (HistMap.startDbgValue(Var, DV, NewIndex)) {
+ // As we already need to iterate all LiveEntries when handling a DbgValue,
+ // we use this map to avoid a more expensive check against RegVars. There
+ // is an assert that we handle this correctly in addRegDescribedVar.
+ //
+ // In other terms, the presence in this map indicates the presence of a
+ // corresponding entry in RegVars.
+ //
+ // The bool value then tracks whether an entry is to be retained (true) or
+ // removed (false); as we end previous entries we speculatively assume they
+ // can be dropped from RegVars, but we then also visit the new entry whose
+ // set of debug register operands may overlap and "save" a reg from being
+ // dropped.
SmallDenseMap<unsigned, bool, 4> TrackedRegs;
// If we have created a new debug value entry, close all preceding
@@ -467,9 +479,6 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF,
for (const auto &MI : MBB) {
if (MI.isDebugValue()) {
assert(MI.getNumOperands() > 1 && "Invalid DBG_VALUE instruction!");
- // Use the base variable (without any DW_OP_piece expressions)
- // as index into History. The full variables including the
- // piece expressions are attached to the MI.
const DILocalVariable *RawVar = MI.getDebugVariable();
assert(RawVar->isValidLocationForIntrinsic(MI.getDebugLoc()) &&
"Expected inlined-at fields to agree");
@@ -493,8 +502,7 @@ void llvm::calculateDbgEntityHistory(const MachineFunction *MF,
if (MI.isMetaInstruction())
continue;
- // Not a DBG_VALUE instruction. It may clobber registers which describe
- // some variables.
+ // Other instructions may clobber registers which describe some variables.
for (const MachineOperand &MO : MI.operands()) {
if (MO.isReg() && MO.isDef() && MO.getReg()) {
// Ignore call instructions that claim to clobber SP. The AArch64
More information about the llvm-commits
mailing list