[llvm] [AMDGPU][ASAN] Move allocas to entry block in amdgpu-sw-lower-lds pass (PR #190772)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 17 11:50:39 PDT 2026


================
@@ -782,7 +782,20 @@ void AMDGPUSwLowerLDS::lowerKernelLDSAccesses(Function *Func,
   // Create WIdBlock block which has instructions related to selection of
   // {0,0,0} indiex work item in the work group.
   auto *WIdBlock = BasicBlock::Create(Ctx, "WId", Func, MallocBlock);
-  IRB.SetInsertPoint(WIdBlock, WIdBlock->begin());
+
+  // Move constant-size allocas from the original entry block to the new entry
+  // block (WIdBlock) so they remain static allocas. Splice the leading cluster
+  // in bulk, then move any stragglers that are interleaved with other
+  // instructions.
+  auto SplitIt = PrevEntryBlock->getFirstNonPHIOrDbgOrAlloca();
+  WIdBlock->splice(WIdBlock->end(), PrevEntryBlock, PrevEntryBlock->begin(),
+                   SplitIt);
+  for (Instruction &I : make_early_inc_range(*PrevEntryBlock))
----------------
arsenm wrote:

Could also reverse iterate instead of early_inc_rnage. This is also long enough for braces 

https://github.com/llvm/llvm-project/pull/190772


More information about the llvm-commits mailing list