From 6eed618909571ee525cb5217665f8555d7c5a0a7 Mon Sep 17 00:00:00 2001 From: Jade Abraham Date: Mon, 16 Dec 2024 10:59:02 -0800 Subject: [PATCH] prevent dead stores due to heapify pass Signed-off-by: Jade Abraham --- compiler/passes/parallel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/passes/parallel.cpp b/compiler/passes/parallel.cpp index 8016b9b611f7..7f32482485e7 100644 --- a/compiler/passes/parallel.cpp +++ b/compiler/passes/parallel.cpp @@ -1145,6 +1145,12 @@ makeHeapAllocations() { call->getStmtExpr()->insertBefore(new DefExpr(tmp)); call->getStmtExpr()->insertBefore(new CallExpr(PRIM_MOVE, tmp, new CallExpr(PRIM_GET_MEMBER_VALUE, use->symbol(), heapType->getField(1)))); use->replace(new SymExpr(tmp)); + if (call-isPrimitive(PRIM_ZERO_VARIABLE)) { + // aftering zeroing the value, we need to set it back + // otherwise its a dead store + call->getStmtExpr()->insertAfter( + new CallExpr(PRIM_SET_MEMBER, use->symbol(), heapType->getField(1), tmp)); + } } } else if (use->parentExpr) INT_FATAL(var, "unexpected case");