48 lines · plain
1; RUN: opt < %s -passes=pgo-instr-gen -pgo-instrument-entry -S | FileCheck %s --check-prefix=GEN2; RUN: opt < %s -passes=pgo-instr-gen,instrprof -pgo-instrument-entry -atomic-first-counter -S | FileCheck %s --check-prefix=GENA3 4; RUN: llvm-profdata merge %S/Inputs/branch2.proftext -o %t.profdata5; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -pgo-instrument-entry -S | FileCheck %s --check-prefix=USE6target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"7target triple = "x86_64-unknown-linux-gnu"8 9; GEN: $__llvm_profile_raw_version = comdat any10; GEN: @__llvm_profile_raw_version = hidden constant i64 {{[0-9]+}}, comdat11; GEN: @__profn_test_br_2 = private constant [9 x i8] c"test_br_2"12 13define i32 @test_br_2(i32 %i) {14entry:15; GEN: entry:16; GEN: call void @llvm.instrprof.increment(ptr @__profn_test_br_2, i64 {{[0-9]+}}, i32 2, i32 0)17; GENA: entry:18; GENA: %{{[0-9+]}} = atomicrmw add ptr @__profc_test_br_2, i64 1 monotonic19; USE: br i1 %cmp, label %if.then, label %if.else20; USE-SAME: !prof ![[BW_ENTRY:[0-9]+]]21; USE: ![[BW_ENTRY]] = !{!"branch_weights", i32 0, i32 1}22 %cmp = icmp sgt i32 %i, 023 br i1 %cmp, label %if.then, label %if.else24 25if.then:26; GEN: if.then:27; GEN-NOT: llvm.instrprof.increment28 %add = add nsw i32 %i, 229 br label %if.end30 31if.else:32; GEN: if.else:33; GEN: call void @llvm.instrprof.increment(ptr @__profn_test_br_2, i64 {{[0-9]+}}, i32 2, i32 1)34; GENA: if.else:35; GENA: %pgocount = load i64, ptr getelementptr inbounds ([2 x i64], ptr @__profc_test_br_2, i32 0, i32 1), align 836; GENA: [[V:%[0-9]*]] = add i64 %pgocount, 137; GENA: store i64 [[V]], ptr getelementptr inbounds ([2 x i64], ptr @__profc_test_br_2, i32 0, i32 1), align 838 %sub = sub nsw i32 %i, 239 br label %if.end40 41if.end:42; GEN: if.end:43; GEN-NOT: llvm.instrprof.increment44 %retv = phi i32 [ %add, %if.then ], [ %sub, %if.else ]45 ret i32 %retv46; GEN: ret47}48