[PATCH] D67313: [MSP430] Allow msp430_intrcc functions to not have interrupt attribute.

Vadzim Dambrouski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 7 03:38:46 PDT 2019


pftbest created this revision.
pftbest added reviewers: asl, krisb.
Herald added subscribers: JDevlieghere, hiraditya.
Herald added a project: LLVM.

Useful in case you want to have control over interrupt vector generation.
For example in Rust language we have an arrangement where all unhandled
ISR vectors gets mapped to a single default handler function. Which is
hard to implement when LLVM tries to generate vectors on its own.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67313

Files:
  llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp
  llvm/test/CodeGen/MSP430/interrupt.ll


Index: llvm/test/CodeGen/MSP430/interrupt.ll
===================================================================
--- llvm/test/CodeGen/MSP430/interrupt.ll
+++ 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 }
Index: llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp
===================================================================
--- llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp
+++ 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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67313.219228.patch
Type: text/x-patch
Size: 1679 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190907/590e1a37/attachment.bin>


More information about the llvm-commits mailing list