[PATCH] D47743: MC: Don't emit the .llvm.call-graph-profile section into dwo files.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 4 13:36:30 PDT 2018


pcc created this revision.
pcc added a reviewer: Bigcheese.
Herald added subscribers: hiraditya, arichardson, emaste.
Herald added a reviewer: espindola.

Noticed by inspection.


https://reviews.llvm.org/D47743

Files:
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/test/MC/ELF/cgprofile.s


Index: llvm/test/MC/ELF/cgprofile.s
===================================================================
--- llvm/test/MC/ELF/cgprofile.s
+++ llvm/test/MC/ELF/cgprofile.s
@@ -1,4 +1,6 @@
 # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -t -sd -elf-cg-profile | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -split-dwarf-file %t.dwo -o - | llvm-readobj -s -t -sd -elf-cg-profile | FileCheck %s
+# RUN: llvm-readobj -s %t.dwo | FileCheck --check-prefix=DWO %s
 
   .section .test,"aw", at progbits
 a: .word b
@@ -97,4 +99,6 @@
 # CHECK-NEXT:     To: b
 # CHECK-NEXT:     Weight: 42
 # CHECK-NEXT:   }
-# CHECK-NEXT: ]
\ No newline at end of file
+# CHECK-NEXT: ]
+
+# DWO-NOT: .llvm.call-graph-profile
Index: llvm/lib/MC/ELFObjectWriter.cpp
===================================================================
--- llvm/lib/MC/ELFObjectWriter.cpp
+++ llvm/lib/MC/ELFObjectWriter.cpp
@@ -1092,14 +1092,6 @@
     }
   }
 
-  MCSectionELF *CGProfileSection = nullptr;
-  if (!Asm.CGProfile.empty()) {
-    CGProfileSection = Ctx.getELFSection(".llvm.call-graph-profile",
-                                         ELF::SHT_LLVM_CALL_GRAPH_PROFILE,
-                                         ELF::SHF_EXCLUDE, 16, "");
-    SectionIndexMap[CGProfileSection] = addToSectionTable(CGProfileSection);
-  }
-
   for (MCSectionELF *Group : Groups) {
     align(Group->getAlignment());
 
@@ -1123,6 +1115,14 @@
     // string tables.
     StrTabBuilder.finalize();
   } else {
+    MCSectionELF *CGProfileSection = nullptr;
+    if (!Asm.CGProfile.empty()) {
+      CGProfileSection = Ctx.getELFSection(".llvm.call-graph-profile",
+                                           ELF::SHT_LLVM_CALL_GRAPH_PROFILE,
+                                           ELF::SHF_EXCLUDE, 16, "");
+      SectionIndexMap[CGProfileSection] = addToSectionTable(CGProfileSection);
+    }
+
     // Compute symbol table information.
     computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap,
                        SectionOffsets);
@@ -1139,17 +1139,17 @@
       uint64_t SecEnd = W.OS.tell();
       SectionOffsets[RelSection] = std::make_pair(SecStart, SecEnd);
     }
-  }
 
-  if (CGProfileSection) {
-    uint64_t SecStart = W.OS.tell();
-    for (const MCAssembler::CGProfileEntry &CGPE : Asm.CGProfile) {
-      W.write<uint32_t>(CGPE.From->getSymbol().getIndex());
-      W.write<uint32_t>(CGPE.To->getSymbol().getIndex());
-      W.write<uint64_t>(CGPE.Count);
+    if (CGProfileSection) {
+      uint64_t SecStart = W.OS.tell();
+      for (const MCAssembler::CGProfileEntry &CGPE : Asm.CGProfile) {
+        W.write<uint32_t>(CGPE.From->getSymbol().getIndex());
+        W.write<uint32_t>(CGPE.To->getSymbol().getIndex());
+        W.write<uint64_t>(CGPE.Count);
+      }
+      uint64_t SecEnd = W.OS.tell();
+      SectionOffsets[CGProfileSection] = std::make_pair(SecStart, SecEnd);
     }
-    uint64_t SecEnd = W.OS.tell();
-    SectionOffsets[CGProfileSection] = std::make_pair(SecStart, SecEnd);
   }
 
   {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47743.149846.patch
Type: text/x-patch
Size: 3056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180604/5a4f928d/attachment.bin>


More information about the llvm-commits mailing list