[clang] [lld] [llvm] [ThinLTO] Reduce the number of renaming due to promotions (PR #178587)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 15 12:19:11 PST 2026
yonghong-song wrote:
@teresajohnson Just uploaded another revision. Major changes are to rename RenameOnPromotion to NotRenameONPromotion and default of NotRenameOnPromotion is false (doing rename on promotion true by default). This is for distributed ThinLTO since for distributed ThinLTO, the GV summaries will be saved in ThinLTO before the ThinLTOBackend and restored in ThinLTOBackend. In this case, we need to preserve the NotRenameOnPromotion value.
But unfortunately my current implementation does not work for distributed thinLTO.
Compare
```
llvm/test/ThinLTO/X86/reduce-promotion-same-local-name.ll
```
and
```
llvm/test/ThinLTO/X86/reduce-promotion-same-local-name-distributed.ll
```
The test reduce-promotion-same-local-name-distributed.ll is not working. The reason is
```
$ llvm-dis a.bc.thinlto.bc -o -
; ModuleID = 'a.bc.thinlto.bc'
source_filename = "a.bc.thinlto.bc"
^0 = module: (path: "a.bc", hash: (660090884, 3143855212, 3403690426, 569036544, 3527848429))
^1 = module: (path: "b.bc", hash: (3844350569, 1286968882, 1839731117, 2253963201, 2649961830))
^2 = gv: (guid: 402851794460930730, summaries: (function: (module: ^1, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition, notRenameOnPromotion: 0), insts: 5)))
^3 = gv: (guid: 2051336639867817221, summaries: (function: (module: ^0, flags: (linkage: internal, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition, notRenameOnPromotion: 0), insts: 3, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0))))
^4 = gv: (guid: 14574395900695837614, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition, notRenameOnPromotion: 0), insts: 5, calls: ((callee: ^3, tail: 1), (callee: ^2, tail: 1)))))
^5 = flags: 1249
^6 = blockcount: 0
$ llvm-dis b.bc.thinlto.bc -o -
; ModuleID = 'b.bc.thinlto.bc'
source_filename = "b.bc.thinlto.bc"
^0 = module: (path: "b.bc", hash: (3844350569, 1286968882, 1839731117, 2253963201, 2649961830))
^1 = gv: (guid: 402851794460930730, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition, notRenameOnPromotion: 0), insts: 5, calls: ((callee: ^2, tail: 1)))))
^2 = gv: (guid: 12472750527131441673, summaries: (function: (module: ^0, flags: (linkage: available_externally, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0, importType: definition, notRenameOnPromotion: 1), insts: 3, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 1, alwaysInline: 0, noUnwind: 0, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0))))
^3 = flags: 1249
^4 = blockcount: 0
```
In distributed mode, the index for each file is constructed in the above.
See b.bc.thinlto.bc, function 'foo' has notRenameOnPromotion = 1, so no promotion.
But in a.bc.thinlto.bc, there is no function 'foo'. The function-import pass cannot find a summary for it.
So in a.bc.thinlto.bc, function 'foo' will be promoted.
This caused the problem.
To fix the problem, we should add 'foo' summary (in module b.bc.thinlto.bc) to a..bc.thinlto.bc. But not sure exactly where we should do it?
https://github.com/llvm/llvm-project/pull/178587
More information about the cfe-commits
mailing list