From 2a9bd7b75699c3507c69ccd55d1bcc810807c351 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Thu, 28 Jun 2018 20:28:29 +0000 Subject: [PATCH] [COFF] Fix constant sharing regression for MinGW 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. Differential Revision: https://reviews.llvm.org/D48567 llvm-svn: 335918 --- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 5 ++++- llvm/test/CodeGen/X86/win_cst_pool.ll | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index df8aecd..dc29397 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1350,7 +1350,10 @@ static std::string scalarConstantToHexString(const Constant *C) { MCSection *TargetLoweringObjectFileCOFF::getSectionForConstant( const DataLayout &DL, SectionKind Kind, const Constant *C, unsigned &Align) const { - if (Kind.isMergeableConst() && C) { + if (Kind.isMergeableConst() && C && + getContext().getAsmInfo()->hasCOFFAssociativeComdats()) { + // GNU binutils doesn't support the kind of symbol with a null + // storage class that this generates. const unsigned Characteristics = COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_LNK_COMDAT; diff --git a/llvm/test/CodeGen/X86/win_cst_pool.ll b/llvm/test/CodeGen/X86/win_cst_pool.ll index a674d8c..cf0aa9b 100644 --- a/llvm/test/CodeGen/X86/win_cst_pool.ll +++ b/llvm/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 @@ define double @double() { ; CHECK: movsd __real@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> } -- 2.7.4