[PATCH] D122569: [lit] Support %if ... %else syntax for RUN lines

Andrew Savonichev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 06:13:51 PDT 2022


asavonic added a comment.

In D122569#3458476 <https://reviews.llvm.org/D122569#3458476>, @arichardson wrote:

> While this is not a huge amount of code to be added to lit, I do wonder if we really need it. Wouldn't something like `%feature{foo}` that expands to 0 or 1 be sufficient? You could then use shell conditionals/`test` to avoid running lines.
> Looking at the examples from D121727 <https://reviews.llvm.org/D121727>, you could do the following:
>
>   RUN: if [ %feature{ptxas} -ne 0 ]; then ptxas -c %t-nvptx.ptx -o /dev/null; fi
>   RUN: test %feature{ptxas} -ne 0 && ptxas -c %t-nvptx.ptx -o /dev/null

The variant with `if` is probably not going to work on windows.
As for the `test` - I'm not sure how it works in this case. If `test` returns a non-zero exit code, then LIT should report an error for the whole RUN line, right?
It is also not clear if we can use more complicated binary expression like `test 1 -eq 1 && ( test 2 -eq 2 || test 3 -eq 3 )`. 
For ptxas we also need to support nested expressions:

  ; The -arch option is only needed for ptxas < 11.0
  ; RUN: %if ptxas %{ %ptxas-verify %if !ptxas-11.0 %{-arch=sm_30%} %t.ptx %}


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

https://reviews.llvm.org/D122569



More information about the llvm-commits mailing list