You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[AMDGPU][LTO] Disable adding AMDGPULowerModuleLDSPass to LTO
This is a workaround to resolve https://ontrack-internal.amd.com/browse/SWDEV-502923
The AMDGPULowerModuleLDS pass is run 2 times. Both times are run on the
combined/linked module for the entire input during LTO.
The first run happens when lto::backend executes the the optimization
pipeline (through calling opt)
(https://github.com/llvm/llvm-project/blob/main/llvm/lib/LTO/LTOBackend.cpp#L551)
and the second run happens when lto::backend later calls
codegen (https://github.com/llvm/llvm-project/blob/main/llvm/lib/LTO/LTOBackend.cpp#L558).
A crash happens in the second run because between the first and second
runs, a new GV is added to the combined module:
```
@llvm.amdgcn.kernel.__omp_offloading_fc00_600030__QQmain_l5.lds = internal addrspace(3) global %llvm.amdgcn.kernel.__omp_offloading_fc00_600030__QQmain_l5.lds.t poison, align 16, !absolute_symbol !0
```
This is the only absolute variable and it is not there yet during the
first run of AMDGPULowerModuleLDS.
In addition to the above absolute variable, we have other GVs that
remain in the combined module (during the second run of the pass):
```
@_ZZ35__kmpc_nvptx_teams_reduce_nowait_v2E14ChunkTeamCount = internal unnamed_addr addrspace(3) global i32 undef, align 4
@_ZZ35__kmpc_nvptx_teams_reduce_nowait_v2E5Bound = internal unnamed_addr addrspace(3) global i32 undef, align 4
```
which are not absolute, causing the issue (https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPUMemoryUtils.cpp#L250).
Disussing this with Jon Chesterfield, running the pass twice is actually
incorrect (it should be run only once during code-gen, the first run of
the pass
creates
"@llvm.amdgcn.kernel.__omp_offloading_fc00_600030__QQmain_l5.lds" which
makes the second run fail). Commenting out these 2 lines "fixes" the
issue:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp#L863-L864.
We raised an issue upstream to further discuss proper fixes:
llvm#122891.
0 commit comments