[PATCH] D29369: [ubsan] Omit superflous overflow checks for promoted arithmetic (PR20193)

Vedant Kumar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 1 23:36:18 PST 2017


vsk added a comment.

In https://reviews.llvm.org/D29369#664366, @regehr wrote:

> Out of curiosity, how many of these superfluous checks are not subsequently eliminated by InstCombine?


I don't have numbers from a benchmark prepped. Here's what we get with the 'ubsan-promoted-arith.cpp' test case from this patch:

| Setup                        | # of overflow checks |
| unpatched, -O0               | 22                   |
| unpatched, -O0 + instcombine | 7                    |
| patched, -O0                 | 8                    |
| patched, -O0 + instcombine   | 7                    |

(There's a difference between the "patched, -O0" setup and the "patched, -O0 + instcombine" setup because llvm figures out that the symbol 'a' is 0, and gets rid of an addition that way.)

At least for us, this patch is still worthwhile, because our use case is `-O0 -fsanitized=undefined`. Also, this makes less work for instcombine, but I haven't measured the compile-time effect.


https://reviews.llvm.org/D29369





More information about the cfe-commits mailing list