[PATCH] D128471: [SPIR-V] Introduce SPIR-V global entities tracking and deduplication infra.

Aleksandr Bezzubikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 15:11:37 PDT 2022


zuban32 created this revision.
Herald added subscribers: ThomasRaoux, hiraditya, mgorny.
Herald added a project: All.
zuban32 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128471

Files:
  llvm/lib/Target/SPIRV/CMakeLists.txt
  llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
  llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.cpp
  llvm/lib/Target/SPIRV/SPIRVDuplicatesTracker.h
  llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
  llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h
  llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
  llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
  llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128471.439546.patch
Type: text/x-patch
Size: 28218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220623/ffc08c3f/attachment.bin>


More information about the llvm-commits mailing list