83 lines · plain
1; RUN: llvm-profgen --format=text --use-dwarf-correlation --ignore-stack-samples --perfscript=%S/Inputs/cs-preinline-cost.perfscript --binary=%S/Inputs/cs-preinline-cost.perfbin --output %t2; RUN: FileCheck %s --input-file %t3 4; CHECK: main:947937:05; CHECK-NEXT: 2: 5456; CHECK-NEXT: 3: 5457; CHECK-NEXT: 5: 5458; CHECK-NEXT: 7: 09; CHECK-NEXT: 65496: 54510; CHECK-NEXT: 3.7: _Z3fooi:91579411; CHECK-NEXT: 1: 54512; CHECK-NEXT: 5: 54513; CHECK-NEXT: 6: 27214; CHECK-NEXT: 10: 27315; CHECK-NEXT: 11: 18016; CHECK-NEXT: 12: 696517; CHECK-NEXT: 13: 696518; CHECK-NEXT: 14: 696519; CHECK-NEXT: 15: 696520; CHECK-NEXT: 20: 18221; CHECK-NEXT: 21: 695822; CHECK-NEXT: 22: 695823; CHECK-NEXT: 23: 695824; CHECK-NEXT: 24: 695825; CHECK-NEXT: 29: 27226; CHECK-NEXT: 65529: 18227; CHECK-NEXT: 4.8: _Z3fooi:1633828; CHECK-NEXT: 1: 27229; CHECK-NEXT: 6: 54530 31 32 33 34; binary is built with the source below using the following command line:35; clang -O3 -g -fpseudo-probe-for-profiling test.cpp36;37;#include <stdio.h>38;39;volatile int state = 9000;40;41;int foo(int x) {42; if (x == 0) {43; return 7;44; }45;46; if ((x & 1) == 0) {47; state--;48; return 9;49; }50;51; if (state > 5000) {52; while (state > 5000) {53; for (int i = 50; i >= 0; i--) {54; state *= 6;55; state /= 7;56; state -= 1;57; }58; }59; }60; else {61; while (state < 5000) {62; for (int i = 50; i >= 0; i--) {63; state *= 6;64; state /= 5;65; state += 1;66; }67; }68; }69;70; return state;71;}72;73;volatile int cnt = 10000000;//10000000;74;int main() {75; int r = 0;76; for (int i = 0; i < cnt; i++) {77; r += foo(i);78; r -= foo(i & (~1));79; r += foo(0);80; }81; return r;82;}83