This is an archive of the discontinued LLVM Phabricator instance.

Fix assertion failure in global-merge with unused ConstantExpr
ClosedPublic

Authored by olista01 on Jun 8 2015, 8:42 AM.

Details

Summary

The global-merge pass was crashing because it assumes that all ConstantExprs (reached via the global variables that they use) have at least one user.

I haven't worked out a way to test this, as an unused ConstantExpr cannot be represented by serialised IR, and global-merge can only be run in llc, which does not run any passes which can make a ConstantExpr dead.

This (reduced to the point of silliness) C code triggers this bug when compiled for arm-none-eabi at -O1:

static a = 7;
static volatile b[10] = {&a};

c;
main() {
  c = 0;
  for (; c < 10;)
    printf(b[c]);
}

Diff Detail

Event Timeline

olista01 updated this revision to Diff 27314.Jun 8 2015, 8:42 AM
olista01 retitled this revision from to Fix assertion failure in global-merge with unused ConstantExpr.
olista01 updated this object.
olista01 edited the test plan for this revision. (Show Details)
olista01 added a reviewer: ab.
olista01 set the repository for this revision to rL LLVM.
olista01 added a subscriber: Unknown Object (MLST).
olista01 updated this object.Jun 8 2015, 8:42 AM
ab accepted this revision.Jun 8 2015, 9:16 AM
ab edited edge metadata.

Nice find, LGTM!

This revision is now accepted and ready to land.Jun 8 2015, 9:16 AM
This revision was automatically updated to reflect the committed changes.