Revert "coff also doesn't have a ReadOnlySection yet, (!)"
authorDavid Majnemer <david.majnemer@gmail.com>
Thu, 8 Aug 2013 01:50:52 +0000 (01:50 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Thu, 8 Aug 2013 01:50:52 +0000 (01:50 +0000)
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
test/MC/COFF/rdata.ll [new file with mode: 0644]

index 7d9382e5233b4555470f9d309db09385f5c2fb73..cf70ad6a2ecb986449f60c0a7cce5fed5475d903 100644 (file)
@@ -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 (file)
index 0000000..f041781
--- /dev/null
@@ -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