[llvm] [AMDGPU] Fix a potential wrong return value indicating whether a pass modifies a function (PR #88197)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 9 14:15:01 PDT 2024


https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/88197

When the alloca is too big for vectorization, the function could have already
been modified in previous iteration of the `for` loop.


>From 3cb7e72549dd47fc5c70911a7d5480037367dbcc Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Tue, 9 Apr 2024 17:12:18 -0400
Subject: [PATCH] [AMDGPU] Fix a potential wrong return value indicating
 whether a pass modifies a function

When the alloca is too big for vectorization, the function could have already
been modified in previous iteration of the `for` loop.
---
 llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
index 6f3cdf54dceec7..c0846b123d1870 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -336,7 +336,7 @@ bool AMDGPUPromoteAllocaImpl::run(Function &F, bool PromoteToLDS) {
     if (AllocaCost > VectorizationBudget) {
       LLVM_DEBUG(dbgs() << "  Alloca too big for vectorization: " << *AI
                         << "\n");
-      return false;
+      return Changed;
     }
 
     if (tryPromoteAllocaToVector(*AI)) {



More information about the llvm-commits mailing list