llvm/llvm/test/tools/llvm-profgen/merge-cold-profile.test

; Used the data from recursion-compression.test, refer it for the unmerged output
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/recursion-compression-pseudoprobe.perfscript --binary=%S/Inputs/recursion-compression-pseudoprobe.perfbin --output=%t1 --compress-recursion=-1 --profile-summary-hot-count=8 --csspgo-preinliner=0 --gen-cs-nested-profile=0
; RUN: FileCheck %s --input-file %t1

; Test --trim-cold-profile=0
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/recursion-compression-pseudoprobe.perfscript --binary=%S/Inputs/recursion-compression-pseudoprobe.perfbin --output=%t2 --compress-recursion=-1 --profile-summary-hot-count=100 --trim-cold-profile=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0
; RUN: FileCheck %s --input-file %t2 --check-prefix=CHECK-KEEP-COLD

; Test --csprof-merge-cold-context=0
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/recursion-compression-pseudoprobe.perfscript --binary=%S/Inputs/recursion-compression-pseudoprobe.perfbin --output=%t3 --compress-recursion=-1 --profile-summary-hot-count=10 --csprof-merge-cold-context=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0
; RUN: FileCheck %s --input-file %t3 --check-prefix=CHECK-UNMERGED

; Test --csprof-frame-depth-for-cold-context
; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/recursion-compression-pseudoprobe.perfscript --binary=%S/Inputs/recursion-compression-pseudoprobe.perfbin --output=%t2 --compress-recursion=-1 --profile-summary-hot-count=100 --trim-cold-profile=0 --csprof-max-cold-context-depth=2 --csspgo-preinliner=0 --gen-cs-nested-profile=0
; RUN: FileCheck %s --input-file %t2 --check-prefix=CHECK-COLD-CONTEXT-LENGTH

; CHECK:     [fa]:14:4
; CHECK-NEXT: 1: 4
; CHECK-NEXT: 3: 4
; CHECK-NEXT: 4: 2
; CHECK-NEXT: 5: 1
; CHECK-NEXT: 6: 0
; CHECK-NEXT: 7: 2 fb:2
; CHECK-NEXT: 8: 1 fa:1
; CHECK-NEXT: !CFGChecksum: 563070469352221
; CHECK-NEXT:[main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb]:13:4
; CHECK-NEXT: 1: 4
; CHECK-NEXT: 2: 3
; CHECK-NEXT: 3: 1
; CHECK-NEXT: 4: 0
; CHECK-NEXT: 5: 4 fb:4
; CHECK-NEXT: 6: 1 fa:1
; CHECK-NEXT: !CFGChecksum: 563022570642068

; CHECK-KEEP-COLD:     [fb]:19:6
; CHECK-KEEP-COLD-NEXT: 1: 6
; CHECK-KEEP-COLD-NEXT: 2: 3
; CHECK-KEEP-COLD-NEXT: 3: 3
; CHECK-KEEP-COLD-NEXT: 4: 0
; CHECK-KEEP-COLD-NEXT: 5: 4 fb:4
; CHECK-KEEP-COLD-NEXT: 6: 3 fa:3
; CHECK-KEEP-COLD-NEXT: !CFGChecksum: 563022570642068
; CHECK-KEEP-COLD-NEXT:[fa]:14:4
; CHECK-KEEP-COLD-NEXT: 1: 4
; CHECK-KEEP-COLD-NEXT: 3: 4
; CHECK-KEEP-COLD-NEXT: 4: 2
; CHECK-KEEP-COLD-NEXT: 5: 1
; CHECK-KEEP-COLD-NEXT: 6: 0
; CHECK-KEEP-COLD-NEXT: 7: 2 fb:2
; CHECK-KEEP-COLD-NEXT: 8: 1 fa:1
; CHECK-KEEP-COLD-NEXT: !CFGChecksum: 563070469352221

; CHECK-UNMERGED:     [main:2 @ foo:5 @ fa:8 @ fa:7 @ fb:5 @ fb]:13:4
; CHECK-UNMERGED-NEXT: 1: 4
; CHECK-UNMERGED-NEXT: 2: 3
; CHECK-UNMERGED-NEXT: 3: 1
; CHECK-UNMERGED-NEXT: 4: 0
; CHECK-UNMERGED-NEXT: 5: 4 fb:4
; CHECK-UNMERGED-NEXT: 6: 1 fa:1
; CHECK-UNMERGED-NEXT: !CFGChecksum: 563022570642068
; CHECK-UNMERGED-NOT: [fa]
; CHECK-UNMERGED-NOT: [fb]

; CHECK-COLD-CONTEXT-LENGTH:     [fb:5 @ fb]:13:4
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 1: 4
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 2: 3
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 3: 1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 4: 0
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 5: 4 fb:4
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 6: 1 fa:1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: !CFGChecksum: 563022570642068
; CHECK-COLD-CONTEXT-LENGTH-NEXT:[fb:6 @ fa]:10:3
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 1: 3
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 3: 3
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 4: 1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 5: 1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 6: 0
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 7: 1 fb:1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 8: 1 fa:1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: !CFGChecksum: 563070469352221
; CHECK-COLD-CONTEXT-LENGTH-NEXT:[fa:7 @ fb]:6:2
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 1: 2
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 2: 0
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 3: 2
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 4: 0
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 5: 0
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 6: 2 fa:2
; CHECK-COLD-CONTEXT-LENGTH-NEXT: !CFGChecksum: 563022570642068
; CHECK-COLD-CONTEXT-LENGTH-NEXT:[fa:8 @ fa]:4:1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 1: 1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 3: 1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 4: 1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 5: 0
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 6: 0
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 7: 1 fb:1
; CHECK-COLD-CONTEXT-LENGTH-NEXT: 8: 0
; CHECK-COLD-CONTEXT-LENGTH-NEXT: !CFGChecksum: 563070469352221

; clang -O3 -fuse-ld=lld -fpseudo-probe-for-profiling
; -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Xclang -mdisable-tail-calls
; -g test.c  -o a.out

; Copied from recursion-compression.test
#include <stdio.h>

int fb(int n) {
  if(n > 10) return fb(n / 2);
  return fa(n - 1);
}

int fa(int n) {
  if(n < 2) return n;
  if(n % 2) return fb(n - 1);
  return fa(n - 1);
}

void foo() {
  int s, i = 0;
  while (i++ < 10000)
    s += fa(i);
  printf("sum is %d\n", s);
}

int main() {
  foo();
  return 0;
}