aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorRahman Lavaee <rahmanl@google.com>2020-04-13 12:14:42 -0700
committerRahman Lavaee <rahmanl@google.com>2020-04-13 12:19:59 -0700
commit05192e585ce175b55f2a26b83b4ed7882785c8e6 (patch)
tree40533ae82158ebb980b70d5bc6c65130c766ef09 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent4ddf7ab454b0b0e885e4970f3896adc53d1c64e4 (diff)
downloadllvm-05192e585ce175b55f2a26b83b4ed7882785c8e6.zip
llvm-05192e585ce175b55f2a26b83b4ed7882785c8e6.tar.gz
llvm-05192e585ce175b55f2a26b83b4ed7882785c8e6.tar.bz2
Extend BasicBlock sections to allow specifying clusters of basic blocks in the same section.
Differential Revision: https://reviews.llvm.org/D76954
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp52
1 files changed, 21 insertions, 31 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index b96cba4..1794669 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -769,42 +769,31 @@ MCSection *TargetLoweringObjectFileELF::getSectionForConstant(
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()))
->getSectionName();
- if (TM.getUniqueBBSectionNames()) {
- Name += ".";
- Name += MBB.getSymbol()->getName();
- }
- unsigned UniqueID = NextUniqueID++;
- unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;
- std::string GroupName = "";
- if (F.hasComdat()) {
- Flags |= ELF::SHF_GROUP;
- GroupName = F.getComdat()->getName().str();
- }
- return getContext().getELFSection(Name, ELF::SHT_PROGBITS, Flags,
- 0 /* Entry Size */, GroupName, UniqueID,
- nullptr);
-}
-
-MCSection *TargetLoweringObjectFileELF::getNamedSectionForMachineBasicBlock(
- const Function &F, const MachineBasicBlock &MBB, const TargetMachine &TM,
- const char *Suffix) const {
- SmallString<128> Name;
- Name = (static_cast<MCSectionELF *>(MBB.getParent()->getSection()))
- ->getSectionName();
+ unsigned UniqueID = MCContext::GenericSectionID;
- // If unique section names is off, explicity add the function name to the
- // section name to make sure named sections for functions are unique
- // across the module.
- if (!TM.getUniqueSectionNames()) {
- Name += ".";
- Name += MBB.getParent()->getName();
+ 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:
+ if (TM.getUniqueBBSectionNames()) {
+ Name += ".";
+ Name += MBB.getSymbol()->getName();
+ } else
+ UniqueID = NextUniqueID++;
+ break;
}
- Name += Suffix;
-
unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;
std::string GroupName = "";
if (F.hasComdat()) {
@@ -812,7 +801,8 @@ MCSection *TargetLoweringObjectFileELF::getNamedSectionForMachineBasicBlock(
GroupName = F.getComdat()->getName().str();
}
return getContext().getELFSection(Name, ELF::SHT_PROGBITS, Flags,
- 0 /* Entry Size */, GroupName);
+ 0 /* Entry Size */, GroupName, UniqueID,
+ nullptr);
}
static MCSectionELF *getStaticStructorSection(MCContext &Ctx, bool UseInitArray,