summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-single-return.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-05-25 23:39:30 -0700
committerGitHub <noreply@github.com>2023-05-26 06:39:30 +0000
commitab284ca61d0c4c29ac7331b99a98f95bb3ad44e5 (patch)
tree761c50913404ee5bf0b827db781f75173c6c123a /source/slang/slang-ir-single-return.cpp
parentf88e1299b7715190ce82f3f4473f0d0eeaa2000e (diff)
Fix bug in legalizeFuncType that leads to invalid IR. (#2902)
* Fix bug in legalizeFuncType that leads to invalid IR. * Diagnose on functions that never returns when differentiate it. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-single-return.cpp')
-rw-r--r--source/slang/slang-ir-single-return.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/source/slang/slang-ir-single-return.cpp b/source/slang/slang-ir-single-return.cpp
index 10d8972bc..0b61e5065 100644
--- a/source/slang/slang-ir-single-return.cpp
+++ b/source/slang/slang-ir-single-return.cpp
@@ -89,7 +89,7 @@ void convertFuncToSingleReturnForm(IRModule* irModule, IRGlobalValueWithCode* fu
context.processFunc(func);
}
-bool isSingleReturnFunc(IRGlobalValueWithCode* func)
+int getReturnCount(IRGlobalValueWithCode* func)
{
int returnCount = 0;
for (auto block : func->getBlocks())
@@ -102,7 +102,12 @@ bool isSingleReturnFunc(IRGlobalValueWithCode* func)
}
}
}
- return returnCount <= 1;
+ return returnCount;
+}
+
+bool isSingleReturnFunc(IRGlobalValueWithCode* func)
+{
+ return getReturnCount(func) == 1;
}
} // namespace Slang