1b0154c36SEllis Hoag; RUN: opt < %s -passes=pgo-instr-gen -pgo-function-entry-coverage -S | FileCheck %s --implicit-check-not="instrprof.cover" --check-prefixes=CHECK,GEN,ENTRY 2b0154c36SEllis Hoag; RUN: opt < %s -passes=pgo-instr-gen -pgo-block-coverage -S | FileCheck %s --implicit-check-not="instrprof.cover" --check-prefixes=CHECK,GEN,BLOCK 3b0154c36SEllis Hoag 4b0154c36SEllis Hoag; RUN: llvm-profdata merge %S/Inputs/coverage.proftext -o %t.profdata 5b0154c36SEllis Hoag; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefixes=CHECK,USE 611d30742SEllis Hoagtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 711d30742SEllis Hoagtarget triple = "x86_64-unknown-linux-gnu" 811d30742SEllis Hoag 9b0154c36SEllis Hoag; CHECK-LABEL: @foo() 10b0154c36SEllis Hoag; USE-SAME: !prof ![[HOT:[0-9]+]] 11167e8f8bSEllis Hoagdefine void @foo() { 12167e8f8bSEllis Hoag; CHECK-LABEL: entry: 1311d30742SEllis Hoagentry: 14167e8f8bSEllis Hoag ; ENTRY: call void @llvm.instrprof.cover({{.*}}) 15167e8f8bSEllis Hoag %c = call i1 @choice() 16167e8f8bSEllis Hoag br i1 %c, label %if.then, label %if.else 17b0154c36SEllis Hoag ; USE: br i1 %c, label %if.then, label %if.else, !prof ![[WEIGHTS0:[0-9]+]] 1811d30742SEllis Hoag 19167e8f8bSEllis Hoag; CHECK-LABEL: if.then: 2011d30742SEllis Hoagif.then: 21167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 2211d30742SEllis Hoag br label %if.end 2311d30742SEllis Hoag 24167e8f8bSEllis Hoag; CHECK-LABEL: if.else: 2511d30742SEllis Hoagif.else: 26167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 2711d30742SEllis Hoag br label %if.end 2811d30742SEllis Hoag 29167e8f8bSEllis Hoag; CHECK-LABEL: if.end: 3011d30742SEllis Hoagif.end: 31167e8f8bSEllis Hoag ret void 3211d30742SEllis Hoag} 3311d30742SEllis Hoag 34b0154c36SEllis Hoag; CHECK-LABEL: @bar() 35b0154c36SEllis Hoag; USE-SAME: !prof ![[HOT:[0-9]+]] 36167e8f8bSEllis Hoagdefine void @bar() { 37167e8f8bSEllis Hoag; CHECK-LABEL: entry: 38167e8f8bSEllis Hoagentry: 39167e8f8bSEllis Hoag ; ENTRY: call void @llvm.instrprof.cover({{.*}}) 40167e8f8bSEllis Hoag %c = call i1 @choice() 41167e8f8bSEllis Hoag br i1 %c, label %if.then, label %if.end 42b0154c36SEllis Hoag ; USE: br i1 %c, label %if.then, label %if.end, !prof ![[WEIGHTS1:[0-9]+]] 43167e8f8bSEllis Hoag 44167e8f8bSEllis Hoag; CHECK-LABEL: if.then: 45167e8f8bSEllis Hoagif.then: 46167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 47167e8f8bSEllis Hoag br label %if.end 48167e8f8bSEllis Hoag 49167e8f8bSEllis Hoag; CHECK-LABEL: if.end: 50167e8f8bSEllis Hoagif.end: 51167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 52167e8f8bSEllis Hoag ret void 53167e8f8bSEllis Hoag} 54167e8f8bSEllis Hoag 55b0154c36SEllis Hoag; CHECK-LABEL: @goo() 56b0154c36SEllis Hoag; USE-SAME: !prof ![[HOT:[0-9]+]] 57167e8f8bSEllis Hoagdefine void @goo() { 58167e8f8bSEllis Hoag; CHECK-LABEL: entry: 59167e8f8bSEllis Hoagentry: 60b0154c36SEllis Hoag ; GEN: call void @llvm.instrprof.cover({{.*}}) 61167e8f8bSEllis Hoag ret void 62167e8f8bSEllis Hoag} 63167e8f8bSEllis Hoag 64b0154c36SEllis Hoag; CHECK-LABEL: @loop() 65b0154c36SEllis Hoag; USE-SAME: !prof ![[HOT:[0-9]+]] 66167e8f8bSEllis Hoagdefine void @loop() { 67167e8f8bSEllis Hoag; CHECK-LABEL: entry: 68167e8f8bSEllis Hoagentry: 69b0154c36SEllis Hoag ; GEN: call void @llvm.instrprof.cover({{.*}}) 70167e8f8bSEllis Hoag br label %while 71167e8f8bSEllis Hoagwhile: 72167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 73167e8f8bSEllis Hoag br label %while 74167e8f8bSEllis Hoag} 75167e8f8bSEllis Hoag 76b0154c36SEllis Hoag; CHECK-LABEL: @hoo( 77b0154c36SEllis Hoag; USE-SAME: !prof ![[HOT:[0-9]+]] 78167e8f8bSEllis Hoagdefine void @hoo(i32 %a) #0 { 79167e8f8bSEllis Hoag; CHECK-LABEL: entry: 80167e8f8bSEllis Hoagentry: 81167e8f8bSEllis Hoag ; ENTRY: call void @llvm.instrprof.cover({{.*}}) 82167e8f8bSEllis Hoag %a.addr = alloca i32, align 4 83167e8f8bSEllis Hoag %i = alloca i32, align 4 84*2d69827cSNikita Popov store i32 %a, ptr %a.addr, align 4 85*2d69827cSNikita Popov %0 = load i32, ptr %a.addr, align 4 86167e8f8bSEllis Hoag %rem = srem i32 %0, 2 87167e8f8bSEllis Hoag %cmp = icmp eq i32 %rem, 0 88167e8f8bSEllis Hoag br i1 %cmp, label %if.then, label %if.else 89b0154c36SEllis Hoag ; USE: br i1 %cmp, label %if.then, label %if.else, !prof ![[WEIGHTS1]] 90167e8f8bSEllis Hoag 91167e8f8bSEllis Hoag; CHECK-LABEL: if.then: 92167e8f8bSEllis Hoagif.then: ; preds = %entry 93167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 94167e8f8bSEllis Hoag br label %if.end 95167e8f8bSEllis Hoag 96167e8f8bSEllis Hoag; CHECK-LABEL: if.else: 97167e8f8bSEllis Hoagif.else: ; preds = %entry 98167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 99167e8f8bSEllis Hoag br label %if.end 100167e8f8bSEllis Hoag 101167e8f8bSEllis Hoag; CHECK-LABEL: if.end: 102167e8f8bSEllis Hoagif.end: ; preds = %if.else, %if.then 103*2d69827cSNikita Popov store i32 1, ptr %i, align 4 104167e8f8bSEllis Hoag br label %for.cond 105167e8f8bSEllis Hoag 106167e8f8bSEllis Hoag; CHECK-LABEL: for.cond: 107167e8f8bSEllis Hoagfor.cond: ; preds = %for.inc, %if.end 108*2d69827cSNikita Popov %1 = load i32, ptr %i, align 4 109*2d69827cSNikita Popov %2 = load i32, ptr %a.addr, align 4 110167e8f8bSEllis Hoag %cmp1 = icmp slt i32 %1, %2 111167e8f8bSEllis Hoag br i1 %cmp1, label %for.body, label %for.end 112b0154c36SEllis Hoag ; USE: br i1 %cmp1, label %for.body, label %for.end, !prof ![[WEIGHTS1]] 113167e8f8bSEllis Hoag 114167e8f8bSEllis Hoag; CHECK-LABEL: for.body: 115167e8f8bSEllis Hoagfor.body: ; preds = %for.cond 116*2d69827cSNikita Popov %3 = load i32, ptr %a.addr, align 4 117167e8f8bSEllis Hoag %rem2 = srem i32 %3, 3 118167e8f8bSEllis Hoag %cmp3 = icmp eq i32 %rem2, 0 119167e8f8bSEllis Hoag br i1 %cmp3, label %if.then4, label %if.else5 120b0154c36SEllis Hoag ; USE: br i1 %cmp3, label %if.then4, label %if.else5, !prof ![[WEIGHTS0]] 121167e8f8bSEllis Hoag 122167e8f8bSEllis Hoag; CHECK-LABEL: if.then4: 123167e8f8bSEllis Hoagif.then4: ; preds = %for.body 124167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 125167e8f8bSEllis Hoag br label %if.end10 126167e8f8bSEllis Hoag 127167e8f8bSEllis Hoag; CHECK-LABEL: if.else5: 128167e8f8bSEllis Hoagif.else5: ; preds = %for.body 129*2d69827cSNikita Popov %4 = load i32, ptr %a.addr, align 4 130167e8f8bSEllis Hoag %rem6 = srem i32 %4, 1001 131167e8f8bSEllis Hoag %cmp7 = icmp eq i32 %rem6, 0 132167e8f8bSEllis Hoag br i1 %cmp7, label %if.then8, label %if.end9 133b0154c36SEllis Hoag ; USE: br i1 %cmp7, label %if.then8, label %if.end9, !prof ![[WEIGHTS1]] 134167e8f8bSEllis Hoag 135167e8f8bSEllis Hoag; CHECK-LABEL: if.then8: 136167e8f8bSEllis Hoagif.then8: ; preds = %if.else5 137167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 138167e8f8bSEllis Hoag br label %return 139167e8f8bSEllis Hoag 140167e8f8bSEllis Hoag; CHECK-LABEL: if.end9: 141167e8f8bSEllis Hoagif.end9: ; preds = %if.else5 142167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 143167e8f8bSEllis Hoag br label %if.end10 144167e8f8bSEllis Hoag 145167e8f8bSEllis Hoag; CHECK-LABEL: if.end10: 146167e8f8bSEllis Hoagif.end10: ; preds = %if.end9, %if.then4 147167e8f8bSEllis Hoag br label %for.inc 148167e8f8bSEllis Hoag 149167e8f8bSEllis Hoag; CHECK-LABEL: for.inc: 150167e8f8bSEllis Hoagfor.inc: ; preds = %if.end10 151*2d69827cSNikita Popov %5 = load i32, ptr %i, align 4 152167e8f8bSEllis Hoag %inc = add nsw i32 %5, 1 153*2d69827cSNikita Popov store i32 %inc, ptr %i, align 4 154167e8f8bSEllis Hoag br label %for.cond 155167e8f8bSEllis Hoag 156167e8f8bSEllis Hoag; CHECK-LABEL: for.end: 157167e8f8bSEllis Hoagfor.end: ; preds = %for.cond 158167e8f8bSEllis Hoag ; BLOCK: call void @llvm.instrprof.cover({{.*}}) 159167e8f8bSEllis Hoag br label %return 160167e8f8bSEllis Hoag 161167e8f8bSEllis Hoag; CHECK-LABEL: return: 162167e8f8bSEllis Hoagreturn: ; preds = %for.end, %if.then8 163167e8f8bSEllis Hoag ret void 164167e8f8bSEllis Hoag} 165167e8f8bSEllis Hoag 166167e8f8bSEllis Hoagdeclare i1 @choice() 167167e8f8bSEllis Hoag 168b0154c36SEllis Hoag; GEN: declare void @llvm.instrprof.cover({{.*}}) 169b0154c36SEllis Hoag 170b0154c36SEllis Hoag; USE-DAG: ![[HOT]] = !{!"function_entry_count", i64 10000} 171b0154c36SEllis Hoag; USE-DAG: ![[WEIGHTS0]] = !{!"branch_weights", i32 1, i32 1} 172b0154c36SEllis Hoag; USE-DAG: ![[WEIGHTS1]] = !{!"branch_weights", i32 1, i32 0} 173