Fix some minor deltas to dxc's disassembly

This commit is contained in:
baldurk
2023-01-13 18:40:32 +00:00
parent 2f1823aaa2
commit f57a53a59d
3 changed files with 34 additions and 2 deletions
@@ -681,6 +681,7 @@ protected:
bool ParseDebugMetaRecord(const LLVMBC::BlockOrRecord &metaRecord, Metadata &meta);
rdcstr GetDebugVarName(const DIBase *d);
rdcstr GetFunctionScopeName(const DIBase *d);
rdcstr &GetValueSymtabString(const Value &v);
@@ -245,6 +245,33 @@ rdcstr Program::GetDebugVarName(const DIBase *d)
return "???";
}
rdcstr Program::GetFunctionScopeName(const DIBase *d)
{
const Metadata *scope = NULL;
if(d->type == DIBase::LocalVariable)
scope = d->As<DILocalVariable>()->scope;
if(d->type == DIBase::GlobalVariable)
scope = d->As<DIGlobalVariable>()->scope;
while(scope && scope->dwarf)
{
if(scope->dwarf->type == DIBase::Subprogram)
{
const rdcstr *name = scope->dwarf->As<DISubprogram>()->name;
return name ? *name : "";
}
else if(scope->dwarf->type == DIBase::LexicalBlock)
{
scope = scope->dwarf->As<DILexicalBlock>()->scope;
continue;
}
break;
}
return "";
}
rdcstr getOptMetaString(const Metadata *meta)
{
return meta ? escapeString(meta->str).c_str() : "\"\"";
@@ -219,7 +219,7 @@ void Program::MakeDisassemblyString()
"CheckAccessFullyMapped(status)",
"GetDimensions(handle,mipLevel)",
"TextureGather(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,channel)",
"TextureGatherCmp(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,channel,compareVale)",
"TextureGatherCmp(srv,sampler,coord0,coord1,coord2,coord3,offset0,offset1,channel,compareValue)",
"Texture2DMSGetSamplePosition(srv,index)",
"RenderTargetGetSamplePosition(index)",
"RenderTargetGetSampleCount()",
@@ -1263,6 +1263,10 @@ void Program::MakeDisassemblyString()
m_Disassembly += StringFormat::Fmt(
" ; var:%s ", escapeString(GetDebugVarName(inst.args[varIdx].meta->dwarf)).c_str());
m_Disassembly += inst.args[exprIdx].meta->valString();
rdcstr funcName = GetFunctionScopeName(inst.args[varIdx].meta->dwarf);
if(!funcName.empty())
m_Disassembly += StringFormat::Fmt(" func:%s", escapeString(funcName).c_str());
}
}
@@ -1539,7 +1543,7 @@ rdcstr Type::toString() const
else
return StringFormat::Fmt("%s addrspace(%d)*", inner->toString().c_str(), addrSpace);
case Array: return StringFormat::Fmt("[%u x %s]", elemCount, inner->toString().c_str());
case Function: return declFunction(rdcstr(), {}, NULL);
case Function: return declFunction(rdcstr(), {}, NULL) + "*";
case Struct:
{
rdcstr ret;