1; Tests that the readnone function which don't cross suspend points could be optimized expectly after split. 2; 3; RUN: opt < %s -S -passes='default<O3>' | FileCheck %s --check-prefixes=CHECK_SPLITTED 4; RUN: opt < %s -S -passes='coro-split,early-cse,simplifycfg' | FileCheck %s --check-prefixes=CHECK_SPLITTED 5; RUN: opt < %s -S -passes='coro-split,gvn,simplifycfg' | FileCheck %s --check-prefixes=CHECK_SPLITTED 6; RUN: opt < %s -S -passes='coro-split,newgvn,simplifycfg' | FileCheck %s --check-prefixes=CHECK_SPLITTED 7; RUN: opt < %s -S -passes='early-cse' | FileCheck %s --check-prefixes=CHECK_UNSPLITTED 8; RUN: opt < %s -S -passes='gvn' | FileCheck %s --check-prefixes=CHECK_UNSPLITTED 9; RUN: opt < %s -S -passes='newgvn' | FileCheck %s --check-prefixes=CHECK_UNSPLITTED 10 11define ptr @f() presplitcoroutine { 12entry: 13 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null) 14 %size = call i32 @llvm.coro.size.i32() 15 %alloc = call ptr @malloc(i32 %size) 16 %hdl = call ptr @llvm.coro.begin(token %id, ptr %alloc) 17 %sus_result = call i8 @llvm.coro.suspend(token none, i1 false) 18 switch i8 %sus_result, label %suspend [i8 0, label %resume 19 i8 1, label %cleanup] 20resume: 21 %i = call i32 @readnone_func() readnone 22 ; noop call to break optimization to combine two consecutive readonly calls. 23 call void @nop() 24 %j = call i32 @readnone_func() readnone 25 %cmp = icmp eq i32 %i, %j 26 br i1 %cmp, label %same, label %diff 27 28same: 29 call void @print_same() 30 br label %cleanup 31 32diff: 33 call void @print_diff() 34 br label %cleanup 35 36cleanup: 37 %mem = call ptr @llvm.coro.free(token %id, ptr %hdl) 38 call void @free(ptr %mem) 39 br label %suspend 40 41suspend: 42 call i1 @llvm.coro.end(ptr %hdl, i1 0, token none) 43 ret ptr %hdl 44} 45 46; 47; CHECK_SPLITTED-LABEL: f.resume( 48; CHECK_SPLITTED-NEXT: : 49; CHECK_SPLITTED-NEXT: call i32 @readnone_func() #[[ATTR_NUM:[0-9]+]] 50; CHECK_SPLITTED-NEXT: call void @nop() 51; CHECK_SPLITTED-NEXT: call void @print_same() 52; 53; CHECK_SPLITTED: attributes #[[ATTR_NUM]] = { memory(none) } 54; 55; CHECK_UNSPLITTED-LABEL: @f( 56; CHECK_UNSPLITTED: br i1 %cmp, label %same, label %diff 57; CHECK_UNSPLITTED-EMPTY: 58; CHECK_UNSPLITTED-NEXT: same: 59; CHECK_UNSPLITTED-NEXT: call void @print_same() 60; CHECK_UNSPLITTED-NEXT: br label 61; CHECK_UNSPLITTED-EMPTY: 62; CHECK_UNSPLITTED-NEXT: diff: 63; CHECK_UNSPLITTED-NEXT: call void @print_diff() 64; CHECK_UNSPLITTED-NEXT: br label 65 66declare i32 @readnone_func() readnone 67declare void @nop() 68 69declare void @print_same() 70declare void @print_diff() 71declare ptr @llvm.coro.free(token, ptr) 72declare i32 @llvm.coro.size.i32() 73declare i8 @llvm.coro.suspend(token, i1) 74 75declare token @llvm.coro.id(i32, ptr, ptr, ptr) 76declare i1 @llvm.coro.alloc(token) 77declare ptr @llvm.coro.begin(token, ptr) 78declare i1 @llvm.coro.end(ptr, i1, token) 79 80declare noalias ptr @malloc(i32) 81declare void @free(ptr) 82