[PATCH] D49492: Run bounds checking sanitizer earlier to make it easier to optimize away its checks.

Joel Galenson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 18 14:19:24 PDT 2018


jgalenson added a comment.

In https://reviews.llvm.org/D49492#1167064, @efriedma wrote:

> Are you sure this will actually do what you want, in general?  I suspect it will end up missing bounds checks in some cases because it's running it too early (before mem2reg/inlining/etc).


No, I'm not sure; that's one reason I'm asking for comments.  But I don't see any specific problems.  For example, I don't see why inlining would matter; the checks should still be added, just before inlining instead of after (which of course affects the inlining heuristic, but that's another matter).  I don't understand mem2reg as well, though.  Do you have specific examples you think might fail?

I was thinking about this in terms of other sanitizers I know, specifically the integer overflow sanitizer.  That adds overflow checks in Clang, which is before all of these LLVM passes.  So my thought was that moving bounds checks to be inserted earlier brings it closer to how the integer overflow sanitizer works.


Repository:
  rC Clang

https://reviews.llvm.org/D49492





More information about the cfe-commits mailing list