[llvm] [NFC][DebugInfo] Deprecate iterator-taking moveBefore and getFirstNonPHI (PR #124290)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 07:28:29 PST 2025
================
@@ -372,9 +372,16 @@ const Instruction* BasicBlock::getFirstNonPHI() const {
}
BasicBlock::const_iterator BasicBlock::getFirstNonPHIIt() const {
- const Instruction *I = getFirstNonPHI();
+ const Instruction *I = [&]() -> const Instruction * {
+ for (const Instruction &I : *this)
+ if (!isa<PHINode>(I))
+ return &I;
+ return nullptr;
+ }();
+
if (!I)
return end();
+
----------------
OCHyams wrote:
I think this function can be simplified by just folding the success-return-path into the loop (and removing the lambda). Not a big deal, YMMV.
https://github.com/llvm/llvm-project/pull/124290
More information about the llvm-commits
mailing list