Skip to content

Commit

Permalink
[AMDGPU] Fix a potential wrong return value indicating whether a pass…
Browse files Browse the repository at this point in the history
… modifies a function (llvm#88197)

When the alloca is too big for vectorization, the function could have
already
been modified in previous iteration of the `for` loop.
  • Loading branch information
shiltian authored Apr 12, 2024
1 parent 3fa8308 commit b4df0da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
11 changes: 11 additions & 0 deletions llvm/test/CodeGen/AMDGPU/half-alloca-promotion.ll
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit b4df0da

Please sign in to comment.