aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorRahman Lavaee <rahmanl@google.com>2020-04-13 12:12:34 -0700
committerRahman Lavaee <rahmanl@google.com>2020-04-13 12:19:59 -0700
commit4ddf7ab454b0b0e885e4970f3896adc53d1c64e4 (patch)
treed8a5e8c88e8cd803fce8a790c2251602bc729f5a /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parent5c7bbe3659a04c1d17deb3b50ab5b88204327842 (diff)
downloadllvm-4ddf7ab454b0b0e885e4970f3896adc53d1c64e4.zip
llvm-4ddf7ab454b0b0e885e4970f3896adc53d1c64e4.tar.gz
llvm-4ddf7ab454b0b0e885e4970f3896adc53d1c64e4.tar.bz2
Revert "Extend BasicBlock sections to allow specifying clusters of basic blocks"
This reverts commit 0d4ec16d3db3a92514e14101f635e8536c208c4f Because tests were not added to the commit.
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 1794669..b96cba4 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -769,31 +769,14 @@ 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();
- 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:
- if (TM.getUniqueBBSectionNames()) {
- Name += ".";
- Name += MBB.getSymbol()->getName();
- } else
- UniqueID = NextUniqueID++;
- break;
+ 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()) {
@@ -805,6 +788,33 @@ MCSection *TargetLoweringObjectFileELF::getSectionForMachineBasicBlock(
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();
+
+ // 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();
+ }
+
+ Name += Suffix;
+
+ 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);
+}
+
static MCSectionELF *getStaticStructorSection(MCContext &Ctx, bool UseInitArray,
bool IsCtor, unsigned Priority,
const MCSymbol *KeySym) {