[Mlir-commits] [mlir] [mlir] Allow trailing digit for alias in AsmPrinter (PR #127993)

Hongren Zheng llvmlistbot at llvm.org
Fri Feb 21 05:46:50 PST 2025


ZenithalHourlyRate wrote:

> For example, for !name123, the only possible way to conflict is another type with !name suggestion attached with 123 (!name12 will only generate !name12_3). So checking for nameCount[!name] > 123 will work

Checking only prefix is not sound, as the if `!name123` generates `!name123_1`, it might conflict with an already generated `!name123_1` before. The sorting at the beginning of `initializeAliases` would prevent the latter to be generated ealier but we should not depend on the sorting behavior.

So the approach by `uniqueValueName` is adopted by using `usedAliases` StringMap to detect duplication and append `N` or `_N` if found confliction. The detection logic now is much simpler compared with the detecting prefix logic. 

https://github.com/llvm/llvm-project/pull/127993


More information about the Mlir-commits mailing list