@@ -275,6 +275,14 @@ impl<'a, 'tcx> OperandRef<'tcx> {
275
275
276
276
impl < ' a , ' tcx > OperandValue {
277
277
pub fn store ( self , bx : & Builder < ' a , ' tcx > , dest : PlaceRef < ' tcx > ) {
278
+ self . store_maybe_volatile ( bx, dest, false ) ;
279
+ }
280
+
281
+ pub fn volatile_store ( self , bx : & Builder < ' a , ' tcx > , dest : PlaceRef < ' tcx > ) {
282
+ self . store_maybe_volatile ( bx, dest, true ) ;
283
+ }
284
+
285
+ fn store_maybe_volatile ( self , bx : & Builder < ' a , ' tcx > , dest : PlaceRef < ' tcx > , volatile : bool ) {
278
286
debug ! ( "OperandRef::store: operand={:?}, dest={:?}" , self , dest) ;
279
287
// Avoid generating stores of zero-sized values, because the only way to have a zero-sized
280
288
// value is through `undef`, and store itself is useless.
@@ -284,9 +292,14 @@ impl<'a, 'tcx> OperandValue {
284
292
match self {
285
293
OperandValue :: Ref ( r, source_align) =>
286
294
base:: memcpy_ty ( bx, dest. llval , r, dest. layout ,
287
- source_align. min ( dest. align ) ) ,
295
+ source_align. min ( dest. align ) , volatile ) ,
288
296
OperandValue :: Immediate ( s) => {
289
- bx. store ( base:: from_immediate ( bx, s) , dest. llval , dest. align ) ;
297
+ let val = base:: from_immediate ( bx, s) ;
298
+ if !volatile {
299
+ bx. store ( val, dest. llval , dest. align ) ;
300
+ } else {
301
+ bx. volatile_store ( val, dest. llval , dest. align ) ;
302
+ }
290
303
}
291
304
OperandValue :: Pair ( a, b) => {
292
305
for ( i, & x) in [ a, b] . iter ( ) . enumerate ( ) {
@@ -295,7 +308,12 @@ impl<'a, 'tcx> OperandValue {
295
308
if common:: val_ty ( x) == Type :: i1 ( bx. cx ) {
296
309
llptr = bx. pointercast ( llptr, Type :: i8p ( bx. cx ) ) ;
297
310
}
298
- bx. store ( base:: from_immediate ( bx, x) , llptr, dest. align ) ;
311
+ let val = base:: from_immediate ( bx, x) ;
312
+ if !volatile {
313
+ bx. store ( val, llptr, dest. align ) ;
314
+ } else {
315
+ bx. volatile_store ( val, llptr, dest. align ) ;
316
+ }
299
317
}
300
318
}
301
319
}
0 commit comments