]> granicus.if.org Git - llvm/commitdiff
llvm-dwarfdump: Support alternative architecture names in the -arch filter
authorAdrian Prantl <aprantl@apple.com>
Thu, 4 Apr 2019 15:48:40 +0000 (15:48 +0000)
committerAdrian Prantl <aprantl@apple.com>
Thu, 4 Apr 2019 15:48:40 +0000 (15:48 +0000)
<rdar://problem/47918606>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357706 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-dwarfdump/AArch64/arch.ll [new file with mode: 0644]
test/tools/llvm-dwarfdump/AArch64/lit.local.cfg [new file with mode: 0644]
tools/llvm-dwarfdump/llvm-dwarfdump.cpp

diff --git a/test/tools/llvm-dwarfdump/AArch64/arch.ll b/test/tools/llvm-dwarfdump/AArch64/arch.ll
new file mode 100644 (file)
index 0000000..d74b199
--- /dev/null
@@ -0,0 +1,24 @@
+; RUN: llc -O0 %s -filetype=obj -o %t.o
+; RUN: llvm-dwarfdump -arch arm64   %t.o | FileCheck %s
+; RUN: llvm-dwarfdump -arch aarch64 %t.o | FileCheck %s
+; RUN: llvm-dwarfdump -arch 0x0100000c %t.o | FileCheck %s
+; CHECK: file format Mach-O arm64
+;
+; RUN: llvm-dwarfdump -arch i386 %t.o \
+; RUN:    | FileCheck %s --allow-empty --check-prefix=NEGATIVE
+; RUN: llvm-dwarfdump -arch 0 %t.o \
+; RUN:    | FileCheck %s --allow-empty --check-prefix=NEGATIVE
+; NEGATIVE-NOT: file format
+source_filename = "/tmp/empty.c"
+target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
+target triple = "arm64-apple-ios"
+
+!llvm.module.flags = !{!1, !2, !3, !4}
+!llvm.dbg.cu = !{!5}
+
+!1 = !{i32 2, !"Dwarf Version", i32 4}
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = !{i32 1, !"wchar_size", i32 4}
+!4 = !{i32 7, !"PIC Level", i32 2}
+!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "Apple clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
+!6 = !DIFile(filename: "/tmp/empty.c", directory: "/Volumes/Data/llvm-project")
diff --git a/test/tools/llvm-dwarfdump/AArch64/lit.local.cfg b/test/tools/llvm-dwarfdump/AArch64/lit.local.cfg
new file mode 100644 (file)
index 0000000..7184443
--- /dev/null
@@ -0,0 +1,2 @@
+if not 'AArch64' in config.root.targets:
+    config.unsupported = True
index 22535e8a3d14c82ceedd04cfaa33f5f2c758845a..c83d647f478524b05de5b4853371a51e5881cd25 100644 (file)
@@ -258,19 +258,16 @@ static bool filterArch(ObjectFile &Obj) {
     return true;
 
   if (auto *MachO = dyn_cast<MachOObjectFile>(&Obj)) {
-    std::string ObjArch =
-        Triple::getArchTypeName(MachO->getArchTriple().getArch());
-
     for (auto Arch : ArchFilters) {
-      // Match name.
-      if (Arch == ObjArch)
-        return true;
-
       // Match architecture number.
       unsigned Value;
       if (!StringRef(Arch).getAsInteger(0, Value))
         if (Value == getCPUType(*MachO))
           return true;
+
+      // Match as name.
+      if (MachO->getArchTriple().getArch() == Triple(Arch).getArch())
+        return true;
     }
   }
   return false;