Skip to content

AVR: interrupt code broken by optimization flags #77541

Closed as not planned
Closed as not planned
@no111u3

Description

@no111u3

I've run into an issue with code that uses interrupts on AVR. I'm not sure if this applies to any other platform.
This issue has same behavior as #75504 but It can't resolved after update compiler to current nightly version.
This issue reproduce on everything nightly rust compiler with AVR target support (I trying to compile it every nightly compiler updates).

I create minimal reproduce project for this issue - https://github.com/no111u3/m328p_robo_rust. Than I change optimization flags to size optimization level opt-level="z" or opt-level="s" upper code doesn't work correctly, there has two options:

  • for release build there is broken in interrupt handler code
  • for debug build there is broken fully, code run stopped and mcu looks halted.

I run upper code on two different mcu's that I have: on Atmega48 and Atmega328p, if we use same flags we have same behavior for run. For optimization level 2 I can use huge code in interrupt such as - https://github.com/no111u3/m48_robo_rust/blob/master/examples/dynamic_indication.rs#L119 but If I use z or s optimization interrupt works only for short code such as - https://github.com/no111u3/m48_robo_rust/blob/master/examples/pwm_int.rs#L39

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessO-AVRTarget: AVR processors (ATtiny, ATmega, etc.)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions