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.
This commit is contained in:
Ryan Houdek committed 2020-09-22 18:20:32 -07:00
1 parent bad3b7da0c
commit adb9b111ca
1 file changed
+10 -2
+10 -2
View File
@@ -70,10 +70,14 @@ static void PrintArg(std::stringstream *out, IRListView<false> 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<false> 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);