[Bug analyzer/104943] New: Analyzer fails to purge state for local structs

dmalcolm at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 15 22:18:32 GMT 2022


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.


More information about the Gcc-bugs mailing list