forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove debug instructions if target-specific setting is NONE
This helps to address shader-slang#6092.
- Loading branch information
Showing
3 changed files
with
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "slang-ir-strip-debug-info.h" | ||
|
||
#include "slang-ir-insts.h" | ||
|
||
namespace Slang | ||
{ | ||
static void findDebugInfo(IRInst* inst, List<IRInst*>& debugInstructions) | ||
{ | ||
switch (inst->getOp()) | ||
{ | ||
case kIROp_DebugValue: | ||
case kIROp_DebugVar: | ||
case kIROp_DebugLine: | ||
case kIROp_DebugLocationDecoration: | ||
case kIROp_DebugSource: | ||
debugInstructions.add(inst); | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
for (auto child : inst->getChildren()) | ||
findDebugInfo(child, debugInstructions); | ||
} | ||
|
||
void stripDebugInfo(IRModule* irModule) | ||
{ | ||
List<IRInst*> debugInstructions; | ||
findDebugInfo(irModule->getModuleInst(), debugInstructions); | ||
for (auto debugInst : debugInstructions) | ||
debugInst->removeAndDeallocate(); | ||
} | ||
} // 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,9 @@ | ||
#pragma once | ||
|
||
namespace Slang | ||
{ | ||
struct IRModule; | ||
|
||
/// Strip all debug info instructions from `irModule` | ||
void stripDebugInfo(IRModule* irModule); | ||
} // namespace Slang |