[PATCH] D115984: [ELF] --time-trace: Trace "Write sections"

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 17 23:39:31 PST 2021


MaskRay created this revision.
MaskRay added reviewers: jhenderson, ikudrin, peter.smith.
Herald added subscribers: arichardson, emaste.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

writeSections is typically a bottleneck.
I have found that benchmarking the following can be useful:

- Output section .rela.dyn (9115d75117b57115fe45153e5f38f2c444c0cd91 <https://reviews.llvm.org/rG9115d75117b57115fe45153e5f38f2c444c0cd91>)
- Output section .debug_str (3aae04c744b03eb3eec7376f9d34fa3e42f8d108 <https://reviews.llvm.org/rG3aae04c744b03eb3eec7376f9d34fa3e42f8d108>)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115984

Files:
  lld/ELF/OutputSections.cpp
  lld/ELF/Writer.cpp


Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -2893,6 +2893,8 @@
 
 // Write section contents to a mmap'ed file.
 template <class ELFT> void Writer<ELFT>::writeSections() {
+  llvm::TimeTraceScope timeScope("Write sections");
+
   // In -r or --emit-relocs mode, write the relocation sections first as in
   // ELf_Rel targets we might find out that we need to modify the relocated
   // section while doing it.
Index: lld/ELF/OutputSections.cpp
===================================================================
--- lld/ELF/OutputSections.cpp
+++ lld/ELF/OutputSections.cpp
@@ -332,6 +332,7 @@
 }
 
 template <class ELFT> void OutputSection::writeTo(uint8_t *buf) {
+  llvm::TimeTraceScope timeScope("Write sections", name);
   if (type == SHT_NOBITS)
     return;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115984.395266.patch
Type: text/x-patch
Size: 866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211218/397a6da2/attachment.bin>


More information about the llvm-commits mailing list