@@ -539,9 +539,10 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
539
539
540
540
fn ret ( & mut self , mut value : RValue < ' gcc > ) {
541
541
if self . structs_as_pointer . borrow ( ) . contains ( & value) {
542
+ panic ! ( ) ;
542
543
// NOTE: hack to workaround a limitation of the rustc API: see comment on
543
544
// CodegenCx.structs_as_pointer
544
- value = value. dereference ( self . location ) . to_rvalue ( ) ;
545
+ // value = value.dereference(self.location).to_rvalue();
545
546
}
546
547
let expected_return_type = self . current_func ( ) . get_return_type ( ) ;
547
548
if !expected_return_type. is_compatible_with ( value. get_type ( ) ) {
@@ -1119,11 +1120,12 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1119
1120
// TODO(antoyo)
1120
1121
}
1121
1122
1122
- fn store ( & mut self , mut val : RValue < ' gcc > , ptr : RValue < ' gcc > , align : Align ) -> RValue < ' gcc > {
1123
+ fn store ( & mut self , val : RValue < ' gcc > , ptr : RValue < ' gcc > , align : Align ) -> RValue < ' gcc > {
1123
1124
if self . structs_as_pointer . borrow ( ) . contains ( & val) {
1125
+ panic ! ( ) ;
1124
1126
// NOTE: hack to workaround a limitation of the rustc API: see comment on
1125
1127
// CodegenCx.structs_as_pointer
1126
- val = val. dereference ( self . location ) . to_rvalue ( ) ;
1128
+ // val = val.dereference(self.location).to_rvalue();
1127
1129
}
1128
1130
1129
1131
self . store_with_flags ( val, ptr, align, MemFlags :: empty ( ) )
@@ -1537,26 +1539,44 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1537
1539
assert_eq ! ( idx as usize as u64 , idx) ;
1538
1540
let value_type = aggregate_value. get_type ( ) ;
1539
1541
1540
- let lvalue = if value_type. dyncast_array ( ) . is_some ( ) {
1542
+ if value_type. dyncast_array ( ) . is_some ( ) {
1541
1543
let index = self
1542
1544
. context
1543
1545
. new_rvalue_from_long ( self . u64_type , i64:: try_from ( idx) . expect ( "i64::try_from" ) ) ;
1544
1546
self . context . new_array_access ( self . location , aggregate_value, index)
1545
1547
} else if value_type. dyncast_vector ( ) . is_some ( ) {
1546
1548
panic ! ( ) ;
1547
- } else if let Some ( pointer_type) = value_type. get_pointee ( ) {
1548
- if let Some ( struct_type) = pointer_type. is_struct ( ) {
1549
+ } else if let Some ( _pointer_type) = value_type. get_pointee ( ) {
1550
+ unreachable ! ( ) ;
1551
+ /*if let Some(struct_type) = pointer_type.is_struct() {
1549
1552
// NOTE: hack to workaround a limitation of the rustc API: see comment on
1550
1553
// CodegenCx.structs_as_pointer
1551
1554
aggregate_value.dereference_field(self.location, struct_type.get_field(idx as i32))
1552
1555
} else {
1553
1556
panic!("Unexpected type {:?}", value_type);
1554
- }
1557
+ }*/
1558
+ } else if let Some ( struct_type) = value_type. is_struct ( ) {
1559
+ let new_val = self . current_func ( ) . new_local ( None , value_type, "aggregate_value" ) ;
1560
+ self . block . add_assignment ( None , new_val, aggregate_value) ;
1561
+ let lvalue = new_val. access_field ( None , struct_type. get_field ( idx as i32 ) ) ;
1562
+ let lvalue_type = lvalue. to_rvalue ( ) . get_type ( ) ;
1563
+ let value =
1564
+ // NOTE: sometimes, rustc will create a value with the wrong type.
1565
+ if lvalue_type != value. get_type ( ) {
1566
+ self . context . new_cast ( self . location , value, lvalue_type)
1567
+ }
1568
+ else {
1569
+ value
1570
+ } ;
1571
+ self . block . add_assignment ( None , lvalue, value) ;
1572
+ return new_val. to_rvalue ( ) ;
1555
1573
} else {
1556
1574
panic ! ( "Unexpected type {:?}" , value_type) ;
1557
1575
} ;
1558
1576
1559
- let lvalue_type = lvalue. to_rvalue ( ) . get_type ( ) ;
1577
+ panic ! ( ) ;
1578
+
1579
+ /*let lvalue_type = lvalue.to_rvalue().get_type();
1560
1580
let value =
1561
1581
// NOTE: sometimes, rustc will create a value with the wrong type.
1562
1582
if lvalue_type != value.get_type() {
@@ -1568,7 +1588,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
1568
1588
1569
1589
self.llbb().add_assignment(self.location, lvalue, value);
1570
1590
1571
- aggregate_value
1591
+ aggregate_value*/
1572
1592
}
1573
1593
1574
1594
fn set_personality_fn ( & mut self , _personality : Function < ' gcc > ) {
0 commit comments