diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2022-05-05 12:30:10 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-05 09:30:10 -0700 |
| commit | aa03cea0da38b2950e6f8694dc8b1405352eda66 (patch) | |
| tree | 755b275d7556fb48c40550603421e3483e26b24c /source/slang/slang-ir-liveness.cpp | |
| parent | e3e0132743ada1569cefe18bfbf54178330204c4 (diff) | |
Output SPIR-V lifetimes (#2221)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP tracking liveness.
* Skeleton around adding liveness instructions.
* Calling into liveness tracking logic.
Adds live start to var insts.
* Liveness macros have initial output.
* Looking at different initialization scenarios.
* Some discussion around liveness.
* WIP for working out liveness end.
* WIP Updated liveness using use lists.
* Is now adding liveness information
* Some small fixes.
* WIP around liveness.
* Seems to output liveness correctly for current scenario.
* Tidy up liveness code.
* Update comment arounds liveness to current status.
* Small fixes to liveness test.
* Add support for call in liveness analysis.
* Improve liveness example with array access.
* Small updates to comments.
* Disable liveness test because inconsistencies with output on CI system.
* First pass support for GLSL SPIR-V liveness support.
* Add the SPIRVOpDecoration.
* Fix signature for OpLivenessStop.
* Simplified by having a Kind type.
* Fix some issues brought up in PR.
* Rename liveness instructions.
* Merge with var-lifetime.
Small improvements.
* Improvements to the documentation/naming in GLSL liveness pass.
Add comment around possible improvements to the liveness pass.
Diffstat (limited to 'source/slang/slang-ir-liveness.cpp')
| -rw-r--r-- | source/slang/slang-ir-liveness.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/source/slang/slang-ir-liveness.cpp b/source/slang/slang-ir-liveness.cpp index 3d1626691..7667a33f0 100644 --- a/source/slang/slang-ir-liveness.cpp +++ b/source/slang/slang-ir-liveness.cpp @@ -83,6 +83,23 @@ is created that is then just copied into the variable. That temporary being some could perhaps have liveness issues. */ +/* This implementation could potentially be improved in a few ways: + +## Use Dominator tree block indexing + +The dominator tree has a mapping from block insts to integer values. These integer value could be used to allow information about blocks to +be stored in an array. A downside, would be exposing that aspect of the implementation to the dominator tree. + +## Store if a block has an access instruction + +As it stands, when traversing the tree to find the last access, the implementation searches for each block backwards to find the last access +by looking if it's in the m_accessSet. + +This searching could be avoided, by when accesses are added the block they are in is marked as having an access. If a block had no accesses +this would remove the linear search for the first access instruction, if the block indicates it doesn't have any. The downside being that every +access would also have to mark the block it is in. +*/ + namespace { // anonymous struct LivenessContext @@ -118,9 +135,6 @@ struct LivenessContext /// Process a 'root'. A variable that has liveness tracking void processRoot(const RootInfo& rootInfo); - /// Process a function in the module - void processFunction(IRFunc* funcInst); - /// Process the module void processModule(); @@ -131,6 +145,9 @@ struct LivenessContext m_builder.init(m_sharedBuilder); } + /// Process a function in the module + void _processFunction(IRFunc* funcInst); + // Add a live end instruction at the start of block, referencing the root 'root'. void _addLiveRangeEndAtBlockStart(IRBlock* block, IRInst* root); @@ -463,7 +480,7 @@ void LivenessContext::processRoot(const RootInfo& rootInfo) } } -void LivenessContext::processFunction(IRFunc* funcInst) +void LivenessContext::_processFunction(IRFunc* funcInst) { List<RootInfo> rootInfos; @@ -508,14 +525,14 @@ void LivenessContext::processModule() IRModuleInst* moduleInst = m_module->getModuleInst(); - for (IRInst* child = moduleInst->getFirstDecorationOrChild(); child; child = child->getNextInst()) + for (IRInst* child : moduleInst->getChildren()) { // We want to find all of the functions, and process them if (auto funcInst = as<IRFunc>(child)) { // Then we want to look through their definition // inserting instructions that mark the liveness start/end - processFunction(funcInst); + _processFunction(funcInst); } } } |
