On Wed, Oct 24, 2012 at 05:11:23PM +0200, Dodji Seketeli wrote: > If I write exactly what you wrote here, I am getting an error for e.g: > > void > bar () > { > char bar[1] = {0}; > int n = 0; > > __builtin_memset (bar, 0, n); > }
I see, the problem is that build_check_stmt is initially called on an iterator in empty bb. Your solution is fine. > > On the other side, you IMHO want to handle here also __atomic_* and > > __sync_* builtins (not by using instrument_mem_region_access, but > > just instrument_derefs > > Updated in the patch below. case BUILT_IN_ATOMIC_ALWAYS_LOCK_FREE: case BUILT_IN_ATOMIC_IS_LOCK_FREE: I think don't touch the memory at all (or not necessarily), and IMHO you don't want to handle the BUILT_IN_*_N variants either, those are just FE builtins that are lowered to the corresponding _{1,2,4,8,16} variants. > @@ -661,13 +702,477 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, > int volatilep = 0, unsignedp = 0; > get_inner_reference (t, &bitsize, &bitpos, &offset, > &mode, &unsignedp, &volatilep, false); > - if (bitpos != 0 || bitsize != size_in_bytes * BITS_PER_UNIT) > + if (bitpos % BITS_PER_UNIT || bitsize != size_in_bytes * BITS_PER_UNIT) > return; Shouldn't that be bitpos % (size_in_bytes * BITS_PER_UNIT) ? 1 byte or 2 byte access at bitpos 80 is fine, but 4 byte access is not. Jakub