This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO] Remove dead and dropped symbol declarations when possible
ClosedPublic

Authored by tejohnson on Feb 1 2018, 2:14 PM.

Details

Summary

Removing the dropped symbols will prevent indirect call promotion in the
ThinLTO Backend from adding a new reference to a symbol, which can
result in linker unsats. This can happen when we compile with a sample
profile collected from one binary by used for another, which may have
profiled targets that aren't used in the new binary.

Note that until dropDeadSymbols handles variables and aliases (in
progress), we may not be able to remove the declaration and can still
have an issue.

Diff Detail

Repository
rL LLVM

Event Timeline

tejohnson created this revision.Feb 1 2018, 2:14 PM
grimar accepted this revision.Feb 2 2018, 2:41 AM

Looks good to me. Thanks !
(suggestion is below)

lib/LTO/LTOBackend.cpp
417 ↗(On Diff #132472)

You can skip this check I think, removeDeadConstantUsers
would just do nothing in this case.

for (GlobalValue *GV : DeadGVs) {
  GV->removeDeadConstantUsers();

  // <comment>
  if (GV->use_empty())
    GV->eraseFromParent();
}
This revision is now accepted and ready to land.Feb 2 2018, 2:41 AM
tejohnson updated this revision to Diff 132905.Feb 5 2018, 4:03 PM

Update to reflect changes to drop dead variables and aliases

tejohnson updated this revision to Diff 132912.Feb 5 2018, 4:43 PM

Address comments

This revision was automatically updated to reflect the committed changes.