Skip to content

Commit acf6307

Browse files
committed
Extend parsing for DbgOpDeclare source data : global variable, nop
It is valid for the instruction for the variable to be NoOp
1 parent 7109ef2 commit acf6307

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

renderdoc/driver/shaders/dxil/dxil_disassemble.cpp

+25-6
Original file line numberDiff line numberDiff line change
@@ -6241,14 +6241,33 @@ SourceMappingInfo Program::ParseDbgOpDeclare(const DXIL::Instruction &inst) cons
62416241
SourceMappingInfo ret;
62426242
ret.isDeclare = true;
62436243

6244-
// arg 0 contains the SSA Id of the alloca result which represents the local variable (a pointer)
6244+
// arg 0 contains the SSA Id of the result which represents the local variable (a pointer)
62456245
const Metadata *allocaInstMD = cast<Metadata>(inst.args[0]);
62466246
RDCASSERT(allocaInstMD);
6247-
const Instruction *allocaInst = cast<Instruction>(allocaInstMD->value);
6248-
RDCASSERT(allocaInst);
6249-
RDCASSERTEQUAL(allocaInst->op, Operation::Alloca);
6250-
ret.dbgVarId = Program::GetResultSSAId(*allocaInst);
6251-
Program::MakeResultId(*allocaInst, ret.dbgVarName);
6247+
const DXIL::Value *value = allocaInstMD->value;
6248+
const Instruction *varInst = cast<Instruction>(value);
6249+
if(varInst)
6250+
{
6251+
// Instruction can be alloca or NoOp
6252+
RDCASSERT(varInst->op == Operation::Alloca || varInst->op == Operation::NoOp);
6253+
ret.dbgVarId = Program::GetResultSSAId(*varInst);
6254+
Program::MakeResultId(*varInst, ret.dbgVarName);
6255+
}
6256+
else
6257+
{
6258+
const GlobalVar *gv = cast<GlobalVar>(allocaInstMD->value);
6259+
if(gv)
6260+
{
6261+
ret.dbgVarId = gv->ssaId;
6262+
rdcstr n = DXBC::BasicDemangle(gv->name);
6263+
DXIL::SanitiseName(n);
6264+
ret.dbgVarName = n;
6265+
}
6266+
else
6267+
{
6268+
RDCERR("Unhandled metadata value type %s", ToStr(allocaInstMD->value->kind()).c_str());
6269+
}
6270+
}
62526271

62536272
// arg 1 is DILocalVariable metadata
62546273
const Metadata *localVariableMD = cast<Metadata>(inst.args[1]);

0 commit comments

Comments
 (0)