1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --prefix-filecheck-ir-name abc
2 ; RUN: opt -passes=dse -S < %s | FileCheck %s
4 ; Make sure invokes are not removed as dead stores.
5 define void @test_nounwind_invoke() personality ptr @__gxx_personality_v0 {
6 ; CHECK-LABEL: @test_nounwind_invoke(
8 ; CHECK-NEXT: [[TMP:%.*]] = alloca i32, align 4
9 ; CHECK-NEXT: invoke void @foo(ptr [[TMP]])
10 ; CHECK-NEXT: to label [[BB1:%.*]] unwind label [[BB2:%.*]]
12 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr [[TMP]])
13 ; CHECK-NEXT: ret void
15 ; CHECK-NEXT: [[ABCTMP1:%.*]] = landingpad { ptr, i32 }
17 ; CHECK-NEXT: resume { ptr, i32 } [[ABCTMP1]]
20 %tmp = alloca i32, align 4
21 ; 'foo' is 'argmemonly', meaning it can only write to memory pointed by %tmp.
22 ; And this def is killed by 'call @llvm.lifetime.end.p0' in bb1 without
23 ; being used elsewhere, becoming a dead store. But we shouldn't remove this
24 ; because invokes are terminators and thus cannot be removed.
25 invoke void @foo(ptr %tmp)
26 to label %bb1 unwind label %bb2
29 call void @llvm.lifetime.end.p0(i64 4, ptr %tmp)
33 %tmp1 = landingpad { ptr, i32 }
35 resume { ptr, i32 } %tmp1
38 ; Function Attrs: argmemonly nocallback nofree nosync nounwind willreturn
39 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0
40 ; Function Attrs: argmemonly nounwind willreturn
41 declare void @foo(ptr) #1
42 declare i32 @__gxx_personality_v0(...)
44 attributes #0 = { argmemonly nocallback nofree nosync nounwind willreturn }
45 attributes #1 = { argmemonly nounwind willreturn }