[llvm] 71ba28e - Revert "AMDGPU: Use generic helper for skipping over allocas"
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 22 15:15:31 PDT 2023
Author: Matt Arsenault
Date: 2023-06-22T18:15:19-04:00
New Revision: 71ba28eaac46f964251a35d9f8d3cf042853e55b
URL: https://github.com/llvm/llvm-project/commit/71ba28eaac46f964251a35d9f8d3cf042853e55b
DIFF: https://github.com/llvm/llvm-project/commit/71ba28eaac46f964251a35d9f8d3cf042853e55b.diff
LOG: Revert "AMDGPU: Use generic helper for skipping over allocas"
This reverts commit aa7e09ebd38c5f23f6d7d6d8394a2aea04715ba9.
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
index 1feb2bf15aed3..f5323725250f3 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
@@ -40,6 +40,21 @@ class AMDGPULowerKernelArguments : public FunctionPass{
} // end anonymous namespace
+// skip allocas
+static BasicBlock::iterator getInsertPt(BasicBlock &BB) {
+ BasicBlock::iterator InsPt = BB.getFirstInsertionPt();
+ for (BasicBlock::iterator E = BB.end(); InsPt != E; ++InsPt) {
+ AllocaInst *AI = dyn_cast<AllocaInst>(&*InsPt);
+
+ // If this is a dynamic alloca, the value may depend on the loaded kernargs,
+ // so loads will need to be inserted before it.
+ if (!AI || !AI->isStaticAlloca())
+ break;
+ }
+
+ return InsPt;
+}
+
bool AMDGPULowerKernelArguments::runOnFunction(Function &F) {
CallingConv::ID CC = F.getCallingConv();
if (CC != CallingConv::AMDGPU_KERNEL || F.arg_empty())
@@ -52,7 +67,7 @@ bool AMDGPULowerKernelArguments::runOnFunction(Function &F) {
LLVMContext &Ctx = F.getParent()->getContext();
const DataLayout &DL = F.getParent()->getDataLayout();
BasicBlock &EntryBlock = *F.begin();
- IRBuilder<> Builder(&*EntryBlock.getFirstNonPHIOrDbgOrAlloca());
+ IRBuilder<> Builder(&*getInsertPt(EntryBlock));
const Align KernArgBaseAlign(16); // FIXME: Increase if necessary
const uint64_t BaseOffset = ST.getExplicitKernelArgOffset();
More information about the llvm-commits
mailing list