summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-liveness.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir-liveness.cpp')
-rw-r--r--source/slang/slang-ir-liveness.cpp29
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);
}
}
}