File tree 2 files changed +20
-5
lines changed
2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ pub fn spin_loop() {
111
111
#[ inline]
112
112
#[ unstable( feature = "test" , issue = "50297" ) ]
113
113
#[ allow( unreachable_code) ] // this makes #[cfg] a bit easier below.
114
- pub fn black_box < T > ( dummy : T ) -> T {
114
+ pub fn black_box < T > ( mut dummy : T ) -> T {
115
115
// We need to "use" the argument in some way LLVM can't introspect, and on
116
116
// targets that support it we can typically leverage inline assembly to do
117
117
// this. LLVM's interpretation of inline assembly is that it's, well, a black
@@ -121,7 +121,8 @@ pub fn black_box<T>(dummy: T) -> T {
121
121
#[ cfg( not( miri) ) ] // This is just a hint, so it is fine to skip in Miri.
122
122
// SAFETY: the inline assembly is a no-op.
123
123
unsafe {
124
- llvm_asm ! ( "" : : "r" ( & dummy) ) ;
124
+ // FIXME: Cannot use `asm!` because it doesn't support MIPS and other architectures.
125
+ llvm_asm ! ( "" : : "r" ( & mut dummy) ) ;
125
126
}
126
127
127
128
dummy
Original file line number Diff line number Diff line change @@ -60,12 +60,19 @@ mod fpu_precision {
60
60
fn set_cw ( cw : u16 ) {
61
61
// SAFETY: the `fldcw` instruction has been audited to be able to work correctly with
62
62
// any `u16`
63
- unsafe { llvm_asm ! ( "fldcw $0" :: "m" ( cw) :: "volatile" ) }
63
+ unsafe {
64
+ asm ! (
65
+ "fldcw ({})" ,
66
+ in( reg) & cw,
67
+ // FIXME: We are using ATT syntax to support LLVM 8 and LLVM 9.
68
+ options( att_syntax, nostack) ,
69
+ )
70
+ }
64
71
}
65
72
66
73
/// Sets the precision field of the FPU to `T` and returns a `FPUControlWord`.
67
74
pub fn set_precision < T > ( ) -> FPUControlWord {
68
- let cw = 0u16 ;
75
+ let mut cw = 0_u16 ;
69
76
70
77
// Compute the value for the Precision Control field that is appropriate for `T`.
71
78
let cw_precision = match size_of :: < T > ( ) {
@@ -78,7 +85,14 @@ mod fpu_precision {
78
85
// `FPUControlWord` structure is dropped
79
86
// SAFETY: the `fnstcw` instruction has been audited to be able to work correctly with
80
87
// any `u16`
81
- unsafe { llvm_asm ! ( "fnstcw $0" : "=*m" ( & cw) :: : "volatile" ) }
88
+ unsafe {
89
+ asm ! (
90
+ "fnstcw ({})" ,
91
+ in( reg) & mut cw,
92
+ // FIXME: We are using ATT syntax to support LLVM 8 and LLVM 9.
93
+ options( att_syntax, nostack) ,
94
+ )
95
+ }
82
96
83
97
// Set the control word to the desired precision. This is achieved by masking away the old
84
98
// precision (bits 8 and 9, 0x300) and replacing it with the precision flag computed above.
You can’t perform that action at this time.
0 commit comments