aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2021-12-06 08:49:10 -0800
committerKazu Hirata <kazu@google.com>2021-12-06 08:49:10 -0800
commitc4a8928b51daa486013abbfa4dad75def2a9528e (patch)
treea47955bbcc57b103e80cabcc6bd59f5beb0f4cd0 /llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
parenta05a0c3c2f8eefc80d84b7a87a23a4452d4a3087 (diff)
downloadllvm-c4a8928b51daa486013abbfa4dad75def2a9528e.zip
llvm-c4a8928b51daa486013abbfa4dad75def2a9528e.tar.gz
llvm-c4a8928b51daa486013abbfa4dad75def2a9528e.tar.bz2
[CodeGen] Use range-based for loops (NFC)
Diffstat (limited to 'llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp')
-rw-r--r--llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp b/llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
index de6129a..49859ae 100644
--- a/llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
+++ b/llvm/lib/CodeGen/RemoveRedundantDebugValues.cpp
@@ -159,20 +159,17 @@ static bool reduceDbgValsBackwardScan(MachineBasicBlock &MBB) {
SmallVector<MachineInstr *, 8> DbgValsToBeRemoved;
SmallDenseSet<DebugVariable> VariableSet;
- for (MachineBasicBlock::reverse_iterator I = MBB.rbegin(), E = MBB.rend();
- I != E; ++I) {
- MachineInstr *MI = &*I;
-
- if (MI->isDebugValue()) {
- DebugVariable Var(MI->getDebugVariable(), MI->getDebugExpression(),
- MI->getDebugLoc()->getInlinedAt());
+ for (MachineInstr &MI : llvm::reverse(MBB)) {
+ if (MI.isDebugValue()) {
+ DebugVariable Var(MI.getDebugVariable(), MI.getDebugExpression(),
+ MI.getDebugLoc()->getInlinedAt());
auto R = VariableSet.insert(Var);
// If it is a DBG_VALUE describing a constant as:
// DBG_VALUE 0, ...
// we just don't consider such instructions as candidates
// for redundant removal.
- if (MI->isNonListDebugValue()) {
- MachineOperand &Loc = MI->getDebugOperand(0);
+ if (MI.isNonListDebugValue()) {
+ MachineOperand &Loc = MI.getDebugOperand(0);
if (!Loc.isReg()) {
// If we have already encountered this variable, just stop
// tracking it.
@@ -185,7 +182,7 @@ static bool reduceDbgValsBackwardScan(MachineBasicBlock &MBB) {
// We have already encountered the value for this variable,
// so this one can be deleted.
if (!R.second)
- DbgValsToBeRemoved.push_back(MI);
+ DbgValsToBeRemoved.push_back(&MI);
continue;
}