File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 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() {
111111#[ inline]
112112#[ unstable( feature = "test" , issue = "50297" ) ]
113113#[ 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 {
115115 // We need to "use" the argument in some way LLVM can't introspect, and on
116116 // targets that support it we can typically leverage inline assembly to do
117117 // 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 {
121121 #[ cfg( not( miri) ) ] // This is just a hint, so it is fine to skip in Miri.
122122 // SAFETY: the inline assembly is a no-op.
123123 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) : "memory" : "volatile" ) ;
125126 }
126127
127128 dummy
Original file line number Diff line number Diff line change @@ -60,12 +60,19 @@ mod fpu_precision {
6060 fn set_cw ( cw : u16 ) {
6161 // SAFETY: the `fldcw` instruction has been audited to be able to work correctly with
6262 // 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+ }
6471 }
6572
6673 /// Sets the precision field of the FPU to `T` and returns a `FPUControlWord`.
6774 pub fn set_precision < T > ( ) -> FPUControlWord {
68- let cw = 0u16 ;
75+ let mut cw = 0_u16 ;
6976
7077 // Compute the value for the Precision Control field that is appropriate for `T`.
7178 let cw_precision = match size_of :: < T > ( ) {
@@ -78,7 +85,14 @@ mod fpu_precision {
7885 // `FPUControlWord` structure is dropped
7986 // SAFETY: the `fnstcw` instruction has been audited to be able to work correctly with
8087 // 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+ }
8296
8397 // Set the control word to the desired precision. This is achieved by masking away the old
8498 // 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