summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-strip-default-construct.cpp
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2024-11-14 12:06:17 -0500
committerGitHub <noreply@github.com>2024-11-14 12:06:17 -0500
commit147ceb1991454b7a5ba6f3ec0c149dd40360a31d (patch)
treef290109f71a4cca9337537ddb42a58ba1fcd6d94 /source/slang/slang-ir-strip-default-construct.cpp
parente58ba6b23cb3ee04d69452bfe7e1f8274956ce7d (diff)
Fix issue with raw default constructors in SPIRV emit (#5556)
Diffstat (limited to 'source/slang/slang-ir-strip-default-construct.cpp')
-rw-r--r--source/slang/slang-ir-strip-default-construct.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/source/slang/slang-ir-strip-default-construct.cpp b/source/slang/slang-ir-strip-default-construct.cpp
new file mode 100644
index 000000000..ea141d2fd
--- /dev/null
+++ b/source/slang/slang-ir-strip-default-construct.cpp
@@ -0,0 +1,45 @@
+// slang-ir-strip-default-construct.cpp
+#include "slang-ir-strip-default-construct.h"
+
+#include "slang-ir-inst-pass-base.h"
+#include "slang-ir-insts.h"
+#include "slang-ir.h"
+
+namespace Slang
+{
+
+struct RemoveDefaultConstructInsts : InstPassBase
+{
+ RemoveDefaultConstructInsts(IRModule* module)
+ : InstPassBase(module)
+ {
+ }
+ void processModule()
+ {
+ processInstsOfType<IRDefaultConstruct>(
+ kIROp_DefaultConstruct,
+ [&](IRDefaultConstruct* defaultConstruct)
+ {
+ List<IRInst*> instsToRemove;
+ for (auto use = defaultConstruct->firstUse; use; use = use->nextUse)
+ {
+ if (as<IRStore>(use->getUser()))
+ instsToRemove.add(use->getUser());
+ else
+ return; // Ignore this inst if there are non-store uses.
+ }
+
+ for (auto inst : instsToRemove)
+ inst->removeAndDeallocate();
+
+ defaultConstruct->removeAndDeallocate();
+ });
+ }
+};
+
+void removeRawDefaultConstructors(IRModule* module)
+{
+ RemoveDefaultConstructInsts(module).processModule();
+}
+
+} // namespace Slang