@@ -9,6 +9,7 @@ use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUs
9
9
use rustc:: mir:: traversal;
10
10
use rustc:: ty;
11
11
use rustc:: ty:: layout:: { LayoutOf , HasTyCtxt } ;
12
+ use syntax_pos:: DUMMY_SP ;
12
13
use super :: FunctionCx ;
13
14
use crate :: traits:: * ;
14
15
@@ -20,10 +21,13 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
20
21
21
22
analyzer. visit_body ( mir) ;
22
23
23
- for ( index, ty) in mir. local_decls . iter ( ) . map ( |l| l. ty ) . enumerate ( ) {
24
+ for ( index, ( ty, span) ) in mir. local_decls . iter ( )
25
+ . map ( |l| ( l. ty , l. source_info . span ) )
26
+ . enumerate ( )
27
+ {
24
28
let ty = fx. monomorphize ( & ty) ;
25
29
debug ! ( "local {} has type {:?}" , index, ty) ;
26
- let layout = fx. cx . layout_of ( ty) ;
30
+ let layout = fx. cx . spanned_layout_of ( ty, span ) ;
27
31
if fx. cx . is_backend_immediate ( layout) {
28
32
// These sorts of types are immediates that we can store
29
33
// in an Value without an alloca.
@@ -93,10 +97,12 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
93
97
}
94
98
}
95
99
96
- fn process_place ( & mut self ,
97
- place_ref : & mir:: PlaceRef < ' _ , ' tcx > ,
98
- context : PlaceContext ,
99
- location : Location ) {
100
+ fn process_place (
101
+ & mut self ,
102
+ place_ref : & mir:: PlaceRef < ' _ , ' tcx > ,
103
+ context : PlaceContext ,
104
+ location : Location ,
105
+ ) {
100
106
let cx = self . fx . cx ;
101
107
102
108
if let Some ( proj) = place_ref. projection {
@@ -116,12 +122,17 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
116
122
. projection_ty ( cx. tcx ( ) , & proj. elem )
117
123
. ty ;
118
124
let elem_ty = self . fx . monomorphize ( & elem_ty) ;
119
- if cx. layout_of ( elem_ty) . is_zst ( ) {
125
+ let span = if let mir:: PlaceBase :: Local ( index) = place_ref. base {
126
+ self . fx . mir . local_decls [ * index] . source_info . span
127
+ } else {
128
+ DUMMY_SP
129
+ } ;
130
+ if cx. spanned_layout_of ( elem_ty, span) . is_zst ( ) {
120
131
return ;
121
132
}
122
133
123
134
if let mir:: ProjectionElem :: Field ( ..) = proj. elem {
124
- let layout = cx. layout_of ( base_ty. ty ) ;
135
+ let layout = cx. spanned_layout_of ( base_ty. ty , span ) ;
125
136
if cx. is_backend_immediate ( layout) || cx. is_backend_scalar_pair ( layout) {
126
137
// Recurse with the same context, instead of `Projection`,
127
138
// potentially stopping at non-operand projections,
@@ -188,7 +199,8 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
188
199
projection : None ,
189
200
} = * place {
190
201
self . assign ( index, location) ;
191
- if !self . fx . rvalue_creates_operand ( rvalue) {
202
+ let decl_span = self . fx . mir . local_decls [ index] . source_info . span ;
203
+ if !self . fx . rvalue_creates_operand ( rvalue, decl_span) {
192
204
self . not_ssa ( index) ;
193
205
}
194
206
} else {
0 commit comments