From 9706d43b56e16eb3029314e02c499305284e99f1 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Thu, 8 Aug 2013 01:50:52 +0000 Subject: [PATCH] Revert "coff also doesn't have a ReadOnlySection yet, (!)" This reverts commit r77814. We were sticking global constants in the .data section instead of in the .rdata section when emitting for COFF. This fixes PR16831. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187956 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 3 +++ test/MC/COFF/rdata.ll | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 test/MC/COFF/rdata.ll diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 7d9382e5233..cf70ad6a2ec 100644 --- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -776,6 +776,9 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, if (Kind.isThreadLocal()) return getTLSDataSection(); + if (Kind.isReadOnly() && ReadOnlySection != 0) + return ReadOnlySection; + return getDataSection(); } diff --git a/test/MC/COFF/rdata.ll b/test/MC/COFF/rdata.ll new file mode 100644 index 00000000000..f0417811704 --- /dev/null +++ b/test/MC/COFF/rdata.ll @@ -0,0 +1,6 @@ +; RUN: llc -mtriple i386-pc-win32 < %s | FileCheck %s + +%struct.foo = type { i32, i32 } + +@"\01?thingy@@3Ufoo@@B" = constant %struct.foo zeroinitializer, align 4 +; CHECK: .section .rdata -- 2.34.1