Skip to content
Permalink
Browse files
8255245: C1: Fix output of -XX:+PrintCFGToFile to open it with visual…
…izer

Reviewed-by: kvn, xliu
  • Loading branch information
chhagedorn committed Oct 28, 2020
1 parent 5e0a8cd commit b7d483c7d5fca2d59b04b06cd12cf34354cf3b2f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
@@ -325,7 +325,7 @@ void CFGPrinterOutput::print_intervals(IntervalList* intervals, const char* name

for (int i = 0; i < intervals->length(); i++) {
if (intervals->at(i) != NULL) {
intervals->at(i)->print_on(output());
intervals->at(i)->print_on(output(), true);
}
}

@@ -3212,6 +3212,12 @@ void LinearScan::print_reg_num(outputStream* out, int reg_num) {
return;
}

LIR_Opr opr = get_operand(reg_num);
assert(opr->is_valid(), "unknown register");
opr->print(out);
}

LIR_Opr LinearScan::get_operand(int reg_num) {
LIR_Opr opr = LIR_OprFact::illegal();

#ifdef X86
@@ -3231,9 +3237,9 @@ void LinearScan::print_reg_num(outputStream* out, int reg_num) {
opr = LIR_OprFact::single_xmm(reg_num - pd_first_xmm_reg);
#endif
} else {
assert(false, "unknown register");
// reg_num == -1 or a virtual register, return the illegal operand
}
opr->print(out);
return opr;
}

Interval* LinearScan::find_interval_at(int reg_num) const {
@@ -4598,7 +4604,7 @@ bool Interval::intersects_any_children_of(Interval* interval) const {


#ifndef PRODUCT
void Interval::print_on(outputStream* out) const {
void Interval::print_on(outputStream* out, bool is_cfg_printer) const {
const char* SpillState2Name[] = { "no definition", "no spill store", "one spill store", "store at definition", "start in memory", "no optimization" };
const char* UseKind2Name[] = { "N", "L", "S", "M" };

@@ -4608,18 +4614,29 @@ void Interval::print_on(outputStream* out) const {
} else {
type_name = type2name(type());
}

out->print("%d %s ", reg_num(), type_name);
if (reg_num() < LIR_OprDesc::vreg_base) {
LinearScan::print_reg_num(out, assigned_reg());
} else if (assigned_reg() != -1 && (LinearScan::num_physical_regs(type()) == 1 || assigned_regHi() != -1)) {
LinearScan::calc_operand_for_interval(this)->print(out);

if (is_cfg_printer) {
// Special version for compatibility with C1 Visualizer.
LIR_Opr opr = LinearScan::get_operand(reg_num());
if (opr->is_valid()) {
out->print("\"");
opr->print(out);
out->print("\" ");
}
} else {
// Virtual register that has no assigned register yet.
out->print("[ANY]");
// Improved output for normal debugging.
if (reg_num() < LIR_OprDesc::vreg_base) {
LinearScan::print_reg_num(out, assigned_reg());
} else if (assigned_reg() != -1 && (LinearScan::num_physical_regs(type()) == 1 || assigned_regHi() != -1)) {
LinearScan::calc_operand_for_interval(this)->print(out);
} else {
// Virtual register that has no assigned register yet.
out->print("[ANY]");
}
out->print(" ");
}

out->print(" %d %d ", split_parent()->reg_num(), (register_hint(false) != NULL ? register_hint(false)->reg_num() : -1));
out->print("%d %d ", split_parent()->reg_num(), (register_hint(false) != NULL ? register_hint(false)->reg_num() : -1));

// print ranges
Range* cur = _first;
@@ -369,6 +369,7 @@ class LinearScan : public CompilationResourceObj {
void print_lir(int level, const char* label, bool hir_valid = true);
static void print_reg_num(int reg_num) { print_reg_num(tty, reg_num); }
static void print_reg_num(outputStream* out, int reg_num);
static LIR_Opr get_operand(int reg_num);
#endif

#ifdef ASSERT
@@ -633,7 +634,11 @@ class Interval : public CompilationResourceObj {
// printing
#ifndef PRODUCT
void print() const { print_on(tty); }
void print_on(outputStream* out) const;
void print_on(outputStream* out) const {
print_on(out, false);
}
// Special version for compatibility with C1 Visualizer.
void print_on(outputStream* out, bool is_cfg_printer) const;

// Used for debugging
void print_parent() const;

1 comment on commit b7d483c

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on b7d483c Oct 28, 2020

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.