[PATCH] D48567: [COFF] Fix constant sharing regression for MinGW
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 25 14:08:52 PDT 2018
mstorsjo created this revision.
mstorsjo added reviewers: rnk, arm-chrjan01.
This fixes a regression since SVN r334523, where the object files built targeting MinGW were rejected by GNU binutils tools. Prior to that commit, we only put constants in comdat for MSVC configurations.
Repository:
rL LLVM
https://reviews.llvm.org/D48567
Files:
include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
test/CodeGen/X86/win_cst_pool.ll
Index: test/CodeGen/X86/win_cst_pool.ll
===================================================================
--- test/CodeGen/X86/win_cst_pool.ll
+++ test/CodeGen/X86/win_cst_pool.ll
@@ -1,4 +1,5 @@
; RUN: llc < %s -mtriple=x86_64-win32 -mattr=sse2 -mattr=avx | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-win32-gnu -mattr=sse2 -mattr=avx | FileCheck -check-prefix=MINGW %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"
@@ -14,6 +15,14 @@
; CHECK: movsd __real at 0000000000800000(%rip), %xmm0
; CHECK-NEXT: ret
+; MINGW: .section .rdata,"dr"
+; MINGW-NEXT: .p2align 3
+; MINGW-NEXT: [[LABEL:\.LC.*]]:
+; MINGW-NEXT: .quad 8388608
+; MINGW: double:
+; MINGW: movsd [[LABEL]](%rip), %xmm0
+; MINGW-NEXT: ret
+
define <4 x i32> @vec1() {
ret <4 x i32> <i32 3, i32 2, i32 1, i32 0>
}
Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1237,6 +1237,7 @@
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
SectionKind::getData());
}
+ TT = T;
}
static MCSectionCOFF *getCOFFStaticStructorSection(MCContext &Ctx,
@@ -1350,6 +1351,11 @@
MCSection *TargetLoweringObjectFileCOFF::getSectionForConstant(
const DataLayout &DL, SectionKind Kind, const Constant *C,
unsigned &Align) const {
+ if (!TT.isKnownWindowsMSVCEnvironment() &&
+ !TT.isWindowsItaniumEnvironment() &&
+ !TT.isWindowsCoreCLREnvironment())
+ return TargetLoweringObjectFile::getSectionForConstant(DL, Kind, C, Align);
+
if (Kind.isMergeableConst() && C) {
const unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
Index: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
===================================================================
--- include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
+++ include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
@@ -134,6 +134,8 @@
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
mutable unsigned NextUniqueID = 0;
+ Triple TT;
+
public:
~TargetLoweringObjectFileCOFF() override = default;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48567.152770.patch
Type: text/x-patch
Size: 2413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180625/4043c71b/attachment.bin>
More information about the llvm-commits
mailing list