Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit d6092d0

Browse files
committed
Auto merge of rust-lang#128785 - matthiaskrgr:rollup-13chr4m, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#128384 (Add tests to ensure MTE tags are preserved across FFI boundaries) - rust-lang#128407 (Migrate `min-global-align` and `no-alloc-shim` `run-make` tests to rmake) - rust-lang#128584 (Add a set of tests for LLVM 19) - rust-lang#128636 (migrate `thumb-none-cortex-m` to rmake) - rust-lang#128696 (Migrate `staticlib-dylib-linkage` `run-make` test to rmake) Failed merges: - rust-lang#128639 (migrate `thumb-none-qemu` to rmake) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8d00669 + acef3a1 commit d6092d0

File tree

25 files changed

+583
-110
lines changed

25 files changed

+583
-110
lines changed

src/tools/compiletest/src/command-list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
170170
"only-32bit",
171171
"only-64bit",
172172
"only-aarch64",
173+
"only-aarch64-unknown-linux-gnu",
173174
"only-apple",
174175
"only-arm",
175176
"only-avr",

src/tools/run-make-support/src/assertion_helpers.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ pub fn assert_not_contains_regex<H: AsRef<str>, N: AsRef<str>>(haystack: H, need
7777
}
7878
}
7979

80+
/// Assert that `haystack` contains `needle` a `count` number of times.
81+
#[track_caller]
82+
pub fn assert_count_is<H: AsRef<str>, N: AsRef<str>>(count: usize, haystack: H, needle: N) {
83+
let haystack = haystack.as_ref();
84+
let needle = needle.as_ref();
85+
if count != haystack.matches(needle).count() {
86+
eprintln!("=== HAYSTACK ===");
87+
eprintln!("{}", haystack);
88+
eprintln!("=== NEEDLE ===");
89+
eprintln!("{}", needle);
90+
panic!("needle did not appear {count} times in haystack");
91+
}
92+
}
93+
8094
/// Assert that all files in `dir1` exist and have the same content in `dir2`
8195
pub fn assert_dirs_are_equal(dir1: impl AsRef<Path>, dir2: impl AsRef<Path>) {
8296
let dir2 = dir2.as_ref();

src/tools/run-make-support/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub use path_helpers::{
8686
pub use scoped_run::{run_in_tmpdir, test_while_readonly};
8787

8888
pub use assertion_helpers::{
89-
assert_contains, assert_contains_regex, assert_dirs_are_equal, assert_equals,
89+
assert_contains, assert_contains_regex, assert_count_is, assert_dirs_are_equal, assert_equals,
9090
assert_not_contains, assert_not_contains_regex,
9191
};
9292

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,15 @@ run-make/libtest-json/Makefile
1313
run-make/libtest-junit/Makefile
1414
run-make/libtest-thread-limit/Makefile
1515
run-make/macos-deployment-target/Makefile
16-
run-make/min-global-align/Makefile
1716
run-make/native-link-modifier-bundle/Makefile
18-
run-make/no-alloc-shim/Makefile
1917
run-make/pdb-buildinfo-cl-cmd/Makefile
2018
run-make/pgo-indirect-call-promotion/Makefile
2119
run-make/remap-path-prefix-dwarf/Makefile
2220
run-make/reproducible-build/Makefile
2321
run-make/rlib-format-packed-bundled-libs/Makefile
2422
run-make/split-debuginfo/Makefile
25-
run-make/staticlib-dylib-linkage/Makefile
2623
run-make/symbol-mangling-hashed/Makefile
2724
run-make/sysroot-crates-are-unstable/Makefile
28-
run-make/thumb-none-cortex-m/Makefile
2925
run-make/thumb-none-qemu/Makefile
3026
run-make/translation/Makefile
3127
run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ compile-flags: -O
2+
//@ min-llvm-version: 19
3+
4+
// Test for #107681.
5+
// Make sure we don't create `br` or `select` instructions.
6+
7+
#![crate_type = "lib"]
8+
9+
use std::iter::Copied;
10+
use std::slice::Iter;
11+
12+
#[no_mangle]
13+
pub unsafe fn foo(x: &mut Copied<Iter<'_, u32>>) -> u32 {
14+
// CHECK-LABEL: @foo(
15+
// CHECK-NOT: br
16+
// CHECK-NOT: select
17+
// CHECK: [[RET:%.*]] = load i32, ptr
18+
// CHECK-NEXT: ret i32 [[RET]]
19+
x.next().unwrap_unchecked()
20+
}

tests/codegen/issues/issue-118306.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ compile-flags: -O -Zno-jump-tables
2+
//@ min-llvm-version: 19
3+
4+
// Test for #118306.
5+
// Ensure that the default branch is optimized to be unreachable.
6+
7+
#![crate_type = "lib"]
8+
9+
#[no_mangle]
10+
pub fn foo(input: u64) -> u64 {
11+
// CHECK-LABEL: @foo(
12+
// CHECK: switch {{.*}}, label %[[UNREACHABLE:.*]] [
13+
// CHECK: [[UNREACHABLE]]:
14+
// CHECK-NEXT: unreachable
15+
match input % 4 {
16+
1 | 2 => 1,
17+
3 => 2,
18+
_ => 0,
19+
}
20+
}

tests/codegen/issues/issue-126585.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@ compile-flags: -Copt-level=s
2+
//@ min-llvm-version: 19
3+
4+
// Test for #126585.
5+
// Ensure that this IR doesn't have extra undef phi input, which also guarantees that this asm
6+
// doesn't have subsequent labels and unnecessary `jmp` instructions.
7+
8+
#![crate_type = "lib"]
9+
10+
#[no_mangle]
11+
fn checked_div_round(a: u64, b: u64) -> Option<u64> {
12+
// CHECK-LABEL: @checked_div_round
13+
// CHECK: phi
14+
// CHECK-NOT: undef
15+
// CHECK: phi
16+
// CHECK-NOT: undef
17+
match b {
18+
0 => None,
19+
1 => Some(a),
20+
// `a / b` is computable and `(a % b) * 2` can not overflow since `b >= 2`.
21+
b => Some(a / b + if (a % b) * 2 >= b { 1 } else { 0 }),
22+
}
23+
}

tests/run-make/min-global-align/Makefile

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This test checks that global variables respect the target minimum alignment.
2+
// The three bools `STATIC_BOOL`, `STATIC_MUT_BOOL`, and `CONST_BOOL` all have
3+
// type-alignment of 1, but some targets require greater global alignment.
4+
// See https://github.com/rust-lang/rust/pull/44440
5+
6+
//@ only-linux
7+
// Reason: this test is target-independent, considering compilation is targeted
8+
// towards linux architectures only.
9+
10+
use run_make_support::{assert_count_is, llvm_components_contain, rfs, rustc};
11+
12+
fn main() {
13+
// Most targets are happy with default alignment -- take i686 for example.
14+
if llvm_components_contain("x86") {
15+
rustc().target("i686-unknown-linux-gnu").emit("llvm-ir").input("min_global_align.rs").run();
16+
assert_count_is(3, rfs::read_to_string("min_global_align.ll"), "align 1");
17+
}
18+
// SystemZ requires even alignment for PC-relative addressing.
19+
if llvm_components_contain("systemz") {
20+
rustc()
21+
.target("s390x-unknown-linux-gnu")
22+
.emit("llvm-ir")
23+
.input("min_global_align.rs")
24+
.run();
25+
assert_count_is(3, rfs::read_to_string("min_global_align.ll"), "align 2");
26+
}
27+
}

tests/run-make/mte-ffi/bar.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef __BAR_H
2+
#define __BAR_H
3+
4+
#include <sys/mman.h>
5+
#include <sys/auxv.h>
6+
#include <sys/prctl.h>
7+
#include <unistd.h>
8+
#include <stdio.h>
9+
10+
// Set the allocation tag on the destination address using the STG instruction.
11+
#define set_tag(tagged_addr) do { \
12+
asm volatile("stg %0, [%0]" : : "r" (tagged_addr) : "memory"); \
13+
} while (0)
14+
15+
int mte_enabled() {
16+
return (getauxval(AT_HWCAP2)) & HWCAP2_MTE;
17+
}
18+
19+
void *alloc_page() {
20+
// Enable MTE with synchronous checking
21+
if (prctl(PR_SET_TAGGED_ADDR_CTRL,
22+
PR_TAGGED_ADDR_ENABLE | PR_MTE_TCF_SYNC | (0xfffe << PR_MTE_TAG_SHIFT),
23+
0, 0, 0))
24+
{
25+
perror("prctl() failed");
26+
}
27+
28+
// Using `mmap` allows us to ensure that, on systems which support MTE, the allocated
29+
// memory is 16-byte aligned for MTE.
30+
// This also allows us to explicitly specify whether the region should be protected by
31+
// MTE or not.
32+
if (mte_enabled()) {
33+
void *ptr = mmap(NULL, sysconf(_SC_PAGESIZE),
34+
PROT_READ | PROT_WRITE | PROT_MTE, MAP_PRIVATE | MAP_ANONYMOUS,
35+
-1, 0);
36+
} else {
37+
void *ptr = mmap(NULL, sysconf(_SC_PAGESIZE),
38+
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
39+
-1, 0);
40+
}
41+
}
42+
43+
#endif // __BAR_H

0 commit comments

Comments
 (0)