-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Port AMDGPURewriteUndefForPHI to new pass manager #66008
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
[AMDGPU] Port AMDGPURewriteUndefForPHI to new pass manager #66008
Conversation
This patch ports the AMDGPURewriteUndefForPHI pass to the new pass manager. With this, the pass is supported under both the legacy and the new pass managers.
@llvm/pr-subscribers-backend-amdgpu ChangesThis patch ports the AMDGPURewriteUndefForPHI pass to the new pass manager. With this, the pass is supported under both the legacy and the new pass managers.Full diff: https://github.com/llvm/llvm-project/pull/66008.diff 4 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h index 157a02ec31b2ec6..434943490caeab3 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPU.h +++ b/llvm/lib/Target/AMDGPU/AMDGPU.h @@ -291,6 +291,16 @@ FunctionPass *createAMDGPURewriteUndefForPHIPass(); void initializeAMDGPURewriteUndefForPHIPass(PassRegistry &); extern char &AMDGPURewriteUndefForPHIPassID; +class AMDGPURewriteUndefForPHIPass + : public PassInfoMixin { +private: + TargetMachine &TM; + +public: + AMDGPURewriteUndefForPHIPass(TargetMachine &TM) : TM(TM){}; + PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); +}; + void initializeSIAnnotateControlFlowPass(PassRegistry&); extern char &SIAnnotateControlFlowPassID; diff --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp b/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp index 9c07851243c9173..3e9625e954ea653 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteUndefForPHI.cpp @@ -177,6 +177,20 @@ bool AMDGPURewriteUndefForPHI::runOnFunction(Function &F) { return rewritePHIs(F, UA, DT); } +PreservedAnalyses +AMDGPURewriteUndefForPHIPass::run(Function &F, FunctionAnalysisManager &AM) { + UniformityInfo &UA = AM.getResult(F); + DominatorTree *DT = &AM.getResult(F); + bool Changed = rewritePHIs(F, UA, DT); + if (Changed) { + PreservedAnalyses PA; + PA.preserveSet(); + return PA; + } + + return PreservedAnalyses::all(); +} + FunctionPass *llvm::createAMDGPURewriteUndefForPHIPass() { return new AMDGPURewriteUndefForPHI(); } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 991681dafedaad1..befa036ee32df14 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -663,6 +663,10 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { PM.addPass(AMDGPULowerKernelArgumentsPass(*this)); return true; } + if (PassName == "amdgpu-rewrite-undef-for-phi") { + PM.addPass(AMDGPURewriteUndefForPHIPass(*this)); + return true; + } return false; }); diff --git a/llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll b/llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll index c0f6c5ae0240a69..4f6b9f474c13171 100644 --- a/llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll +++ b/llvm/test/CodeGen/AMDGPU/rewrite-undef-for-phi.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -mtriple=amdgcn-- -S -amdgpu-rewrite-undef-for-phi %s | FileCheck -check-prefix=OPT %s +; RUN: opt -mtriple=amdgcn-- -S -passes=amdgpu-rewrite-undef-for-phi %s | FileCheck -check-prefix=OPT %s define amdgpu_ps float @basic(float inreg %c, i32 %x) #0 { ; OPT-LABEL: @basic( |
|
||
return PreservedAnalyses::all(); | ||
} | ||
|
||
FunctionPass *llvm::createAMDGPURewriteUndefForPHIPass() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should rename all the legacy pass bits to end with "LegacyPass"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the class "AMDGPURewriteUndefForPHI" be renamed "AMDGPURewriteUndefForPHILegacy" or "AMDGPURewriteUndefForPHILegacyPass"? If the latter, we will end up with a function named "initializeAMDGPURewriteUndefForPHILegacyPassPass".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AMDGPURewriteUndefForPHILegacy, some places have always been stuck with "PassPass"
f2068b9
to
c68ad69
Compare
…-rewrite-undef-to-new-pass-mgr
This patch ports the AMDGPURewriteUndefForPHI pass to the new pass manager. With this, the pass is supported under both the legacy and the new pass managers.
PreservedAnalyses | ||
AMDGPURewriteUndefForPHIPass::run(Function &F, FunctionAnalysisManager &AM) { | ||
UniformityInfo &UA = AM.getResult<UniformityInfoAnalysis>(F); | ||
DominatorTree *DT = &AM.getResult<DominatorTreeAnalysis>(F); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why address of here?
This patch ports the AMDGPURewriteUndefForPHI pass to the new pass manager. With this, the pass is supported under both the legacy and the new pass managers. --------- Co-authored-by: Jun Wang <[email protected]>
This patch ports the AMDGPURewriteUndefForPHI pass to the new pass manager. With this, the pass is supported under both the legacy and the new pass managers.