[llvm] [GlobalISel][Localizer] Allow localization of a small number of repeated phi uses. (PR #77566)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 03:42:18 PST 2024


================
@@ -58,18 +58,19 @@ bool Localizer::isLocalUse(MachineOperand &MOUse, const MachineInstr &Def,
   return InsertMBB == Def.getParent();
 }
 
-bool Localizer::isNonUniquePhiValue(MachineOperand &Op) const {
+unsigned Localizer::getNumPhiUses(MachineOperand &Op) const {
   MachineInstr *MI = Op.getParent();
   if (!MI->isPHI())
-    return false;
+    return 0;
 
   Register SrcReg = Op.getReg();
+  unsigned NumUses = 0;
   for (unsigned Idx = 1; Idx < MI->getNumOperands(); Idx += 2) {
----------------
tschuett wrote:

This violation `Idx < MI->getNumOperands()` is not your fault, but you are close.
`Idx < NumOperands`

https://github.com/llvm/llvm-project/pull/77566


More information about the llvm-commits mailing list