Skip to content

Commit afdfa8c

Browse files
Add regression test for <#288>
1 parent 81acbae commit afdfa8c

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/run/call-llvm-intrinsics.rs

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

0 commit comments

Comments
 (0)