1 ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/artificial-branch.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t --skip-symbolization --use-offset=0
2 ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-EXT-ADDR
3 ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t --skip-symbolization --use-offset=0
4 ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-RAW-PROFILE
5 ; RUN: llvm-profgen --format=text --unsymbolized-profile=%t --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t1 --use-offset=0
6 ; RUN: FileCheck %s --input-file %t1 --check-prefix=CHECK
8 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t --populate-profile-symbol-list=1
9 ; RUN: llvm-profdata show -show-prof-sym-list -sample %t | FileCheck %s --check-prefix=CHECK-SYM-LIST
12 ; CHECK-EXT-ADDR-NEXT: 400870-400870:2
13 ; CHECK-EXT-ADDR-NEXT: 400875-4008bf:1
14 ; CHECK-EXT-ADDR-NEXT: 2
15 ; Value 1 is external address
16 ; CHECK-EXT-ADDR-NEXT: 1->400875:1
17 ; CHECK-EXT-ADDR-NEXT: 4008bf->400870:2
20 ; CHECK-SYM-LIST: Dump profile symbol list
21 ; CHECK-SYM-LIST: main
22 ; CHECK-SYM-LIST: partition_pivot_first
23 ; CHECK-SYM-LIST: partition_pivot_last
24 ; CHECK-SYM-LIST: quick_sort
25 ; CHECK-SYM-LIST: swap
28 ;CHECK-RAW-PROFILE-NOT: 7f7448e889e4
29 ;CHECK-RAW-PROFILE-NOT: 7f7448e88826
31 ;CHECK: partition_pivot_first:3022:5
63 ;CHECK: 8: 1 quick_sort:1
68 ;CHECK: partition_pivot_last:1210:7
73 ;w/o duplication factor : 3.1: 18
74 ;w/o duplication factor : 3.3: 18
75 ;w/o duplication factor : 4: 19
76 ;w/o duplication factor : 5: 9
87 ;w/o duplication factor : 1: 9
88 ;w/o duplication factor : 2: 9
89 ;w/o duplication factor : 3: 9
98 ;CHECK: quick_sort:903:25
100 ;CHECK: 2: 12 partition_pivot_last:7 partition_pivot_first:5
101 ;CHECK: 3: 12 quick_sort:12
102 ;CHECK: 4: 12 quick_sort:12
109 ; clang -O3 -g -fno-optimize-sibling-calls -fdebug-info-for-profiling qsort.c -o a.out
113 void swap(int *a, int *b) {
119 int partition_pivot_last(int* array, int low, int high) {
120 int pivot = array[high];
122 for (int j = low; j < high; j++)
123 if (array[j] < pivot)
124 swap(&array[++i], &array[j]);
125 swap(&array[i + 1], &array[high]);
129 int partition_pivot_first(int* array, int low, int high) {
130 int pivot = array[low];
132 for (int j = low + 1; j <= high; j++)
133 if (array[j] < pivot) { if (j != i) swap(&array[i], &array[j]); i++;}
134 swap(&array[i - 1], &array[low]);
138 void quick_sort(int* array, int low, int high, int (*partition_func)(int *, int, int)) {
140 int pi = (*partition_func)(array, low, high);
141 quick_sort(array, low, pi - 1, partition_func);
142 quick_sort(array, pi + 1, high, partition_func);
147 const int size = 200;
149 int *array = malloc(size * sizeof(int));
150 for(int i = 0; i < 100 * 1000; i++) {
151 for(int j = 0; j < size; j++)
152 array[j] = j % 10 ? rand() % size: j;
153 int (*fptr)(int *, int, int) = i % 3 ? partition_pivot_last : partition_pivot_first;
154 quick_sort(array, 0, size - 1, fptr);
155 sum += array[i % size];
157 printf("sum=%d\n", sum);