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,31 @@ - +; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/artificial-branch.perfscript --binary=%S/Inputs/inline-noprobe2.perfbin --output=%t --skip-symbolization --use-offset=0 +; 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-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 @@ -492,13 +492,13 @@ if (IsExternal) { if (PrevTrDst) continue; - else if (!LBRStack.empty()) { + if (!LBRStack.empty()) { WithColor::warning() << "Invalid transfer to external code in LBR record at line " << TraceIt.getLineNumber() << ": " << TraceIt.getCurrentLine() << "\n"; - break; } + break; } if (IsOutgoing) {