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

via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 12 23:19:21 PDT 2026


================
@@ -784,15 +784,18 @@ void AMDGPUSwLowerLDS::lowerKernelLDSAccesses(Function *Func,
   auto *WIdBlock = BasicBlock::Create(Ctx, "WId", Func, MallocBlock);
 
   // Move constant-size allocas from the original entry block to the new entry
-  // block (WIdBlock) so they remain static allocas.
-  for (BasicBlock::iterator BI = PrevEntryBlock->begin(),
-                            BE = PrevEntryBlock->end();
-       BI != BE;) {
-    Instruction &I = *BI++;
+  // 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->begin();
+  while (SplitIt != PrevEntryBlock->end() && isa<AllocaInst>(&*SplitIt))
----------------
skc7 wrote:

Updated in latest patch. Also rebased to latest main.

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


More information about the llvm-commits mailing list