Konstantin Serebryany <konstantin.s.serebry...@gmail.com> a écrit: > When we have a code like X++ (either RMW, or a regular increment) it > is enough for asan to instrument it just once (either as a read or a > write, doesn't matter). > LLVM implementation does this optimization for regular increments, > while GCC does not (yet). > > % cat inc.cc > void foo(int *a) { > (*a)++; > } > % clang -O2 -fsanitize=address -S -o - inc.cc | grep __asan_report > callq __asan_report_load4 > % gcc -O2 -fsanitize=address -S -o - inc.cc | grep __asan_report > call __asan_report_load4 > call __asan_report_store4 > > Doing two __asan_report* calls here is not a correctness bug, but a > performance problem. > I think we saw ~3%-5% performance gain due to this optimization in > LLVM, i.e. this is nice to have, but not critical.
Right. I plan to work on this kind of optimizations on asan soonish. I guess I should file a bug to track this in the mean time. -- Dodji