From a026df756096ca580ca9d19019abd08fa5d2c015 Mon Sep 17 00:00:00 2001 From: Anders Leino Date: Fri, 31 Jan 2025 19:27:20 +0200 Subject: 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. --- source/slang/slang-ir-strip-debug-info.cpp | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 source/slang/slang-ir-strip-debug-info.cpp (limited to 'source/slang/slang-ir-strip-debug-info.cpp') 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& 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 debugInstructions; + findDebugInfo(irModule->getModuleInst(), debugInstructions); + for (auto debugInst : debugInstructions) + debugInst->removeAndDeallocate(); +} +} // namespace Slang -- cgit v1.2.3