Commit ce3b639
authored
[Codegen][Tuner] solve name conflicts for merging td specs (iree-org#22409)
**Follow-up fix for:** iree-org#20127
**Fixes:** iree-org#20673,
nod-ai/amd-shark-ai#2440
This issue was discovered while tuning BOO, where the same naming
conflict pattern caused the pass to fail.
## Problem
When a module contains both a conflicting name and a suffixed variant of
that name, the pass could create duplicate names during conflict
resolution.
### Example
```mlir
module { // First module
@apply_op_config
}
module { // Second module
@apply_op_config // conflicts → would rename to @apply_op_config_0
@apply_op_config_0 // but this already exists! → BUG
}
```
The second module's `@apply_op_config` would be renamed to
`@apply_op_config_0`, but that name already exists in the same module,
creating a duplicate.
## Solution
This PR checks the newly generated name against `seenNames` and
increments the numeric suffix until finding a unique name:
- `@apply_op_config` → `@apply_op_config_1` (skipping `_0` since it
exists)
The fix uses a simple numeric suffix scheme (e.g., `_0`, `_1`, `_2`)
instead of module prefixes for cleaner and more maintainable code.
---------
Signed-off-by: Bangtian Liu <[email protected]>1 parent 0e46977 commit ce3b639
File tree
3 files changed
+69
-39
lines changed- compiler
- plugins/target/ROCM/test
- src/iree/compiler/Codegen/Common
- test
3 files changed
+69
-39
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
Lines changed: 13 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 146 | + | |
152 | 147 | | |
153 | 148 | | |
154 | 149 | | |
155 | | - | |
156 | | - | |
| 150 | + | |
157 | 151 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
174 | 157 | | |
175 | 158 | | |
176 | | - | |
177 | | - | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
178 | 162 | | |
179 | 163 | | |
180 | 164 | | |
| |||
187 | 171 | | |
188 | 172 | | |
189 | 173 | | |
190 | | - | |
| 174 | + | |
191 | 175 | | |
192 | 176 | | |
193 | 177 | | |
| |||
236 | 220 | | |
237 | 221 | | |
238 | 222 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 223 | + | |
| 224 | + | |
246 | 225 | | |
247 | 226 | | |
248 | 227 | | |
| |||
Lines changed: 55 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
272 | | - | |
| 271 | + | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
341 | | - | |
342 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
0 commit comments