-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[AMDGPU][Attributor] Add ThinOrFullLTOPhase
as an argument
#123994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-lto @llvm/pr-subscribers-backend-amdgpu Author: Shilei Tian (shiltian) ChangesFull diff: https://github.com/llvm/llvm-project/pull/123994.diff 3 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 3d5a44a3623a00..f4921a68d7a1d6 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -333,9 +333,12 @@ class AMDGPUAttributorPass : public PassInfoMixin<AMDGPUAttributorPass> {
AMDGPUAttributorOptions Options;
+ const ThinOrFullLTOPhase LTOPhase;
+
public:
- AMDGPUAttributorPass(TargetMachine &TM, AMDGPUAttributorOptions Options = {})
- : TM(TM), Options(Options) {};
+ AMDGPUAttributorPass(TargetMachine &TM, AMDGPUAttributorOptions Options,
+ ThinOrFullLTOPhase LTOPhase = ThinOrFullLTOPhase::None)
+ : TM(TM), Options(Options), LTOPhase(LTOPhase) {};
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
};
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
index 546db318c17d53..2bc68cf2fd6a4a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAttributor.cpp
@@ -1330,7 +1330,8 @@ static void addPreloadKernArgHint(Function &F, TargetMachine &TM) {
}
static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
- AMDGPUAttributorOptions Options) {
+ AMDGPUAttributorOptions Options,
+ ThinOrFullLTOPhase LTOPhase) {
SetVector<Function *> Functions;
for (Function &F : M) {
if (!F.isIntrinsic())
@@ -1365,9 +1366,30 @@ static bool runImpl(Module &M, AnalysisGetter &AG, TargetMachine &TM,
Attributor A(Functions, InfoCache, AC);
- LLVM_DEBUG(dbgs() << "[AMDGPUAttributor] Module " << M.getName() << " is "
- << (AC.IsClosedWorldModule ? "" : "not ")
- << "assumed to be a closed world.\n");
+ LLVM_DEBUG({
+ StringRef LTOPhaseStr;
+ switch (LTOPhase) {
+ case ThinOrFullLTOPhase::None:
+ LTOPhaseStr = "None";
+ break;
+ case ThinOrFullLTOPhase::ThinLTOPreLink:
+ LTOPhaseStr = "ThinLTOPreLink";
+ break;
+ case ThinOrFullLTOPhase::ThinLTOPostLink:
+ LTOPhaseStr = "ThinLTOPostLink";
+ break;
+ case ThinOrFullLTOPhase::FullLTOPreLink:
+ LTOPhaseStr = "FullLTOPreLink";
+ break;
+ case ThinOrFullLTOPhase::FullLTOPostLink:
+ LTOPhaseStr = "FullLTOPostLink";
+ break;
+ }
+ dbgs() << "[AMDGPUAttributor] Running at phase " << LTOPhaseStr << '\n';
+ dbgs() << "[AMDGPUAttributor] Module " << M.getName() << " is "
+ << (AC.IsClosedWorldModule ? "" : "not ")
+ << "assumed to be a closed world.\n";
+ });
for (auto *F : Functions) {
A.getOrCreateAAFor<AAAMDAttributes>(IRPosition::function(*F));
@@ -1420,7 +1442,8 @@ class AMDGPUAttributorLegacy : public ModulePass {
bool runOnModule(Module &M) override {
AnalysisGetter AG(this);
- return runImpl(M, AG, *TM, /*Options=*/{});
+ return runImpl(M, AG, *TM, /*Options=*/{},
+ /*LTOPhase=*/ThinOrFullLTOPhase::None);
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
@@ -1441,8 +1464,8 @@ PreservedAnalyses llvm::AMDGPUAttributorPass::run(Module &M,
AnalysisGetter AG(FAM);
// TODO: Probably preserves CFG
- return runImpl(M, AG, TM, Options) ? PreservedAnalyses::none()
- : PreservedAnalyses::all();
+ return runImpl(M, AG, TM, Options, LTOPhase) ? PreservedAnalyses::none()
+ : PreservedAnalyses::all();
}
char AMDGPUAttributorLegacy::ID = 0;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index cb662258b26672..da4aa92c090fab 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -852,8 +852,10 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
OptimizationLevel Level,
ThinOrFullLTOPhase Phase) {
if (Level != OptimizationLevel::O0) {
- if (!isLTOPreLink(Phase))
- MPM.addPass(AMDGPUAttributorPass(*this));
+ if (!isLTOPreLink(Phase)) {
+ AMDGPUAttributorOptions Opts;
+ MPM.addPass(AMDGPUAttributorPass(*this, Opts, Phase));
+ }
}
});
@@ -876,7 +878,8 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
AMDGPUAttributorOptions Opt;
if (HasClosedWorldAssumption)
Opt.IsClosedWorld = true;
- PM.addPass(AMDGPUAttributorPass(*this, Opt));
+ PM.addPass(AMDGPUAttributorPass(
+ *this, Opt, ThinOrFullLTOPhase::FullLTOPostLink));
}
}
});
|
I'll add a test and update the description if the PR depending on it is good; otherwise this change is useless. |
arsenm
reviewed
Jan 23, 2025
34fd831
to
1c1acf3
Compare
arsenm
reviewed
Feb 5, 2025
55196cc
to
9b9a320
Compare
3118593
to
c3685eb
Compare
arsenm
reviewed
Mar 24, 2025
0666b69
to
5cb643d
Compare
5cb643d
to
b7efaf3
Compare
arsenm
reviewed
Apr 8, 2025
b7efaf3
to
aafd825
Compare
arsenm
approved these changes
May 1, 2025
aafd825
to
35fda65
Compare
35fda65
to
ed136cc
Compare
shiltian
added a commit
that referenced
this pull request
May 2, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
llvm-sync bot
pushed a commit
to arm/arm-toolchain
that referenced
this pull request
May 6, 2025
…inOrFullLTOPhase Phase)` llvm/llvm-project#123994 (comment)
GeorgeARM
pushed a commit
to GeorgeARM/llvm-project
that referenced
this pull request
May 7, 2025
GeorgeARM
pushed a commit
to GeorgeARM/llvm-project
that referenced
this pull request
May 7, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.