1 ; Tests that coro-split does not generate noinline variant for noinline functions
2 ; RUN: opt < %s -passes='cgscc(coro-split),simplifycfg,early-cse' -S | FileCheck %s
4 ; CHECK-LABEL: @cannotinline()
5 define ptr @cannotinline() presplitcoroutine noinline {
7 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)
8 %need.alloc = call i1 @llvm.coro.alloc(token %id)
9 br i1 %need.alloc, label %dyn.alloc, label %begin
12 %size = call i32 @llvm.coro.size.i32()
13 %alloc = call ptr @malloc(i32 %size)
17 %phi = phi ptr [ null, %entry ], [ %alloc, %dyn.alloc ]
18 %hdl = call ptr @llvm.coro.begin(token %id, ptr %phi)
19 call void @print(i32 0)
20 %0 = call i8 @llvm.coro.suspend(token none, i1 false)
21 switch i8 %0, label %suspend [i8 0, label %resume
24 call void @print(i32 1)
28 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl)
29 call void @free(ptr %mem)
32 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none)
36 ; CHECK-NOT-LABEL: @cannotinline.noalloc()
39 ; Make a safe_elide call to cannotinline
40 define void @caller() presplitcoroutine {
42 %ptr = call ptr @cannotinline() #1
47 declare ptr @llvm.coro.free(token, ptr)
48 declare i32 @llvm.coro.size.i32()
49 declare i8 @llvm.coro.suspend(token, i1)
50 declare void @llvm.coro.resume(ptr)
51 declare void @llvm.coro.destroy(ptr)
53 declare token @llvm.coro.id(i32, ptr, ptr, ptr)
54 declare i1 @llvm.coro.alloc(token)
55 declare ptr @llvm.coro.begin(token, ptr)
56 declare i1 @llvm.coro.end(ptr, i1, token)
58 declare noalias ptr @malloc(i32) allockind("alloc,uninitialized") "alloc-family"="malloc"
59 declare void @print(i32)
60 declare void @free(ptr) willreturn allockind("free") "alloc-family"="malloc"
62 attributes #1 = { coro_elide_safe }