llvm-project/llvm/lib
Max Kazantsev b09b5db793 [SCEV] Fix sorting order for AddRecExprs
The existing sorting order in defined CompareSCEVComplexity sorts AddRecExprs
by loop depth, but does not pay attention to dominance of loops. This can
lead us to the following buggy situation:

for (...) { // loop1
  op1 = {A,+,B}
}
for (...) { // loop2
  op2 = {A,+,B}
  S = add op1, op2
}

In this case there is no guarantee that in operand list of S the op2 comes
before op1 (loop depth is the same, so they will be sorted just
lexicographically), so we can incorrectly treat S as a recurrence of loop1,
which is wrong.

This patch changes the sorting logic so that it places the dominated recs
before the dominating recs. This ensures that when we pick the first recurrency
in the operands order, it will be the bottom-most in terms of domination tree.
The attached test set includes some tests that produce incorrect SCEV
estimations and crashes with oldlogic.

Reviewers: sanjoy, reames, apilipenko, anna

Reviewed By: sanjoy

Subscribers: llvm-commits, mzolotukhin

Differential Revision: https://reviews.llvm.org/D33121

llvm-svn: 303148
2017-05-16 07:27:06 +00:00
..
Analysis [SCEV] Fix sorting order for AddRecExprs 2017-05-16 07:27:06 +00:00
AsmParser [IR] Allow attributes with global variables 2017-05-11 12:28:08 +00:00
Bitcode Remove ignore-empty-index-file option 2017-05-12 19:32:11 +00:00
CodeGen IR: Give function GlobalValue::getRealLinkageName() a less misleading name: dropLLVMManglingEscape(). 2017-05-16 00:39:01 +00:00
DebugInfo [DWARF] - Speedup handling of relocations in DWARFContextInMemory. 2017-05-15 11:45:28 +00:00
Demangle Add support for demangling C++11 thread_local variables. 2017-01-31 15:56:36 +00:00
ExecutionEngine [ExecutionEngine] Make RuntimeDyld::MemoryManager responsible for tracking EH 2017-05-09 21:32:18 +00:00
Fuzzer [libFuzzer] fix tests on Windows 2017-05-15 22:55:00 +00:00
IR IR: Give function GlobalValue::getRealLinkageName() a less misleading name: dropLLVMManglingEscape(). 2017-05-16 00:39:01 +00:00
IRReader Timer: Track name and description. 2016-11-18 19:43:18 +00:00
LTO IR: Give function GlobalValue::getRealLinkageName() a less misleading name: dropLLVMManglingEscape(). 2017-05-16 00:39:01 +00:00
LineEditor
Linker De-virtualize GlobalValue 2017-05-11 21:14:29 +00:00
MC MCObjectStreamer : fail with a diagnostic when emitting an out of range value. 2017-05-15 08:43:27 +00:00
Object [COFF] Gracefully handle empty .drectve sections 2017-05-14 18:34:56 +00:00
ObjectYAML [WebAssembly] Fix build error in wasm YAML code 2017-05-10 00:14:04 +00:00
Option ArgList: cache index ranges containing arguments with each ID 2017-04-12 23:19:51 +00:00
Passes [PM] Add ProfileSummaryAnalysis as a required pass in the new pipeline. 2017-05-04 16:58:45 +00:00
ProfileData Change sample profile writer to make it deterministic. 2017-05-11 23:43:44 +00:00
Support [APInt] Simplify a for loop initialization based on the fact that 'n' is known to be 1 by an earlier 'if'. 2017-05-15 22:01:03 +00:00
TableGen Use print() instead of dump() in code 2017-01-28 02:47:46 +00:00
Target AMDGPUCodeGen: Fix warnings in r303111. [-Wunused-variable] 2017-05-16 04:01:23 +00:00
ToolDrivers Add missing files 2017-05-13 22:10:13 +00:00
Transforms [CorrelatedValuePropagation] Don't use -> to call a static method of ConstantRange. NFC 2017-05-16 07:05:38 +00:00
XRay [XRay][lib] Support and temporarily skip over CustomEvent records 2017-05-12 01:06:41 +00:00
CMakeLists.txt Move lib/LibDriver -> lib/ToolDrivers/llvm-lib. NFCI. 2017-05-13 22:06:46 +00:00
LLVMBuild.txt Move lib/LibDriver -> lib/ToolDrivers/llvm-lib. NFCI. 2017-05-13 22:06:46 +00:00