@@ -243,22 +243,25 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
243243 _ => bug ! ( "OperandRef::extract_field({:?}): not applicable" , self )
244244 } ;
245245
246- let bitcast = |bx : & mut Bx , val, ty| {
246+ // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types.
247+ // Bools in union fields needs to be truncated.
248+ let to_immediate_or_cast = |bx : & mut Bx , val, ty| {
247249 if ty == bx. cx ( ) . type_i1 ( ) {
248250 bx. trunc ( val, ty)
249251 } else {
250252 bx. bitcast ( val, ty)
251253 }
252254 } ;
253255
254- // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types.
255256 match val {
256257 OperandValue :: Immediate ( ref mut llval) => {
257- * llval = bitcast ( bx, * llval, bx. cx ( ) . immediate_backend_type ( field) ) ;
258+ * llval = to_immediate_or_cast ( bx, * llval, bx. cx ( ) . immediate_backend_type ( field) ) ;
258259 }
259260 OperandValue :: Pair ( ref mut a, ref mut b) => {
260- * a = bitcast ( bx, * a, bx. cx ( ) . scalar_pair_element_backend_type ( field, 0 , true ) ) ;
261- * b = bitcast ( bx, * b, bx. cx ( ) . scalar_pair_element_backend_type ( field, 1 , true ) ) ;
261+ * a = to_immediate_or_cast ( bx, * a, bx. cx ( )
262+ . scalar_pair_element_backend_type ( field, 0 , true ) ) ;
263+ * b = to_immediate_or_cast ( bx, * b, bx. cx ( )
264+ . scalar_pair_element_backend_type ( field, 1 , true ) ) ;
262265 }
263266 OperandValue :: Ref ( ..) => bug ! ( )
264267 }
0 commit comments