[llvm] [TargetLowering] Deduplicate choosing InlineAsm constraint between ISels (PR #67057)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 22 01:43:55 PDT 2023


================
@@ -207,7 +142,16 @@ static void computeConstraintToUse(const TargetLowering *TLI,
     OpInfo.ConstraintCode = OpInfo.Codes[0];
     OpInfo.ConstraintType = TLI->getConstraintType(OpInfo.ConstraintCode);
   } else {
-    chooseConstraint(OpInfo, TLI);
+    TargetLowering::ConstraintGroup G = TLI->getConstraintPreferences(OpInfo);
+    if (G.empty())
+      return;
+    // FIXME: prefer immediate constraints if the target allows it
+    unsigned BestIdx = 0;
+    while (G[BestIdx].second == TargetLowering::C_Other ||
+           G[BestIdx].second == TargetLowering::C_Immediate)
----------------
qcolombet wrote:

I'm nervous when I see loops without clear bound.
Why don't we have to check that `BestIdx < G.size()` to prevent out-of-bounds accesses?

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


More information about the llvm-commits mailing list