[llvm] 3220571 - [llvm-profgen] Skip disassembling for PLT section

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 14 16:42:46 PST 2021


Author: wlei
Date: 2021-12-14T16:40:53-08:00
New Revision: 322057179316c03b2b25ce341b1e55d01890730d

URL: https://github.com/llvm/llvm-project/commit/322057179316c03b2b25ce341b1e55d01890730d
DIFF: https://github.com/llvm/llvm-project/commit/322057179316c03b2b25ce341b1e55d01890730d.diff

LOG: [llvm-profgen] Skip disassembling for PLT section

Skip disassembling .plt section, then .plt section code will be treated as external code.

Reviewed By: hoy, wenlei

Differential Revision: https://reviews.llvm.org/D115699

Added: 
    

Modified: 
    llvm/test/tools/llvm-profgen/inline-noprobe2.test
    llvm/tools/llvm-profgen/ProfiledBinary.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llvm-profgen/inline-noprobe2.test b/llvm/test/tools/llvm-profgen/inline-noprobe2.test
index 14e1518ba4341..70842f7b1ec57 100644
--- a/llvm/test/tools/llvm-profgen/inline-noprobe2.test
+++ b/llvm/test/tools/llvm-profgen/inline-noprobe2.test
@@ -8,13 +8,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
 ; 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-ARTIFICIAL-BRANCH: 0
+; CHECK-ARTIFICIAL-BRANCH: 0
 
 ; CHECK-SYM-LIST: Dump profile symbol list
 ; CHECK-SYM-LIST: main
@@ -78,16 +73,16 @@
 ;CHECK:   1: 5
 ;CHECK:   2: 5
 ;CHECK:   3: 5
-;CHECK: main:820:0
+;CHECK: main:486:0
 ;CHECK:  0: 0
 ;CHECK:  3: 0
 ;CHECK:  4.1: 0
 ;CHECK:  4.3: 0
-;CHECK:  5.1: 10
-;CHECK:  5.3: 10
-;CHECK:  6: 10
-;CHECK:  6.1: 12
-;CHECK:  6.3: 10
+;CHECK:  5.1: 6
+;CHECK:  5.3: 6
+;CHECK:  6: 6
+;CHECK:  6.1: 6
+;CHECK:  6.3: 6
 ;CHECK:  7: 0
 ;CHECK:  8: 0 quick_sort:1
 ;CHECK:  9: 0

diff  --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 15e8f0e620588..aa4dd426f66da 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -545,14 +545,18 @@ void ProfiledBinary::disassemble(const ELFObjectFileBase *Obj) {
     // Register the text section.
     TextSections.insert({SectionOffset, SectSize});
 
+    StringRef SectionName = unwrapOrError(Section.getName(), FileName);
+
     if (ShowDisassemblyOnly) {
-      StringRef SectionName = unwrapOrError(Section.getName(), FileName);
       outs() << "\nDisassembly of section " << SectionName;
       outs() << " [" << format("0x%" PRIx64, Section.getAddress()) << ", "
              << format("0x%" PRIx64, Section.getAddress() + SectSize)
              << "]:\n\n";
     }
 
+    if (SectionName == ".plt")
+      continue;
+
     // Get the section data.
     ArrayRef<uint8_t> Bytes =
         arrayRefFromStringRef(unwrapOrError(Section.getContents(), FileName));


        


More information about the llvm-commits mailing list