Skip to content

Commit ec12f76

Browse files
committed
[AMDGPU] Add an option to run AMDGPUAttributorPass in full LTO
Currently `AMDGPUAttributorPass` is registered in default optimizer pipeline. This will allow the pass to run in default pipeline as well as at thinLTO post link stage. However, it will not run in full LTO post link stage. This patch adds an option to run it in full LTO. It is set to false by default.
1 parent 1d9e1c6 commit ec12f76

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ static cl::opt<bool> EnableSIModeRegisterPass(
301301
cl::init(true),
302302
cl::Hidden);
303303

304+
static cl::opt<bool> EnableAMDGPUAttributorInFullLTO(
305+
"amdgpu-attributor-enable-full-lto",
306+
cl::desc("Enable AMDGPUAttributorPass in full LTO post link stage"),
307+
cl::init(false), cl::Hidden);
308+
304309
// Enable GFX11.5+ s_singleuse_vdst insertion
305310
static cl::opt<bool>
306311
EnableInsertSingleUseVDST("amdgpu-enable-single-use-vdst",
@@ -734,21 +739,15 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
734739
PM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
735740
});
736741

737-
// FIXME: Why is AMDGPUAttributor not in CGSCC?
738-
PB.registerOptimizerLastEPCallback(
739-
[this](ModulePassManager &MPM, OptimizationLevel Level) {
740-
if (Level != OptimizationLevel::O0) {
741-
MPM.addPass(AMDGPUAttributorPass(*this));
742-
}
743-
});
744-
745742
PB.registerFullLinkTimeOptimizationLastEPCallback(
746743
[this](ModulePassManager &PM, OptimizationLevel Level) {
747744
// We want to support the -lto-partitions=N option as "best effort".
748745
// For that, we need to lower LDS earlier in the pipeline before the
749746
// module is partitioned for codegen.
750747
if (EnableLowerModuleLDS)
751748
PM.addPass(AMDGPULowerModuleLDSPass(*this));
749+
750+
PM.addPass(AMDGPUAttributorPass(*this));
752751
});
753752

754753
PB.registerRegClassFilterParsingCallback(

0 commit comments

Comments
 (0)