[PATCH] D60386: FileCheck [6/12]: Introduce numeric variable definition

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 9 09:27:05 PST 2020


hliao added inline comments.


================
Comment at: llvm/trunk/docs/CommandGuide/FileCheck.rst:630-632
+Important note: In its current implementation, a numeric expression cannot use
+a numeric variable defined on the same line.
+
----------------
hliao wrote:
> thopre wrote:
> > hliao wrote:
> > > Just curious why we have such a restriction. Could someone elaborate more?
> > > 
> > > That makes numeric checks on the same line must be written in split like this
> > > 
> > > CHECK: [[#VAR:...]]
> > > CHECK-SAME: [[#VAR + 1]]
> > > 
> > > instead of
> > > 
> > > CHECK: [[#VAR:...]] [[#VAR + 1]]
> > > 
> > > That's quite verbose.
> > This is not currently done for 2 reasons:
> > 
> >   # The first reason is that the current code assumes the value of numeric expression is known at match time but in the case [[#VAR:]] [[#VAR+1]] the value VAR+1 is not known since VAR is not known yet. I have a patch planned to address that later in the patch series [1]
> >   # The more serious problem is how to deal with input such as 10 12 13 and the CHECK [[#VAR:]] {{.*}} [[#VAR+1]] check. Here you'd want the CHECK to be successful and VAR to be assigned the value 12. However FileCheck with the aforementioned patch will ask the regex engine to match the input against the regex "([0-9]+) ([0-9]+)" and will then check the captured text to verify that the numeric expression is verified. However that regex will capture 10 and 12, being the first 2 numbers. Now given the .* how to look at all other possible matches? We would need help from the regex engine but the API only gives us a match/no match answer with captured text.
> > 
> > [1] https://reviews.llvm.org/D60392 which needs serious rebasing
> > 
> > Hope this answers your question.
> 1. I wish [1] could be landed as soon as possible. So far, numeric substitution is inconsistent with the previous string substitution. The later allows the use and def in the same line. E.g. the following works
>   ```
>   11 11
>   CHECK: [[VAR:[0-9]+]] [[VAR]]
>   ```
> 2. I haven't looked into the numeric support in detail. We should reference the original string block in FileCheck. A similar pattern works for the string block:
>   ```
>   11 22 22
>   CHECK: [[VAR:[0-9]+]] [[VAR]]
>   ```
> Any details on why numeric block works differently from string block?
> 
Fix the formatting of the examples aforesaid:

```
11 11
CHECK: [[VAR:[0-9]+]] [[VAR]]
```

```
11 22 22
CHECK: [[VAR:[0-9]+]] [[VAR]]
```

both of them work for string blocks.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60386/new/

https://reviews.llvm.org/D60386





More information about the llvm-commits mailing list