public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/104943] New: Analyzer fails to purge state for local structs
@ 2022-03-15 22:18 dmalcolm at gcc dot gnu.org
  2022-03-18 23:20 ` [Bug analyzer/104943] " cvs-commit at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-15 22:18 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104943
           Summary: Analyzer fails to purge state for local structs
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

State purging only happens for SSA names, and locals of struct type aren't SSA
names.

Given e.g.:

struct boxed {
  int value;
};

extern struct boxed boxed_add (struct boxed a, struct boxed b);
extern struct boxed boxed_mul (struct boxed a, struct boxed b);

struct boxed
test (struct boxed a, struct boxed b)
{
  struct boxed result = boxed_add (boxed_mul (a, a),
                                   boxed_mul (b, b));
  return result;
}

without optimization we have this gimple:

struct boxed test (struct boxed a, struct boxed b)
{
  struct boxed result;
  struct boxed D.1994;
  struct boxed D.1993;
  struct boxed D.1992;

  <bb 2> :
  D.1992 = boxed_mul (b, b);
  D.1993 = boxed_mul (a, a);
  result = boxed_add (D.1993, D.1992);
  D.1994 = result;
  result ={v} {CLOBBER(eol)};

  <bb 3> :
<L1>:
  return D.1994;

}

and this final exploded node:

EN 11:
preds: EN: 10
succs: 
callstring: []
after SN: 3
rmodel:
stack depth: 1
  frame (index 0): frame: ‘test’@1
clusters within frame: ‘test’@1
  cluster for: <anonymous>: CONJURED(D.1992 = boxed_mul (b, b);, <anonymous>)
  cluster for: <anonymous>: CONJURED(D.1993 = boxed_mul (a, a);, <anonymous>)
  cluster for: <anonymous>: CONJURED(result = boxed_add (D.1993, D.1992);,
result)
  cluster for: <anonymous>: CONJURED(result = boxed_add (D.1993, D.1992);,
result)
m_called_unknown_fn: TRUE
constraint_manager:
  equiv classes:
  constraints:

where the various <anonymous> are the values of the local temporaries of struct
type, which ought to be purged; they don't matter anymore.

Seen on linux kernel: drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c which
amongst other things has:

struct bw_fixed {
  int64_t value;
};

with numerous calls to manipulate values; the states get bloated with bindings
for temporaries that persist far longer than they are needed.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-18 23:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-15 22:18 [Bug analyzer/104943] New: Analyzer fails to purge state for local structs dmalcolm at gcc dot gnu.org
2022-03-18 23:20 ` [Bug analyzer/104943] " cvs-commit at gcc dot gnu.org
2022-03-18 23:21 ` cvs-commit at gcc dot gnu.org
2022-03-18 23:26 ` dmalcolm at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).