llvm / llvm/llvm-project

SPIRVGlobalRegistry should not be owned by the subtarget

Open
#223,774 0 comments 0 reactions 0 assignees View on GitHub
backend:SPIR-V
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.