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);
diff --git a/compiler/utils/assembler_thumb_test_expected.cc.inc b/compiler/utils/assembler_thumb_test_expected.cc.inc
index 1678f87..4205bf1 100644
--- a/compiler/utils/assembler_thumb_test_expected.cc.inc
+++ b/compiler/utils/assembler_thumb_test_expected.cc.inc
@@ -78,7 +78,7 @@
   "      f6: 0d f2 01 4c   addwne r12, sp, #1025\n"
   "      fa: d9 f8 9c c0   ldr.w r12, [r9, #156]\n"
   "      fe: bc f1 00 0f   cmp.w r12, #0\n"
-  "     102: 71 d1         bne #226\n"
+  "     102: 71 d1         bne 0x1e8     @ imm = #226\n"
   "     104: cd f8 ff c7   str.w r12, [sp, #2047]\n"
   "     108: cd f8 ff c7   str.w r12, [sp, #2047]\n"
   "     10c: cd f8 ff c7   str.w r12, [sp, #2047]\n"
@@ -135,8 +135,8 @@
   "     1d8: cd f8 ff c7   str.w r12, [sp, #2047]\n"
   "     1dc: cd f8 ff c7   str.w r12, [sp, #2047]\n"
   "     1e0: cd f8 ff c7   str.w r12, [sp, #2047]\n"
-  "     1e4: 00 f0 02 b8   b.w #4\n"
-  "     1e8: 00 f0 1b b8   b.w #54\n"
+  "     1e4: 00 f0 02 b8   b.w 0x1ec     @ imm = #4\n"
+  "     1e8: 00 f0 1b b8   b.w 0x222     @ imm = #54\n"
   "     1ec: cd f8 ff c7   str.w r12, [sp, #2047]\n"
   "     1f0: cd f8 ff c7   str.w r12, [sp, #2047]\n"
   "     1f4: cd f8 ff c7   str.w r12, [sp, #2047]\n"