Skip to content

Commit 5499901

Browse files
authored
[llvm-reduce] Do not replace lifetime pointer arg with zero/one/poison (#151697)
The lifetime argument is now required to be an alloca, so we should not try to replace it with a constant. We also shouldn't try to change the size argument to zero/one, similar to how we avoid zero-size allocas.
1 parent 28ed57e commit 5499901

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,15 @@ define void @alloca_constexpr_elt() {
6767
store i32 0, ptr %alloca
6868
ret void
6969
}
70+
71+
; CHECK-LABEL: @alloca_lifetimes(
72+
; ZERO: call void @llvm.lifetime.start.p0(i64 4, ptr %alloca)
73+
; ONE: call void @llvm.lifetime.start.p0(i64 4, ptr %alloca)
74+
; POISON: call void @llvm.lifetime.start.p0(i64 4, ptr %alloca)
75+
define void @alloca_lifetimes() {
76+
%alloca = alloca i32
77+
call void @llvm.lifetime.start.p0(i64 4, ptr %alloca)
78+
store i32 0, ptr %alloca
79+
call void @llvm.lifetime.end.p0(i64 4, ptr %alloca)
80+
ret void
81+
}

llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ static bool shouldReduceOperand(Use &Op) {
7373
if (&CB->getCalledOperandUse() == &Op)
7474
return false;
7575
}
76+
// lifetime intrinsic argument must be an alloca.
77+
if (isa<LifetimeIntrinsic>(Op.getUser()))
78+
return false;
7679
return true;
7780
}
7881

0 commit comments

Comments
 (0)