diff --git a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp --- a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -159,8 +159,6 @@ void MSP430AsmPrinter::EmitInterruptVectorSection(MachineFunction &ISR) { MCSection *Cur = OutStreamer->getCurrentSectionOnly(); const auto *F = &ISR.getFunction(); - assert(F->hasFnAttribute("interrupt") && - "Functions with MSP430_INTR CC should have 'interrupt' attribute"); StringRef IVIdx = F->getFnAttribute("interrupt").getValueAsString(); MCSection *IV = OutStreamer->getContext().getELFSection( "__interrupt_vector_" + IVIdx, @@ -174,8 +172,10 @@ bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) { // Emit separate section for an interrupt vector if ISR - if (MF.getFunction().getCallingConv() == CallingConv::MSP430_INTR) + if (MF.getFunction().getCallingConv() == CallingConv::MSP430_INTR && + MF.getFunction().hasFnAttribute("interrupt")) { EmitInterruptVectorSection(MF); + } SetupMachineFunction(MF); EmitFunctionBody(); diff --git a/llvm/test/CodeGen/MSP430/interrupt.ll b/llvm/test/CodeGen/MSP430/interrupt.ll --- a/llvm/test/CodeGen/MSP430/interrupt.ll +++ b/llvm/test/CodeGen/MSP430/interrupt.ll @@ -50,4 +50,13 @@ ret void } +; Functions without 'interrupt' attribute don't get a vector section. +; CHECK-NOT: __interrupt_vector +; CHECK-LABEL: NMI: +; CHECK: reti +define msp430_intrcc void @NMI() #1 { + ret void +} + attributes #0 = { noinline nounwind optnone "interrupt"="2" } +attributes #1 = { noinline nounwind optnone }