[PATCH] D111749: [llvm-profgen] Also ignore the first external branch

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 13 16:26:31 PDT 2021


wlei updated this revision to Diff 379551.
wlei added a comment.

1. revert back to preivous version, ignore the whole trace
2. add test case for artificial branch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111749/new/

https://reviews.llvm.org/D111749

Files:
  llvm/test/tools/llvm-profgen/Inputs/artificial-branch.perfscript
  llvm/test/tools/llvm-profgen/inline-noprobe2.test
  llvm/tools/llvm-profgen/PerfReader.cpp


Index: llvm/tools/llvm-profgen/PerfReader.cpp
===================================================================
--- llvm/tools/llvm-profgen/PerfReader.cpp
+++ 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();
Index: llvm/test/tools/llvm-profgen/inline-noprobe2.test
===================================================================
--- llvm/test/tools/llvm-profgen/inline-noprobe2.test
+++ 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
Index: llvm/test/tools/llvm-profgen/Inputs/artificial-branch.perfscript
===================================================================
--- /dev/null
+++ 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111749.379551.patch
Type: text/x-patch
Size: 3752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211013/6dc16262/attachment.bin>


More information about the llvm-commits mailing list