summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit.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-emit.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-emit.cpp')
-rw-r--r--source/slang/slang-emit.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp
index d8594ffdd..70521c7ee 100644
--- a/source/slang/slang-emit.cpp
+++ b/source/slang/slang-emit.cpp
@@ -94,6 +94,7 @@
#include "slang-ir-ssa-simplification.h"
#include "slang-ir-ssa.h"
#include "slang-ir-string-hash.h"
+#include "slang-ir-strip-debug-info.h"
#include "slang-ir-strip-default-construct.h"
#include "slang-ir-strip-legalization-insts.h"
#include "slang-ir-synthesize-active-mask.h"
@@ -301,6 +302,7 @@ struct LinkingAndOptimizationOptions
//
struct RequiredLoweringPassSet
{
+ bool debugInfo;
bool resultType;
bool optionalType;
bool combinedTextureSamplers;
@@ -332,6 +334,13 @@ void calcRequiredLoweringPassSet(
{
switch (inst->getOp())
{
+ case kIROp_DebugValue:
+ case kIROp_DebugVar:
+ case kIROp_DebugLine:
+ case kIROp_DebugLocationDecoration:
+ case kIROp_DebugSource:
+ result.debugInfo = true;
+ break;
case kIROp_ResultType:
result.resultType = true;
break;
@@ -584,6 +593,7 @@ Result linkAndOptimizeIR(
auto target = codeGenContext->getTargetFormat();
auto targetRequest = codeGenContext->getTargetReq();
auto targetProgram = codeGenContext->getTargetProgram();
+ auto targetCompilerOptions = targetRequest->getOptionSet();
// Get the artifact desc for the target
const auto artifactDesc = ArtifactDescUtil::makeDescForCompileTarget(asExternal(target));
@@ -615,6 +625,13 @@ Result linkAndOptimizeIR(
RequiredLoweringPassSet requiredLoweringPassSet = {};
calcRequiredLoweringPassSet(requiredLoweringPassSet, codeGenContext, irModule->getModuleInst());
+ // Debug info is added by the front-end, and therefore needs to be stripped out by targets that
+ // opt out of debug info.
+ if (requiredLoweringPassSet.debugInfo &&
+ (targetCompilerOptions.getIntOption(CompilerOptionName::DebugInformation) ==
+ SLANG_DEBUG_INFO_LEVEL_NONE))
+ stripDebugInfo(irModule);
+
if (!isKhronosTarget(targetRequest) && requiredLoweringPassSet.glslSSBO)
lowerGLSLShaderStorageBufferObjectsToStructuredBuffers(irModule, sink);