Exemplo n.º 1
0
/*
 * 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);
    }
  });
}
Exemplo n.º 2
0
/*
 * 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);
    }
  });
}
Exemplo n.º 3
0
void optimizeTrace(Trace* trace, IRFactory* irFactory) {
    if (RuntimeOption::EvalHHIRMemOpt) {
        optimizeMemoryAccesses(trace, irFactory);
        if (RuntimeOption::EvalDumpIR > 5) {
            std::cout << "----- HHIR after MemElim -----\n";
            trace->print(std::cout, false);
            std::cout << "---------------------------\n";
        }
    }
    if (RuntimeOption::EvalHHIRDeadCodeElim) {
        eliminateDeadCode(trace, irFactory);
        optimizeJumps(trace, irFactory);
        if (RuntimeOption::EvalDumpIR > 5) {
            std::cout << "----- HHIR after DCE -----\n";
            trace->print(std::cout, false);
            std::cout << "---------------------------\n";
        }
    }
    if (RuntimeOption::EvalHHIRGenerateAsserts) {
        insertRefCountAsserts(trace, irFactory);
    }
}
Exemplo n.º 4
0
/*
 * 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);
      }
    });
}