From 2df12188c55cf8e764407b32834d820fbb6acada Mon Sep 17 00:00:00 2001 From: Vasileios Kalintiris Date: Mon, 26 Oct 2015 14:24:30 +0000 Subject: [PATCH] [mips] Check for the correct error message in tests for interrupt attributes. Instead of XFAIL-ing the tests with the wrong usage of the "interrupt" attribute, we should check that we emit the correct error messages to the user. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251295 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Mips/MipsISelLowering.cpp | 6 +++--- lib/Target/Mips/MipsSEFrameLowering.cpp | 6 +++--- test/CodeGen/Mips/interrupt-attr-64-error.ll | 9 +++++++++ test/CodeGen/Mips/interrupt-attr-64-fail.ll | 11 ----------- test/CodeGen/Mips/interrupt-attr-args-error.ll | 9 +++++++++ test/CodeGen/Mips/interrupt-attr-args-fail.ll | 11 ----------- test/CodeGen/Mips/interrupt-attr-error.ll | 9 +++++++++ test/CodeGen/Mips/interrupt-attr-fail.ll | 11 ----------- 8 files changed, 33 insertions(+), 39 deletions(-) create mode 100644 test/CodeGen/Mips/interrupt-attr-64-error.ll delete mode 100644 test/CodeGen/Mips/interrupt-attr-64-fail.ll create mode 100644 test/CodeGen/Mips/interrupt-attr-args-error.ll delete mode 100644 test/CodeGen/Mips/interrupt-attr-args-fail.ll create mode 100644 test/CodeGen/Mips/interrupt-attr-error.ll delete mode 100644 test/CodeGen/Mips/interrupt-attr-fail.ll diff --git a/lib/Target/Mips/MipsISelLowering.cpp b/lib/Target/Mips/MipsISelLowering.cpp index a36725a9208..7e8bccddca5 100644 --- a/lib/Target/Mips/MipsISelLowering.cpp +++ b/lib/Target/Mips/MipsISelLowering.cpp @@ -2952,9 +2952,9 @@ MipsTargetLowering::LowerFormalArguments(SDValue Chain, const Function *Func = DAG.getMachineFunction().getFunction(); Function::const_arg_iterator FuncArg = Func->arg_begin(); - if (Func->hasFnAttribute("interrupt")) - assert(Func->arg_empty() && - "Functions with the interrupt attribute cannot have arguments!"); + if (Func->hasFnAttribute("interrupt") && !Func->arg_empty()) + report_fatal_error( + "Functions with the interrupt attribute cannot have arguments!"); CCInfo.AnalyzeFormalArguments(Ins, CC_Mips_FixedArg); MipsFI->setFormalArgInfo(CCInfo.getNextStackOffset(), diff --git a/lib/Target/Mips/MipsSEFrameLowering.cpp b/lib/Target/Mips/MipsSEFrameLowering.cpp index 70f4a637217..297e7a2ec8b 100644 --- a/lib/Target/Mips/MipsSEFrameLowering.cpp +++ b/lib/Target/Mips/MipsSEFrameLowering.cpp @@ -548,8 +548,8 @@ void MipsSEFrameLowering::emitInterruptPrologueStub( // clearing is not provided so reject that configuration. if (!STI.hasMips32r2()) report_fatal_error( - "\"interrupt\" attribute is not supported on pre-r2 MIPS or" - "Mips16 targets."); + "\"interrupt\" attribute is not supported on pre-MIPS32R2 or " + "MIPS16 targets."); // The GP register contains the "user" value, so we cannot perform // any gp relative loads until we restore the "kernel" or "system" gp @@ -561,7 +561,7 @@ void MipsSEFrameLowering::emitInterruptPrologueStub( if (!STI.isABI_O32() || STI.hasMips64()) report_fatal_error("\"interrupt\" attribute is only supported for the " - "O32 ABI on MIPS32r2+ at the present time."); + "O32 ABI on MIPS32R2+ at the present time."); // Perform ISR handling like GCC StringRef IntKind = diff --git a/test/CodeGen/Mips/interrupt-attr-64-error.ll b/test/CodeGen/Mips/interrupt-attr-64-error.ll new file mode 100644 index 00000000000..830c199d91d --- /dev/null +++ b/test/CodeGen/Mips/interrupt-attr-64-error.ll @@ -0,0 +1,9 @@ +; RUN: not llc -mcpu=mips64r6 -march=mipsel -relocation-model=static < %s 2>%t +; RUN: FileCheck %s < %t + +; CHECK: LLVM ERROR: "interrupt" attribute is only supported for the O32 ABI on MIPS32R2+ at the present time. +define i32 @isr_sw0() #0 { + ret i32 0 +} + +attributes #0 = { "interrupt"="sw0" } diff --git a/test/CodeGen/Mips/interrupt-attr-64-fail.ll b/test/CodeGen/Mips/interrupt-attr-64-fail.ll deleted file mode 100644 index 49929d218e5..00000000000 --- a/test/CodeGen/Mips/interrupt-attr-64-fail.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: llc -mcpu=mips64r6 -march=mipsel -relocation-model=static -o - %s | FileCheck %s -; XFAIL: * - -define void @isr_sw0() #0 { - call void bitcast (void (...)* @write to void ()*)() -} - -declare void @write(...) - -attributes #0 = { "interrupt"="sw0" } - diff --git a/test/CodeGen/Mips/interrupt-attr-args-error.ll b/test/CodeGen/Mips/interrupt-attr-args-error.ll new file mode 100644 index 00000000000..993629bdbcd --- /dev/null +++ b/test/CodeGen/Mips/interrupt-attr-args-error.ll @@ -0,0 +1,9 @@ +; RUN: not llc -mcpu=mips32r2 -march=mipsel -relocation-model=static < %s 2> %t +; RUN: FileCheck %s < %t + +; CHECK: LLVM ERROR: Functions with the interrupt attribute cannot have arguments! +define i32 @isr_sw0(i8 signext %n) #0 { + ret i32 0 +} + +attributes #0 = { "interrupt"="sw0" } diff --git a/test/CodeGen/Mips/interrupt-attr-args-fail.ll b/test/CodeGen/Mips/interrupt-attr-args-fail.ll deleted file mode 100644 index 9f15a15ca9c..00000000000 --- a/test/CodeGen/Mips/interrupt-attr-args-fail.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: llc -mcpu=mips32r2 -march=mipsel -relocation-model=static -o - %s | FileCheck %s -; XFAIL: * - -define void @isr_sw0(i8 signext %n) #0 { - call void bitcast (void (...)* @write to void ()*)() -} - -declare void @write(...) - -attributes #0 = { "interrupt"="sw0" } - diff --git a/test/CodeGen/Mips/interrupt-attr-error.ll b/test/CodeGen/Mips/interrupt-attr-error.ll new file mode 100644 index 00000000000..f35e98ea14b --- /dev/null +++ b/test/CodeGen/Mips/interrupt-attr-error.ll @@ -0,0 +1,9 @@ +; RUN: not llc -mcpu=mips32 -march=mipsel -relocation-model=static < %s 2>%t +; RUN: FileCheck %s < %t + +; CHECK: LLVM ERROR: "interrupt" attribute is not supported on pre-MIPS32R2 or MIPS16 targets. +define i32 @isr_sw0() #0 { + ret i32 0 +} + +attributes #0 = { "interrupt"="sw0" } diff --git a/test/CodeGen/Mips/interrupt-attr-fail.ll b/test/CodeGen/Mips/interrupt-attr-fail.ll deleted file mode 100644 index d3914ee86f6..00000000000 --- a/test/CodeGen/Mips/interrupt-attr-fail.ll +++ /dev/null @@ -1,11 +0,0 @@ -; RUN: llc -mcpu=mips32 -march=mipsel -relocation-model=static -o - %s | FileCheck %s -; XFAIL: * - -define void @isr_sw0() #0 { - call void bitcast (void (...)* @write to void ()*)() -} - -declare void @write(...) - -attributes #0 = { "interrupt"="sw0" } - -- 2.34.1