[PATCH] D79590: [lld] Add a new output section ".text.unknown" for funtions with unknown hotness info especially in sampleFDO
Wei Mi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 7 13:02:13 PDT 2020
wmi updated this revision to Diff 262732.
wmi added a comment.
Address MaskRay's comment.
Repository:
rLLD LLVM Linker
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79590/new/
https://reviews.llvm.org/D79590
Files:
lld/ELF/Writer.cpp
lld/test/ELF/text-section-prefix.s
Index: lld/test/ELF/text-section-prefix.s
===================================================================
--- lld/test/ELF/text-section-prefix.s
+++ lld/test/ELF/text-section-prefix.s
@@ -1,6 +1,7 @@
# REQUIRES: x86
## -z keep-text-section-prefix separates text sections with prefix .text.hot,
-## .text.unlikely, .text.startup, or .text.exit, in the absence of a SECTIONS command.
+## .text.unknown, .text.unlikely, .text.startup, or .text.exit, in the absence
+## of a SECTIONS command.
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
# RUN: ld.lld %t.o -o %t1
@@ -13,9 +14,10 @@
# KEEP: [ 1] .text
# KEEP-NEXT: [ 2] .text.hot
-# KEEP-NEXT: [ 3] .text.startup
-# KEEP-NEXT: [ 4] .text.exit
-# KEEP-NEXT: [ 5] .text.unlikely
+# KEEP-NEXT: [ 3] .text.unknown
+# KEEP-NEXT: [ 4] .text.startup
+# KEEP-NEXT: [ 5] .text.exit
+# KEEP-NEXT: [ 6] .text.unlikely
# NOKEEP: [ 1] .text
# NOKEEP-NOT: .text
@@ -29,6 +31,7 @@
# SCRIPT: .text
# SCRIPT-NEXT: .text.f
# SCRIPT-NEXT: .text.hot.f_hot
+# SCRIPT-NEXT: .text.unknown.f_unknown
# SCRIPT-NEXT: .text.startup.f_startup
# SCRIPT-NEXT: .text.exit.f_exit
# SCRIPT-NEXT: .text.unlikely.f_unlikely
@@ -43,6 +46,9 @@
.section .text.hot.f_hot,"ax"
nop
+.section .text.unknown.f_unknown,"ax"
+ nop
+
.section .text.startup.f_startup,"ax"
nop
Index: lld/ELF/Writer.cpp
===================================================================
--- lld/ELF/Writer.cpp
+++ lld/ELF/Writer.cpp
@@ -122,13 +122,18 @@
// When no SECTIONS is specified, emulate GNU ld's internal linker scripts
// by grouping sections with certain prefixes.
- // GNU ld places text sections with prefix ".text.hot.", ".text.unlikely.",
- // ".text.startup." or ".text.exit." before others. We provide an option -z
- // keep-text-section-prefix to group such sections into separate output
- // sections. This is more flexible. See also sortISDBySectionOrder().
+ // GNU ld places text sections with prefix ".text.hot.", ".text.unknown.",
+ // ".text.unlikely.", ".text.startup." or ".text.exit." before others.
+ // We provide an option -z keep-text-section-prefix to group such sections
+ // into separate output sections. This is more flexible. See also
+ // sortISDBySectionOrder().
+ // ".text.unknown" means the hotness of the section is unknown. When
+ // SampleFDO is used, if a function doesn't have sample, it could be very
+ // cold or it could be a new function never being sampled. Those functions
+ // will be kept in the ".text.unknown" section.
if (config->zKeepTextSectionPrefix)
- for (StringRef v :
- {".text.hot.", ".text.unlikely.", ".text.startup.", ".text.exit."})
+ for (StringRef v : {".text.hot.", ".text.unknown.", ".text.unlikely.",
+ ".text.startup.", ".text.exit."})
if (isSectionPrefix(v, s->name))
return v.drop_back();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79590.262732.patch
Type: text/x-patch
Size: 2895 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200507/f7a0721a/attachment.bin>
More information about the llvm-commits
mailing list