This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO][NewPM] Clean up dead code under -O0
ClosedPublic

Authored by aeubanks on Feb 24 2021, 1:40 PM.

Details

Summary

We're running into undefined references using ThinLTO with -O0 on
Windows/Chrome. This fixes that.

This matches the legacy PM.

Diff Detail

Event Timeline

aeubanks created this revision.Feb 24 2021, 1:40 PM
aeubanks requested review of this revision.Feb 24 2021, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2021, 1:40 PM
aeubanks retitled this revision from [ThinLTO] Clean up dead code under -O0 to [ThinLTO][NewPM] Clean up dead code under -O0.Feb 24 2021, 1:41 PM
aeubanks added reviewers: hans, rnk, tejohnson.
tejohnson added inline comments.Feb 24 2021, 2:49 PM
llvm/lib/Passes/PassBuilder.cpp
1542–1550

Looking at the old PM, we also call:
MPM.add(createLowerTypeTestsPass(nullptr, nullptr, true));

to drop any leftover type tests. Thinking that should probably get added here too (it's normally done below in the ModuleSimplificationPipeline, but of course that doesn't get reached for O0).

aeubanks added inline comments.Feb 24 2021, 3:13 PM
llvm/lib/Passes/PassBuilder.cpp
1542–1550

It's already added right above, but only when we have an ImportSummary. Should another be added when we don't have an ImportSummary?

tejohnson added inline comments.Feb 24 2021, 4:18 PM
llvm/lib/Passes/PassBuilder.cpp
1542–1550

Note the args are different - LTT needs to be called a second time with the third parameter set to true to remove all the type tests that the first call leaves behind for potential use in optimization.

aeubanks updated this revision to Diff 326240.Feb 24 2021, 4:35 PM

add lowertypetests

llvm/lib/Passes/PassBuilder.cpp
1542–1550

ah I didn't notice that, done

tejohnson accepted this revision.Feb 24 2021, 4:38 PM

lgtm

llvm/lib/Passes/PassBuilder.cpp
1542–1550

Can you add a comment? Just use the one used where we do the same thing for O0 in the regular LTO pipeline:

// Run a second time to clean up any type tests left behind by WPD for use
// in ICP.
This revision is now accepted and ready to land.Feb 24 2021, 4:38 PM
aeubanks updated this revision to Diff 326241.Feb 24 2021, 4:43 PM

add comment

This revision was landed with ongoing or failed builds.Feb 24 2021, 5:09 PM
This revision was automatically updated to reflect the committed changes.