[vm/compiler] Cleanup IL dumps a bit

* Do not print redundant ParallelMove instructions unless
  `--print_redundant_il` is specified.
* Do not print `;; Inlined` comments if
  `--no_include_inlining_info_in_disassembly` is specified.

TEST=manually

Change-Id: I9a8c83514e2a749484863a4cc010c8ea7950b0fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278748
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
diff --git a/runtime/vm/compiler/assembler/disassembler.cc b/runtime/vm/compiler/assembler/disassembler.cc
index 11484f1..432f3dd 100644
--- a/runtime/vm/compiler/assembler/disassembler.cc
+++ b/runtime/vm/compiler/assembler/disassembler.cc
@@ -25,6 +25,10 @@
 #endif
 
 DEFINE_FLAG(bool, trace_source_positions, false, "Source position diagnostics");
+DEFINE_FLAG(bool,
+            include_inlining_info_in_disassembly,
+            true,
+            "Include inlining information when printing disassembly")
 
 void DisassembleToStdout::ConsumeInstruction(char* hex_buffer,
                                              intptr_t hex_size,
@@ -160,7 +164,8 @@
       formatter->Print("        ;; %s\n", comments->CommentAt(comment_finger));
       comment_finger++;
     }
-    if (old_comment_finger != comment_finger && !code.IsNull()) {
+    if (FLAG_include_inlining_info_in_disassembly &&
+        old_comment_finger != comment_finger && !code.IsNull()) {
       char str[4000];
       BufferFormatter f(str, sizeof(str));
       // Comment emitted, emit inlining information.
diff --git a/runtime/vm/compiler/backend/il_printer.cc b/runtime/vm/compiler/backend/il_printer.cc
index b29a69a..0524742 100644
--- a/runtime/vm/compiler/backend/il_printer.cc
+++ b/runtime/vm/compiler/backend/il_printer.cc
@@ -26,9 +26,24 @@
             print_flow_graph_as_json,
             false,
             "Use machine readable output when printing IL graphs.");
+DEFINE_FLAG(bool, print_redundant_il, false, "Print redundant IL instructions");
 
 DECLARE_FLAG(bool, trace_inlining_intervals);
 
+static bool IsRedundant(Instruction* instr) {
+  if (auto constant = instr->AsConstant()) {
+    return !constant->HasUses();
+  } else if (auto move = instr->AsParallelMove()) {
+    return move->IsRedundant();
+  } else {
+    return true;
+  }
+}
+
+static bool ShouldPrintInstruction(Instruction* instr) {
+  return FLAG_print_redundant_il || !IsRedundant(instr);
+}
+
 const char* RepresentationToCString(Representation rep) {
   switch (rep) {
     case kTagged:
@@ -96,8 +111,9 @@
           block_with_defs->initial_definitions()->length() > 0) {
         writer->OpenArray("d");
         for (auto defn : *block_with_defs->initial_definitions()) {
-          if (defn->IsConstant() && !defn->HasUses()) continue;
-          PrintInstruction(writer, defn);
+          if (ShouldPrintInstruction(defn)) {
+            PrintInstruction(writer, defn);
+          }
         }
         writer->CloseArray();
       }
@@ -261,6 +277,12 @@
   // And all the successors in the block.
   for (ForwardInstructionIterator it(block); !it.Done(); it.Advance()) {
     Instruction* current = it.Current();
+
+    // Skip redundant parallel moves.
+    if (!ShouldPrintInstruction(current)) {
+      continue;
+    }
+
     PrintOneInstruction(current, print_locations);
     THR_Print("\n");
   }
@@ -1081,7 +1103,9 @@
     for (intptr_t i = 0; i < defns.length(); ++i) {
       Definition* def = defns[i];
       // Skip constants which are not used in the graph.
-      if (def->IsConstant() && !def->HasUses()) continue;
+      if (!ShouldPrintInstruction(def)) {
+        continue;
+      }
       f->AddString("\n      ");
       def->PrintTo(f);
     }