@@ -616,171 +616,171 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
616
616
( _, "i8_add_with_overflow" ) =>
617
617
with_overflow_intrinsic ( bcx,
618
618
"llvm.sadd.with.overflow.i8" ,
619
- ret_ty,
620
619
llargs[ 0 ] ,
621
620
llargs[ 1 ] ,
621
+ llresult,
622
622
call_debug_location) ,
623
623
( _, "i16_add_with_overflow" ) =>
624
624
with_overflow_intrinsic ( bcx,
625
625
"llvm.sadd.with.overflow.i16" ,
626
- ret_ty,
627
626
llargs[ 0 ] ,
628
627
llargs[ 1 ] ,
628
+ llresult,
629
629
call_debug_location) ,
630
630
( _, "i32_add_with_overflow" ) =>
631
631
with_overflow_intrinsic ( bcx,
632
632
"llvm.sadd.with.overflow.i32" ,
633
- ret_ty,
634
633
llargs[ 0 ] ,
635
634
llargs[ 1 ] ,
635
+ llresult,
636
636
call_debug_location) ,
637
637
( _, "i64_add_with_overflow" ) =>
638
638
with_overflow_intrinsic ( bcx,
639
639
"llvm.sadd.with.overflow.i64" ,
640
- ret_ty,
641
640
llargs[ 0 ] ,
642
641
llargs[ 1 ] ,
642
+ llresult,
643
643
call_debug_location) ,
644
644
645
645
( _, "u8_add_with_overflow" ) =>
646
646
with_overflow_intrinsic ( bcx,
647
647
"llvm.uadd.with.overflow.i8" ,
648
- ret_ty,
649
648
llargs[ 0 ] ,
650
649
llargs[ 1 ] ,
650
+ llresult,
651
651
call_debug_location) ,
652
652
( _, "u16_add_with_overflow" ) =>
653
653
with_overflow_intrinsic ( bcx,
654
654
"llvm.uadd.with.overflow.i16" ,
655
- ret_ty,
656
655
llargs[ 0 ] ,
657
656
llargs[ 1 ] ,
657
+ llresult,
658
658
call_debug_location) ,
659
659
( _, "u32_add_with_overflow" ) =>
660
660
with_overflow_intrinsic ( bcx,
661
661
"llvm.uadd.with.overflow.i32" ,
662
- ret_ty,
663
662
llargs[ 0 ] ,
664
663
llargs[ 1 ] ,
664
+ llresult,
665
665
call_debug_location) ,
666
666
( _, "u64_add_with_overflow" ) =>
667
667
with_overflow_intrinsic ( bcx,
668
668
"llvm.uadd.with.overflow.i64" ,
669
- ret_ty,
670
669
llargs[ 0 ] ,
671
670
llargs[ 1 ] ,
671
+ llresult,
672
672
call_debug_location) ,
673
673
( _, "i8_sub_with_overflow" ) =>
674
674
with_overflow_intrinsic ( bcx,
675
675
"llvm.ssub.with.overflow.i8" ,
676
- ret_ty,
677
676
llargs[ 0 ] ,
678
677
llargs[ 1 ] ,
678
+ llresult,
679
679
call_debug_location) ,
680
680
( _, "i16_sub_with_overflow" ) =>
681
681
with_overflow_intrinsic ( bcx,
682
682
"llvm.ssub.with.overflow.i16" ,
683
- ret_ty,
684
683
llargs[ 0 ] ,
685
684
llargs[ 1 ] ,
685
+ llresult,
686
686
call_debug_location) ,
687
687
( _, "i32_sub_with_overflow" ) =>
688
688
with_overflow_intrinsic ( bcx,
689
689
"llvm.ssub.with.overflow.i32" ,
690
- ret_ty,
691
690
llargs[ 0 ] ,
692
691
llargs[ 1 ] ,
692
+ llresult,
693
693
call_debug_location) ,
694
694
( _, "i64_sub_with_overflow" ) =>
695
695
with_overflow_intrinsic ( bcx,
696
696
"llvm.ssub.with.overflow.i64" ,
697
- ret_ty,
698
697
llargs[ 0 ] ,
699
698
llargs[ 1 ] ,
699
+ llresult,
700
700
call_debug_location) ,
701
701
( _, "u8_sub_with_overflow" ) =>
702
702
with_overflow_intrinsic ( bcx,
703
703
"llvm.usub.with.overflow.i8" ,
704
- ret_ty,
705
704
llargs[ 0 ] ,
706
705
llargs[ 1 ] ,
706
+ llresult,
707
707
call_debug_location) ,
708
708
( _, "u16_sub_with_overflow" ) =>
709
709
with_overflow_intrinsic ( bcx,
710
710
"llvm.usub.with.overflow.i16" ,
711
- ret_ty,
712
711
llargs[ 0 ] ,
713
712
llargs[ 1 ] ,
713
+ llresult,
714
714
call_debug_location) ,
715
715
( _, "u32_sub_with_overflow" ) =>
716
716
with_overflow_intrinsic ( bcx,
717
717
"llvm.usub.with.overflow.i32" ,
718
- ret_ty,
719
718
llargs[ 0 ] ,
720
719
llargs[ 1 ] ,
720
+ llresult,
721
721
call_debug_location) ,
722
722
( _, "u64_sub_with_overflow" ) =>
723
723
with_overflow_intrinsic ( bcx,
724
724
"llvm.usub.with.overflow.i64" ,
725
- ret_ty,
726
725
llargs[ 0 ] ,
727
726
llargs[ 1 ] ,
727
+ llresult,
728
728
call_debug_location) ,
729
729
( _, "i8_mul_with_overflow" ) =>
730
730
with_overflow_intrinsic ( bcx,
731
731
"llvm.smul.with.overflow.i8" ,
732
- ret_ty,
733
732
llargs[ 0 ] ,
734
733
llargs[ 1 ] ,
734
+ llresult,
735
735
call_debug_location) ,
736
736
( _, "i16_mul_with_overflow" ) =>
737
737
with_overflow_intrinsic ( bcx,
738
738
"llvm.smul.with.overflow.i16" ,
739
- ret_ty,
740
739
llargs[ 0 ] ,
741
740
llargs[ 1 ] ,
741
+ llresult,
742
742
call_debug_location) ,
743
743
( _, "i32_mul_with_overflow" ) =>
744
744
with_overflow_intrinsic ( bcx,
745
745
"llvm.smul.with.overflow.i32" ,
746
- ret_ty,
747
746
llargs[ 0 ] ,
748
747
llargs[ 1 ] ,
748
+ llresult,
749
749
call_debug_location) ,
750
750
( _, "i64_mul_with_overflow" ) =>
751
751
with_overflow_intrinsic ( bcx,
752
752
"llvm.smul.with.overflow.i64" ,
753
- ret_ty,
754
753
llargs[ 0 ] ,
755
754
llargs[ 1 ] ,
755
+ llresult,
756
756
call_debug_location) ,
757
757
( _, "u8_mul_with_overflow" ) =>
758
758
with_overflow_intrinsic ( bcx,
759
759
"llvm.umul.with.overflow.i8" ,
760
- ret_ty,
761
760
llargs[ 0 ] ,
762
761
llargs[ 1 ] ,
762
+ llresult,
763
763
call_debug_location) ,
764
764
( _, "u16_mul_with_overflow" ) =>
765
765
with_overflow_intrinsic ( bcx,
766
766
"llvm.umul.with.overflow.i16" ,
767
- ret_ty,
768
767
llargs[ 0 ] ,
769
768
llargs[ 1 ] ,
769
+ llresult,
770
770
call_debug_location) ,
771
771
( _, "u32_mul_with_overflow" ) =>
772
772
with_overflow_intrinsic ( bcx,
773
773
"llvm.umul.with.overflow.i32" ,
774
- ret_ty,
775
774
llargs[ 0 ] ,
776
775
llargs[ 1 ] ,
776
+ llresult,
777
777
call_debug_location) ,
778
778
( _, "u64_mul_with_overflow" ) =>
779
779
with_overflow_intrinsic ( bcx,
780
780
"llvm.umul.with.overflow.i64" ,
781
- ret_ty,
782
781
llargs[ 0 ] ,
783
782
llargs[ 1 ] ,
783
+ llresult,
784
784
call_debug_location) ,
785
785
786
786
( _, "unchecked_udiv" ) => UDiv ( bcx, llargs[ 0 ] , llargs[ 1 ] , call_debug_location) ,
@@ -1053,9 +1053,9 @@ fn count_zeros_intrinsic(bcx: Block,
1053
1053
1054
1054
fn with_overflow_intrinsic < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
1055
1055
name : & ' static str ,
1056
- t : Ty < ' tcx > ,
1057
1056
a : ValueRef ,
1058
1057
b : ValueRef ,
1058
+ out : ValueRef ,
1059
1059
call_debug_location : DebugLoc )
1060
1060
-> ValueRef {
1061
1061
let llfn = bcx. ccx ( ) . get_intrinsic ( & name) ;
@@ -1064,16 +1064,10 @@ fn with_overflow_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
1064
1064
let val = Call ( bcx, llfn, & [ a, b] , None , call_debug_location) ;
1065
1065
let result = ExtractValue ( bcx, val, 0 ) ;
1066
1066
let overflow = ZExt ( bcx, ExtractValue ( bcx, val, 1 ) , Type :: bool ( bcx. ccx ( ) ) ) ;
1067
- let ret = C_undef ( type_of:: type_of ( bcx. ccx ( ) , t) ) ;
1068
- let ret = InsertValue ( bcx, ret, result, 0 ) ;
1069
- let ret = InsertValue ( bcx, ret, overflow, 1 ) ;
1070
- if !arg_is_indirect ( bcx. ccx ( ) , t) {
1071
- let tmp = alloc_ty ( bcx, t, "tmp" ) ;
1072
- Store ( bcx, ret, tmp) ;
1073
- load_ty ( bcx, tmp, t)
1074
- } else {
1075
- ret
1076
- }
1067
+ Store ( bcx, result, StructGEP ( bcx, out, 0 ) ) ;
1068
+ Store ( bcx, overflow, StructGEP ( bcx, out, 1 ) ) ;
1069
+
1070
+ C_nil ( bcx. ccx ( ) )
1077
1071
}
1078
1072
1079
1073
fn try_intrinsic < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
0 commit comments