From 1d371882b6da32538d198004be1b272567b150a3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 19 Jan 2010 02:09:44 +0000 Subject: Cleanup handling of .zerofill on darwin: 1. TargetLoweringObjectFileMachO should decide if something goes in zerofill instead of having every target do it. 2. TargetLoweringObjectFileMachO should assign said symbols to the right MCSection, the asmprinters should just emit to the right section. 3. Since all zerofill stuff goes through mcstreamer anymore, MAI can have a bool "haszerofill" instead of having the textual directive to emit. llvm-svn: 93838 --- llvm/lib/Target/TargetLoweringObjectFile.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'llvm/lib/Target/TargetLoweringObjectFile.cpp') diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index 93cb420d628..26a181aea0d 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -750,6 +750,9 @@ void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx, ConstDataCoalSection = getMachOSection("__DATA","__const_coal", MCSectionMachO::S_COALESCED, SectionKind::getText()); + DataCommonSection + = getMachOSection("__DATA","__common", MCSectionMachO::S_ZEROFILL, + SectionKind::getBSS()); ConstDataSection // .const_data = getMachOSection("__DATA", "__const", 0, SectionKind::getReadOnlyWithRel()); @@ -915,6 +918,11 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, if (Kind.isReadOnlyWithRel()) return ConstDataSection; + // Put zero initialized globals with strong external linkage in the + // DATA, __common section with the .zerofill directive. + if (Kind.isBSS() && GV->hasExternalLinkage()) + return DataCommonSection; + // Otherwise, just drop the variable in the normal data section. return DataSection; } -- cgit v1.2.3