File: cs-preinline-cost.test

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (68 lines) | stat: -rw-r--r-- 2,717 bytes parent folder | download | duplicates (3)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
; REQUIRES: asserts
; Test default using size of profile as a proxy
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/cs-preinline-cost.perfscript --binary=%S/Inputs/cs-preinline-cost.perfbin --csspgo-preinliner --debug-only=cs-preinliner --use-context-cost-for-preinliner=0 --output=/dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT

; Test use-context-cost-for-preinliner using inlinee's byte size as context-sensitive inline cost
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/cs-preinline-cost.perfscript --binary=%S/Inputs/cs-preinline-cost.perfbin --csspgo-preinliner --debug-only=cs-preinliner --use-context-cost-for-preinliner --output=/dev/null 2>&1 | FileCheck %s --check-prefix=CHECK-CSCOST

CHECK-DEFAULT:      Process main for context-sensitive pre-inlining (pre-inline size: 9, size limit: 108)
CHECK-DEFAULT-NEXT:   Inlined context profile for: main:9 @ _Z3fooi (callee size: 2, call count:545)
CHECK-DEFAULT-NEXT:   Inlined context profile for: main:7 @ _Z3fooi (callee size: 14, call count:545)
CHECK-DEFAULT-NEXT:   Inlined context profile for: main:8 @ _Z3fooi (callee size: 4, call count:544)

CHECK-CSCOST:      Process main for context-sensitive pre-inlining (pre-inline size: 69, size limit: 828)
; This inlinee is fully optimized away, make sure we have the correct zero size for that context even if the size is
; not available through symbolization.
CHECK-CSCOST-NEXT:   Inlined context profile for: main:9 @ _Z3fooi (callee size: 0, call count:545)
CHECK-CSCOST-NEXT:   Inlined context profile for: main:7 @ _Z3fooi (callee size: 279, call count:545)
CHECK-CSCOST-NEXT:   Inlined context profile for: main:8 @ _Z3fooi (callee size: 44, call count:544)

; binary is built with the source below using the following command line:
;   clang -O3 -g -fpseudo-probe-for-profiling -fexperimental-new-pass-manager test.cpp
;
;#include <stdio.h>
;
;volatile int state = 9000;
;
;int foo(int x) {
;    if (x == 0) {
;        return 7;
;    }
;
;    if ((x & 1) == 0) {
;        state--;
;        return 9;
;    }
;
;    if (state > 5000) {
;        while (state > 5000) {
;               for (int i = 50; i >= 0; i--) {
;                state *= 6;
;                state /= 7;
;                state -= 1;
;            }
;        }
;    }
;    else {
;        while (state < 5000) {
;            for (int i = 50; i >= 0; i--) {
;                state *= 6;
;                state /= 5;
;                state += 1;
;            }
;        }
;    }
;
;    return state;
;}
;
;volatile int cnt = 10000000;//10000000;
;int main() {
;    int r = 0;
;    for (int i = 0; i < cnt; i++) {
;      r += foo(i);
;      r -= foo(i & (~1));
;      r += foo(0);
;    }
;    return r;
;}