From a3ea407d48eba34c712399c8885a49861ea9a741 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 21 Feb 2016 01:30:30 +0000 Subject: [X86] Use the correct alignment for COMDAT constant pool entries COFF doesn't have sections with mergeable contents. Instead, each constant pool entry ends up in a COMDAT section. The linker, when choosing between COMDAT sections, doesn't choose the max alignment of the two sections. You just get whatever alignment was on the section. If one constant needed a higher alignment in one object file from another one, then we will get into trouble if the linker chooses the lower alignment one. Instead, lets promote the alignment of the constant pool entry to make sure we don't use an under aligned constant with an instruction which assumed otherwise. This fixes PR26680. llvm-svn: 261462 --- llvm/lib/Target/TargetLoweringObjectFile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Target/TargetLoweringObjectFile.cpp') diff --git a/llvm/lib/Target/TargetLoweringObjectFile.cpp b/llvm/lib/Target/TargetLoweringObjectFile.cpp index a0b0d8f2404..3c04a214fad 100644 --- a/llvm/lib/Target/TargetLoweringObjectFile.cpp +++ b/llvm/lib/Target/TargetLoweringObjectFile.cpp @@ -252,8 +252,10 @@ TargetLoweringObjectFile::SectionForGlobal(const GlobalValue *GV, MCSection *TargetLoweringObjectFile::getSectionForJumpTable( const Function &F, Mangler &Mang, const TargetMachine &TM) const { + unsigned Align = 0; return getSectionForConstant(F.getParent()->getDataLayout(), - SectionKind::getReadOnly(), /*C=*/nullptr); + SectionKind::getReadOnly(), /*C=*/nullptr, + Align); } bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection( @@ -277,7 +279,8 @@ bool TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection( /// Given a mergable constant with the specified size and relocation /// information, return a section that it should be placed in. MCSection *TargetLoweringObjectFile::getSectionForConstant( - const DataLayout &DL, SectionKind Kind, const Constant *C) const { + const DataLayout &DL, SectionKind Kind, const Constant *C, + unsigned &Align) const { if (Kind.isReadOnly() && ReadOnlySection != nullptr) return ReadOnlySection; -- cgit v1.2.3