summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-propagate-func-properties.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-13 18:35:42 -0700
committerGitHub <noreply@github.com>2024-03-13 18:35:42 -0700
commite4b01c4ba53c40ff0704e72615422e5a96f636e3 (patch)
treee339f84d7dba74d26e22cde9a296d8cd78d24bb7 /source/slang/slang-ir-propagate-func-properties.cpp
parent25df6b868c2af58435bbd09d89e64d77bea87bc7 (diff)
Fix side effect checking around storage buffer type. (#3762)
Diffstat (limited to 'source/slang/slang-ir-propagate-func-properties.cpp')
-rw-r--r--source/slang/slang-ir-propagate-func-properties.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/source/slang/slang-ir-propagate-func-properties.cpp b/source/slang/slang-ir-propagate-func-properties.cpp
index f186a3a57..c5e8712f1 100644
--- a/source/slang/slang-ir-propagate-func-properties.cpp
+++ b/source/slang/slang-ir-propagate-func-properties.cpp
@@ -11,6 +11,7 @@ class FuncPropertyPropagationContext
{
public:
virtual bool canProcess(IRFunc* f) = 0;
+ virtual bool isInitialFunc(IRFunc* f) = 0;
virtual bool propagate(IRBuilder& builder, IRFunc* func) = 0;
};
@@ -53,6 +54,19 @@ static bool isKnownOpCodeWithSideEffect(IROp op)
class ReadNoneFuncPropertyPropagationContext : public FuncPropertyPropagationContext
{
public:
+ virtual bool isInitialFunc(IRFunc* f) override
+ {
+ // If the func has already been marked with any decorations, skip.
+ for (auto decoration : f->getDecorations())
+ {
+ switch (decoration->getOp())
+ {
+ case kIROp_ReadNoneDecoration:
+ return true;
+ }
+ }
+ return false;
+ }
virtual bool canProcess(IRFunc* f) override
{
// If the func has already been marked with any decorations, skip.
@@ -193,7 +207,7 @@ bool propagateFuncPropertiesImpl(IRModule* module, FuncPropertyPropagationContex
}
if (auto func = as<IRFunc>(inst))
{
- if (context->canProcess(func))
+ if (context->isInitialFunc(func))
{
addCallersToWorkList(func);
}
@@ -257,7 +271,20 @@ public:
}
return true;
}
-
+ virtual bool isInitialFunc(IRFunc* f) override
+ {
+ // If the func has already been marked with any decorations, skip.
+ for (auto decoration : f->getDecorations())
+ {
+ switch (decoration->getOp())
+ {
+ case kIROp_ReadNoneDecoration:
+ case kIROp_NoSideEffectDecoration:
+ return true;
+ }
+ }
+ return false;
+ }
virtual bool propagate(IRBuilder& builder, IRFunc* f) override
{
bool hasSideEffectCall = false;