summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-strip-debug-info.cpp
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2025-01-31 19:27:20 +0200
committerGitHub <noreply@github.com>2025-01-31 09:27:20 -0800
commita026df756096ca580ca9d19019abd08fa5d2c015 (patch)
treec11335fc0834aac4ccfc783b76a539956683b97e /source/slang/slang-ir-strip-debug-info.cpp
parenteebe849075c21d163739cbc5e976e7b5b6837e7f (diff)
Respect per-target debug options (#6193)
* Base compiler options for targets on target-specific compiler options Before this change, the target compiler options were based on the linkage-wide compiler options, which where later again inherited from (basically a no-op). With this change, the target-specific compiler options are added first, and then the linkage-wide comnpiler options are inherited from. * Remove debug instructions if target-specific setting is NONE This helps to address #6092. * Make sure the linkage debug info level is sufficient for each target This closes #6092.
Diffstat (limited to 'source/slang/slang-ir-strip-debug-info.cpp')
-rw-r--r--source/slang/slang-ir-strip-debug-info.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/slang/slang-ir-strip-debug-info.cpp b/source/slang/slang-ir-strip-debug-info.cpp
new file mode 100644
index 000000000..8b2a07663
--- /dev/null
+++ b/source/slang/slang-ir-strip-debug-info.cpp
@@ -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