aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp27
1 files changed, 24 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index bf3b89e..4859919 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -2027,8 +2027,8 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForExternalReference(
MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
- assert(!TM.getFunctionSections() && !TM.getDataSections() &&
- "XCOFF unique sections not yet implemented.");
+ assert(!TM.getDataSections() &&
+ "XCOFF unique data sections not yet implemented.");
// Common symbols go into a csect with matching name which will get mapped
// into the .bss section.
@@ -2057,8 +2057,13 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal(
Kind, /* BeginSymbolName */ nullptr);
}
- if (Kind.isText())
+ if (Kind.isText()) {
+ if (TM.getFunctionSections()) {
+ return cast<MCSymbolXCOFF>(getFunctionEntryPointSymbol(GO, TM))
+ ->getRepresentedCsect();
+ }
return TextSection;
+ }
if (Kind.isData() || Kind.isReadOnlyWithRel())
// TODO: We may put this under option control, because user may want to
@@ -2161,6 +2166,22 @@ MCSymbol *TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol(
SmallString<128> NameStr;
NameStr.push_back('.');
getNameWithPrefix(NameStr, Func, TM);
+
+ // When -function-sections is enabled, it's not necessary to emit
+ // function entry point label any more. We will use function entry
+ // point csect instead. For function delcarations, it's okay to continue
+ // using label semantic because undefined symbols gets treated as csect with
+ // XTY_ER property anyway.
+ if (TM.getFunctionSections() && !Func->isDeclaration() &&
+ isa<Function>(Func)) {
+ XCOFF::StorageClass SC =
+ TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(Func);
+ return cast<MCSectionXCOFF>(getContext().getXCOFFSection(
+ NameStr, XCOFF::XMC_PR, XCOFF::XTY_SD, SC,
+ SectionKind::getText()))
+ ->getQualNameSymbol();
+ }
+
return getContext().getOrCreateSymbol(NameStr);
}