[llvm] b4df0da - [AMDGPU] Fix a potential wrong return value indicating whether a pass modifies a function (#88197)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 12 06:34:50 PDT 2024
Author: Shilei Tian
Date: 2024-04-12T09:34:46-04:00
New Revision: b4df0da9e8421c8026bd09980b8a6acd7a6ce8c9
URL: https://github.com/llvm/llvm-project/commit/b4df0da9e8421c8026bd09980b8a6acd7a6ce8c9
DIFF: https://github.com/llvm/llvm-project/commit/b4df0da9e8421c8026bd09980b8a6acd7a6ce8c9.diff
LOG: [AMDGPU] Fix a potential wrong return value indicating whether a pass modifies a function (#88197)
When the alloca is too big for vectorization, the function could have
already
been modified in previous iteration of the `for` loop.
Added:
llvm/test/CodeGen/AMDGPU/half-alloca-promotion.ll
Modified:
llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
Removed:
################################################################################
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)) {
diff --git a/llvm/test/CodeGen/AMDGPU/half-alloca-promotion.ll b/llvm/test/CodeGen/AMDGPU/half-alloca-promotion.ll
new file mode 100644
index 00000000000000..cfec49f3652fbd
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/half-alloca-promotion.ll
@@ -0,0 +1,11 @@
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes="amdgpu-promote-alloca-to-vector" -o - %s
+; We don't really need to check anything here because with expensive check, this
+; test case crashes. The correctness of the pass is beyond the scope.
+
+define fastcc void @foo() {
+entry:
+ %det = alloca [4 x i32], align 16, addrspace(5)
+ %trkltPosTmpYZ = alloca [2 x float], align 4, addrspace(5)
+ %trkltCovTmp = alloca [3 x float], align 4, addrspace(5)
+ ret void
+}
More information about the llvm-commits
mailing list