Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All interrupt ABIs should enforce either () or ! as return types #132841

Open
Tracked by #40180
workingjubilee opened this issue Nov 10, 2024 · 0 comments
Open
Tracked by #40180

All interrupt ABIs should enforce either () or ! as return types #132841

workingjubilee opened this issue Nov 10, 2024 · 0 comments
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-hardware-interrupts Area: Code for handling the "interrupt ABI" of various processors A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. F-abi_x86_interrupt O-msp430 O-riscv Target: RISC-V architecture O-x86_32 Target: x86 processors, 32 bit (like i686-*) O-x86_64 Target: x86-64 processors (like x86_64-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@workingjubilee
Copy link
Member

workingjubilee commented Nov 10, 2024

I tried this code: Godbolt

I expected to see this happen: ...interrupts don't really return things, they're side effects, that's kind of in the definition, so these shouldn't return anything, and the ABI should enforce that, or during lowering..?

Instead, this happened:

rustc-LLVM ERROR: ISRs cannot return any value
rustc-LLVM ERROR: Functions with the interrupt attribute must have void return type!
rustc-LLVM ERROR: X86 interrupts may not return any value

msp430

#![feature(abi_msp430_interrupt)]

pub extern "msp430-interrupt" fn msp430_isr() -> u64 {
    9001u64
}

pub fn call() {
    let _ = msp430_isr();
}

riscv

#![feature(abi_riscv_interrupt)]
pub extern "riscv-interrupt-m" fn interrupt_machine() -> u64 {
    9001u64
}

pub extern "riscv-interrupt-s" fn interrupt_supervisor() -> u64 {
    9002u64
}

pub fn main() {
    let a = interrupt_machine();
    let b = interrupt_supervisor();
    println!("{}", a + b);
}

x86

#![feature(abi_x86_interrupt)]
pub extern "x86-interrupt" fn interrupt_machine() -> u64 {
    9001u64
}


pub fn main() {
    let a = interrupt_machine();
    println!("{}", a);
}

Meta

rustc --version --verbose:

rustc 1.84.0-nightly (a0d98ff0e 2024-10-31)
binary: rustc
commit-hash: a0d98ff0e5b6e1f2c63fd26f68484792621b235c
commit-date: 2024-10-31
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1

@rustbot label: +A-ABI +A-hardware-interrupts +A-LLVM +F-abi_x86_interrupt +O-x86_64 +O-x86_32 +O-riscv +O-msp430 +T-compiler

Related Issues

@workingjubilee workingjubilee added the C-bug Category: This is a bug. label Nov 10, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-ABI Area: Concerning the application binary interface (ABI) A-hardware-interrupts Area: Code for handling the "interrupt ABI" of various processors A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-abi_x86_interrupt O-msp430 O-riscv Target: RISC-V architecture O-x86_32 Target: x86 processors, 32 bit (like i686-*) O-x86_64 Target: x86-64 processors (like x86_64-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 10, 2024
@workingjubilee workingjubilee removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-hardware-interrupts Area: Code for handling the "interrupt ABI" of various processors A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. F-abi_x86_interrupt O-msp430 O-riscv Target: RISC-V architecture O-x86_32 Target: x86 processors, 32 bit (like i686-*) O-x86_64 Target: x86-64 processors (like x86_64-*) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants