This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Add support for existing Config::Freestanding option.
ClosedPublic

Authored by fhahn on Jan 13 2021, 1:00 PM.

Details

Summary

lto::Config has a field to control whether the build is "freestanding"
(no builtins) or not, but it is not hooked up to the code actually
running the passes.

This patch adds support for the flag to both the code that runs
optimization with the new and old pass managers, by explicitly adding a
TargetLibraryInfo instance. If Freestanding is true, all library functions
are disabled.

Diff Detail

Event Timeline

fhahn created this revision.Jan 13 2021, 1:00 PM
fhahn requested review of this revision.Jan 13 2021, 1:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2021, 1:00 PM
fhahn added inline comments.Jan 13 2021, 1:07 PM
llvm/lib/LTO/LTOBackend.cpp
313

@asbirlea I am trying to make the new PM use a TargetLibraryInfo with all functions disabled here. But for some reason, it appears as if the custom TLI is not used. Do you have any idea what the right way to do that would be?

LGTM. Did you figure out the answer of your inline comment?

fhahn added a subscriber: aeubanks.Jan 21 2021, 9:38 AM

LGTM. Did you figure out the answer of your inline comment?

Unfortunately not so far. @aeubanks @asbirlea do you know how to best disable all builtin functions with new NewPM?

aeubanks added inline comments.Jan 21 2021, 10:29 AM
llvm/lib/LTO/LTOBackend.cpp
313

I think you want runNewPMPasses on top of runNewPMCustomPasses (idk how much runNewPMCustomPasses is used).

asbirlea added inline comments.Jan 21 2021, 1:24 PM
llvm/lib/LTO/LTOBackend.cpp
313

^ add these changes to runNewPMPasses as well.

fhahn updated this revision to Diff 318302.Jan 21 2021, 1:25 PM

handle freestanding also for runNewPMPasses, add test for runNewPMCustomPasses.

This works as expected with the NewPM now, thanks!

llvm/lib/LTO/LTOBackend.cpp
313

Ah, there are 2 helpers for the NewPM, thanks!

steven_wu accepted this revision.Jan 21 2021, 1:53 PM

Looks good now. Thanks.

This revision is now accepted and ready to land.Jan 21 2021, 1:53 PM
This revision was automatically updated to reflect the committed changes.