Page MenuHomePhabricator

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

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



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

Diff Detail

Unit TestsFailed

390 mslinux > HWAddressSanitizer-x86_64.TestCases::sizes.cpp
Script: -- : 'RUN: at line 3'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang --driver-mode=g++ -m64 -gline-tables-only -fsanitize=hwaddress -fuse-ld=lld -mcmodel=large -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions /mnt/disks/ssd0/agent/llvm-project/compiler-rt/test/hwasan/TestCases/sizes.cpp -nostdlib++ -lstdc++ -o /mnt/disks/ssd0/agent/llvm-project/build/projects/compiler-rt/test/hwasan/X86_64/TestCases/Output/sizes.cpp.tmp

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.

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

You're right, I didn't realize that. for that approach

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