[llvm] [TableGen] Fix operand constraint checking problem. (PR #85859)

Jason Eckhardt via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 07:38:46 PDT 2024


================
@@ -325,7 +325,8 @@ static void ParseConstraint(StringRef CStr, CGIOperandList &Ops, Record *Rec) {
 
   // Only other constraint is "TIED_TO" for now.
   StringRef::size_type pos = CStr.find_first_of('=');
-  if (pos == StringRef::npos)
+  if (pos == StringRef::npos || CStr.find_first_of(" \t", pos) != (pos + 1) ||
+      CStr.find_last_of(" \t", pos) != (pos - 1))
----------------
nvjle wrote:

Right @topperc -- for the corner case `=`, the behavior is as you describe, so that `npos` == `pos-1` and the condition on `pos+1` fires instead. In other cases, we'll drop through to the following check on the operands as @davidchisnall mentions.

I've added these and other corner cases to the `ConstraintChecking8.td` test file (consolidated).

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


More information about the llvm-commits mailing list