Page MenuHomePhabricator

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

Authored by fhahn on Wed, Jan 13, 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.Wed, Jan 13, 1:00 PM
fhahn requested review of this revision.Wed, Jan 13, 1:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptWed, Jan 13, 1:00 PM
fhahn added inline comments.Wed, Jan 13, 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.Thu, Jan 21, 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.Thu, Jan 21, 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.Thu, Jan 21, 1:24 PM
llvm/lib/LTO/LTOBackend.cpp
313

^ add these changes to runNewPMPasses as well.

fhahn updated this revision to Diff 318302.Thu, Jan 21, 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.Thu, Jan 21, 1:53 PM

Looks good now. Thanks.

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