https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126130

            Bug ID: 126130
           Summary: IPA PTA: Points-to sets shouldn't contain
                    function-name.{clobber, use, result}
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pheeck at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu

Compile this testcase with -O2 -fipa-pta -fdump-tree-pta2-details with trunk
GCC

---- testcase.c ----
enum vlc_module_properties { VLC_MODULE_CB_OPEN };
char ParseNALBlock_p_frag_0;
int vlc_entry__0_9_0f_p_submodule;
void Open();
void vlc_module_set(int *, enum vlc_module_properties, void *);
void vlc_entry__0_9_0f() {
  vlc_module_set(&vlc_entry__0_9_0f_p_submodule, VLC_MODULE_CB_OPEN, Open);
}
void ParseNALBlock();
void Open() { ParseNALBlock(); }
void bs_read_ue();
void ParseNALBlock() {
  if (ParseNALBlock_p_frag_0)
    bs_read_ue();
}
---- ----

In the pta2 dump you'll see

vlc_entry__0_9_0f_p_submodule = { NULL ESCAPED NONLOCAL Open
vlc_entry__0_9_0f_p_submodule Open.clobber Open.use Open.result }
callarg(36) = { NULL ESCAPED NONLOCAL Open vlc_entry__0_9_0f_p_submodule
Open.clobber Open.use Open.result }
callarg(38) = { ESCAPED Open Open.clobber Open.use Open.result }

and more points-to sets containing .clobber .use, and .result points-to
subvariables of the function Open.  As far as I know, this is meaningless.  A
pointer cannot point to Open.clobber nor .use nor .result.  Therefore it
shouldn't be possible for them to be elements of points-to sets.

The fact that this currently happens possibly makes IPA PTA less precise.

The problem stems from these two constraints:

callarg(38) = &Open
callarg(38) = callarg(38) + UNKNOWN

The first one ensures that the points-to set of callarg(38) contains Open.  The
second one is responsible for Open being expanded into Open.clobber, Open.use
and Open.result (this is done in pta-andersen.cc:solution_set_expand()).

While the constraints themselves make sense, we should ensure that
solution_set_expand() doesn't expand Open into .clobber, .use and .result
(perhaps by somehow specialcasing these kinds of subvariables).

Reply via email to