Skip to content

Commit 3dc3a43

Browse files
[AMDGPU] Bail if assume-like intrinsic is used in PromoteAllocaToVector
Attached test will cause crash without this change.
1 parent b3c4f64 commit 3dc3a43

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,8 @@ bool AMDGPUPromoteAllocaImpl::tryPromoteAllocaToVector(AllocaInst &Alloca) {
772772

773773
// Ignore assume-like intrinsics and comparisons used in assumes.
774774
if (isAssumeLikeIntrinsic(Inst)) {
775+
if (!Inst->use_empty())
776+
return RejectUser(Inst, "assume-like intrinsic cannot have any users");
775777
UsersToRemove.push_back(Inst);
776778
continue;
777779
}

llvm/test/CodeGen/AMDGPU/promote-alloca-mem-intrinsics.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ define amdgpu_kernel void @promote_with_objectsize(ptr addrspace(1) %out) #0 {
5353
ret void
5454
}
5555

56+
; CHECK-LABEL: @promote_with_objectsize_8(
57+
; CHECK: [[PTR:%[0-9]+]] = getelementptr inbounds [64 x [8 x i32]], ptr addrspace(3) @promote_with_objectsize_8.alloca, i32 0, i32 %{{[0-9]+}}
58+
; CHECK: call i32 @llvm.objectsize.i32.p3(ptr addrspace(3) [[PTR]], i1 false, i1 false, i1 false)
59+
define amdgpu_kernel void @promote_with_objectsize_8(ptr addrspace(1) %out) #0 {
60+
%alloca = alloca [8 x i32], align 4, addrspace(5)
61+
%size = call i32 @llvm.objectsize.i32.p5(ptr addrspace(5) %alloca, i1 false, i1 false, i1 false)
62+
store i32 %size, ptr addrspace(1) %out
63+
ret void
64+
}
5665
; CHECK-LABEL: @promote_alloca_used_twice_in_memcpy(
5766
; CHECK: call void @llvm.memcpy.p3.p3.i64(ptr addrspace(3) align 8 dereferenceable(16) %arrayidx1, ptr addrspace(3) align 8 dereferenceable(16) %arrayidx2, i64 16, i1 false)
5867
define amdgpu_kernel void @promote_alloca_used_twice_in_memcpy(i32 %c) {

0 commit comments

Comments
 (0)