128 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2;RUN: opt < %s -passes='require<profile-summary>,function(chr,instcombine,simplifycfg)' -S | FileCheck %s3 4declare void @foo()5declare void @bar()6 7declare token @llvm.coro.id(i32, ptr, ptr, ptr)8declare i1 @llvm.coro.alloc(token)9declare ptr @llvm.coro.begin(token, ptr)10declare noalias ptr @malloc(i32)11 12%f.Frame = type { ptr, ptr, i1 }13 14; resume part of the coroutine15define fastcc void @f.resume(ptr noalias nonnull align 8 dereferenceable(24) %FramePtr) {16 tail call void @bar()17 ret void18}19 20; destroy part of the coroutine21define fastcc void @f.destroy(ptr noalias nonnull align 8 dereferenceable(24) %FramePtr) {22 tail call void @bar()23 ret void24}25 26; cleanup part of the coroutine27define fastcc void @f.cleanup(ptr noalias nonnull align 8 dereferenceable(24) %FramePtr) {28 tail call void @bar()29 ret void30}31 32@f.resumers = private constant [3 x ptr] [ptr @f.resume, ptr @f.destroy, ptr @f.cleanup]33 34; Test that chr will skip block containing llvm.coro.id.35define ptr @test_chr_with_coro_id(ptr %i) !prof !14 {36; CHECK-LABEL: @test_chr_with_coro_id(37; CHECK-NEXT: entry:38; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[I:%.*]], align 439; CHECK-NEXT: [[DOTFR1:%.*]] = freeze i32 [[TMP0]]40; CHECK-NEXT: [[TMP1:%.*]] = and i32 [[DOTFR1]], 341; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 342; CHECK-NEXT: br i1 [[TMP2]], label [[BB0:%.*]], label [[ENTRY_SPLIT_NONCHR:%.*]], !prof [[PROF15:![0-9]+]]43; CHECK: bb0:44; CHECK-NEXT: call void @foo()45; CHECK-NEXT: br label [[BB_CORO_ID:%.*]]46; CHECK: entry.split.nonchr:47; CHECK-NEXT: [[TMP3:%.*]] = and i32 [[DOTFR1]], 148; CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i32 [[TMP3]], 049; CHECK-NEXT: br i1 [[DOTNOT]], label [[BB1_NONCHR:%.*]], label [[BB0_NONCHR:%.*]], !prof [[PROF16:![0-9]+]]50; CHECK: bb0.nonchr:51; CHECK-NEXT: call void @foo()52; CHECK-NEXT: br label [[BB1_NONCHR]]53; CHECK: bb1.nonchr:54; CHECK-NEXT: [[TMP4:%.*]] = and i32 [[DOTFR1]], 255; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[TMP4]], 056; CHECK-NEXT: br i1 [[TMP5]], label [[BB2_NONCHR:%.*]], label [[BB_CORO_ID]], !prof [[PROF16]]57; CHECK: bb2.nonchr:58; CHECK-NEXT: call void @foo()59; CHECK-NEXT: br label [[BB_CORO_ID]]60; CHECK: bb.coro.id:61; CHECK-NEXT: [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr nonnull @f.resumers)62; CHECK-NEXT: [[NEED_DYN_ALLOC:%.*]] = call i1 @llvm.coro.alloc(token [[ID]])63; CHECK-NEXT: br i1 [[NEED_DYN_ALLOC]], label [[BB_CORO_DYN_ALLOC:%.*]], label [[BB_CORO_BEGIN:%.*]]64; CHECK: bb.coro.dyn.alloc:65; CHECK-NEXT: [[ALLOC:%.*]] = call ptr @malloc(i32 24)66; CHECK-NEXT: br label [[BB_CORO_BEGIN]]67; CHECK: bb.coro.begin:68; CHECK-NEXT: [[PHI:%.*]] = phi ptr [ null, [[BB_CORO_ID]] ], [ [[ALLOC]], [[BB_CORO_DYN_ALLOC]] ]69; CHECK-NEXT: [[HDL:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[PHI]])70; CHECK-NEXT: ret ptr [[HDL]]71;72entry:73 %0 = load i32, ptr %i74 %1 = and i32 %0, 175 %2 = icmp eq i32 %1, 076 br i1 %2, label %bb1, label %bb0, !prof !1577 78bb0:79 call void @foo()80 br label %bb181 82bb1:83 %3 = and i32 %0, 284 %4 = icmp eq i32 %3, 085 br i1 %4, label %bb2, label %bb.coro.id, !prof !1586 87bb2:88 call void @foo()89 br label %bb.coro.id90 91bb.coro.id:92 %id = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @f.resumers)93 %need.dyn.alloc = call i1 @llvm.coro.alloc(token %id)94 br i1 %need.dyn.alloc, label %bb.coro.dyn.alloc, label %bb.coro.begin95 96bb.coro.dyn.alloc:97 %alloc = call ptr @malloc(i32 24)98 br label %bb.coro.begin99 100bb.coro.begin:101 %phi = phi ptr [ null, %bb.coro.id ], [ %alloc, %bb.coro.dyn.alloc ]102 %hdl = call noalias nonnull ptr @llvm.coro.begin(token %id, ptr %phi)103 ret ptr %hdl104}105 106!llvm.module.flags = !{!0}107!0 = !{i32 1, !"ProfileSummary", !1}108!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}109!2 = !{!"ProfileFormat", !"InstrProf"}110!3 = !{!"TotalCount", i64 10000}111!4 = !{!"MaxCount", i64 10}112!5 = !{!"MaxInternalCount", i64 1}113!6 = !{!"MaxFunctionCount", i64 1000}114!7 = !{!"NumCounts", i64 3}115!8 = !{!"NumFunctions", i64 3}116!9 = !{!"DetailedSummary", !10}117!10 = !{!11, !12, !13}118!11 = !{i32 10000, i64 100, i32 1}119!12 = !{i32 999000, i64 100, i32 1}120!13 = !{i32 999999, i64 1, i32 2}121 122!14 = !{!"function_entry_count", i64 100}123!15 = !{!"branch_weights", i32 0, i32 1}124!16 = !{!"branch_weights", i32 1, i32 1}125!17 = !{!"branch_weights", i32 0, i32 0}126; CHECK: !15 = !{!"branch_weights", i32 1000, i32 0}127; CHECK: !16 = !{!"branch_weights", i32 0, i32 1}128