From adb9b111ca4e5deed7cdfb5a107bd48e9e635bad Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 22 Sep 2020 18:20:32 -0700 Subject: [PATCH] Fixes crash when SSA value has size of zero In the case of an invalid SSA destination size, the IR validation pass would catch it and then when printing the IR it would crash with a divide by zero. Fixes that. --- External/FEXCore/Source/Interface/IR/IR.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/External/FEXCore/Source/Interface/IR/IR.cpp b/External/FEXCore/Source/Interface/IR/IR.cpp index 8fffc6e0a..ac1dc5415 100644 --- a/External/FEXCore/Source/Interface/IR/IR.cpp +++ b/External/FEXCore/Source/Interface/IR/IR.cpp @@ -70,10 +70,14 @@ static void PrintArg(std::stringstream *out, IRListView const* IR, Ordere if (IROp->HasDest) { uint32_t ElementSize = IROp->ElementSize; + uint32_t NumElements = IROp->Size; if (!IROp->ElementSize) { ElementSize = IROp->Size; } - uint32_t NumElements = IROp->Size / ElementSize; + + if (ElementSize) { + NumElements /= ElementSize; + } *out << " i" << std::dec << (ElementSize * 8); @@ -153,10 +157,14 @@ void Dump(std::stringstream *out, IRListView const* IR, IR::RegisterAlloc if (IROp->HasDest) { uint32_t ElementSize = IROp->ElementSize; + uint32_t NumElements = IROp->Size; if (!IROp->ElementSize) { ElementSize = IROp->Size; } - uint32_t NumElements = IROp->Size / ElementSize; + + if (ElementSize) { + NumElements /= ElementSize; + } *out << "%ssa" << std::to_string(ID);