本文整理汇总了C++中IRInstruction::getTrace方法的典型用法代码示例。如果您正苦于以下问题:C++ IRInstruction::getTrace方法的具体用法?C++ IRInstruction::getTrace怎么用?C++ IRInstruction::getTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRInstruction
的用法示例。
在下文中一共展示了IRInstruction::getTrace方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eliminateDeadCode
void eliminateDeadCode(Trace* trace, IRFactory* irFactory) {
auto removeEmptyExitTraces = [&] {
trace->getExitTraces().remove_if([](Trace* exit) {
return exit->getBlocks().empty();
});
};
// kill unreachable code and remove any traces that are now empty
BlockList blocks = removeUnreachable(trace, irFactory);
removeEmptyExitTraces();
// mark the essential instructions and add them to the initial
// work list; this will also mark reachable exit traces. All
// other instructions marked dead.
DceState state(irFactory, DceFlags());
WorkList wl = initInstructions(trace, blocks, state, irFactory);
// process the worklist
while (!wl.empty()) {
auto* inst = wl.front();
wl.pop_front();
for (uint32_t i = 0; i < inst->getNumSrcs(); i++) {
SSATmp* src = inst->getSrc(i);
if (src->getInstruction()->getOpcode() == DefConst) {
continue;
}
IRInstruction* srcInst = src->getInstruction();
if (state[srcInst].isDead()) {
state[srcInst].setLive();
wl.push_back(srcInst);
}
// <inst> consumes <srcInst> which is an IncRef, so we mark <srcInst> as
// REFCOUNT_CONSUMED. If the source instruction is a GuardType and guards
// to a maybeCounted type, we need to trace through to the source for
// refcounting purposes.
while (srcInst->getOpcode() == GuardType &&
srcInst->getTypeParam().maybeCounted()) {
srcInst = srcInst->getSrc(0)->getInstruction();
}
if (inst->consumesReference(i) && srcInst->getOpcode() == IncRef) {
if (inst->getTrace()->isMain() || !srcInst->getTrace()->isMain()) {
// <srcInst> is consumed from its own trace.
state[srcInst].setCountConsumed();
} else {
// <srcInst> is consumed off trace.
if (!state[srcInst].countConsumed()) {
// mark <srcInst> as REFCOUNT_CONSUMED_OFF_TRACE unless it is
// also consumed from its own trace.
state[srcInst].setCountConsumedOffTrace();
}
}
}
}
}
// Optimize IncRefs and DecRefs.
forEachTrace(trace, [&](Trace* t) { optimizeRefCount(t, state); });
if (RuntimeOption::EvalHHIREnableSinking) {
// Sink IncRefs consumed off trace.
sinkIncRefs(trace, irFactory, state);
}
// now remove instructions whose id == DEAD
removeDeadInstructions(trace, state);
for (Trace* exit : trace->getExitTraces()) {
removeDeadInstructions(exit, state);
}
// and remove empty exit traces
removeEmptyExitTraces();
}