Skip to content

Commit 38c7129

Browse files
committed
Auto merge of rust-lang#151646 - matthiaskrgr:rollup-HPnXGA3, r=matthiaskrgr
Rollup of 2 pull requests Successful merges: - rust-lang#151404 (LoongArch: Fix direct-access-external-data test) - rust-lang#151405 (LoongArch: Fix call-llvm-intrinsics test)
2 parents 9415853 + 0de96f4 commit 38c7129

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

tests/codegen-llvm/direct-access-external-data.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//@ ignore-loongarch64 (handles dso_local differently)
12
//@ ignore-powerpc64 (handles dso_local differently)
23
//@ ignore-apple (handles dso_local differently)
34

tests/codegen-llvm/loongarch-abi/call-llvm-intrinsics.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ pub fn do_call() {
2323

2424
unsafe {
2525
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
26-
// CHECK: store float 4.000000e+00, ptr %{{.}}, align 4
27-
// CHECK: load float, ptr %{{.}}, align 4
28-
// CHECK: call float @llvm.sqrt.f32(float %{{.}}
26+
// CHECK: call float @llvm.sqrt.f32(float 4.000000e+00)
2927
sqrt(4.0);
3028
}
3129
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//@ only-loongarch64
2+
3+
//@ revisions: DEFAULT PIE DIRECT INDIRECT
4+
//@ [DEFAULT] compile-flags: -C relocation-model=static
5+
//@ [PIE] compile-flags: -C relocation-model=pie
6+
//@ [DIRECT] compile-flags: -C relocation-model=pie -Z direct-access-external-data=yes
7+
//@ [INDIRECT] compile-flags: -C relocation-model=static -Z direct-access-external-data=no
8+
9+
#![crate_type = "rlib"]
10+
#![feature(linkage)]
11+
12+
unsafe extern "C" {
13+
// CHECK: @VAR = external
14+
// DEFAULT-NOT: dso_local
15+
// PIE-NOT: dso_local
16+
// DIRECT-SAME: dso_local
17+
// INDIRECT-NOT: dso_local
18+
// CHECK-SAME: global i32
19+
safe static VAR: i32;
20+
21+
// When "linkage" is used, we generate an indirection global.
22+
// Check dso_local is still applied to the actual global.
23+
// CHECK: @EXTERNAL = external
24+
// DEFAULT-NOT: dso_local
25+
// PIE-NOT: dso_local
26+
// DIRECT-SAME: dso_local
27+
// INDIRECT-NOT: dso_local
28+
// CHECK-SAME: global i8
29+
#[linkage = "external"]
30+
safe static EXTERNAL: *const u32;
31+
32+
// CHECK: @WEAK = extern_weak
33+
// DEFAULT-NOT: dso_local
34+
// PIE-NOT: dso_local
35+
// DIRECT-SAME: dso_local
36+
// INDIRECT-NOT: dso_local
37+
// CHECK-SAME: global i8
38+
#[linkage = "extern_weak"]
39+
safe static WEAK: *const u32;
40+
}
41+
42+
#[no_mangle]
43+
pub fn refer() {
44+
core::hint::black_box(VAR);
45+
core::hint::black_box(EXTERNAL);
46+
core::hint::black_box(WEAK);
47+
}

0 commit comments

Comments
 (0)