llvm-project
1a70420f - [mlir] Attempt to resolve edge cases in PassPipeline textual format (#118877)

Commit
288 days ago
[mlir] Attempt to resolve edge cases in PassPipeline textual format (#118877) This commit makes the following changes: 1. Previously certain pipeline options could cause the options parser to get stuck in an an infinite loop. An example is: ``` mlir-opt %s -verify-each=false -pass-pipeline='builtin.module(func.func(test-options-super-pass{list={list=1,2},{list=3,4}}))'' ``` In this example, the 'list' option of the `test-options-super-pass` is itself a pass options specification (this capability was added in https://github.com/llvm/llvm-project/issues/101118). However, while the textual format allows `ListOption<int>` to be given as `list=1,2,3`, it did not allow the same format for `ListOption<T>` when T is a subclass of `PassOptions` without extra enclosing `{....}`. Lack of enclosing `{...}` would cause the infinite looping in the parser. This change resolves the parser bug and also allows omitting the outer `{...}` for `ListOption`-of-options. 2. Previously, if you specified a default list value for your `ListOption`, e.g. `ListOption<int> opt{*this, "list", llvm::cl::list_init({1,2,3})}`, it would be impossible to override that default value of `{1,2,3}` with an *empty* list on the command line, since `my-pass{list=}` was not allowed. This was not allowed because of ambiguous handling of lists-of-strings (no literal marker is currently required). This change makes it explicit in the ListOption construction that we would like to treat all ListOption as having a default value of "empty" unless otherwise specified (e.g. using `llvm::list_init`). It removes the requirement that lists are not printed if empty. Instead, lists are not printed if they do not have their default value. It is now clarified that the textual format `my-pass{string-list=""}` or `my-pass{string-list={}}` is interpreted as "empty list". This makes it imposssible to specify that ListOption `string-list` should be a size-1 list containing the empty string. However, `my-pass{string-list={"",""}}` *does* specify a size-2 list containing the empty string. This behavior seems preferable to allow for overriding non-empty defaults as described above.
Parents
Loading