Skip to content

Commit

Permalink
8306922: IR verification fails because IR dump is chopped up
Browse files Browse the repository at this point in the history
Backport-of: 9057b3503349ead7d995b1a705317324830eabb2
  • Loading branch information
GoeLin committed Jan 17, 2024
1 parent f011538 commit a51c74d
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 147 deletions.
37 changes: 23 additions & 14 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,28 +551,37 @@ void Compile::print_compile_messages() {

#ifndef PRODUCT
void Compile::print_ideal_ir(const char* phase_name) {
ttyLocker ttyl;
// keep the following output all in one block
// This output goes directly to the tty, not the compiler log.
// To enable tools to match it up with the compilation activity,
// be sure to tag this tty output with the compile ID.
if (xtty != nullptr) {
xtty->head("ideal compile_id='%d'%s compile_phase='%s'",
compile_id(),
is_osr_compilation() ? " compile_kind='osr'" : "",
phase_name);
}

// Node dumping can cause a safepoint, which can break the tty lock.
// Buffer all node dumps, so that all safepoints happen before we lock.
ResourceMark rm;
stringStream ss;

if (_output == nullptr) {
tty->print_cr("AFTER: %s", phase_name);
ss.print_cr("AFTER: %s", phase_name);
// Print out all nodes in ascending order of index.
root()->dump_bfs(MaxNodeLimit, nullptr, "+S$");
root()->dump_bfs(MaxNodeLimit, nullptr, "+S$", &ss);
} else {
// Dump the node blockwise if we have a scheduling
_output->print_scheduling();
_output->print_scheduling(&ss);
}

// Check that the lock is not broken by a safepoint.
NoSafepointVerifier nsv;
ttyLocker ttyl;
if (xtty != nullptr) {
xtty->head("ideal compile_id='%d'%s compile_phase='%s'",
compile_id(),
is_osr_compilation() ? " compile_kind='osr'" : "",
phase_name);
xtty->print("%s", ss.as_string()); // print to tty would use xml escape encoding
xtty->tail("ideal");
} else {
tty->print("%s", ss.as_string());
}
}
#endif
Expand Down Expand Up @@ -4991,8 +5000,8 @@ bool Compile::randomized_select(int count) {
CloneMap& Compile::clone_map() { return _clone_map; }
void Compile::set_clone_map(Dict* d) { _clone_map._dict = d; }

void NodeCloneInfo::dump() const {
tty->print(" {%d:%d} ", idx(), gen());
void NodeCloneInfo::dump_on(outputStream* st) const {
st->print(" {%d:%d} ", idx(), gen());
}

void CloneMap::clone(Node* old, Node* nnn, int gen) {
Expand Down Expand Up @@ -5039,11 +5048,11 @@ int CloneMap::max_gen() const {
return g;
}

void CloneMap::dump(node_idx_t key) const {
void CloneMap::dump(node_idx_t key, outputStream* st) const {
uint64_t val = value(key);
if (val != 0) {
NodeCloneInfo ni(val);
ni.dump();
ni.dump_on(st);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/opto/compile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class NodeCloneInfo {
NodeCloneInfo(uint64_t idx_clone_orig) : _idx_clone_orig(idx_clone_orig) {}
NodeCloneInfo(node_idx_t x, int g) : _idx_clone_orig(0) { set(x, g); }

void dump() const;
void dump_on(outputStream* st) const;
};

class CloneMap {
Expand All @@ -158,7 +158,7 @@ class CloneMap {
int max_gen() const;
void clone(Node* old, Node* nnn, int gen);
void verify_insert_and_clone(Node* old, Node* nnn, int gen);
void dump(node_idx_t key) const;
void dump(node_idx_t key, outputStream* st) const;

int clone_idx() const { return _clone_idx; }
void set_clone_idx(int x) { _clone_idx = x; }
Expand Down

1 comment on commit a51c74d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.