From 7bdf787a3adc3184b7ac31cb1aee1f43008bd1fb Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 9 Dec 2019 17:14:10 -0800 Subject: [PATCH] [llvm/dwarfdump] Use the architecture string to filter. Currently dwarfdump uses the ArchType to filter out architectures, which is problematic for architectures like arm64e and x86_64h that map back to arm64 and x86_64 respectively. The result is that the filter doesn't work for these architectures because it matches all the variants. This is especially bad because usually these architectures are the reason to use the filter in the first place. Instead, we should match the architecture based on the string name. This means the filter works for the values printed by dwarfdump. It has the unfortunate side effect of not working for aliases, like AArch64, but I think that's worth the trade-off. rdar://53653014 Differential revision: https://reviews.llvm.org/D71230 (cherry picked from commit d9466653e4ddbde5e787ac8cdbe67c1f356a5f69) --- llvm/test/tools/llvm-dwarfdump/AArch64/arch.ll | 1 - llvm/test/tools/llvm-dwarfdump/filter.test | 4 ++++ llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 llvm/test/tools/llvm-dwarfdump/filter.test diff --git a/llvm/test/tools/llvm-dwarfdump/AArch64/arch.ll b/llvm/test/tools/llvm-dwarfdump/AArch64/arch.ll index d74b199778eb4..86505a3f9a8a1 100644 --- a/llvm/test/tools/llvm-dwarfdump/AArch64/arch.ll +++ b/llvm/test/tools/llvm-dwarfdump/AArch64/arch.ll @@ -1,6 +1,5 @@ ; 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 ; diff --git a/llvm/test/tools/llvm-dwarfdump/filter.test b/llvm/test/tools/llvm-dwarfdump/filter.test new file mode 100644 index 0000000000000..60537d233f53d --- /dev/null +++ b/llvm/test/tools/llvm-dwarfdump/filter.test @@ -0,0 +1,4 @@ +Make sure that passing --arch armv7s only shows the armv7s slice and not the armv7 slice. + +RUN: llvm-dwarfdump -arch armv7s %S/../dsymutil/Inputs/fat-test.arm.dylib | FileCheck %s +CHECK-NOT: (armv7) diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp index 1efc96df6657b..8bb95bb030163 100644 --- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -271,7 +271,7 @@ static bool filterArch(ObjectFile &Obj) { return true; // Match as name. - if (MachO->getArchTriple().getArch() == Triple(Arch).getArch()) + if (MachO->getArchTriple().getArchName() == Triple(Arch).getArchName()) return true; } }