This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How does address sanitizer handle read-modify-write memory access?


Konstantin Serebryany <konstantin.s.serebryany@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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]