DebugInfoManager::ConvertDebugGlobalToLocalVariable
incorrectly converts a debug global variable to a debug local variable.
#5776
Labels
Summary
Hey all,
I believe this code in
DebugInfoManager::ConvertDebugGlobalToLocalVariable
incorrectly handles converting the operands fromDebugGlobalVariable
toDebugLocalVariable
.SPIRV-Tools/source/opt/debug_info_manager.cpp
Lines 775 to 778 in edc6895
NumInOperands
(typically returning 11) only represents the input operands count butkDebugLocalVariableOperandFlagsIndex
is written in absolute operands (10).Additionally, I think we want
i > kDebugLocalVariableOperandFlagsIndex
noti >= kDebugLocalVariableOperandFlagsIndex
since we don't want to erase the flags operand.I believe the correct code should look similar to:
Repro Steps
I've included an example case using Shaderplayground and DXC:
https://shader-playground.timjones.io/b7f995367a738273718f6813ec847b8e
%37 = OpExtInst %void %1 DebugLocalVariable %14 %17 %23 %uint_6 %uint_20 %24 %uint_8 %uint_8
Notice that
%37
represents the globalPi
but notice theargs
operand is set to%uint_8
even though this is a global and not the 8th argument in a function.When we disable optimizations we see the original variable declaration before the conversion.
https://shader-playground.timjones.io/c9f52e4e48b2de44f65e185b3e800a78
%48 = OpExtInst %void %1 DebugGlobalVariable %47 %19 %24 %uint_6 %uint_20 %25 %47 %Pi %uint_8
Conclusion
Hopefully this provides the information necessary. Let me know if there's anything else I can do to help.
Apologies for not directly submitting a patch. I don't have the appropriate testing environment set up.
The text was updated successfully, but these errors were encountered: