1 ; Tests that the meaningless lifetime intrinsics could be removed after corosplit.
2 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 define ptr @f(i1 %n) presplitcoroutine {
8 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
9 %size = call i32 @llvm.coro.size.i32()
10 %alloc = call ptr @malloc(i32 %size)
11 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc)
12 br i1 %n, label %flag_true, label %flag_false
15 call void @llvm.lifetime.start.p0(i64 8, ptr %x)
19 call void @llvm.lifetime.start.p0(i64 8, ptr %y)
23 %phi = phi ptr [ %x, %flag_true ], [ %y, %flag_false ]
25 %sp1 = call i8 @llvm.coro.suspend(token none, i1 false)
26 switch i8 %sp1, label %suspend [i8 0, label %resume
29 call void @print(ptr %phi)
30 call void @llvm.lifetime.end.p0(i64 8, ptr %x)
31 call void @llvm.lifetime.end.p0(i64 8, ptr %y)
35 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
36 call void @free(ptr %mem)
40 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
44 ; CHECK-NOT: call{{.*}}@llvm.lifetime
46 declare ptr @llvm.coro.free(token, ptr)
47 declare i32 @llvm.coro.size.i32()
48 declare i8 @llvm.coro.suspend(token, i1)
49 declare void @llvm.coro.resume(ptr)
50 declare void @llvm.coro.destroy(ptr)
52 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
53 declare i1 @llvm.coro.alloc(token)
54 declare ptr @llvm.coro.begin(token, ptr)
55 declare i1 @llvm.coro.end(ptr, i1, token)
57 declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
58 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
60 declare void @print(ptr)
61 declare noalias ptr @malloc(i32)
62 declare void @free(ptr)