blob: ea141d2fd048a1f0700975f06a4f18908c6f93b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
|