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

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 02:31:31 PDT 2022


arichardson added a comment.

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

Or alternatively if %feature expands to an empty string (`""`) or `"1"`:

  RUN: if [ -n %feature{ptxas} ]; then ptxas -c %t-nvptx.ptx -o /dev/null; fi
  RUN: test -n %feature{ptxas} && ptxas -c %t-nvptx.ptx -o /dev/null

Depending on how you set up the `ptxas` substitution it might even be possible without a `%feature{}` lit substitution.


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

https://reviews.llvm.org/D122569



More information about the llvm-commits mailing list