This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Ignore call graph node which does not have function info.
ClosedPublic

Authored by hsmhsm on Aug 3 2021, 1:48 AM.

Details

Summary

While collecting reachable callees (from kernels), ignore call graph node which
does not have associated function or associated function is not a definition.

Diff Detail

Event Timeline

hsmhsm created this revision.Aug 3 2021, 1:48 AM
hsmhsm requested review of this revision.Aug 3 2021, 1:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2021, 1:48 AM
foad added inline comments.Aug 3 2021, 4:55 AM
llvm/test/CodeGen/AMDGPU/replace-lds-by-ptr-call-to-declare-only-func.ll
2

Surely you don't need -amdgpu-enable-lds-replace-with-pointer=true here.

hsmhsm marked an inline comment as done.Aug 3 2021, 7:08 AM
hsmhsm added inline comments.
llvm/test/CodeGen/AMDGPU/replace-lds-by-ptr-call-to-declare-only-func.ll
2

Correct, but now the pass is disabled (off by default) because of the two openmp issues reported. Please refer https://reviews.llvm.org/D104962.

rampitec added inline comments.Aug 3 2021, 11:06 AM
llvm/lib/Target/AMDGPU/Utils/AMDGPULDSUtils.cpp
73

What will happen if we have a call to a real function, but bitcasted/aliased? getFunction() will return nullptr, but the function is still reachable.

hsmhsm marked 2 inline comments as done.Aug 3 2021, 8:04 PM
hsmhsm added inline comments.
llvm/lib/Target/AMDGPU/Utils/AMDGPULDSUtils.cpp
73

We have not yet handled bitcasted/aliased function pointers. We have planned it as a separate patch. We definetely need to relook into it at that point. But, for now, this check is essentailly required. This is the root cause behind the openmp compile time issue reported at https://reviews.llvm.org/D103225.

rampitec added inline comments.Aug 3 2021, 8:46 PM
llvm/lib/Target/AMDGPU/Utils/AMDGPULDSUtils.cpp
73

I understand. But is it safe if we have a bitcast and you reenable the pass?

hsmhsm marked 2 inline comments as done.Aug 3 2021, 8:53 PM
hsmhsm added inline comments.
llvm/lib/Target/AMDGPU/Utils/AMDGPULDSUtils.cpp
73

If we have bitcast, then this pass will not reach those bitcasted functions. So, it will not replace any LDS used within those functions. Then LDS lowering pass will directly pack those LDS into a module struct which possibly results in unoptimized use of LDS but the program is safe.

rampitec accepted this revision.Aug 3 2021, 8:55 PM

LGTM

llvm/lib/Target/AMDGPU/Utils/AMDGPULDSUtils.cpp
73

OK, this is conservatively correct but suboptimal. That is what I wanted to know.

This revision is now accepted and ready to land.Aug 3 2021, 8:55 PM
This revision was automatically updated to reflect the committed changes.
hsmhsm marked an inline comment as done.