[llvm] [SelectionDAG] Use a range-based for loop (NFC) (PR #97154)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 29 01:07:25 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
UI++ in the loop might appear to indicate that the loop modifies the
container in some way (deletion or insertion), but the loop just
examines the container.
---
Full diff: https://github.com/llvm/llvm-project/pull/97154.diff
1 Files Affected:
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (+8-8)
``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index e5a34bccff8e1..1e54af2f098ef 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -756,16 +756,16 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
// that COPY instructions also need DBG_VALUE, if it is the only
// user of LDI->second.
MachineInstr *CopyUseMI = nullptr;
- for (MachineRegisterInfo::use_instr_iterator
- UI = RegInfo->use_instr_begin(LDI->second),
- E = RegInfo->use_instr_end(); UI != E; ) {
- MachineInstr *UseMI = &*(UI++);
- if (UseMI->isDebugValue()) continue;
- if (UseMI->isCopy() && !CopyUseMI && UseMI->getParent() == EntryMBB) {
- CopyUseMI = UseMI; continue;
+ for (MachineInstr &UseMI : RegInfo->use_instructions(LDI->second)) {
+ if (UseMI.isDebugValue())
+ continue;
+ if (UseMI.isCopy() && !CopyUseMI && UseMI.getParent() == EntryMBB) {
+ CopyUseMI = &UseMI;
+ continue;
}
// Otherwise this is another use or second copy use.
- CopyUseMI = nullptr; break;
+ CopyUseMI = nullptr;
+ break;
}
if (CopyUseMI &&
TRI.getRegSizeInBits(LDI->second, MRI) ==
``````````
</details>
https://github.com/llvm/llvm-project/pull/97154
More information about the llvm-commits
mailing list