1; REQUIRES: asserts 2; Test default using size of profile as a proxy 3; 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 4 5; Test use-context-cost-for-preinliner using inlinee's byte size as context-sensitive inline cost 6; 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 7 8CHECK-DEFAULT: Process main for context-sensitive pre-inlining (pre-inline size: 9, size limit: 108) 9CHECK-DEFAULT-NEXT: Inlined context profile for: main:9 @ _Z3fooi (callee size: 2, call count:545) 10CHECK-DEFAULT-NEXT: Inlined context profile for: main:7 @ _Z3fooi (callee size: 14, call count:545) 11CHECK-DEFAULT-NEXT: Inlined context profile for: main:8 @ _Z3fooi (callee size: 4, call count:544) 12 13CHECK-CSCOST: Process main for context-sensitive pre-inlining (pre-inline size: 69, size limit: 828) 14; This inlinee is fully optimized away, make sure we have the correct zero size for that context even if the size is 15; not available through symbolization. 16CHECK-CSCOST-NEXT: Inlined context profile for: main:9 @ _Z3fooi (callee size: 0, call count:545) 17CHECK-CSCOST-NEXT: Inlined context profile for: main:7 @ _Z3fooi (callee size: 279, call count:545) 18CHECK-CSCOST-NEXT: Inlined context profile for: main:8 @ _Z3fooi (callee size: 44, call count:544) 19 20; binary is built with the source below using the following command line: 21; clang -O3 -g -fpseudo-probe-for-profiling test.cpp 22; 23;#include <stdio.h> 24; 25;volatile int state = 9000; 26; 27;int foo(int x) { 28; if (x == 0) { 29; return 7; 30; } 31; 32; if ((x & 1) == 0) { 33; state--; 34; return 9; 35; } 36; 37; if (state > 5000) { 38; while (state > 5000) { 39; for (int i = 50; i >= 0; i--) { 40; state *= 6; 41; state /= 7; 42; state -= 1; 43; } 44; } 45; } 46; else { 47; while (state < 5000) { 48; for (int i = 50; i >= 0; i--) { 49; state *= 6; 50; state /= 5; 51; state += 1; 52; } 53; } 54; } 55; 56; return state; 57;} 58; 59;volatile int cnt = 10000000;//10000000; 60;int main() { 61; int r = 0; 62; for (int i = 0; i < cnt; i++) { 63; r += foo(i); 64; r -= foo(i & (~1)); 65; r += foo(0); 66; } 67; return r; 68;} 69