aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
authorJon Roelofs <jonathan_roelofs@apple.com>2021-02-23 08:01:27 -0800
committerJon Roelofs <jonathan_roelofs@apple.com>2021-02-25 09:30:10 -0800
commit7f6e3316456f939a062aad0eeaac983251a1747c (patch)
treed8ee90dbc3a50e8000ad5a4f9b3b6429f0602bab /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
parentceaedfb5fc3a94adf9e67616d65414ddfee71e24 (diff)
downloadllvm-7f6e3316456f939a062aad0eeaac983251a1747c.zip
llvm-7f6e3316456f939a062aad0eeaac983251a1747c.tar.gz
llvm-7f6e3316456f939a062aad0eeaac983251a1747c.tar.bz2
Support `#pragma clang section` directives on MachO targets
rdar://59560986 Differential Revision: https://reviews.llvm.org/D97233
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 2530fdc..8f74866 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1129,13 +1129,12 @@ void TargetLoweringObjectFileMachO::emitModuleMetadata(MCStreamer &Streamer,
StringRef Segment, Section;
unsigned TAA = 0, StubSize = 0;
bool TAAParsed;
- std::string ErrorCode =
- MCSectionMachO::ParseSectionSpecifier(SectionVal, Segment, Section,
- TAA, TAAParsed, StubSize);
- if (!ErrorCode.empty())
+ if (Error E = MCSectionMachO::ParseSectionSpecifier(
+ SectionVal, Segment, Section, TAA, TAAParsed, StubSize)) {
// If invalid, report the error with report_fatal_error.
- report_fatal_error("Invalid section specifier '" + Section + "': " +
- ErrorCode + ".");
+ report_fatal_error("Invalid section specifier '" + Section +
+ "': " + toString(std::move(E)) + ".");
+ }
// Get the section.
MCSectionMachO *S = getContext().getMachOSection(
@@ -1159,6 +1158,14 @@ static void checkMachOComdat(const GlobalValue *GV) {
MCSection *TargetLoweringObjectFileMachO::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
+
+ StringRef SectionName = GO->getSection();
+
+ const Function *F = dyn_cast<Function>(GO);
+ if (F && F->hasFnAttribute("implicit-section-name")) {
+ SectionName = F->getFnAttribute("implicit-section-name").getValueAsString();
+ }
+
// Parse the section specifier and create it if valid.
StringRef Segment, Section;
unsigned TAA = 0, StubSize = 0;
@@ -1166,14 +1173,12 @@ MCSection *TargetLoweringObjectFileMachO::getExplicitSectionGlobal(
checkMachOComdat(GO);
- std::string ErrorCode =
- MCSectionMachO::ParseSectionSpecifier(GO->getSection(), Segment, Section,
- TAA, TAAParsed, StubSize);
- if (!ErrorCode.empty()) {
+ if (Error E = MCSectionMachO::ParseSectionSpecifier(
+ SectionName, Segment, Section, TAA, TAAParsed, StubSize)) {
// If invalid, report the error with report_fatal_error.
report_fatal_error("Global variable '" + GO->getName() +
"' has an invalid section specifier '" +
- GO->getSection() + "': " + ErrorCode + ".");
+ GO->getSection() + "': " + toString(std::move(E)) + ".");
}
// Get the section.