This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO] Serialize WithGlobalValueDeadStripping index flag for distributed backends
ClosedPublic

Authored by tejohnson on Feb 1 2018, 8:17 AM.

Details

Summary

A recent fix to drop dead symbols (r323633) did not work for ThinLTO
distributed backends because we lose the WithGlobalValueDeadStripping
set on the index during the thin link. This patch adds a new flags
record to the bitcode format for the index, and serializes this flag
for the combined index (it would always be 0 for the per-module index
generated by the compile step, so no need to serialize the new flags
record there until/unless we add another flag that applies to the
per-module indexes).

Generally this flag should always be set for the distributed backends,
which are necessarily performed after the thin link. However, if we were
to simply set this flag on the index applied to the distributed backends
(invoked via clang), we would lose the ability to disable dead stripping
via -compute-dead=false for debugging purposes.

Diff Detail

Repository
rL LLVM

Event Timeline

tejohnson created this revision.Feb 1 2018, 8:17 AM
grimar added a comment.Feb 1 2018, 9:50 AM

Patch looks good and correct to me (with minor comment/suggestion).
I am newbie in LTO though, so I think somebody else should
give a final approval.

lib/Bitcode/Reader/BitcodeReader.cpp
5145 ↗(On Diff #132404)

I would make it a bit shorter:

uint64_t Flags = Record[0];
// Scan flags (set only on the combined index).
assert(Flags <= 1 && "Unexpected bits in flag");

// 1 bit: WithGlobalValueDeadStripping flag.
if (Flags & 0x1)
  TheIndex.setWithGlobalValueDeadStripping();
tejohnson updated this revision to Diff 132580.Feb 2 2018, 6:41 AM

Address comments

tejohnson marked an inline comment as done.Feb 2 2018, 6:42 AM

Patch looks good and correct to me (with minor comment/suggestion).
I am newbie in LTO though, so I think somebody else should
give a final approval.

@pcc can you take a look?

ping - @pcc any objections?

pcc accepted this revision.Feb 6 2018, 4:34 PM

LGTM

This revision is now accepted and ready to land.Feb 6 2018, 4:34 PM
This revision was automatically updated to reflect the committed changes.