/* * Insert asserts at various points in the IR. * TODO: t2137231 Insert DbgAssertPtr at points that use or produces a GenPtr */ static void insertAsserts(IRTrace* trace, IRFactory& factory) { forEachTraceBlock(trace, [&](Block* block) { for (auto it = block->begin(), end = block->end(); it != end; ) { IRInstruction& inst = *it; ++it; if (inst.op() == SpillStack) { insertSpillStackAsserts(inst, factory); continue; } if (inst.op() == Call) { SSATmp* sp = inst.dst(); IRInstruction* addr = factory.gen(LdStackAddr, inst.marker(), Type::PtrToGen, StackOffset(0), sp); insertAfter(&inst, addr); insertAfter(addr, factory.gen(DbgAssertPtr, inst.marker(), addr->dst())); continue; } if (!inst.isBlockEnd()) insertRefCountAsserts(inst, factory); } }); }
/* * Insert asserts at various points in the IR. * TODO: t2137231 Insert DbgAssertPtr at points that use or produces a GenPtr */ static void insertAsserts(Trace* trace, IRFactory* factory) { forEachTraceBlock(trace, [=](Block* block) { for (auto it = block->begin(), end = block->end(); it != end; ) { IRInstruction& inst = *it; ++it; if (inst.getOpcode() == SpillStack) { insertSpillStackAsserts(inst, factory); continue; } if (inst.getOpcode() == Call) { SSATmp* sp = inst.getDst(); IRInstruction* addr = factory->gen(LdStackAddr, sp, factory->defConst(0)); insertAfter(&inst, addr); insertAfter(addr, factory->gen(DbgAssertPtr, addr->getDst())); continue; } if (!inst.isBlockEnd()) insertRefCountAsserts(inst, factory); } }); }
/* * Insert asserts at various points in the IR. * TODO: t2137231 Insert DbgAssertPtr at points that use or produces a GenPtr */ static void insertAsserts(IRUnit& unit) { postorderWalk(unit, [&](Block* block) { for (auto it = block->begin(), end = block->end(); it != end; ) { IRInstruction& inst = *it; ++it; if (inst.op() == SpillStack) { insertSpillStackAsserts(inst, unit); continue; } if (inst.op() == Call) { SSATmp* sp = inst.dst(); IRInstruction* addr = unit.gen(LdStackAddr, inst.marker(), Type::PtrToGen, StackOffset(0), sp); insertAfter(&inst, addr); insertAfter(addr, unit.gen(DbgAssertPtr, inst.marker(), addr->dst())); continue; } if (!inst.isBlockEnd()) insertRefCountAsserts(inst, unit); } }); }