SPIRVGlobalRegistry should not be owned by the subtarget
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
SPIRVGlobalRegistry is owned by the subtarget, and created in the SPIRVSubtarget constructor. The global registry depends on program state, so this is inappropriate. The subtarget is a universal constant that cannot depend on specific IR. A single TargetMachine may be reused for multiple compiles with the same constant TargetSubtargetInfo instances.
This also makes the constructor dependent on TargetMachine::createDataLayout to pass to the constructor.
This needs to be moved somewhere else, like a proper Module analysis pass
Contributor guide
Research direction
Start by tracing SPIRVGlobalRegistry creation in the SPIRVSubtarget constructor and the TargetMachine::createDataLayout dependency. Review how a Module analysis pass could own program-specific state while TargetSubtargetInfo remains reusable across compilations. Done means the registry is no longer owned by the subtarget and the constructor no longer requires this data-layout setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100