Handle encoding DXIL bytecode with multiple functions

* After each function we need to reset the IDs of any function-local constants
  since they may be referenced in other functions and need to be given new
  function-local IDs for reference.
This commit is contained in:
baldurk
2024-09-30 11:08:30 +01:00
parent 4c003525b3
commit 9795d8fbb0
@@ -2687,6 +2687,16 @@ void LLVMOrderAccumulator::processFunction(const Function *f)
void LLVMOrderAccumulator::exitFunction()
{
// reset IDs for function constants, so that if they're used in a different function they get a new id
for(size_t i = firstFuncConst; i < firstFuncConst + numFuncConsts; i++)
{
if(cast<Constant>(values[i]))
{
Value *value = (Value *)values[i];
value->id = Value::UnvisitedID;
}
}
values.resize(functionWaterMark);
}