[llvm] [llvm-reduce] Do not replace lifetime pointer arg with zero/one/poison (PR #151697)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 1 06:06:40 PDT 2025


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/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.

>From 75897f45059eff52353a54362a3f0dcfbdf63d34 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 1 Aug 2025 15:03:53 +0200
Subject: [PATCH] [llvm-reduce] Do not replace lifetime pointer arg with
 zero/one/poison

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.
---
 .../test/tools/llvm-reduce/reduce-operands-alloca.ll | 12 ++++++++++++
 llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp     |  3 +++
 2 files changed, 15 insertions(+)

diff --git a/llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll b/llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll
index 61c46185b3378..b68f7182feaa2 100644
--- a/llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll
+++ b/llvm/test/tools/llvm-reduce/reduce-operands-alloca.ll
@@ -67,3 +67,15 @@ define void @alloca_constexpr_elt() {
  store i32 0, ptr %alloca
  ret void
 }
+
+; CHECK-LABEL: @alloca_lifetimes(
+; ZERO: call void @llvm.lifetime.start.p0(i64 4, ptr %alloca)
+; ONE: call void @llvm.lifetime.start.p0(i64 4, ptr %alloca)
+; POISON: call void @llvm.lifetime.start.p0(i64 4, ptr %alloca)
+define void @alloca_lifetimes() {
+  %alloca = alloca i32
+  call void @llvm.lifetime.start.p0(i64 4, ptr %alloca)
+  store i32 0, ptr %alloca
+  call void @llvm.lifetime.end.p0(i64 4, ptr %alloca)
+  ret void
+}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
index 8b6446725b7d4..79272fe2eaeb7 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
@@ -73,6 +73,9 @@ static bool shouldReduceOperand(Use &Op) {
     if (&CB->getCalledOperandUse() == &Op)
       return false;
   }
+  // lifetime intrinsic argument must be an alloca.
+  if (isa<LifetimeIntrinsic>(Op.getUser()))
+    return false;
   return true;
 }
 



More information about the llvm-commits mailing list