aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorSnehasish Kumar <snehasishk@google.com>2020-04-24 14:35:19 -0700
committerSriraman Tallam <tmsriram@google.com>2020-04-24 15:07:38 -0700
commit0cc063a8ffc896aa82ebe4b11003f0bbd78d6d5b (patch)
treeb07fdbb5f8c4023c03e06e0496aefd718b187cdd /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent10bc12588dac532fad044b2851dde8e7b9121e88 (diff)
downloadllvm-0cc063a8ffc896aa82ebe4b11003f0bbd78d6d5b.zip
llvm-0cc063a8ffc896aa82ebe4b11003f0bbd78d6d5b.tar.gz
llvm-0cc063a8ffc896aa82ebe4b11003f0bbd78d6d5b.tar.bz2
Use .text.unlikely and .text.eh prefixes for MachineBasicBlock sections.
Summary: Instead of adding a ".unlikely" or ".eh" suffix for machine basic blocks, this change updates the behaviour to use an appropriate prefix instead. This allows lld to group basic block sections together when -z,keep-text-section-prefix is specified and matches the behaviour observed in gcc. Reviewers: tmsriram, mtrofin, efriedma Reviewed By: tmsriram, efriedma Subscribers: eli.friedman, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D78742
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 8ed3e86..a2dfa0a 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -859,28 +859,28 @@ MCSection *TargetLoweringObjectFileELF::getSectionForMachineBasicBlock(
const Function &F, const MachineBasicBlock &MBB,
const TargetMachine &TM) const {
assert(MBB.isBeginSection() && "Basic block does not start a section!");
- SmallString<128> Name;
- Name =
- (static_cast<MCSectionELF *>(MBB.getParent()->getSection()))->getName();
unsigned UniqueID = MCContext::GenericSectionID;
- switch (MBB.getSectionID().Type) {
- // Append suffixes to represent special cold and exception sections.
- case MBBSectionID::SectionType::Exception:
- Name += ".eh";
- break;
- case MBBSectionID::SectionType::Cold:
- Name += ".unlikely";
- break;
- // For regular sections, either use a unique name, or a unique ID for the
- // section.
- default:
+ // For cold sections use the .text.unlikely prefix along with the parent
+ // function name. All cold blocks for the same function go to the same
+ // section. Similarly all exception blocks are grouped by symbol name
+ // under the .text.eh prefix. For regular sections, we either use a unique
+ // name, or a unique ID for the section.
+ SmallString<128> Name;
+ if (MBB.getSectionID() == MBBSectionID::ColdSectionID) {
+ Name += ".text.unlikely.";
+ Name += MBB.getParent()->getName();
+ } else if (MBB.getSectionID() == MBBSectionID::ExceptionSectionID) {
+ Name += ".text.eh.";
+ Name += MBB.getParent()->getName();
+ } else {
+ Name += MBB.getParent()->getSection()->getName();
if (TM.getUniqueBBSectionNames()) {
Name += ".";
Name += MBB.getSymbol()->getName();
- } else
+ } else {
UniqueID = NextUniqueID++;
- break;
+ }
}
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;