On Fri, Aug 8, 2014 at 2:37 PM, Jakub Jelinek <ja...@redhat.com> wrote: > On Fri, Aug 08, 2014 at 02:26:25PM +0400, Yury Gribov wrote: >> I have been working on Asan global optimization pass lately. The goal is to >> remove redundant Asan checks from sanitized code. This should hopefully >> reduce Asan's speed/size overhead (which is currently ~2x). The patch is not >> yet ready for trunk (e.g. I haven't done bootstrap, etc. but Asan testsuite >> passed wo errors) but I thought I'd send it for preliminary review of >> algorithm and data structures (*). > > Thanks for working on it, I've just quickly skimmed it and it looks > reasonable. > > Similar optimization could be used for tsan builtins, or some of the ubsan > builtins (which is the reason why the pass is called sanopt).
That would be great. Note that tsan optimizations must be based around a different criteria. Any unlock/release operations must reset set of already checked locations. Also tsan does not care about non-escaped to other threads variables; e.g. it does not care about local_stack_array[rand()] expressions, while asan does. >> 3) in addition to redundant check removal, we could also move duplicate >> checks from e.g. branches of if-statement to their dominators. > > For that you'd need to be extra careful, you would need to avoid doing that > if any path doesn't contain the check, or if there are calls that e.g. could > not return (abort/exit/have infinite loop) in between, etc. > > Jakub