[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 07:34:20 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa2b1cb8c910: [NFC][AMDGPULowerKernelAttributes] Factorize repeated code into function (authored by jmmartinez).
Changed prior to commit:
https://reviews.llvm.org/D135266?vs=465379&id=465392#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135266/new/
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 IntrinsicId = IsV5OrAbove ? Intrinsic::amdgcn_implicitarg_ptr
+ : Intrinsic::amdgcn_dispatch_ptr;
+ StringRef Name = Intrinsic::getName(IntrinsicId);
+ 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.465392.patch
Type: text/x-patch
Size: 2135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221005/47674242/attachment.bin>
More information about the llvm-commits
mailing list