Adapt ART tests for the new llvm-objdump output format

llvm-objdump now emit comments where it sees helpful, breaking many test
expectations. Since these comments are subject to frequent format changes,
trim them from the output in ART tests.

Test: m test-art-host-gtest
Bug: 197230471
Change-Id: I27f33e28f993f3826b3a1da75afa9a79ad9c360d
diff --git a/compiler/utils/assembler_test_base.h b/compiler/utils/assembler_test_base.h
index b4c0d0c..7331863 100644
--- a/compiler/utils/assembler_test_base.h
+++ b/compiler/utils/assembler_test_base.h
@@ -22,6 +22,7 @@
 #include <cstdlib>
 #include <fstream>
 #include <iterator>
+#include <regex>
 
 #include "android-base/strings.h"
 
@@ -110,9 +111,11 @@
     std::string art_disassembly;
     ASSERT_TRUE(Disassemble(art_obj_file, &art_disassembly));
     art_disassembly = Replace(art_disassembly, art_obj_file, test_path("<extension-redacted>"));
+    art_disassembly = StripComments(art_disassembly);
     std::string ref_disassembly;
     ASSERT_TRUE(Disassemble(ref_obj_file, &ref_disassembly));
     ref_disassembly = Replace(ref_disassembly, ref_obj_file, test_path("<extension-redacted>"));
+    ref_disassembly = StripComments(ref_disassembly);
     ASSERT_EQ(art_disassembly, ref_disassembly) << "Outputs (and disassembly) not identical.";
 
     // ART produced different (but valid) code than the reference assembler, report it.
@@ -247,6 +250,11 @@
     return output;
   }
 
+  // Remove comments emitted by objdump.
+  std::string StripComments(const std::string& str) {
+    return std::regex_replace(str, std::regex(" +#.*"), "");
+  }
+
   std::optional<ScratchDir> scratch_dir_;
   std::string android_data_;
   DISALLOW_COPY_AND_ASSIGN(AssemblerTestBase);