diff options
author | dim <dim@FreeBSD.org> | 2014-03-26 07:42:43 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-03-26 07:42:43 +0000 |
commit | 45ae227ed48f53447b0000be4c2f1cb142fa5237 (patch) | |
tree | 2c3d1790f54e2af0e10eeb88cb26a0d91f029053 /contrib/llvm/patches/patch-r262261-llvm-r200373-sparc.diff | |
parent | fb422e6d310915f9e2641190198698d922f7ef58 (diff) | |
download | FreeBSD-src-45ae227ed48f53447b0000be4c2f1cb142fa5237.zip FreeBSD-src-45ae227ed48f53447b0000be4c2f1cb142fa5237.tar.gz |
MFC r263312:
Pull in r196939 from upstream llvm trunk (by Reid Kleckner):
Reland "Fix miscompile of MS inline assembly with stack realignment"
This re-lands commit r196876, which was reverted in r196879.
The tests have been fixed to pass on platforms with a stack alignment
larger than 4.
Update to clang side tests will land shortly.
Pull in r196986 from upstream llvm trunk (by Reid Kleckner):
Revert the backend fatal error from r196939
The combination of inline asm, stack realignment, and dynamic allocas
turns out to be too common to reject out of hand.
ASan inserts empy inline asm fragments and uses aligned allocas.
Compiling any trivial function containing a dynamic alloca with ASan is
enough to trigger the check.
XFAIL the test cases that would be miscompiled and add one that uses the
relevant functionality.
Pull in r202930 from upstream llvm trunk (by Hans Wennborg):
Check for dynamic allocas and inline asm that clobbers sp before building
selection dag (PR19012)
In X86SelectionDagInfo::EmitTargetCodeForMemcpy we check with MachineFrameInfo
to make sure that ESI isn't used as a base pointer register before we choose to
emit rep movs (which clobbers esi).
The problem is that MachineFrameInfo wouldn't know about dynamic allocas or
inline asm that clobbers the stack pointer until SelectionDAGBuilder has
encountered them.
This patch fixes the problem by checking for such things when building the
FunctionLoweringInfo.
Differential Revision: http://llvm-reviews.chandlerc.com/D2954
Together, these commits fix the problem encountered in the devel/emacs
port on the i386 architecture, where a combination of stack realignment,
alloca() and memcpy() could incidentally clobber the %esi register,
leading to segfaults in the temacs build-time utility.
See also: http://llvm.org/PR18171 and http://llvm.org/PR19012
Reported by: ashish
PR: ports/183064
MFC r263313:
Pull in r203311 from upstream llvm trunk (by Arnold Schwaighofer):
ISel: Make VSELECT selection terminate in cases where the condition type has to
be split and the result type widened.
When the condition of a vselect has to be split it makes no sense widening the
vselect and thereby widening the condition. We end up in an endless loop of
widening (vselect result type) and splitting (condition mask type) doing this.
Instead, split both the condition and the vselect and widen the result.
I ran this over the test suite with i686 and mattr=+sse and saw no regressions.
Fixes PR18036.
With this fix the original problem case from the graphics/rawtherapee
port (posted in http://llvm.org/PR18036 ) now compiles within ~97MB RSS.
Reported by: mandree
MFC r263320:
Add separate patch files for all the customizations we have currently
applied to our copy of llvm/clang. These can be applied in alphabetical
order to a pristine llvm/clang 3.4 release source tree, to result in the
same version used in FreeBSD.
This is intended to clearly document all the changes until now, which
mostly consist of cherry pickings from the respective upstream trunks,
plus a number of hand-written FreeBSD-specific ones. Hopefully those
can eventually be cleaned up and sent upstream too.
Diffstat (limited to 'contrib/llvm/patches/patch-r262261-llvm-r200373-sparc.diff')
-rw-r--r-- | contrib/llvm/patches/patch-r262261-llvm-r200373-sparc.diff | 296 |
1 files changed, 296 insertions, 0 deletions
diff --git a/contrib/llvm/patches/patch-r262261-llvm-r200373-sparc.diff b/contrib/llvm/patches/patch-r262261-llvm-r200373-sparc.diff new file mode 100644 index 0000000..f9bed35 --- /dev/null +++ b/contrib/llvm/patches/patch-r262261-llvm-r200373-sparc.diff @@ -0,0 +1,296 @@ +Pull in r200373 from upstream llvm trunk (by Venkatraman Govindaraju): + + [Sparc] Use %r_disp32 for pc_rel entries in gcc_except_table and eh_frame. + + Otherwise, assembler (gas) fails to assemble them with error message "operation + combines symbols in different segments". This is because MC computes + pc_rel entries with subtract expression between labels from different sections. + +Introduced here: http://svn.freebsd.org/changeset/base/262261 + +Index: lib/Target/Sparc/SparcTargetObjectFile.h +=================================================================== +--- lib/Target/Sparc/SparcTargetObjectFile.h ++++ lib/Target/Sparc/SparcTargetObjectFile.h +@@ -0,0 +1,34 @@ ++//===-- SparcTargetObjectFile.h - Sparc Object Info -------------*- C++ -*-===// ++// ++// The LLVM Compiler Infrastructure ++// ++// This file is distributed under the University of Illinois Open Source ++// License. See LICENSE.TXT for details. ++// ++//===----------------------------------------------------------------------===// ++ ++#ifndef LLVM_TARGET_SPARC_TARGETOBJECTFILE_H ++#define LLVM_TARGET_SPARC_TARGETOBJECTFILE_H ++ ++#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" ++ ++namespace llvm { ++ ++class MCContext; ++class TargetMachine; ++ ++class SparcELFTargetObjectFile : public TargetLoweringObjectFileELF { ++public: ++ SparcELFTargetObjectFile() : ++ TargetLoweringObjectFileELF() ++ {} ++ ++ const MCExpr * ++ getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang, ++ MachineModuleInfo *MMI, unsigned Encoding, ++ MCStreamer &Streamer) const; ++}; ++ ++} // end namespace llvm ++ ++#endif +Index: lib/Target/Sparc/SparcISelLowering.cpp +=================================================================== +--- lib/Target/Sparc/SparcISelLowering.cpp ++++ lib/Target/Sparc/SparcISelLowering.cpp +@@ -16,6 +16,7 @@ + #include "SparcMachineFunctionInfo.h" + #include "SparcRegisterInfo.h" + #include "SparcTargetMachine.h" ++#include "SparcTargetObjectFile.h" + #include "MCTargetDesc/SparcBaseInfo.h" + #include "llvm/CodeGen/CallingConvLower.h" + #include "llvm/CodeGen/MachineFrameInfo.h" +@@ -1361,7 +1362,7 @@ static SPCC::CondCodes FPCondCCodeToFCC(ISD::CondC + } + + SparcTargetLowering::SparcTargetLowering(TargetMachine &TM) +- : TargetLowering(TM, new TargetLoweringObjectFileELF()) { ++ : TargetLowering(TM, new SparcELFTargetObjectFile()) { + Subtarget = &TM.getSubtarget<SparcSubtarget>(); + + // Set up the register classes. +Index: lib/Target/Sparc/SparcTargetObjectFile.cpp +=================================================================== +--- lib/Target/Sparc/SparcTargetObjectFile.cpp ++++ lib/Target/Sparc/SparcTargetObjectFile.cpp +@@ -0,0 +1,48 @@ ++//===------- SparcTargetObjectFile.cpp - Sparc Object Info Impl -----------===// ++// ++// The LLVM Compiler Infrastructure ++// ++// This file is distributed under the University of Illinois Open Source ++// License. See LICENSE.TXT for details. ++// ++//===----------------------------------------------------------------------===// ++ ++#include "SparcTargetObjectFile.h" ++#include "MCTargetDesc/SparcMCExpr.h" ++#include "llvm/CodeGen/MachineModuleInfoImpls.h" ++#include "llvm/Support/Dwarf.h" ++#include "llvm/Target/Mangler.h" ++ ++using namespace llvm; ++ ++ ++const MCExpr *SparcELFTargetObjectFile:: ++getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang, ++ MachineModuleInfo *MMI, unsigned Encoding, ++ MCStreamer &Streamer) const { ++ ++ if (Encoding & dwarf::DW_EH_PE_pcrel) { ++ MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>(); ++ ++ //MCSymbol *SSym = getSymbolWithGlobalValueBase(*Mang, GV, ".DW.stub"); ++ SmallString<60> NameStr; ++ Mang->getNameWithPrefix(NameStr, GV, true); ++ NameStr.append(".DW.stub"); ++ MCSymbol *SSym = getContext().GetOrCreateSymbol(NameStr.str()); ++ ++ // Add information about the stub reference to ELFMMI so that the stub ++ // gets emitted by the asmprinter. ++ MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); ++ if (StubSym.getPointer() == 0) { ++ MCSymbol *Sym = getSymbol(*Mang, GV); ++ StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); ++ } ++ ++ MCContext &Ctx = getContext(); ++ return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32, ++ MCSymbolRefExpr::Create(SSym, Ctx), Ctx); ++ } ++ ++ return TargetLoweringObjectFileELF:: ++ getTTypeGlobalReference(GV, Mang, MMI, Encoding, Streamer); ++} +Index: lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp +=================================================================== +--- lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp ++++ lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp +@@ -12,7 +12,9 @@ + //===----------------------------------------------------------------------===// + + #include "SparcMCAsmInfo.h" ++#include "SparcMCExpr.h" + #include "llvm/ADT/Triple.h" ++#include "llvm/MC/MCStreamer.h" + + using namespace llvm; + +@@ -44,4 +46,15 @@ SparcELFMCAsmInfo::SparcELFMCAsmInfo(StringRef TT) + PrivateGlobalPrefix = ".L"; + } + ++const MCExpr* ++SparcELFMCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym, ++ unsigned Encoding, ++ MCStreamer &Streamer) const { ++ if (Encoding & dwarf::DW_EH_PE_pcrel) { ++ MCContext &Ctx = Streamer.getContext(); ++ return SparcMCExpr::Create(SparcMCExpr::VK_Sparc_R_DISP32, ++ MCSymbolRefExpr::Create(Sym, Ctx), Ctx); ++ } + ++ return MCAsmInfo::getExprForPersonalitySymbol(Sym, Encoding, Streamer); ++} +Index: lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp +=================================================================== +--- lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp ++++ lib/Target/Sparc/MCTargetDesc/SparcMCExpr.cpp +@@ -41,6 +41,7 @@ void SparcMCExpr::PrintImpl(raw_ostream &OS) const + case VK_Sparc_L44: OS << "%l44("; break; + case VK_Sparc_HH: OS << "%hh("; break; + case VK_Sparc_HM: OS << "%hm("; break; ++ case VK_Sparc_R_DISP32: OS << "%r_disp32("; break; + case VK_Sparc_TLS_GD_HI22: OS << "%tgd_hi22("; break; + case VK_Sparc_TLS_GD_LO10: OS << "%tgd_lo10("; break; + case VK_Sparc_TLS_GD_ADD: OS << "%tgd_add("; break; +@@ -77,6 +78,7 @@ SparcMCExpr::VariantKind SparcMCExpr::parseVariant + .Case("l44", VK_Sparc_L44) + .Case("hh", VK_Sparc_HH) + .Case("hm", VK_Sparc_HM) ++ .Case("r_disp32", VK_Sparc_R_DISP32) + .Case("tgd_hi22", VK_Sparc_TLS_GD_HI22) + .Case("tgd_lo10", VK_Sparc_TLS_GD_LO10) + .Case("tgd_add", VK_Sparc_TLS_GD_ADD) +@@ -101,6 +103,8 @@ SparcMCExpr::VariantKind SparcMCExpr::parseVariant + bool + SparcMCExpr::EvaluateAsRelocatableImpl(MCValue &Res, + const MCAsmLayout *Layout) const { ++ if (!Layout) ++ return false; + return getSubExpr()->EvaluateAsRelocatable(Res, *Layout); + } + +Index: lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.h +=================================================================== +--- lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.h ++++ lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.h +@@ -17,13 +17,16 @@ + #include "llvm/MC/MCAsmInfoELF.h" + + namespace llvm { +- class StringRef; ++class StringRef; + +- class SparcELFMCAsmInfo : public MCAsmInfoELF { +- virtual void anchor(); +- public: +- explicit SparcELFMCAsmInfo(StringRef TT); +- }; ++class SparcELFMCAsmInfo : public MCAsmInfoELF { ++ virtual void anchor(); ++public: ++ explicit SparcELFMCAsmInfo(StringRef TT); ++ virtual const MCExpr* getExprForPersonalitySymbol(const MCSymbol *Sym, ++ unsigned Encoding, ++ MCStreamer &Streamer) const; ++}; + + } // namespace llvm + +Index: lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h +=================================================================== +--- lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h ++++ lib/Target/Sparc/MCTargetDesc/SparcMCExpr.h +@@ -31,6 +31,7 @@ class SparcMCExpr : public MCTargetExpr { + VK_Sparc_L44, + VK_Sparc_HH, + VK_Sparc_HM, ++ VK_Sparc_R_DISP32, + VK_Sparc_TLS_GD_HI22, + VK_Sparc_TLS_GD_LO10, + VK_Sparc_TLS_GD_ADD, +Index: lib/Target/Sparc/CMakeLists.txt +=================================================================== +--- lib/Target/Sparc/CMakeLists.txt ++++ lib/Target/Sparc/CMakeLists.txt +@@ -27,6 +27,7 @@ add_llvm_target(SparcCodeGen + SparcJITInfo.cpp + SparcCodeEmitter.cpp + SparcMCInstLower.cpp ++ SparcTargetObjectFile.cpp + ) + + add_dependencies(LLVMSparcCodeGen SparcCommonTableGen intrinsics_gen) +Index: test/CodeGen/SPARC/exception.ll +=================================================================== +--- test/CodeGen/SPARC/exception.ll ++++ test/CodeGen/SPARC/exception.ll +@@ -1,7 +1,9 @@ + ; RUN: llc < %s -march=sparc -relocation-model=static | FileCheck -check-prefix=V8ABS %s + ; RUN: llc < %s -march=sparc -relocation-model=pic | FileCheck -check-prefix=V8PIC %s ++; RUN: llc < %s -march=sparc -relocation-model=pic -disable-cfi | FileCheck -check-prefix=V8PIC_NOCFI %s + ; RUN: llc < %s -march=sparcv9 -relocation-model=static | FileCheck -check-prefix=V9ABS %s + ; RUN: llc < %s -march=sparcv9 -relocation-model=pic | FileCheck -check-prefix=V9PIC %s ++; RUN: llc < %s -march=sparcv9 -relocation-model=pic -disable-cfi | FileCheck -check-prefix=V9PIC_NOCFI %s + + + %struct.__fundamental_type_info_pseudo = type { %struct.__type_info_pseudo } +@@ -40,11 +42,23 @@ + ; V8PIC: .cfi_register 15, 31 + ; V8PIC: .section .gcc_except_table + ; V8PIC-NOT: .section +-; V8PIC: .word .L_ZTIi.DW.stub- ++; V8PIC: .word %r_disp32(.L_ZTIi.DW.stub) + ; V8PIC: .data + ; V8PIC: .L_ZTIi.DW.stub: + ; V8PIC-NEXT: .word _ZTIi + ++; V8PIC_NOCFI-LABEL: main: ++; V8PIC_NOCFI: .section .gcc_except_table ++; V8PIC_NOCFI-NOT: .section ++; V8PIC_NOCFI: .word %r_disp32(.L_ZTIi.DW.stub) ++; V8PIC_NOCFI: .data ++; V8PIC_NOCFI: .L_ZTIi.DW.stub: ++; V8PIC_NOCFI-NEXT: .word _ZTIi ++; V8PIC_NOCFI: .section .eh_frame ++; V8PIC_NOCFI-NOT: .section ++; V8PIC_NOCFI: .word %r_disp32(DW.ref.__gxx_personality_v0) ++ ++ + ; V9ABS-LABEL: main: + ; V9ABS: .cfi_startproc + ; V9ABS: .cfi_personality 0, __gxx_personality_v0 +@@ -65,11 +79,22 @@ + ; V9PIC: .cfi_register 15, 31 + ; V9PIC: .section .gcc_except_table + ; V9PIC-NOT: .section +-; V9PIC: .word .L_ZTIi.DW.stub- ++; V9PIC: .word %r_disp32(.L_ZTIi.DW.stub) + ; V9PIC: .data + ; V9PIC: .L_ZTIi.DW.stub: + ; V9PIC-NEXT: .xword _ZTIi + ++; V9PIC_NOCFI-LABEL: main: ++; V9PIC_NOCFI: .section .gcc_except_table ++; V9PIC_NOCFI-NOT: .section ++; V9PIC_NOCFI: .word %r_disp32(.L_ZTIi.DW.stub) ++; V9PIC_NOCFI: .data ++; V9PIC_NOCFI: .L_ZTIi.DW.stub: ++; V9PIC_NOCFI-NEXT: .xword _ZTIi ++; V9PIC_NOCFI: .section .eh_frame ++; V9PIC_NOCFI-NOT: .section ++; V9PIC_NOCFI: .word %r_disp32(DW.ref.__gxx_personality_v0) ++ + define i32 @main(i32 %argc, i8** nocapture readnone %argv) unnamed_addr #0 { + entry: + %0 = icmp eq i32 %argc, 2 |