Repository: rust
Issue: SIGILL compiler crash when using AVR inline assembly
Labels: I-crash,A-LLVM,T-compiler,C-bug,O-AVR

<!--
Thank you for finding an Internal Compiler Error! 🧊  If possible, try to provide
a minimal verifiable example. You can read "Rust Bug Minimization Patterns" for
how to create smaller examples.
http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
-->

### Code

```Rust
#![no_std]
#![no_main]
#![feature(asm_experimental_arch)]

use core::{panic::PanicInfo, arch::asm};

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

#[no_mangle]
pub extern "C" fn main() {
    let target: *mut u8 = 0x0025 as *mut u8;
    let value: u8 = 0;
    unsafe {
        asm!(
            "st {port}, {value}",
            port = in(reg_ptr) target,
            value = in(reg) value,
        );
    }
    panic!()
}
```


### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.84.0-nightly (a93c1718c 2024-10-24)
binary: rustc
commit-hash: a93c1718c80b9f100056c8eec3fc37fbd6424134
commit-date: 2024-10-24
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.1
```

### Error output

```
error: could not compile `avr-project` (bin "avr-project")

Caused by:
  process didn't exit successfully: `/home/ondre/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc --crate-name avr_project --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=186 --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C lto -C codegen-units=1 --check-cfg 'cfg(docsrs)' --check-cfg 'cfg(feature, values())' -C metadata=3c8db77931085eba -C extra-filename=-3c8db77931085eba --out-dir /home/ondre/avrlibstest/target/avr-atmega328p/release/deps --target /home/ondre/avrlibstest/avr-atmega328p.json -C strip=debuginfo -L dependency=/home/ondre/avrlibstest/target/avr-atmega328p/release/deps -L dependency=/home/ondre/avrlibstest/target/release/deps --extern 'noprelude:compiler_builtins=/home/ondre/avrlibstest/target/avr-atmega328p/release/deps/libcompiler_builtins-013c779640681efb.rlib' --extern 'noprelude:core=/home/ondre/avrlibstest/target/avr-atmega328p/release/deps/libcore-1167638d3e17fa03.rlib' -Z unstable-options` (signal: 4, SIGILL: illegal instruction)
```

### Project config

In file `rust-toolchain.toml`:
```toml
[toolchain]
channel = "nightly"
```

In file `.cargo/config.toml`:
```toml
[build]
target = "avr-atmega328p.json"

[unstable]
build-std = ["core"]
```

In file `avr-atmega328p.json`:
```json
{
  "arch": "avr",
  "atomic-cas": false,
  "cpu": "atmega328p",
  "crt-objects-fallback": "false",
  "data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
  "eh-frame-header": false,
  "env": "gnu",
  "exe-suffix": ".elf",
  "late-link-args": {
    "gnu-cc": [
      "-lgcc"
    ],
    "gnu-lld-cc": [
      "-lgcc"
    ]
  },
  "linker": "avr-gcc",
  "linker-flavor": "gnu-cc",
  "llvm-target": "avr-unknown-unknown",
  "max-atomic-width": 16,
  "metadata": {
    "description": null,
    "host_tools": null,
    "std": null,
    "tier": null
  },
  "pre-link-args": {
    "gnu-cc": [
      "-mmcu=atmega328p"
    ],
    "gnu-lld-cc": [
      "-mmcu=atmega328p"
    ]
  },
  "relocation-model": "static",
  "target-c-int-width": "16",
  "target-pointer-width": "16"
}
```