-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with raw default constructors in SPIRV emit (#5556)
- Loading branch information
1 parent
e58ba6b
commit 147ceb1
Showing
4 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// slang-ir-strip-default-construct.h | ||
#pragma once | ||
|
||
namespace Slang | ||
{ | ||
struct IRModule; | ||
|
||
/// Strip the contents of all witness table instructions from the given IR `module` | ||
void removeRawDefaultConstructors(IRModule* module); | ||
|
||
} // namespace Slang |