Handle non-void return instructions properly in DXIL

This commit is contained in:
baldurk
2023-02-15 15:45:46 +00:00
parent 953e702e47
commit deeb7fe3eb
2 changed files with 12 additions and 15 deletions
@@ -1293,22 +1293,12 @@ Program::Program(const byte *bytes, size_t length) : alloc(32 * 1024)
}
else if(op.type == FunctionRecord::INST_RET)
{
Instruction *inst = NULL;
// even rets returning a value are still void
Instruction *inst = new(alloc) Instruction;
inst->type = GetVoidType();
if(op.remaining() == 0)
{
inst = new(alloc) Instruction;
inst->type = GetVoidType();
RDCASSERT(inst->type);
}
else
{
inst = values.nextValue<Instruction>();
if(op.remaining() != 0)
inst->args.push_back(op.getSymbol());
inst->type = inst->args.back()->type;
values.addValue();
}
inst->op = Operation::Ret;
@@ -732,7 +732,14 @@ void Program::MakeDisassemblyString()
break;
}
case Operation::Ret: m_Disassembly += "ret " + inst.type->toString(); break;
case Operation::Ret:
{
if(inst.args.empty())
m_Disassembly += "ret " + inst.type->toString();
else
m_Disassembly += "ret " + argToString(inst.args[0], true);
break;
}
case Operation::Unreachable: m_Disassembly += "unreachable"; break;
case Operation::Alloca:
{