Skip to content

Commit ab00841

Browse files
committed
Convert to a rmake-test
Since the `tests/assembly` use `emit=asm`, the issue is not observable as reported in the linked issue. Therefore the existing test case is converted and a simple `rmake`-test is added. The test only checks, if the correct `rjmp`-offset is used.
1 parent db6c736 commit ab00841

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

tests/assembly/avr-rjmp-offsets.rs renamed to tests/run-make/avr-rjmp-offset/avr-rjmp-offsets.rs

+12-23
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
//@ compile-flags: -Copt-level=s --target=avr-unknown-gnu-atmega328 -C panic=abort
2-
//@ needs-llvm-components: avr
3-
//@ assembly-output: emit-asm
4-
5-
#![feature(
6-
no_core,
7-
lang_items,
8-
intrinsics,
9-
rustc_attrs,
10-
arbitrary_self_types,
11-
asm_experimental_arch
12-
)]
13-
#![crate_type = "rlib"]
1+
//! This test case is a `#![no_core]`-version of the MVCE presented in #129301.
2+
//!
3+
//! The function [`delay()`] is minimized and does not actually contain a loop
4+
//! in order to remove the need for additional lang items.
5+
#![feature(no_core, lang_items, intrinsics, rustc_attrs, asm_experimental_arch)]
146
#![no_core]
7+
#![no_main]
8+
#![allow(internal_features)]
159

1610
#[rustc_builtin_macro]
1711
macro_rules! asm {
@@ -20,18 +14,13 @@ macro_rules! asm {
2014

2115
use minicore::ptr;
2216

23-
// CHECK-LABEL: pin_toggling
24-
// CHECK: ldi [[REG_1:r[0-9]+]], 1
25-
// CHECK: ldi [[REG_2:r[0-9]+]], 2
26-
// CHECK: .LBB0_1:
27-
// CHECK-NEXT: out 5, [[REG_1]]
28-
// CHECK-NEXT: call delay
29-
// CHECK-NEXT: out 5, [[REG_2]]
30-
// CHECK-NEXT: call delay
31-
// CHECK-NEXT: rjmp .LBB0_1
3217
#[no_mangle]
33-
pub fn pin_toggling() {
18+
pub fn main() -> ! {
3419
let port_b = 0x25 as *mut u8; // the I/O-address of PORTB
20+
21+
// a simple loop with some trivial instructions within. This loop label has
22+
// to be placed correctly before the `ptr::write_volatile()` (some LLVM ver-
23+
// sions did place it after the first loop instruction, causing unsoundness)
3524
loop {
3625
unsafe { ptr::write_volatile(port_b, 1) };
3726
delay(500_0000);
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@ needs-llvm-components: avr
2+
//! Regression test for #129301/llvm-project#106722 within `rustc`.
3+
//!
4+
//! Some LLVM-versions had wrong offsets in the local labels, causing the first
5+
//! loop instruction to be missed. This test therefore contains a simple loop
6+
//! with trivial instructions in it, to see, where the label is placed.
7+
//!
8+
//! This must be a `rmake`-test and cannot be a `tests/assembly`-test, since the
9+
//! wrong output is only produced with direct assembly generation, but not when
10+
//! "emit-asm" is used, as described in the issue description of #129301:
11+
//! https://github.com/rust-lang/rust/issues/129301#issue-2475070770
12+
use run_make_support::{llvm_objdump, rustc};
13+
14+
fn main() {
15+
rustc()
16+
.input("avr-rjmp-offsets.rs")
17+
.opt_level("s")
18+
.panic("abort")
19+
.target("avr-unknown-gnu-atmega328")
20+
.output("compiled")
21+
.run();
22+
23+
llvm_objdump()
24+
.disassemble()
25+
.input("compiled")
26+
.run()
27+
.assert_stdout_contains_regex(r"rjmp.*\.-14");
28+
}

0 commit comments

Comments
 (0)