[llvm] r188244 - [-cxx-abi microsoft] Stick zero initialized symbols into the .bss section for COFF
David Majnemer
david.majnemer at gmail.com
Mon Aug 12 18:23:53 PDT 2013
Author: majnemer
Date: Mon Aug 12 20:23:53 2013
New Revision: 188244
URL: http://llvm.org/viewvc/llvm-project?rev=188244&view=rev
Log:
[-cxx-abi microsoft] Stick zero initialized symbols into the .bss section for COFF
Summary:
We need to do two things:
- Initialize BSSSection in MCObjectFileInfo::InitCOFFMCObjectFileInfo
- Teach TargetLoweringObjectFileCOFF::SelectSectionForGlobal what to do
with it
This fixes PR16861.
Reviewers: rnk
Reviewed By: rnk
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1361
Added:
llvm/trunk/test/MC/COFF/bss_section.ll
Modified:
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/trunk/lib/MC/MCObjectFileInfo.cpp
Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=188244&r1=188243&r2=188244&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Mon Aug 12 20:23:53 2013
@@ -771,15 +771,18 @@ SelectSectionForGlobal(const GlobalValue
}
if (Kind.isText())
- return getTextSection();
+ return TextSection;
if (Kind.isThreadLocal())
- return getTLSDataSection();
+ return TLSDataSection;
- if (Kind.isReadOnly() && ReadOnlySection != 0)
+ if (Kind.isReadOnly())
return ReadOnlySection;
- return getDataSection();
+ if (Kind.isBSS())
+ return BSSSection;
+
+ return DataSection;
}
void TargetLoweringObjectFileCOFF::
Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=188244&r1=188243&r2=188244&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Mon Aug 12 20:23:53 2013
@@ -496,6 +496,12 @@ void MCObjectFileInfo::InitELFMCObjectFi
void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
// COFF
+ BSSSection =
+ Ctx->getCOFFSection(".bss",
+ COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ |
+ COFF::IMAGE_SCN_MEM_WRITE,
+ SectionKind::getBSS());
TextSection =
Ctx->getCOFFSection(".text",
COFF::IMAGE_SCN_CNT_CODE |
Added: llvm/trunk/test/MC/COFF/bss_section.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/bss_section.ll?rev=188244&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/bss_section.ll (added)
+++ llvm/trunk/test/MC/COFF/bss_section.ll Mon Aug 12 20:23:53 2013
@@ -0,0 +1,6 @@
+; RUN: llc -mtriple i386-pc-win32 < %s | FileCheck %s
+
+%struct.foo = type { i32, i32 }
+
+@"\01?thingy@@3Ufoo@@B" = global %struct.foo zeroinitializer, align 4
+; CHECK: .bss
More information about the llvm-commits
mailing list