Skip to content

Commit 37e8e05

Browse files
committed
test: codegen: Add riscv abi llvm intrinsics test
1 parent c872dcf commit 37e8e05

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/test/codegen/call-llvm-intrinsics.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// compile-flags: -C no-prepopulate-passes
22

3+
// ignore-riscv64
4+
35
#![feature(link_llvm_intrinsics)]
46
#![crate_type = "lib"]
57

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// compile-flags: -C no-prepopulate-passes
2+
3+
// only-riscv64
4+
5+
#![feature(link_llvm_intrinsics)]
6+
#![crate_type = "lib"]
7+
8+
struct A;
9+
10+
impl Drop for A {
11+
fn drop(&mut self) {
12+
println!("A");
13+
}
14+
}
15+
16+
extern {
17+
#[link_name = "llvm.sqrt.f32"]
18+
fn sqrt(x: f32) -> f32;
19+
}
20+
21+
pub fn do_call() {
22+
let _a = A;
23+
24+
unsafe {
25+
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them
26+
// CHECK: store float 4.000000e+00, float* %{{.}}, align 4
27+
// CHECK: call float @llvm.sqrt.f32(float %{{.}}
28+
sqrt(4.0);
29+
}
30+
}

0 commit comments

Comments
 (0)