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-r262611-llvm-r196874-fix-invalid-pwd-crash.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-r262611-llvm-r196874-fix-invalid-pwd-crash.diff')
-rw-r--r-- | contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff b/contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff new file mode 100644 index 0000000..587693d --- /dev/null +++ b/contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff @@ -0,0 +1,76 @@ +Pull in r196874 from upstream llvm trunk (by Andrew Trick): + + Fix a crash that occurs when PWD is invalid. + + MCJIT needs to be able to run in hostile environments, even when PWD + is invalid. There's no need to crash MCJIT in this case. + + The obvious fix is to simply leave MCContext's CompilationDir empty + when PWD can't be determined. This way, MCJIT clients, + and other clients that link with LLVM don?\226?\128?\153t need a valid working directory. + + If we do want to guarantee valid CompilationDir, that should be done + only for clients of getCompilationDir(). This is as simple as checking + for an empty string. + + The only current use of getCompilationDir is EmitGenDwarfInfo, which + won?\226?\128?\153t conceivably run with an invalid working dir. However, in the + purely hypothetically and untestable case that this happens, the + AT_comp_dir will be omitted from the compilation_unit DIE. + +Introduced here: http://svn.freebsd.org/changeset/base/262611 + +Index: include/llvm/MC/MCContext.h +=================================================================== +--- include/llvm/MC/MCContext.h ++++ include/llvm/MC/MCContext.h +@@ -278,6 +278,7 @@ namespace llvm { + /// This can be overridden by clients which want to control the reported + /// compilation directory and have it be something other than the current + /// working directory. ++ /// Returns an empty string if the current directory cannot be determined. + StringRef getCompilationDir() const { return CompilationDir; } + + /// \brief Set the compilation directory for DW_AT_comp_dir +Index: lib/MC/MCContext.cpp +=================================================================== +--- lib/MC/MCContext.cpp ++++ lib/MC/MCContext.cpp +@@ -47,8 +47,8 @@ MCContext::MCContext(const MCAsmInfo *mai, const M + AllowTemporaryLabels(true), DwarfCompileUnitID(0), AutoReset(DoAutoReset) { + + error_code EC = llvm::sys::fs::current_path(CompilationDir); +- assert(!EC && "Could not determine the current directory"); +- (void)EC; ++ if (EC) ++ CompilationDir.clear(); + + MachOUniquingMap = 0; + ELFUniquingMap = 0; +Index: lib/MC/MCDwarf.cpp +=================================================================== +--- lib/MC/MCDwarf.cpp ++++ lib/MC/MCDwarf.cpp +@@ -467,7 +467,8 @@ static void EmitGenDwarfAbbrev(MCStreamer *MCOS) { + EmitAbbrev(MCOS, dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr); + EmitAbbrev(MCOS, dwarf::DW_AT_high_pc, dwarf::DW_FORM_addr); + EmitAbbrev(MCOS, dwarf::DW_AT_name, dwarf::DW_FORM_string); +- EmitAbbrev(MCOS, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string); ++ if (!context.getCompilationDir().empty()) ++ EmitAbbrev(MCOS, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string); + StringRef DwarfDebugFlags = context.getDwarfDebugFlags(); + if (!DwarfDebugFlags.empty()) + EmitAbbrev(MCOS, dwarf::DW_AT_APPLE_flags, dwarf::DW_FORM_string); +@@ -643,8 +644,10 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS, + MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string. + + // AT_comp_dir, the working directory the assembly was done in. +- MCOS->EmitBytes(context.getCompilationDir()); +- MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string. ++ if (!context.getCompilationDir().empty()) { ++ MCOS->EmitBytes(context.getCompilationDir()); ++ MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string. ++ } + + // AT_APPLE_flags, the command line arguments of the assembler tool. + StringRef DwarfDebugFlags = context.getDwarfDebugFlags(); |