On Thu, Jan 21, 2021 at 06:35:48PM -0300, Alexandre Oliva wrote:
> 
> Ada makes extensive use of nested functions, which turn all automatic
> variables of the enclosing function that are used in nested ones into
> members of an artificial FRAME record type.
> 
> The address of a local variable is usually passed to asan marking
> functions without using a temporary.  Taking the address of a member
> of FRAME within a nested function, however, is not regarded as a
> gimple val: while introducing FRAME variables, current_function_decl
> is always the outermost function, even while processing a nested
> function, so decl_address_invariant_p returns false for such
> ADDR_EXPRs.  So, as automatic variables are moved into FRAME, any asan
> call that marks such a variable has its ADDR_EXPR replaced with a
> SSA_NAME set to the ADDR_EXPR of the FRAME member.
> 
> asan_expand_mark_ifn was not prepared to deal with ADDR_EXPRs split
> out into SSA_NAMEs.  This patch deals with such cases.
> 
> [It does NOT deal with PHI nodes and whatnot.  I'm not even sure it
> should.  Maybe we want the ADDR_EXPR to be a gimple val instead, but
> this more conservative fix felt more appropriate for this stage.]
> 
> Regstrapped on x86_64-linux-gnu.  Ok to install?
> 
> 
> for  gcc/ChangeLog
> 
>       * asan.c (asan_expand_mark_ifn): Follow SSA_NAME defs for
>       an ADDR_EXPR base.
> 
> for  gcc/testsuite/ChangeLog
> 
>       * gcc.dg/asan/nested-1.c: New.

Ok, thanks (and thanks for coming with a C testcase, for me as not an Ada
speaker that helps a lot).

        Jakub

Reply via email to