This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Lazily init pal metadata on first function
ClosedPublic

Authored by sebastian-ne on Jan 28 2022, 10:03 AM.

Details

Summary

Delay reading global metadata until the first function or the end of
the file is emitted. That way, earlier module passes can set metadata
that is emitted in the ELF.

emitStartOfAsmFile gets called when the passes are initialized,
which prevented earlier passes from changing the metadata.

This fixes issues encountered after converting
AMDGPUResourceUsageAnalysis to a Module pass in D117504.

Diff Detail

Event Timeline

sebastian-ne created this revision.Jan 28 2022, 10:03 AM
sebastian-ne requested review of this revision.Jan 28 2022, 10:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 28 2022, 10:03 AM
arsenm added inline comments.Jan 31 2022, 2:55 PM
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
450–451

This feels like an abuse of the pass manager. You're not supposed to depend on passes on other functions from a function pass. What pass is setting this metadata? Is it a module pass?

sebastian-ne added inline comments.Feb 1 2022, 1:29 AM
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
450–451

A module pass is setting the metadata.
emitStartOfAsmFile is called before the module pass is run (when AMDGPUResourceUsageAnalysis is a ModulePass, it works fine with the current main state for some reason).

arsenm accepted this revision.Feb 1 2022, 5:30 PM

LGTM. Apparently emitStartOfAsmFile is called as part of AsmPrinter's doInitialization

This revision is now accepted and ready to land.Feb 1 2022, 5:30 PM
This revision was landed with ongoing or failed builds.Feb 4 2022, 9:41 AM
This revision was automatically updated to reflect the committed changes.