llvm-project/llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll
Nikita Popov c23b4fbdbb
[IR] Remove size argument from lifetime intrinsics (#150248)
Now that #149310 has restricted lifetime intrinsics to only work on
allocas, we can also drop the explicit size argument. Instead, the size
is implied by the alloca.

This removes the ability to only mark a prefix of an alloca alive/dead.
We never used that capability, so we should remove the need to handle
that possibility everywhere (though many key places, including stack
coloring, did not actually respect this).
2025-08-08 11:09:34 +02:00

86 lines
2.6 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt < %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
declare void @llvm.lifetime.start.p0(ptr)
declare void @llvm.lifetime.end.p0(ptr)
declare void @escape(ptr)
declare void @throwing_callee_foo()
declare void @throwing_callee_bar()
declare i32 @__gxx_personality_v0(...)
define void @caller(i1 %c) personality ptr @__gxx_personality_v0 {
; CHECK-LABEL: @caller(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[I0:%.*]] = alloca i32, align 4
; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr nonnull [[I0]])
; CHECK-NEXT: call void @escape(ptr [[I0]])
; CHECK-NEXT: [[I2:%.*]] = alloca i32, align 4
; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr nonnull [[I2]])
; CHECK-NEXT: call void @escape(ptr [[I2]])
; CHECK-NEXT: [[I4:%.*]] = alloca i32, align 4
; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr nonnull [[I4]])
; CHECK-NEXT: call void @escape(ptr [[I4]])
; CHECK-NEXT: [[I6:%.*]] = alloca i32, align 4
; CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr nonnull [[I6]])
; CHECK-NEXT: call void @escape(ptr [[I6]])
; CHECK-NEXT: br i1 [[C:%.*]], label [[V0:%.*]], label [[V1:%.*]]
; CHECK: v0:
; CHECK-NEXT: call void @throwing_callee_foo()
; CHECK-NEXT: unreachable
; CHECK: v1:
; CHECK-NEXT: call void @throwing_callee_bar()
; CHECK-NEXT: unreachable
;
entry:
%i0 = alloca i32
call void @llvm.lifetime.start.p0(ptr nonnull %i0)
call void @escape(ptr %i0)
%i2 = alloca i32
call void @llvm.lifetime.start.p0(ptr nonnull %i2)
call void @escape(ptr %i2)
%i4 = alloca i32
call void @llvm.lifetime.start.p0(ptr nonnull %i4)
call void @escape(ptr %i4)
%i6 = alloca i32
call void @llvm.lifetime.start.p0(ptr nonnull %i6)
call void @escape(ptr %i6)
br i1 %c, label %v0, label %v1
v0:
invoke void @throwing_callee_foo()
to label %invoke.cont unwind label %lpad.v0
v1:
invoke void @throwing_callee_bar()
to label %invoke.cont unwind label %lpad.v1
invoke.cont:
unreachable
lpad.v0:
%i8 = landingpad { ptr, i32 } cleanup
call void @llvm.lifetime.end.p0(ptr nonnull %i0)
call void @llvm.lifetime.end.p0(ptr nonnull %i4)
br label %end
lpad.v1:
%i9 = landingpad { ptr, i32 } cleanup
call void @llvm.lifetime.end.p0(ptr nonnull %i2)
call void @llvm.lifetime.end.p0(ptr nonnull %i6)
br label %end
end:
%i10 = phi { ptr, i32 } [ %i8, %lpad.v0 ], [ %i9, %lpad.v1 ]
resume { ptr, i32 } %i10
}
;.
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
;.