freebsd-skq/contrib/llvm/lib/Target
dim bd32a5b2ac Pull in r219009 from upstream llvm trunk (by Adam Nemet):
[ISel] Keep matching state consistent when folding during X86 address match

  In the X86 backend, matching an address is initiated by the 'addr' complex
  pattern and its friends.  During this process we may reassociate and-of-shift
  into shift-of-and (FoldMaskedShiftToScaledMask) to allow folding of the
  shift into the scale of the address.

  However as demonstrated by the testcase, this can trigger CSE of not only the
  shift and the AND which the code is prepared for but also the underlying load
  node.  In the testcase this node is sitting in the RecordedNode and MatchScope
  data structures of the matcher and becomes a deleted node upon CSE.  Returning
  from the complex pattern function, we try to access it again hitting an assert
  because the node is no longer a load even though this was checked before.

  Now obviously changing the DAG this late is bending the rules but I think it
  makes sense somewhat.  Outside of addresses we prefer and-of-shift because it
  may lead to smaller immediates (FoldMaskAndShiftToScale is an even better
  example because it create a non-canonical node).  We currently don't recognize
  addresses during DAGCombiner where arguably this canonicalization should be
  performed.  On the other hand, having this in the matcher allows us to cover
  all the cases where an address can be used in an instruction.

  I've also talked a little bit to Dan Gohman on llvm-dev who added the RAUW for
  the new shift node in FoldMaskedShiftToScaledMask.  This RAUW is responsible
  for initiating the recursive CSE on users
  (http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-September/076903.html) but it
  is not strictly necessary since the shift is hooked into the visited user.  Of
  course it's safer to keep the DAG consistent at all times (e.g. for accurate
  number of uses, etc.).

  So rather than changing the fundamentals, I've decided to continue along the
  previous patches and detect the CSE.  This patch installs a very targeted
  DAGUpdateListener for the duration of a complex-pattern match and updates the
  matching state accordingly.  (Previous patches used HandleSDNode to detect the
  CSE but that's not practical here).  The listener is only installed on X86.

  I tested that there is no measurable overhead due to this while running
  through the spec2k BC files with llc.  The only thing we pay for is the
  creation of the listener.  The callback never ever triggers in spec2k since
  this is a corner case.

  Fixes rdar://problem/18206171

This fixes a possible crash in x86 code generation when compiling recent
llvm/clang trunk sources.

Direct commit to stable/10, since head already has llvm/clang 3.6.1,
which includes this fix.

Reported by:	jonathan, theraven
Upstream PR:	https://llvm.org/bugs/show_bug.cgi?id=24249
2015-07-29 12:59:16 +00:00
..
AArch64 MFC r265925: 2014-05-26 20:45:44 +00:00
ARM MFC r271025, r271029, r271030 (by sbruno): 2015-02-13 21:19:02 +00:00
CppBackend MFC 261991: 2014-03-21 17:53:59 +00:00
Hexagon MFC 261991: 2014-03-21 17:53:59 +00:00
Mips MFC 261991: 2014-03-21 17:53:59 +00:00
MSP430 MFC 261991: 2014-03-21 17:53:59 +00:00
NVPTX MFC 261991: 2014-03-21 17:53:59 +00:00
PowerPC MFC r267981: 2014-06-30 20:26:30 +00:00
R600 MFC r265925: 2014-05-26 20:45:44 +00:00
Sparc MFC r262613: 2014-03-26 07:31:57 +00:00
SystemZ MFC 261991: 2014-03-21 17:53:59 +00:00
X86 Pull in r219009 from upstream llvm trunk (by Adam Nemet): 2015-07-29 12:59:16 +00:00
XCore MFC 261991: 2014-03-21 17:53:59 +00:00
Mangler.cpp MFC 261991: 2014-03-21 17:53:59 +00:00
Target.cpp MFC 261991: 2014-03-21 17:53:59 +00:00
TargetIntrinsicInfo.cpp Upgrade our copy of llvm/clang to trunk r178860, in preparation of the 2013-04-12 17:57:40 +00:00
TargetJITInfo.cpp Upgrade our copy of llvm/clang to trunk r154661, in preparation of the 2012-04-16 21:23:25 +00:00
TargetLibraryInfo.cpp MFC 261991: 2014-03-21 17:53:59 +00:00
TargetLoweringObjectFile.cpp MFC 261991: 2014-03-21 17:53:59 +00:00
TargetMachine.cpp MFC 261991: 2014-03-21 17:53:59 +00:00
TargetMachineC.cpp MFC 261991: 2014-03-21 17:53:59 +00:00
TargetSubtargetInfo.cpp MFC 261991: 2014-03-21 17:53:59 +00:00