This is an archive of the discontinued LLVM Phabricator instance.

[amdgpu] Always, instead of mostly, remove unused LDS symbols
ClosedPublic

Authored by JonChesterfield on Aug 31 2022, 8:13 AM.

Details

Summary

Currently LDS variables are removed by the lower module pass
if they have a use which is caught by the replace with struct control flow.
This makes tests brittle to changes to that control flow which induces
noise when trying to improve lowering. Some tests already check that
variables are removed, while others checked that they are not removed.

LDS variables are not (currently) externally accessible, and if that
changes the machinery which makes them externally accessible will look
like a use. This change therefore breaks no applications.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 8:13 AM
JonChesterfield requested review of this revision.Aug 31 2022, 8:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 31 2022, 8:13 AM
jhuber6 added inline comments.Aug 31 2022, 9:19 AM
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
247–253

Nit. formatting.

rampitec added inline comments.Aug 31 2022, 10:31 AM
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
248

It can be a single if and no braces around eraseFromParent. A little more readable.

  • remove braces

I like braces as they make git merge less error prone. Let me know if you want them removed from the for block as well.

  • guess in favour of removing braces

Guessing in the other direction, please let me know if you want the braces put back in for the for.

rampitec accepted this revision.Sep 7 2022, 9:52 AM

LGTM

This revision is now accepted and ready to land.Sep 7 2022, 9:52 AM
This revision was landed with ongoing or failed builds.Sep 7 2022, 10:28 AM
This revision was automatically updated to reflect the committed changes.
foad added a comment.Sep 8 2022, 12:04 AM

Guessing in the other direction, please let me know if you want the braces put back in for the for.

The LLVM rules are complicated -- too complicated in my opinion. In AMDGPU code we usually omit braces if the thing inside them would be a single line.