[PATCH] D45472: [MachO] Emit Weak ReadOnlyWithRel to ConstDataSection
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 10 13:19:39 PDT 2018
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329752: [MachO] Emit Weak ReadOnlyWithRel to ConstDataSection (authored by steven_wu, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D45472
Files:
llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/trunk/lib/MC/MCObjectFileInfo.cpp
llvm/trunk/test/CodeGen/X86/global-sections.ll
Index: llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
===================================================================
--- llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
+++ llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
@@ -183,6 +183,7 @@
MCSection *ConstTextCoalSection;
MCSection *ConstDataSection;
MCSection *DataCoalSection;
+ MCSection *ConstDataCoalSection;
MCSection *DataCommonSection;
MCSection *DataBSSSection;
MCSection *FourByteConstantSection;
@@ -328,6 +329,9 @@
}
const MCSection *getConstDataSection() const { return ConstDataSection; }
const MCSection *getDataCoalSection() const { return DataCoalSection; }
+ const MCSection *getConstDataCoalSection() const {
+ return ConstDataCoalSection;
+ }
const MCSection *getDataCommonSection() const { return DataCommonSection; }
MCSection *getDataBSSSection() const { return DataBSSSection; }
const MCSection *getFourByteConstantSection() const {
Index: llvm/trunk/test/CodeGen/X86/global-sections.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/global-sections.ll
+++ llvm/trunk/test/CodeGen/X86/global-sections.ll
@@ -329,3 +329,8 @@
; WIN32-SECTIONS: .section .bss,"bw",one_only,_G17
; WIN32-SECTIONS: _G17:
; WIN32-SECTIONS:.byte 0
+
+; check weak ReadOnlyWithRel globals.
+ at G18 = linkonce_odr unnamed_addr constant i64* @G15
+; DARWIN64: .section __DATA,__const
+; DARWIN64: _G18:
Index: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -744,6 +744,8 @@
if (GO->isWeakForLinker()) {
if (Kind.isReadOnly())
return ConstTextCoalSection;
+ if (Kind.isReadOnlyWithRel())
+ return ConstDataCoalSection;
return DataCoalSection;
}
Index: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
===================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp
@@ -135,6 +135,10 @@
// "__DATA/__datacoal_nt" => section "__DATA/__data"
Triple::ArchType ArchTy = T.getArch();
+ ConstDataSection // .const_data
+ = Ctx->getMachOSection("__DATA", "__const", 0,
+ SectionKind::getReadOnlyWithRel());
+
if (ArchTy == Triple::ppc || ArchTy == Triple::ppc64) {
TextCoalSection
= Ctx->getMachOSection("__TEXT", "__textcoal_nt",
@@ -147,15 +151,14 @@
SectionKind::getReadOnly());
DataCoalSection = Ctx->getMachOSection(
"__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData());
+ ConstDataCoalSection = DataCoalSection;
} else {
TextCoalSection = TextSection;
ConstTextCoalSection = ReadOnlySection;
DataCoalSection = DataSection;
+ ConstDataCoalSection = ConstDataSection;
}
- ConstDataSection // .const_data
- = Ctx->getMachOSection("__DATA", "__const", 0,
- SectionKind::getReadOnlyWithRel());
DataCommonSection
= Ctx->getMachOSection("__DATA","__common",
MachO::S_ZEROFILL,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45472.141896.patch
Type: text/x-patch
Size: 3242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180410/fa3e3fca/attachment.bin>
More information about the llvm-commits
mailing list