[llvm] r218179 - MC: Treat ReadOnlyWithRel and ReadOnlyWithRelLocal as ReadOnly for COFF
David Majnemer
david.majnemer at gmail.com
Sat Sep 20 00:31:46 PDT 2014
Author: majnemer
Date: Sat Sep 20 02:31:46 2014
New Revision: 218179
URL: http://llvm.org/viewvc/llvm-project?rev=218179&view=rev
Log:
MC: Treat ReadOnlyWithRel and ReadOnlyWithRelLocal as ReadOnly for COFF
A problem with our old behavior becomes observable under x86-64 COFF
when we need a read-only GV which has an initializer which is referenced
using a relocation: we would mark the section as writable. Marking the
section as writable interferes with section merging.
This fixes PR21009.
Added:
llvm/trunk/test/MC/COFF/const-gv-with-rel-init.ll
Modified:
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/trunk/lib/MC/MCSectionCOFF.cpp
Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=218179&r1=218178&r2=218179&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Sat Sep 20 02:31:46 2014
@@ -761,7 +761,7 @@ getCOFFSectionFlags(SectionKind K) {
COFF::IMAGE_SCN_MEM_EXECUTE |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_CNT_CODE;
- else if (K.isBSS ())
+ else if (K.isBSS())
Flags |=
COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
@@ -771,7 +771,7 @@ getCOFFSectionFlags(SectionKind K) {
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE;
- else if (K.isReadOnly())
+ else if (K.isReadOnly() || K.isReadOnlyWithRel())
Flags |=
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ;
Modified: llvm/trunk/lib/MC/MCSectionCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSectionCOFF.cpp?rev=218179&r1=218178&r2=218179&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSectionCOFF.cpp (original)
+++ llvm/trunk/lib/MC/MCSectionCOFF.cpp Sat Sep 20 02:31:46 2014
@@ -51,7 +51,7 @@ void MCSectionCOFF::PrintSwitchToSection
OS << 'x';
else if (getKind().isBSS())
OS << 'b';
- if (getKind().isWriteable())
+ if (getKind().isWriteable() && !getKind().isReadOnlyWithRel())
OS << 'w';
else
OS << 'r';
Added: llvm/trunk/test/MC/COFF/const-gv-with-rel-init.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/const-gv-with-rel-init.ll?rev=218179&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/const-gv-with-rel-init.ll (added)
+++ llvm/trunk/test/MC/COFF/const-gv-with-rel-init.ll Sat Sep 20 02:31:46 2014
@@ -0,0 +1,8 @@
+; RUN: llc -mtriple x86_64-pc-windows-msvc < %s | FileCheck %s
+
+define void @f() {
+ ret void
+}
+
+ at ptr = constant void ()* @f, section ".CRT$XLB", align 8
+; CHECK: .section .CRT$XLB,"rd"
More information about the llvm-commits
mailing list