This is a prerequisite patch for http://reviews.llvm.org/D14603
Details
Diff Detail
Event Timeline
Just to be clear - APInt operators don't prevent or assert on overflow, it just provides *_ov methods that make it easier to recognise when overflow occurs. Please can you confirm that this approach will work for D14603?
I just want to make sure that you've been able to use this patch locally with a suitably updated D14603 to deal with the overflow test cases that we discussed.
I applied the patch locally and it worked with 0xFFFFFFFF. However, in practice, neither 0xFFFFFFFF nor 0 will flow into this function because llvm handles them with special cases. For 0, it returns a 0 directly, and for 0xFFFFFFFF, it returns 0 - (the other operand). I've hacked to bypass the special cases in order to test the overflow case could be handled correctly by this code.
If that is true - might it be better just to add suitable asserts / early returns to D14603 that check for cases that would overflow. In which case, I feel rather guilty as the APInt conversion work is probably unnecessary.....
I applied the patch locally and it worked with 0xFFFFFFFF. However, in practice, neither 0xFFFFFFFF nor 0 will flow into this function because llvm handles them with special cases. For 0, it returns a 0 directly, and for 0xFFFFFFFF, it returns 0 - (the other operand). I've hacked to bypass the special cases in order to test the overflow case could be handled correctly by this code.
Sure. I will discard this patch and update D14603.