File: counter_promo_with_bias.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (33 lines) | stat: -rw-r--r-- 1,412 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
; RUN: opt < %s -passes=instrprof -runtime-counter-relocation -do-counter-promotion=true -S | FileCheck %s

target triple = "x86_64-unknown-linux-gnu"

@__profn_foo = private constant [3 x i8] c"foo"

define void @foo(i1 %c) {
entry:
; CHECK: %[[BIAS:.+]] = load i64, ptr @__llvm_profile_counter_bias
  br label %while.cond

while.cond:                                       ; preds = %land.rhs, %while.cond.preheader
; CHECK: %[[COUNT:[a-z0-9.]+]] = phi i64 [ %[[LAND_COUNT:[0-9]+]], %land.rhs ], [ 0, %entry ]
  br i1 %c, label %while.cond.cleanup_crit_edge, label %land.rhs

while.cond.cleanup_crit_edge:                     ; preds = %while.cond
; CHECK: %[[COUNTER_PTR:[0-9]+]] = add i64 ptrtoint (ptr @__profc_foo to i64), %[[BIAS]]
; CHECK: %[[COUNTER_ADDR:[0-9]+]] = inttoptr i64 %[[COUNTER_PTR]] to ptr
; CHECK: %[[COUNTER_PROMO:[a-z0-9.]+]] = load i64, ptr %[[COUNTER_ADDR]]
; CHECK: %[[VALUE:[0-9]+]] = add i64 %[[COUNTER_PROMO]], %[[COUNT]]
; CHECK: store i64 %[[VALUE]], ptr %[[COUNTER_ADDR]]
  br label %cleanup

land.rhs:                                         ; preds = %while.cond
  call void @llvm.instrprof.increment(ptr @__profn_foo, i64 0, i32 1, i32 0)
; CHECK: %[[LAND_COUNT]] = add i64 %[[COUNT]], 1
  br label %while.cond

cleanup:                                          ; preds = %while.cond.cleanup_crit_edge
  ret void
}

declare void @llvm.instrprof.increment(ptr, i64, i32, i32)