1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-24 13:33:37 +02:00
llvm-mirror/lib
Chandler Carruth 090cb1bc30 [x86] Start fixing a really subtle and terrible form of miscompile in
these DAG combines.

The DAG auto-CSE thing is truly terrible. Due to it, when RAUW-ing
a node with its operand, you can cause its uses to CSE to itself, which
then causes their uses to become your uses which causes them to be
picked up by the RAUW. For nodes that are determined to be "no-ops",
this is "fine". But if the RAUW is one of several steps to enact
a transformation, this causes the DAG to really silently eat an discard
nodes that you would never expect. It took days for me to actually
pinpoint a test case triggering this and a really frustrating amount of
time to even comprehend the bug because I never even thought about the
ability of RAUW to iteratively consume nodes due to CSE-ing them into
itself.

To fix this, we have to build up a brand-new chain of operations any
time we are combining across (potentially) intervening nodes. But once
the logic is added to do this, another issue surfaces: CombineTo eagerly
deletes the one node combined, *but no others*. This is... really
frustrating. If deleting it makes its operands become dead, those
operand nodes often won't go onto the worklist in the
order you would want -- they're already on it and not near the top. That
means things higher on the worklist will get combined prior to these
dead nodes being GCed out of the worklist, and if the chain is long, the
immediate users won't be enough to re-detect where the root of the chain
is that became single-use again after deleting the dead nodes. The
better way to do this is to never immediately delete nodes, and instead
to just enqueue them so we can recursively delete them. The
combined-from node is typically not on the worklist anyways by virtue of
having been popped off.... But that in turn breaks other tests that
*require* CombineTo to delete unused nodes. :: sigh ::

Fortunately, there is a better way. This whole routine should have been
returning the replacement rather than using CombineTo which is quite
hacky. Switch to that, and all the pieces fall together.

I suspect the same kind of miscompile is possible in the half-shuffle
folding code, and potentially the recursive folding code. I'll be
switching those over to a pattern more like this one for safety's sake
even though I don't immediately have any test cases for them. Note that
the only way I got a test case for this instance was with *heavily* DAG
combined 256-bit shuffle sequences generated by my fuzzer. ;]

llvm-svn: 216319
2014-08-23 10:25:15 +00:00
..
Analysis ValueTracking: Figure out more bits when looking at add/sub 2014-08-22 00:40:43 +00:00
AsmParser Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr 2014-08-21 20:44:56 +00:00
Bitcode BitcodeReader: Only create one basic block for each blockaddress 2014-08-16 01:54:37 +00:00
CodeGen Revert r215611 because it caused the infinite loop in bug 20736. There is a reduced testcase in that bug. 2014-08-23 00:45:03 +00:00
DebugInfo Don't own the buffer in object::Binary. 2014-08-19 18:44:46 +00:00
ExecutionEngine Remove dead code. NFC. 2014-08-21 18:11:21 +00:00
IR InstCombine: sub nsw %x, C -> add nsw %x, -C if C isn't INT_MIN 2014-08-22 16:41:23 +00:00
IRReader Modernize the .ll parsing interface. 2014-08-19 16:58:54 +00:00
LineEditor
Linker Set comdats when lazily linking functions. 2014-08-15 20:17:08 +00:00
LTO Move some logic to populateLTOPassManager. 2014-08-21 20:03:44 +00:00
MC Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr 2014-08-21 20:44:56 +00:00
Object Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr 2014-08-21 20:44:56 +00:00
Option Fix PR17239 by changing the semantics of the RemainingArgsClass Option kind 2014-08-22 19:29:17 +00:00
ProfileData llvm-cov: add code coverage tool that's based on coverage mapping format and clang's pgo. 2014-08-22 22:56:03 +00:00
Support Fix PR17239 by changing the semantics of the RemainingArgsClass Option kind 2014-08-22 19:29:17 +00:00
TableGen Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr 2014-08-21 20:44:56 +00:00
Target [x86] Start fixing a really subtle and terrible form of miscompile in 2014-08-23 10:25:15 +00:00
Transforms [SROA] Fold a PHI node if all its incoming values are the same 2014-08-22 22:45:57 +00:00
CMakeLists.txt
LLVMBuild.txt
Makefile