std::string show(const RegionDesc::Block& b) { std::string ret{"Block "}; folly::toAppend( b.func()->fullName()->data(), '@', b.start().offset(), " length ", b.length(), '\n', &ret ); auto const& tpRange = b.typePreds(); auto tpIter = begin(tpRange); auto skIter = b.start(); for (int i = 0; i < b.length(); ++i) { while (tpIter != end(tpRange) && tpIter->first < skIter) { ++tpIter; } while (tpIter != end(tpRange) && tpIter->first == skIter) { folly::toAppend(" predict: ", show(tpIter->second), "\n", &ret); ++tpIter; } folly::toAppend( " ", skIter.offset(), " ", instrToString(b.unit()->at(skIter.offset()), b.unit()), '\n', &ret ); skIter.advance(b.unit()); } return ret; }
std::string show(const RegionDesc::Block& b) { std::string ret{"Block "}; folly::toAppend(b.id(), ' ', b.func()->fullName()->data(), '@', b.start().offset(), b.start().resumed() ? "r" : "", " length ", b.length(), " initSpOff ", b.initialSpOffset().offset, " inlineLevel ", b.inlineLevel(), '\n', &ret ); auto typePreds = makeMapWalker(b.typePreds()); auto byRefs = makeMapWalker(b.paramByRefs()); auto refPreds = makeMapWalker(b.reffinessPreds()); auto knownFuncs= makeMapWalker(b.knownFuncs()); auto skIter = b.start(); const Func* topFunc = nullptr; for (int i = 0; i < b.length(); ++i) { while (typePreds.hasNext(skIter)) { folly::toAppend(" predict: ", show(typePreds.next()), "\n", &ret); } while (refPreds.hasNext(skIter)) { folly::toAppend(" predict reffiness: ", show(refPreds.next()), "\n", &ret); } std::string knownFunc; if (knownFuncs.hasNext(skIter)) { topFunc = knownFuncs.next(); } if (topFunc) { const char* inlined = ""; if (i == b.length() - 1 && b.inlinedCallee()) { assertx(topFunc == b.inlinedCallee()); inlined = " (call is inlined)"; } knownFunc = folly::format(" (top func: {}{})", topFunc->fullName()->data(), inlined).str(); } else { assertx((i < b.length() - 1 || !b.inlinedCallee()) && "inlined FCall without a known funcd"); } std::string byRef; if (byRefs.hasNext(skIter)) { byRef = folly::format(" (passed by {})", byRefs.next() ? "reference" : "value").str(); } std::string instrString; folly::toAppend(instrToString((Op*)b.unit()->at(skIter.offset()), b.unit()), byRef, &instrString); folly::toAppend( " ", skIter.offset(), " ", knownFunc.empty() ? instrString : folly::format("{:<40}", instrString).str(), knownFunc, "\n", &ret ); skIter.advance(b.unit()); } folly::toAppend(show(b.postConds()), &ret); return ret; }