[PATCH] D135266: [NFC][AMDGPULowerKernelAttributes] Factorize repeated code into function
Juan Manuel Martinez CaamaƱo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 5 06:49:10 PDT 2022
jmmartinez created this revision.
Herald added subscribers: kosarev, foad, jdoerfert, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, jvesely, kzhuravl, arsenm.
Herald added a project: All.
jmmartinez requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135266
Files:
llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPULowerKernelAttributes.cpp
@@ -74,6 +74,13 @@
}
};
+Function *getBasePtrIntrinsic(Module &M, bool IsV5OrAbove) {
+ auto Intrinsic = IsV5OrAbove ? Intrinsic::amdgcn_implicitarg_ptr
+ : Intrinsic::amdgcn_dispatch_ptr;
+ StringRef Name = Intrinsic::getName(Intrinsic);
+ return M.getFunction(Name);
+}
+
} // end anonymous namespace
static bool processUse(CallInst *CI, bool IsV5OrAbove) {
@@ -315,17 +322,8 @@
// TargetPassConfig for subtarget.
bool AMDGPULowerKernelAttributes::runOnModule(Module &M) {
bool MadeChange = false;
- Function *BasePtr = nullptr;
bool IsV5OrAbove = AMDGPU::getAmdhsaCodeObjectVersion() >= 5;
- if (IsV5OrAbove) {
- StringRef ImplicitArgPtrName =
- Intrinsic::getName(Intrinsic::amdgcn_implicitarg_ptr);
- BasePtr = M.getFunction(ImplicitArgPtrName);
- } else { // Pre-V5.
- StringRef DispatchPtrName =
- Intrinsic::getName(Intrinsic::amdgcn_dispatch_ptr);
- BasePtr = M.getFunction(DispatchPtrName);
- }
+ Function *BasePtr = getBasePtrIntrinsic(M, IsV5OrAbove);
if (!BasePtr) // ImplicitArgPtr/DispatchPtr not used.
return false;
@@ -356,17 +354,8 @@
PreservedAnalyses
AMDGPULowerKernelAttributesPass::run(Function &F, FunctionAnalysisManager &AM) {
- Function *BasePtr = nullptr;
bool IsV5OrAbove = AMDGPU::getAmdhsaCodeObjectVersion() >= 5;
- if (IsV5OrAbove) {
- StringRef ImplicitArgPtrName =
- Intrinsic::getName(Intrinsic::amdgcn_implicitarg_ptr);
- BasePtr = F.getParent()->getFunction(ImplicitArgPtrName);
- } else { // Pre_V5.
- StringRef DispatchPtrName =
- Intrinsic::getName(Intrinsic::amdgcn_dispatch_ptr);
- BasePtr = F.getParent()->getFunction(DispatchPtrName);
- }
+ Function *BasePtr = getBasePtrIntrinsic(*F.getParent(), IsV5OrAbove);
if (!BasePtr) // ImplicitArgPtr/DispatchPtr not used.
return PreservedAnalyses::all();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135266.465379.patch
Type: text/x-patch
Size: 2129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/6b98c8c8/attachment.bin>
More information about the llvm-commits
mailing list