@@ -518,27 +518,29 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
518
518
}
519
519
}
520
520
521
- // Work around: avoid ICE in miri.
522
- // FIXME(wesleywiser) we don't currently handle the case where we try to make a ref
523
- // from a function argument that hasn't been assigned to in this function. The main
524
- // issue is if an arg is a fat-pointer, miri `expects()` to be able to read the value
525
- // of that pointer to get size info. However, since this is `ConstProp`, that argument
526
- // doesn't actually have a backing value and so this causes an ICE.
521
+ // Work around: avoid ICE in miri. FIXME(wesleywiser)
522
+ // The Miri engine ICEs when taking a reference to an uninitialized unsized
523
+ // local. There's nothing it can do here: taking a reference needs an allocation
524
+ // which needs to know the size. Normally that's okay as during execution
525
+ // (e.g. for CTFE) it can never happen. But here in const_prop
526
+ // we leave function arguments uninitialized, so if one of these is unsized
527
+ // and has a reference taken, we get an ICE.
527
528
Rvalue :: Ref ( _, _, Place { base : PlaceBase :: Local ( local) , projection : box [ ] } ) => {
528
529
trace ! ( "checking Ref({:?})" , place) ;
529
530
let alive =
530
531
if let LocalValue :: Live ( _) = self . ecx . frame ( ) . locals [ * local] . value {
531
532
true
532
533
} else { false } ;
533
534
535
+ // local 0 is the return place; locals 1..=arg_count are the arguments.
534
536
if local. as_usize ( ) <= self . ecx . frame ( ) . body . arg_count && !alive {
535
537
trace ! ( "skipping Ref({:?})" , place) ;
536
538
return None ;
537
539
}
538
540
}
539
541
540
- // Work around: avoid extra unnecessary locals.
541
- // FIXME(wesleywiser): const eval will turn this into a `const Scalar(<ZST>)` that
542
+ // Work around: avoid extra unnecessary locals. FIXME(wesleywiser)
543
+ // Const eval will turn this into a `const Scalar(<ZST>)` that
542
544
// `SimplifyLocals` doesn't know it can remove.
543
545
Rvalue :: Aggregate ( _, operands) if operands. len ( ) == 0 => {
544
546
return None ;
0 commit comments