This is an archive of the discontinued LLVM Phabricator instance.

[NewPM] Add OptimizationLevel param to TargetMachine::registerPassBuilderCallbacks()
AbandonedPublic

Authored by aeubanks on Oct 30 2020, 10:57 AM.

Details

Reviewers
bollu
Summary

To prevent targets from adding optional passes for -O0,
TargetMachine::registerPassBuilderCallbacks() needs an OptimizationLevel
parameter to see if it's O0.

Currently no existing users require this, but some targets that haven't
implemented TargetMachine::registerPassBuilderCallbacks() yet will
require it, e.g. AMDGPU.

This requires moving OptimizationLevel out of PassBuilder, or else
TargetMachine.h will have to #include all of PassBuilder.h.

Since registerPassBuilderCallbacks() now requires an OptimizationLevel,
we can't call it in PassBuilder's constructor. Rather, it's called when
we create a full pipeline, whether default or LTO or O0. This makes
sense since there's no need to run registerPassBuilderCallbacks() when
adding individual passes via PassBuilder, only when creating full
pipelines.

Diff Detail

Event Timeline

aeubanks created this revision.Oct 30 2020, 10:57 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
aeubanks requested review of this revision.Oct 30 2020, 10:57 AM
ychen added a subscriber: ychen.Nov 4 2020, 9:18 AM
ychen added inline comments.
llvm/lib/Target/BPF/BPFTargetMachine.cpp
129

Maybe I missed something. Except for PipelineStartEPCallback, all the other EP callbacks already take OptimizationLevel as input, do we only need to extend PipelineStartEPCallback to also take OptimizationLevel as input?

aeubanks added inline comments.Nov 4 2020, 10:42 AM
llvm/lib/Target/BPF/BPFTargetMachine.cpp
129

You're right, I didn't realize that. https://reviews.llvm.org/D90777 for that approach

aeubanks abandoned this revision.Nov 4 2020, 12:54 PM