Skip to content

Commit c4c0a59

Browse files
authored
[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 #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.
1 parent c300a99 commit c4c0a59

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; 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
2+
; RUN: FileCheck %s --input-file %t --check-prefix=REDUCED
3+
4+
; INTERESTING: store
5+
; REDUCED: define void @test(ptr %a) {
6+
; REDUCED-NEXT: %a1 = alloca i32
7+
; REDUCED-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr %a1)
8+
; REDUCED-NEXT: store i32 0, ptr %a
9+
; REDUCED-NEXT: store i32 1, ptr %a
10+
; REDUCED-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr %a1)
11+
define void @test() {
12+
%a = alloca i32
13+
call void @llvm.lifetime.start.p0(i64 4, ptr %a)
14+
store i32 0, ptr %a
15+
store i32 1, ptr %a
16+
call void @llvm.lifetime.end.p0(i64 4, ptr %a)
17+
ret void
18+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "llvm/IR/InstIterator.h"
1414
#include "llvm/IR/InstrTypes.h"
1515
#include "llvm/IR/Instructions.h"
16+
#include "llvm/IR/IntrinsicInst.h"
1617
#include "llvm/IR/Operator.h"
1718
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
1819
#include "llvm/Transforms/Utils/Cloning.h"
@@ -49,6 +50,10 @@ static bool canReduceUse(Use &Op) {
4950
if (&CI->getCalledOperandUse() == &Op)
5051
return false;
5152

53+
// lifetime.start/lifetime.end require alloca argument.
54+
if (isa<LifetimeIntrinsic>(Op.getUser()))
55+
return false;
56+
5257
return true;
5358
}
5459

0 commit comments

Comments
 (0)