[llvm] c4c0a59 - [llvm-reduce] Do not convert lifetime operand to argument (#151694)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 06:34:55 PDT 2025
Author: Nikita Popov
Date: 2025-08-01T15:34:52+02:00
New Revision: c4c0a597414316d30a209dab1012b96d130dc545
URL: https://github.com/llvm/llvm-project/commit/c4c0a597414316d30a209dab1012b96d130dc545
DIFF: https://github.com/llvm/llvm-project/commit/c4c0a597414316d30a209dab1012b96d130dc545.diff
LOG: [llvm-reduce] Do not convert lifetime operand to argument (#151694)
The lifetime argument is now required to be an alloca, so do not try to
convert it to a function argument.
The reduction is now going to leave behind an unused alloca with
lifetime markers, which should be cleaned up separately.
I'd say this fixes https://github.com/llvm/llvm-project/issues/93713. It
doesn't remove the lifetime markers as the issue suggests, but at least
they're now not going to be on the argument.
Added:
llvm/test/tools/llvm-reduce/operands-to-args-lifetimes.ll
Modified:
llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-reduce/operands-to-args-lifetimes.ll b/llvm/test/tools/llvm-reduce/operands-to-args-lifetimes.ll
new file mode 100644
index 0000000000000..d9ed9dff02b6e
--- /dev/null
+++ b/llvm/test/tools/llvm-reduce/operands-to-args-lifetimes.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-reduce %s -o %t --abort-on-invalid-reduction --delta-passes=operands-to-args --test FileCheck --test-arg %s --test-arg --check-prefix=INTERESTING --test-arg --input-file
+; RUN: FileCheck %s --input-file %t --check-prefix=REDUCED
+
+; INTERESTING: store
+; REDUCED: define void @test(ptr %a) {
+; REDUCED-NEXT: %a1 = alloca i32
+; REDUCED-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr %a1)
+; REDUCED-NEXT: store i32 0, ptr %a
+; REDUCED-NEXT: store i32 1, ptr %a
+; REDUCED-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr %a1)
+define void @test() {
+ %a = alloca i32
+ call void @llvm.lifetime.start.p0(i64 4, ptr %a)
+ store i32 0, ptr %a
+ store i32 1, ptr %a
+ call void @llvm.lifetime.end.p0(i64 4, ptr %a)
+ ret void
+}
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
index 1865a596afca0..864f695503402 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
@@ -13,6 +13,7 @@
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Operator.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Cloning.h"
@@ -49,6 +50,10 @@ static bool canReduceUse(Use &Op) {
if (&CI->getCalledOperandUse() == &Op)
return false;
+ // lifetime.start/lifetime.end require alloca argument.
+ if (isa<LifetimeIntrinsic>(Op.getUser()))
+ return false;
+
return true;
}
More information about the llvm-commits
mailing list