[all-commits] [llvm/llvm-project] 70074c: [mlir][AsmPrinter] Fallback to using qualified pri...
Markus Böck via All-commits
all-commits at lists.llvm.org
Mon Mar 27 06:50:04 PDT 2023
Author: Markus Böck <markus.boeck02 at gmail.com>
Date: 2023-03-27 (Mon, 27 Mar 2023)
[mlir][AsmPrinter] Fallback to using qualified printer if unqualified output is empty
The current behaviour of always writing the unqualified form of an attribute or type is problematic for any type or attribute that might output an empty string, making it impossible to parse and therefore roundtrip. This is commonly the case for any types or attributes with optional parameters. One would have to currently woarkaround the issue by either changing ones syntax to not be completetly empty or by explicitly using `qualified` in ALL ops using that type or attribute.
This patch fixes that issue by simply checking whether anything was written to the output. In the case there wasn't, it simply falls back to using the normal printer with the dialect prefix. This also makes the default of unqualified printing always correct and safe. The implementation could theoretically still be tricked if the user were to print just a space or similar. I'd argue this'd be user error and not worth handling.
Differential Revision: https://reviews.llvm.org/D146944
More information about the All-commits