-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: codegen: Add riscv abi llvm intrinsics test
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// compile-flags: -C no-prepopulate-passes | ||
|
||
// only-riscv64 | ||
|
||
#![feature(link_llvm_intrinsics)] | ||
#![crate_type = "lib"] | ||
|
||
struct A; | ||
|
||
impl Drop for A { | ||
fn drop(&mut self) { | ||
println!("A"); | ||
} | ||
} | ||
|
||
extern { | ||
#[link_name = "llvm.sqrt.f32"] | ||
fn sqrt(x: f32) -> f32; | ||
} | ||
|
||
pub fn do_call() { | ||
let _a = A; | ||
|
||
unsafe { | ||
// Ensure that we `call` LLVM intrinsics instead of trying to `invoke` them | ||
// CHECK: store float 4.000000e+00, float* %{{.}}, align 4 | ||
// CHECK: call float @llvm.sqrt.f32(float %{{.}} | ||
sqrt(4.0); | ||
} | ||
} |