diff --git a/llvm/test/tools/llvm-profgen/Inputs/artificial-branch.perfscript b/llvm/test/tools/llvm-profgen/Inputs/artificial-branch.perfscript new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-profgen/Inputs/artificial-branch.perfscript @@ -0,0 +1 @@ + 400870 0x400870/0x400540/P/-/-/1 0x4008bf/0x400870/P/-/-/7 0x7f7448e88cc1/0x400875/P/-/-/1 0x7f7448e88875/0x7f7448e88cbd/P/-/-/2 0x7f7448e88840/0x7f7448e8885c/P/-/-/1 0x7f7448e8882d/0x7f7448e8883a/P/-/-/1 0x7f7448e889e4/0x7f7448e88826/P/-/-/1 0x7f7448e8899f/0x7f7448e889d8/P/-/-/4 0x7f7448e88821/0x7f7448e88960/P/-/-/1 0x7f7448e887f9/0x7f7448e88815/P/-/-/2 0x7f7448e887e4/0x7f7448e887f2/P/-/-/2 0x7f7448e88cb8/0x7f7448e887c0/P/-/-/1 0x400540/0x7f7448e88cb0/P/-/-/1 0x400870/0x400540/P/-/-/1 0x4008bf/0x400870/P/-/-/5 diff --git a/llvm/test/tools/llvm-profgen/inline-noprobe2.test b/llvm/test/tools/llvm-profgen/inline-noprobe2.test --- a/llvm/test/tools/llvm-profgen/inline-noprobe2.test +++ b/llvm/test/tools/llvm-profgen/inline-noprobe2.test @@ -1,16 +1,38 @@ - +; REQUIRES: asserts +; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/artificial-branch.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t --skip-symbolization --use-offset=0 --debug-only=perf-reader 2>&1 | FileCheck %s --check-prefix=CHECK-LBR +; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-ARTIFICIAL-BRANCH +; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t --skip-symbolization --use-offset=0 +; RUN: FileCheck %s --input-file %t --check-prefix=CHECK-RAW-PROFILE ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t ; RUN: FileCheck %s --input-file %t --check-prefix=CHECK ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/inline-noprobe2.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t ; RUN: llvm-profdata show -show-prof-sym-list -sample %t | FileCheck %s --check-prefix=CHECK-SYM-LIST +; CHECK-LBR: [0] from 0x00400870 to 0x00400540 +; CHECK-LBR: [1] from 0x004008bf to 0x00400870 +; CHECK-LBR: [2] from 0x00400540 to 0x00400875 Artificial +; CHECK-LBR: [3] from 0x00400870 to 0x00400540 +; CHECK-LBR: [4] from 0x004008bf to 0x00400870 + +; CHECK-ARTIFICIAL-BRANCH: 3 +; CHECK-ARTIFICIAL-BRANCH: 400540-400540:1 +; CHECK-ARTIFICIAL-BRANCH: 400870-400870:2 +; CHECK-ARTIFICIAL-BRANCH: 400875-4008bf:1 +; CHECK-ARTIFICIAL-BRANCH: 2 +; CHECK-ARTIFICIAL-BRANCH: 400870->400540:2 +; CHECK-ARTIFICIAL-BRANCH: 4008bf->400870:2 + ; CHECK-SYM-LIST: Dump profile symbol list ; CHECK-SYM-LIST: main ; CHECK-SYM-LIST: partition_pivot_first ; CHECK-SYM-LIST: partition_pivot_last ; CHECK-SYM-LIST: quick_sort + +;CHECK-RAW-PROFILE-NOT: 7f7448e889e4 +;CHECK-RAW-PROFILE-NOT: 7f7448e88826 + ;CHECK: partition_pivot_first:1045:5 ;CHECK-NEXT: 0: 5 ;CHECK-NEXT: 1: 5 diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp --- a/llvm/tools/llvm-profgen/PerfReader.cpp +++ b/llvm/tools/llvm-profgen/PerfReader.cpp @@ -497,8 +497,8 @@ << "Invalid transfer to external code in LBR record at line " << TraceIt.getLineNumber() << ": " << TraceIt.getCurrentLine() << "\n"; - break; } + break; } if (IsOutgoing) { @@ -941,6 +941,12 @@ // Parse perf traces and do aggregation. parseAndAggregateTrace(); +#ifndef NDEBUG + LLVM_DEBUG(for (const auto &S + : AggregatedSamples) S.first.getPtr() + ->print();); +#endif + // Generate unsymbolized profile. warnTruncatedStack(); generateRawProfile();