summaryrefslogtreecommitdiffstats
path: root/src/test/codegen/intrinsics/volatile.rs
blob: 7980c00e7e729c69c94ccbe46716a1fe34238d8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// compile-flags: -C no-prepopulate-passes

#![crate_type = "lib"]
#![feature(core_intrinsics)]

use std::intrinsics;

// CHECK-LABEL: @volatile_copy_memory
#[no_mangle]
pub unsafe fn volatile_copy_memory(a: *mut u8, b: *const u8) {
    // CHECK: llvm.memmove.{{\w*(.*true)}}
    intrinsics::volatile_copy_memory(a, b, 1)
}

// CHECK-LABEL: @volatile_copy_nonoverlapping_memory
#[no_mangle]
pub unsafe fn volatile_copy_nonoverlapping_memory(a: *mut u8, b: *const u8) {
    // CHECK: llvm.memcpy.{{\w*(.*true)}}
    intrinsics::volatile_copy_nonoverlapping_memory(a, b, 1)
}

// CHECK-LABEL: @volatile_set_memory
#[no_mangle]
pub unsafe fn volatile_set_memory(a: *mut u8, b: u8) {
    // CHECK: llvm.memset.{{\w*(.*true)}}
    intrinsics::volatile_set_memory(a, b, 1)
}

// CHECK-LABEL: @volatile_load
#[no_mangle]
pub unsafe fn volatile_load(a: *const u8) -> u8 {
    // CHECK: load volatile
    intrinsics::volatile_load(a)
}

// CHECK-LABEL: @volatile_store
#[no_mangle]
pub unsafe fn volatile_store(a: *mut u8, b: u8) {
    // CHECK: store volatile
    intrinsics::volatile_store(a, b)
}

// CHECK-LABEL: @unaligned_volatile_load
#[no_mangle]
pub unsafe fn unaligned_volatile_load(a: *const u8) -> u8 {
    // CHECK: load volatile
    intrinsics::unaligned_volatile_load(a)
}

// CHECK-LABEL: @unaligned_volatile_store
#[no_mangle]
pub unsafe fn unaligned_volatile_store(a: *mut u8, b: u8) {
    // CHECK: store volatile
    intrinsics::unaligned_volatile_store(a, b)
}