Skip to content

Commit b4df0da

Browse files
authored
[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.
1 parent 3fa8308 commit b4df0da

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ bool AMDGPUPromoteAllocaImpl::run(Function &F, bool PromoteToLDS) {
336336
if (AllocaCost > VectorizationBudget) {
337337
LLVM_DEBUG(dbgs() << " Alloca too big for vectorization: " << *AI
338338
<< "\n");
339-
return false;
339+
return Changed;
340340
}
341341

342342
if (tryPromoteAllocaToVector(*AI)) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes="amdgpu-promote-alloca-to-vector" -o - %s
2+
; We don't really need to check anything here because with expensive check, this
3+
; test case crashes. The correctness of the pass is beyond the scope.
4+
5+
define fastcc void @foo() {
6+
entry:
7+
%det = alloca [4 x i32], align 16, addrspace(5)
8+
%trkltPosTmpYZ = alloca [2 x float], align 4, addrspace(5)
9+
%trkltCovTmp = alloca [3 x float], align 4, addrspace(5)
10+
ret void
11+
}

0 commit comments

Comments
 (0)