From 147ceb1991454b7a5ba6f3ec0c149dd40360a31d Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Thu, 14 Nov 2024 12:06:17 -0500 Subject: Fix issue with raw default constructors in SPIRV emit (#5556) --- source/slang/slang-ir-strip-default-construct.cpp | 45 +++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 source/slang/slang-ir-strip-default-construct.cpp (limited to 'source/slang/slang-ir-strip-default-construct.cpp') 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( + kIROp_DefaultConstruct, + [&](IRDefaultConstruct* defaultConstruct) + { + List instsToRemove; + for (auto use = defaultConstruct->firstUse; use; use = use->nextUse) + { + if (as(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 -- cgit v1.2.3