From 068db2ed4d1879e100fb12f2a3d75e38b8867b46 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Wed, 13 Nov 2019 12:08:38 +0300 Subject: [PATCH] [mips] Show an error if 64-bit target triple provided with 32-bit CPU MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When a 64-bit triple is used emit an error if the CPU only supports 32-bit code. Patch by Miloš Stojanović. Differential Revision: https://reviews.llvm.org/D70018 --- llvm/lib/Target/Mips/MipsSubtarget.cpp | 4 ++++ llvm/test/CodeGen/Mips/cpus-no-mips64.ll | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 llvm/test/CodeGen/Mips/cpus-no-mips64.ll diff --git a/llvm/lib/Target/Mips/MipsSubtarget.cpp b/llvm/lib/Target/Mips/MipsSubtarget.cpp index 29e557c..133b818 100644 --- a/llvm/lib/Target/Mips/MipsSubtarget.cpp +++ b/llvm/lib/Target/Mips/MipsSubtarget.cpp @@ -256,6 +256,10 @@ MipsSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS, stackAlignment = Align(8); } + if ((isABI_N32() || isABI_N64()) && !isGP64bit()) + report_fatal_error("64-bit code requested on a subtarget that doesn't " + "support it!"); + return *this; } diff --git a/llvm/test/CodeGen/Mips/cpus-no-mips64.ll b/llvm/test/CodeGen/Mips/cpus-no-mips64.ll new file mode 100644 index 0000000..301f6c2 --- /dev/null +++ b/llvm/test/CodeGen/Mips/cpus-no-mips64.ll @@ -0,0 +1,16 @@ +; Check that we reject 64-bit mode on 32-bit only CPUs. + +; RUN: not llc < %s -o /dev/null -mtriple=mips64 -mcpu=mips1 2>&1 | FileCheck %s +; RUN: not llc < %s -o /dev/null -mtriple=mips64 -mcpu=mips2 2>&1 | FileCheck %s + +; RUN: not llc < %s -o /dev/null -mtriple=mips64 -mcpu=mips32 2>&1 | FileCheck %s +; RUN: not llc < %s -o /dev/null -mtriple=mips64 -mcpu=mips32r2 2>&1 | FileCheck %s +; RUN: not llc < %s -o /dev/null -mtriple=mips64 -mcpu=mips32r3 2>&1 | FileCheck %s +; RUN: not llc < %s -o /dev/null -mtriple=mips64 -mcpu=mips32r5 2>&1 | FileCheck %s +; RUN: not llc < %s -o /dev/null -mtriple=mips64 -mcpu=mips32r6 2>&1 | FileCheck %s + +; CHECK: LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it! + +define void @foo() { + ret void +} -- 2.7.4