On Tue, Jun 13, 2017 at 03:11:41PM +0300, Maxim Ostapenko wrote: > @@ -531,11 +533,166 @@ get_mem_ref_of_assignment (const gassign *assignment, > return true; > } > > +/* Return address of last allocated dynamic alloca. */ > + > +static tree > +get_last_alloca_addr () > +{ > + if (last_alloca_addr) > + return last_alloca_addr; > + > + gimple_seq seq = NULL; > + gassign *g; > + > + last_alloca_addr = create_tmp_reg (ptr_type_node, "last_alloca_addr"); > +/* Insert __asan_allocas_unpoison(top, bottom) call after > + __builtin_stackrestore(new_sp) call.
s/stackrestore/stack_restore/, that is how the builtin is called, right? Also, please put a space before ( even in comments. > +static void > +handle_builtin_stackrestore (gcall *call, gimple_stmt_iterator *iter) Again, stack_restore > + bool alloca_with_align > + = (DECL_FUNCTION_CODE (callee) == BUILT_IN_ALLOCA_WITH_ALIGN); Unnecessary ()s around the comparison? > --- a/gcc/cfgexpand.c > +++ b/gcc/cfgexpand.c > @@ -2241,6 +2241,10 @@ expand_used_vars (void) > expand_stack_vars (NULL, &data); > } > > + if ((flag_sanitize & SANITIZE_ADDRESS) && cfun->calls_alloca) > + var_end_seq = asan_emit_allocas_unpoison (virtual_stack_dynamic_rtx, > + virtual_stack_vars_rtx); > + Doesn't this mean the old var_end_seq is lost because of this (in functions that call alloca, but also have addressable variables we asan instrument)? I'd think you need to append the sequences, or call asan_emit_allocas_unpoison with the var_end_seq as argument and insert it into the new sequence. Jakub