llvm-dwarfdump: Support alternative architecture names in the -arch filter

<rdar://problem/47918606>

llvm-svn: 357706
This commit is contained in:
Adrian Prantl 2019-04-04 15:48:40 +00:00
parent 9d75d88d30
commit ce2d45e7ba
3 changed files with 30 additions and 7 deletions

View File

@ -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")

View File

@ -0,0 +1,2 @@
if not 'AArch64' in config.root.targets:
config.unsupported = True

View 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;