[llvm-dev] New Pass Manager '<' '>' syntax

Cameron McInally via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 11 12:41:59 PST 2021


Hey llvm-dev,

The new Pass Manager's "-passes=default<Ox>" syntax is a little wonky.
It was unfortunate that "<" and ">" were chosen, since those are the
Unix I/O redirection operators.

Let's take the case of a simple driver:

#include <stddef.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char *argv[]) {
  char* cmd = "opt";
  char* arr[] = {"-passes=default<O2>", "-S", "test.ll", NULL};

  if (argc == 1)
    execv(cmd, arr);
  else {
    if (strcmp(argv[1], "-###") == 0) {
        printf("%s ", cmd);
      for(int i =0 ; arr[i] != NULL; i++)
        printf("%s ", arr[i]);
      printf("\n");
    }
  }
  return 0;
}

So there's two modes there: execute the opt subcommand; or dump the
subcommand in a dryrun. Typically, we'd want to be able to
copy-and-paste the output of the dryrun to the command line.

$ ./driver -###
opt -passes=default<O2> -S test.ll
$ opt -passes=default<O2> -S test.ll
-bash: O2: No such file or directory

But in this case, the new -passes=default<O2> option makes that
awkward since we'd need to escape the '<' and '>' symbols, so that the
shell doesn't interpret them as I/O redirectors.

Unfortunately, patching this up in our driver is clunky. So I'm
reaching out to the list to see if there's an appetite for a better
way to express this option.

Thanks,
Cameron


More information about the llvm-dev mailing list