Skip to content

Commit

Permalink
Don't print unreachable vasm blocks below a certain trace level
Browse files Browse the repository at this point in the history
Summary: Certain optimizations can cause us to end up with more unreachable
than reachable blocks, and printing them makes the output very noisy. They do
matter for passes that iterate over unit.blocks, though, so it's important to
be aware that they exist. When the vasm trace level is below 6, we now print
something like "43 unreachable blocks not shown. Set TRACE=vasm:6 or greater."
in place of the unreachable blocks.

Reviewed By: @ottoni

Differential Revision: D1921821
  • Loading branch information
swtaarrs authored and hhvm-bot committed Mar 18, 2015
1 parent 24e13cb commit 7cc2edf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
20 changes: 12 additions & 8 deletions hphp/runtime/vm/jit/vasm-print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,20 @@ std::string show(const Vunit& unit) {
}

// Print unreachable blocks last.
bool printedMsg{false};
for (size_t b = 0; b < unit.blocks.size(); b++) {
if (!reachableSet.test(b)) {
if (!printedMsg) {
out << "\nUnreachable blocks:\n";
printedMsg = true;
}
printBlock(out, unit, preds, Vlabel{b});
auto const numUnreachable = reachableSet.size() - reachableSet.count();
if (numUnreachable == 0) return out.str();

if (Trace::moduleEnabledRelease(Trace::vasm, kVasmUnreachableLevel)) {
out << "\nUnreachable blocks:\n";
for (size_t b = 0; b < unit.blocks.size(); b++) {
if (!reachableSet.test(b)) printBlock(out, unit, preds, Vlabel{b});
}
} else {
out << folly::format("\n{} unreachable blocks not shown. "
"Set TRACE=vasm:{} or greater to print them.\n",
numUnreachable, kVasmUnreachableLevel);
}

return out.str();
}

Expand Down
1 change: 1 addition & 0 deletions hphp/runtime/vm/jit/vasm-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ constexpr int kVasmJumpsLevel = 4;
constexpr int kVasmExitsLevel = 4;
constexpr int kVasmDCELevel = 4;
constexpr int kVasmLowerLevel = 4;
constexpr int kVasmUnreachableLevel = 6;

// Print the cfg digraph followed by a vasm code listing, if the trace level is
// above `level'.
Expand Down

0 comments on commit 7cc2edf

Please sign in to comment.