This is an archive of the discontinued LLVM Phabricator instance.

[DeviceRTL] Allow IsSPMDMode to be optimized out in LTO mode
ClosedPublic

Authored by jhuber6 on Oct 5 2022, 9:06 AM.

Details

Summary

A previous patch merged the static and bitcode versions of the
deviceRTL. We previously used the static library's separate compilation
to set a special flag that prevented IsSPMDMode from being put in the
used list and preventing it from being optimized out. When they were
merged we could no longer do this separate compilation that allowed
users of LTO to get more optimal code.

This patch rearranges the code. The IsSPMDMode global is now
transitively used by its inclusion in the changed __keep_alive
function. This allows us to then manually delete the __keep_alive
function from the module when building the static library via
llvm-extract. The result is that the bitcode library correctly will
maintain the needed shared state, while the static library will be able
to internalize it and optimize it out.

Diff Detail

Event Timeline

jhuber6 created this revision.Oct 5 2022, 9:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 9:06 AM
Herald added a subscriber: inglorion. · View Herald Transcript
jhuber6 requested review of this revision.Oct 5 2022, 9:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 9:06 AM
This revision is now accepted and ready to land.Oct 5 2022, 11:30 AM