This is an archive of the discontinued LLVM Phabricator instance.

[WPD/LTT] Lower type test feeding assumes via phi correctly
ClosedPublic

Authored by tejohnson on Sep 15 2022, 8:48 PM.

Details

Summary

This fixes https://github.com/llvm/llvm-project/issues/57616.

Type test lowering in ThinLTO modules relies on having type id
summaries set up for the referenced types, which provide the type
test resolution. If there is no summary, the type tests are lowered
to false. At the very least, a default type id summary gives the
type tests a resolution of Unknown, which is handled correctly (ignored
by the first invocation of LTT, and lowered to true by the second).

WPD sets up the type id summaries (with a default type test resolution)
as it is processing the type tests, but only does this for the patterns
handled by WPD, which is a type test directly feeding an assume. In the
case of type tests feeding an assume via a phi, the type id summary was
not being set up, leading to the type tests being lowered to false
incorrectly.

Fix this by adding the default type id summary entries for all type ids
used on globals during index-only WPD.

This is not an issue for hybrid (split-lto-unit) LTO, as in that case
the type test resolution is determined and set up during LTT, since the
type definitions are in the regular LTO split module, and exported via
the summary to the ThinLTO split module.

Diff Detail

Event Timeline

tejohnson created this revision.Sep 15 2022, 8:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2022, 8:48 PM
tejohnson requested review of this revision.Sep 15 2022, 8:49 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2022, 8:49 PM
tejohnson edited the summary of this revision. (Show Details)Sep 15 2022, 8:50 PM
aeubanks accepted this revision.Sep 16 2022, 10:15 AM

thanks for the quick turnaround!

llvm/test/ThinLTO/X86/lower_type_test_phi.ll
52

can you simplify the IR? e.g. remove hidden, noundef, tbaa metadata, etc

This revision is now accepted and ready to land.Sep 16 2022, 10:15 AM

verified that this fixes the issue we're seeing

tejohnson updated this revision to Diff 460883.Sep 16 2022, 1:34 PM

Simplify test case and fix comment typo

This revision was landed with ongoing or failed builds.Sep 16 2022, 1:50 PM
This revision was automatically updated to reflect the committed changes.