File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
tests/compiletests/ui/lang/core/intrinsics Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 1
1
// Test black_box intrinsic
2
2
// build-pass
3
+ // compile-flags: -C llvm-args=--disassemble-fn=black_box::disassemble
3
4
4
5
#![ allow( internal_features) ]
5
6
#![ feature( core_intrinsics) ]
@@ -9,7 +10,14 @@ use core::hint::black_box;
9
10
use spirv_std:: spirv;
10
11
11
12
#[ spirv( compute( threads( 1 ) ) ) ]
12
- pub fn main ( ) {
13
+ pub fn main ( #[ spirv( descriptor_set = 0 , binding = 0 , storage_buffer) ] out : & mut [ u32 ] ) {
14
+ let result = disassemble ( ) ;
15
+ for i in 0 ..result. len ( ) {
16
+ out[ i] = result[ i] ;
17
+ }
18
+ }
19
+
20
+ pub fn disassemble ( ) -> [ u32 ; 8 ] {
13
21
// Test with various types
14
22
let x = 42i32 ;
15
23
let y = black_box ( x) ;
@@ -26,4 +34,15 @@ pub fn main() {
26
34
// Test with references
27
35
let data = 100u32 ;
28
36
let ref_data = black_box ( & data) ;
37
+
38
+ [
39
+ y as u32 ,
40
+ f32:: to_bits ( b) ,
41
+ w[ 0 ] ,
42
+ w[ 1 ] ,
43
+ w[ 2 ] ,
44
+ w[ 3 ] ,
45
+ result,
46
+ * ref_data,
47
+ ]
29
48
}
Original file line number Diff line number Diff line change 1
1
warning: black_box intrinsic does not prevent optimization in Rust GPU
2
2
3
+ %1 = OpFunction %2 None %3
4
+ %4 = OpLabel
5
+ OpLine %5 34 17
6
+ %6 = OpIAdd %7 %8 %9
7
+ OpLine %5 40 5
8
+ %10 = OpBitcast %7 %11
9
+ OpLine %12 1092 17
10
+ %13 = OpBitcast %7 %14
11
+ OpLine %5 40 4
12
+ %15 = OpCompositeConstruct %2 %10 %13 %16 %17 %18 %19 %6 %20
13
+ OpNoLine
14
+ OpReturnValue %15
15
+ OpFunctionEnd
3
16
warning: 1 warning emitted
4
17
You can’t perform that action at this time.
0 commit comments