AArch64: stop trying to take control of all UnknownArch triples.
authorTim Northover <tnorthover@apple.com>
Fri, 8 Aug 2014 08:27:44 +0000 (08:27 +0000)
committerTim Northover <tnorthover@apple.com>
Fri, 8 Aug 2014 08:27:44 +0000 (08:27 +0000)
This short-circuited our error reporting for incorrectly specified
target triples (you'd get AArch64 code instead).

Should fix PR20567.

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

lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp
test/CodeGen/AArch64/dont-take-over-the-world.ll [new file with mode: 0644]

index 1fee256c72c7ef8752646193cc27814b00ceb608..f42ecb1677dec93ee73c650122d5face0380290d 100644 (file)
@@ -20,8 +20,9 @@ Target TheARM64Target;
 extern "C" void LLVMInitializeAArch64TargetInfo() {
   // Now register the "arm64" name for use with "-march". We don't want it to
   // take possession of the Triple::aarch64 tag though.
-  RegisterTarget<Triple::UnknownArch, /*HasJIT=*/true> X(
-      TheARM64Target, "arm64", "ARM64 (little endian)");
+  TargetRegistry::RegisterTarget(TheARM64Target, "arm64",
+                                 "ARM64 (little endian)",
+                                 [](Triple::ArchType) { return false; }, true);
 
   RegisterTarget<Triple::aarch64, /*HasJIT=*/true> Z(
       TheAArch64leTarget, "aarch64", "AArch64 (little endian)");
diff --git a/test/CodeGen/AArch64/dont-take-over-the-world.ll b/test/CodeGen/AArch64/dont-take-over-the-world.ll
new file mode 100644 (file)
index 0000000..d9e13b7
--- /dev/null
@@ -0,0 +1,7 @@
+; RUN: not llc -mtriple=x86-64 2>&1 | FileCheck %s
+
+; To support "arm64" as a -march option, we need to register a second AArch64
+; target, but we have to be careful how we do that so that it doesn't become the
+; target of last resort when the specified triple is completely wrong.
+
+; CHECK: unable to get target for 'x86-64', see --version and --triple.