[PATCH] D155588: [NFC][AMDGPULowerModuleLDSPass] Cleanup of getTableLookupKernelIndex
Juan Manuel Martinez CaamaƱo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 07:50:03 PDT 2023
jmmartinez updated this revision to Diff 541533.
jmmartinez added a comment.
- Use structured binding declaration
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155588/new/
https://reviews.llvm.org/D155588
Files:
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -701,22 +701,18 @@
// Accesses from a function use the amdgcn_lds_kernel_id intrinsic which
// lowers to a read from a live in register. Emit it once in the entry
// block to spare deduplicating it later.
- if (tableKernelIndexCache.count(F) == 0) {
- LLVMContext &Ctx = M.getContext();
- IRBuilder<> Builder(Ctx);
- FunctionType *FTy = FunctionType::get(Type::getInt32Ty(Ctx), {});
+ auto [It, Inserted] = tableKernelIndexCache.try_emplace(F);
+ if (Inserted) {
Function *Decl =
Intrinsic::getDeclaration(&M, Intrinsic::amdgcn_lds_kernel_id, {});
- BasicBlock::iterator it =
- F->getEntryBlock().getFirstNonPHIOrDbgOrAlloca();
- Instruction &i = *it;
- Builder.SetInsertPoint(&i);
+ auto InsertAt = F->getEntryBlock().getFirstNonPHIOrDbgOrAlloca();
+ IRBuilder<> Builder(&*InsertAt);
- tableKernelIndexCache[F] = Builder.CreateCall(FTy, Decl, {});
+ It->second = Builder.CreateCall(Decl, {});
}
- return tableKernelIndexCache[F];
+ return It->second;
}
static std::vector<Function *> assignLDSKernelIDToEachKernel(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155588.541533.patch
Type: text/x-patch
Size: 1384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230718/b8abc354/attachment.bin>
More information about the llvm-commits
mailing list