@@ -367,7 +367,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
367
367
#[ instrument( level = "trace" , skip( self ) , ret) ]
368
368
fn eval_to_const ( & mut self , value : VnIndex ) -> Option < OpTy < ' tcx > > {
369
369
use Value :: * ;
370
- let op = match * self . get ( value) {
370
+ let vvalue = self . get ( value) ;
371
+ debug ! ( ?vvalue) ;
372
+ let op = match * vvalue {
371
373
Opaque ( _) => return None ,
372
374
// Do not bother evaluating repeat expressions. This would uselessly consume memory.
373
375
Repeat ( ..) => return None ,
@@ -376,10 +378,11 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
376
378
self . ecx . eval_mir_constant ( value, DUMMY_SP , None ) . ok ( ) ?
377
379
}
378
380
Aggregate ( kind, variant, ref fields) => {
381
+ debug ! ( ?kind, ?variant, ?fields) ;
379
382
let fields = fields
380
383
. iter ( )
381
384
. map ( |& f| self . evaluated [ f] . as_ref ( ) )
382
- . collect :: < Option < Vec < _ > > > ( ) ?;
385
+ . collect :: < Option < Vec < & OpTy < ' _ > > > > ( ) ?;
383
386
let ty = match kind {
384
387
AggregateTy :: Array => {
385
388
assert ! ( fields. len( ) > 0 ) ;
@@ -407,6 +410,24 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
407
410
} ;
408
411
let ptr_imm = Immediate :: new_pointer_with_meta ( data, meta, & self . ecx ) ;
409
412
ImmTy :: from_immediate ( ptr_imm, ty) . into ( )
413
+ } else if matches ! ( kind, AggregateTy :: Array ) {
414
+ let mut mplace = None ;
415
+ let alloc_id = self . ecx . intern_with_temp_alloc ( ty, |ecx, dest| {
416
+ for ( field_index, op) in fields. iter ( ) . copied ( ) . enumerate ( ) {
417
+ let field_dest = ecx. project_field ( dest, field_index) ?;
418
+ ecx. copy_op ( op, & field_dest) ?;
419
+ }
420
+
421
+ let place = dest. assert_mem_place ( ) ;
422
+ mplace. replace ( place) ;
423
+ Ok ( ( ) )
424
+ } ) . ok ( ) ?;
425
+ let GlobalAlloc :: Memory ( _alloc) = self . tcx . global_alloc ( alloc_id) else {
426
+ bug ! ( )
427
+ } ;
428
+ let mplace = mplace. unwrap ( ) ;
429
+ debug ! ( ?mplace) ;
430
+ return Some ( mplace. into ( ) ) ;
410
431
} else if matches ! ( ty. abi, Abi :: Scalar ( ..) | Abi :: ScalarPair ( ..) ) {
411
432
let dest = self . ecx . allocate ( ty, MemoryKind :: Stack ) . ok ( ) ?;
412
433
let variant_dest = if let Some ( variant) = variant {
@@ -429,6 +450,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
429
450
}
430
451
431
452
Projection ( base, elem) => {
453
+ debug ! ( ?base, ?elem) ;
432
454
let value = self . evaluated [ base] . as_ref ( ) ?;
433
455
let elem = match elem {
434
456
ProjectionElem :: Deref => ProjectionElem :: Deref ,
@@ -450,6 +472,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
450
472
self . ecx . project ( value, elem) . ok ( ) ?
451
473
}
452
474
Address { place, kind, provenance : _ } => {
475
+ debug ! ( ?place, ?kind) ;
453
476
if !place. is_indirect_first_projection ( ) {
454
477
return None ;
455
478
}
0 commit comments