This is an archive of the discontinued LLVM Phabricator instance.

[SPIR-V] Introduce SPIR-V global entities tracking and deduplication infra.
ClosedPublic

Authored by zuban32 on Jun 23 2022, 3:11 PM.

Details

Summary

SPIR-V module typically contains some global entities that were not
global before made it to SPIR-V, e.g. types and constants are not usually
declared globally in LLVM. By design SPIR-V requires such stuff to be declared
once and in the module's global section. Since MIR is not able to represent
such things properly they were generated per-function, and then at the very end
of the backend's pipeline hoisted into some 'meta' function minding possible
duplicates.

New SPIRVDuplicatesTracker keeps mapping of the original LLVM entities such
as types, constant, global variables, etc to their MIR counterparts -
(MachineFunction, Register). Later SPIRVModuleAnalysis (apart from other
thing it's responsible for) performs topological sorting of the
tracker's entries to ensure proper ordering before the hoisting,
and actually performs the hoisting in a duplicates-free manner
by the tracker's nature.

Diff Detail

Event Timeline

zuban32 created this revision.Jun 23 2022, 3:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 3:11 PM
zuban32 requested review of this revision.Jun 23 2022, 3:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2022, 3:11 PM

LGTM.
It might be worth adding two passed LIT tests (transcoding/RelationalOperators.ll transcoding/fcmp.ll) that demonstrate the work of this patch.

iliya-diyachkov accepted this revision.Jun 29 2022, 3:33 AM
This revision is now accepted and ready to land.Jun 29 2022, 3:33 AM
zuban32 updated this revision to Diff 441910.Jul 2 2022, 4:30 PM

Fix potential failure, add 2 newly passed LITs

zuban32 updated this revision to Diff 441912.Jul 2 2022, 4:56 PM
  • Fix potential failure, add 2 newly passed LITs
zuban32 added a comment.EditedJul 2 2022, 4:59 PM

@iliya-diyachkov FYI there're 6 more passing tests which are not upstreamed yet, but I've not added them here since they're irrelevant to the current changes

iliya-diyachkov accepted this revision.Jul 3 2022, 3:20 PM

@iliya-diyachkov FYI there're 6 more passing tests which are not upstreamed yet, but I've not added them here since they're irrelevant to the current changes

Ok, these tests can be added later along with next new passed tests. I suppose you can commit this patch.

This revision was landed with ongoing or failed builds.Jul 7 2022, 8:15 AM
This revision was automatically updated to reflect the committed changes.