aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugVariables.cpp
diff options
context:
space:
mode:
authorMax Kazantsev <mkazantsev@azul.com>2021-01-29 12:08:34 +0700
committerMax Kazantsev <mkazantsev@azul.com>2021-01-29 12:08:34 +0700
commit8a4ad8849f4898dd19e31b9dcede7ace3575d00d (patch)
tree19b20ac7c9938511f6d13aa83847e4724b0acfc7 /llvm/lib/CodeGen/LiveDebugVariables.cpp
parent892e4567e1357ee10ef67ee6dfbe45aeded9d2dc (diff)
downloadllvm-8a4ad8849f4898dd19e31b9dcede7ace3575d00d.zip
llvm-8a4ad8849f4898dd19e31b9dcede7ace3575d00d.tar.gz
llvm-8a4ad8849f4898dd19e31b9dcede7ace3575d00d.tar.bz2
[SCEV] Do not cache comparison result upon reached max depth as "equivalence". PR48725
We use `EquivalenceClasses` to cache the notion that two SCEVs are equivalent, so save time in situation when `A` is equivalent to `B` and `B` is equivalent to `C`, making check "if `A` is equivalent to `C`?" cheaper. We also return `0` in the comparator when we reach max analysis depth to save compile time. After doing this, we also cache them as being equivalent. Now, imagine the following situation: - `A` is proved equivalent to `B`; - `C` is proved equivalent to `D`; - Comparison of `A` against `D` is proved non-zero; - Comparison of `B` against `C` reaches max depth (and gets cached as equivalence). Now, before the invocation of compare(`B`, `C`), `A` and `D` belonged to different equivalence classes, and their comparison returned non-zero. After the the invocation of compare(`B`, `C`), equivalence classes get merged and `A`, `B`, `C` and `D` all fall into the same equivalence class. So the comparator will change its behavior for couple `A` and `D`, with weird consequences following it. This comparator is finally used in `std::stable_sort`, and this behavior change makes it crash (looks like it's causing a memory corruption). Solution: this patch changes `CompareSCEVComplexity` to return `None` when the max depth is reached. So in this case, we do not cache these SCEVs (and their parents in the tree) as being equivalent. Differential Revision: https://reviews.llvm.org/D94654 Reviewed By: lebedev.ri
Diffstat (limited to 'llvm/lib/CodeGen/LiveDebugVariables.cpp')
0 files changed, 0 insertions, 0 deletions