[clang] [CIR] Avoid duplicate name collisions in LoweringPrepare (PR #194469)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 28 11:51:57 PDT 2026


andykaylor wrote:

> Sorry seeing this too late. It might be worth to leverage `SymbolTable::generateSymbolName` to generate unique names. At the moment this uses `_` before suffix, might make sense to extend the function API with custom separator, e.g.
> 
> ```
>   static SmallString<N> generateSymbolName(StringRef name,
>                                            UniqueChecker uniqueChecker,
>                                            unsigned &uniquingCounter
>                                            char separator = '_') {
> ```
> 
> Also we might want to use `SymbolTableAnalysis` instead of passing SymbolTableCollection around, this won't polute API, and also can be used for cross pass invalidation/table manipulation etc.

Using `generalSymbolName` could certainly simplify this code, but I'm concerned about the efficiency. If I provide a `uniqueChecker` that jumps through the hoops I have in place to avoid symbol table lookups, I don't see that `generateSymbolName` adds anything. That function itself is just a simple wrapper around the uniqueChecker and counter variable.

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


More information about the cfe-commits mailing list