@@ -616,171 +616,171 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
616616 ( _, "i8_add_with_overflow" ) =>
617617 with_overflow_intrinsic ( bcx,
618618 "llvm.sadd.with.overflow.i8" ,
619- ret_ty,
620619 llargs[ 0 ] ,
621620 llargs[ 1 ] ,
621+ llresult,
622622 call_debug_location) ,
623623 ( _, "i16_add_with_overflow" ) =>
624624 with_overflow_intrinsic ( bcx,
625625 "llvm.sadd.with.overflow.i16" ,
626- ret_ty,
627626 llargs[ 0 ] ,
628627 llargs[ 1 ] ,
628+ llresult,
629629 call_debug_location) ,
630630 ( _, "i32_add_with_overflow" ) =>
631631 with_overflow_intrinsic ( bcx,
632632 "llvm.sadd.with.overflow.i32" ,
633- ret_ty,
634633 llargs[ 0 ] ,
635634 llargs[ 1 ] ,
635+ llresult,
636636 call_debug_location) ,
637637 ( _, "i64_add_with_overflow" ) =>
638638 with_overflow_intrinsic ( bcx,
639639 "llvm.sadd.with.overflow.i64" ,
640- ret_ty,
641640 llargs[ 0 ] ,
642641 llargs[ 1 ] ,
642+ llresult,
643643 call_debug_location) ,
644644
645645 ( _, "u8_add_with_overflow" ) =>
646646 with_overflow_intrinsic ( bcx,
647647 "llvm.uadd.with.overflow.i8" ,
648- ret_ty,
649648 llargs[ 0 ] ,
650649 llargs[ 1 ] ,
650+ llresult,
651651 call_debug_location) ,
652652 ( _, "u16_add_with_overflow" ) =>
653653 with_overflow_intrinsic ( bcx,
654654 "llvm.uadd.with.overflow.i16" ,
655- ret_ty,
656655 llargs[ 0 ] ,
657656 llargs[ 1 ] ,
657+ llresult,
658658 call_debug_location) ,
659659 ( _, "u32_add_with_overflow" ) =>
660660 with_overflow_intrinsic ( bcx,
661661 "llvm.uadd.with.overflow.i32" ,
662- ret_ty,
663662 llargs[ 0 ] ,
664663 llargs[ 1 ] ,
664+ llresult,
665665 call_debug_location) ,
666666 ( _, "u64_add_with_overflow" ) =>
667667 with_overflow_intrinsic ( bcx,
668668 "llvm.uadd.with.overflow.i64" ,
669- ret_ty,
670669 llargs[ 0 ] ,
671670 llargs[ 1 ] ,
671+ llresult,
672672 call_debug_location) ,
673673 ( _, "i8_sub_with_overflow" ) =>
674674 with_overflow_intrinsic ( bcx,
675675 "llvm.ssub.with.overflow.i8" ,
676- ret_ty,
677676 llargs[ 0 ] ,
678677 llargs[ 1 ] ,
678+ llresult,
679679 call_debug_location) ,
680680 ( _, "i16_sub_with_overflow" ) =>
681681 with_overflow_intrinsic ( bcx,
682682 "llvm.ssub.with.overflow.i16" ,
683- ret_ty,
684683 llargs[ 0 ] ,
685684 llargs[ 1 ] ,
685+ llresult,
686686 call_debug_location) ,
687687 ( _, "i32_sub_with_overflow" ) =>
688688 with_overflow_intrinsic ( bcx,
689689 "llvm.ssub.with.overflow.i32" ,
690- ret_ty,
691690 llargs[ 0 ] ,
692691 llargs[ 1 ] ,
692+ llresult,
693693 call_debug_location) ,
694694 ( _, "i64_sub_with_overflow" ) =>
695695 with_overflow_intrinsic ( bcx,
696696 "llvm.ssub.with.overflow.i64" ,
697- ret_ty,
698697 llargs[ 0 ] ,
699698 llargs[ 1 ] ,
699+ llresult,
700700 call_debug_location) ,
701701 ( _, "u8_sub_with_overflow" ) =>
702702 with_overflow_intrinsic ( bcx,
703703 "llvm.usub.with.overflow.i8" ,
704- ret_ty,
705704 llargs[ 0 ] ,
706705 llargs[ 1 ] ,
706+ llresult,
707707 call_debug_location) ,
708708 ( _, "u16_sub_with_overflow" ) =>
709709 with_overflow_intrinsic ( bcx,
710710 "llvm.usub.with.overflow.i16" ,
711- ret_ty,
712711 llargs[ 0 ] ,
713712 llargs[ 1 ] ,
713+ llresult,
714714 call_debug_location) ,
715715 ( _, "u32_sub_with_overflow" ) =>
716716 with_overflow_intrinsic ( bcx,
717717 "llvm.usub.with.overflow.i32" ,
718- ret_ty,
719718 llargs[ 0 ] ,
720719 llargs[ 1 ] ,
720+ llresult,
721721 call_debug_location) ,
722722 ( _, "u64_sub_with_overflow" ) =>
723723 with_overflow_intrinsic ( bcx,
724724 "llvm.usub.with.overflow.i64" ,
725- ret_ty,
726725 llargs[ 0 ] ,
727726 llargs[ 1 ] ,
727+ llresult,
728728 call_debug_location) ,
729729 ( _, "i8_mul_with_overflow" ) =>
730730 with_overflow_intrinsic ( bcx,
731731 "llvm.smul.with.overflow.i8" ,
732- ret_ty,
733732 llargs[ 0 ] ,
734733 llargs[ 1 ] ,
734+ llresult,
735735 call_debug_location) ,
736736 ( _, "i16_mul_with_overflow" ) =>
737737 with_overflow_intrinsic ( bcx,
738738 "llvm.smul.with.overflow.i16" ,
739- ret_ty,
740739 llargs[ 0 ] ,
741740 llargs[ 1 ] ,
741+ llresult,
742742 call_debug_location) ,
743743 ( _, "i32_mul_with_overflow" ) =>
744744 with_overflow_intrinsic ( bcx,
745745 "llvm.smul.with.overflow.i32" ,
746- ret_ty,
747746 llargs[ 0 ] ,
748747 llargs[ 1 ] ,
748+ llresult,
749749 call_debug_location) ,
750750 ( _, "i64_mul_with_overflow" ) =>
751751 with_overflow_intrinsic ( bcx,
752752 "llvm.smul.with.overflow.i64" ,
753- ret_ty,
754753 llargs[ 0 ] ,
755754 llargs[ 1 ] ,
755+ llresult,
756756 call_debug_location) ,
757757 ( _, "u8_mul_with_overflow" ) =>
758758 with_overflow_intrinsic ( bcx,
759759 "llvm.umul.with.overflow.i8" ,
760- ret_ty,
761760 llargs[ 0 ] ,
762761 llargs[ 1 ] ,
762+ llresult,
763763 call_debug_location) ,
764764 ( _, "u16_mul_with_overflow" ) =>
765765 with_overflow_intrinsic ( bcx,
766766 "llvm.umul.with.overflow.i16" ,
767- ret_ty,
768767 llargs[ 0 ] ,
769768 llargs[ 1 ] ,
769+ llresult,
770770 call_debug_location) ,
771771 ( _, "u32_mul_with_overflow" ) =>
772772 with_overflow_intrinsic ( bcx,
773773 "llvm.umul.with.overflow.i32" ,
774- ret_ty,
775774 llargs[ 0 ] ,
776775 llargs[ 1 ] ,
776+ llresult,
777777 call_debug_location) ,
778778 ( _, "u64_mul_with_overflow" ) =>
779779 with_overflow_intrinsic ( bcx,
780780 "llvm.umul.with.overflow.i64" ,
781- ret_ty,
782781 llargs[ 0 ] ,
783782 llargs[ 1 ] ,
783+ llresult,
784784 call_debug_location) ,
785785
786786 ( _, "unchecked_udiv" ) => UDiv ( bcx, llargs[ 0 ] , llargs[ 1 ] , call_debug_location) ,
@@ -1053,9 +1053,9 @@ fn count_zeros_intrinsic(bcx: Block,
10531053
10541054fn with_overflow_intrinsic < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
10551055 name : & ' static str ,
1056- t : Ty < ' tcx > ,
10571056 a : ValueRef ,
10581057 b : ValueRef ,
1058+ out : ValueRef ,
10591059 call_debug_location : DebugLoc )
10601060 -> ValueRef {
10611061 let llfn = bcx. ccx ( ) . get_intrinsic ( & name) ;
@@ -1064,16 +1064,10 @@ fn with_overflow_intrinsic<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
10641064 let val = Call ( bcx, llfn, & [ a, b] , None , call_debug_location) ;
10651065 let result = ExtractValue ( bcx, val, 0 ) ;
10661066 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 ( ) )
10771071}
10781072
10791073fn try_intrinsic < ' blk , ' tcx > ( bcx : Block < ' blk , ' tcx > ,
0 commit comments