File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ // assembly-output: emit-asm
2+ // compile-flags: -Copt-level=1
3+ // only-x86_64
4+ // min-llvm-version: 15.0
5+ #![ crate_type = "rlib" ]
6+
7+ // CHECK-LABEL: old_style
8+ // CHECK: movq %{{.*}}, %rax
9+ // CHECK: orq $1, %rax
10+ // CHECK: retq
11+ #[ no_mangle]
12+ pub fn old_style ( a : * mut u8 ) -> * mut u8 {
13+ ( a as usize | 1 ) as * mut u8
14+ }
15+
16+ // CHECK-LABEL: cheri_compat
17+ // CHECK: movq %{{.*}}, %rax
18+ // CHECK: orq $1, %rax
19+ // CHECK: retq
20+ #[ no_mangle]
21+ pub fn cheri_compat ( a : * mut u8 ) -> * mut u8 {
22+ let old = a as usize ;
23+ let new = old | 1 ;
24+ let diff = new. wrapping_sub ( old) ;
25+ a. wrapping_add ( diff)
26+ }
27+
28+ // CHECK-LABEL: definitely_not_a_null_pointer
29+ // CHECK: movq %{{.*}}, %rax
30+ // CHECK: orq $1, %rax
31+ // CHECK: retq
32+ #[ no_mangle]
33+ pub fn definitely_not_a_null_pointer ( a : * mut u8 ) -> * mut u8 {
34+ let old = a as usize ;
35+ let new = old | 1 ;
36+ a. wrapping_sub ( old) . wrapping_add ( new)
37+ }
You can’t perform that action at this time.
0 commit comments