diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2023-01-04 18:29:39 -0800 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2023-01-04 21:29:42 -0800 |
commit | 665e47777df17db406c698d57b4f3c28d67c432e (patch) | |
tree | eea7bc2a83321d597cfdcd7e83b72aa16677f274 /llvm/lib | |
parent | 87b2c760d0183246c27f9e1c34e1e1120e03449b (diff) | |
download | llvm-665e47777df17db406c698d57b4f3c28d67c432e.zip llvm-665e47777df17db406c698d57b4f3c28d67c432e.tar.gz llvm-665e47777df17db406c698d57b4f3c28d67c432e.tar.bz2 |
[ObjC][ARC] Fix non-deterministic behavior in ProvenanceAnalysis
If the second value passed to relatedSelect is a select, check whether
neither arm of the select is related to the first value.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp b/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp index 845038b..2fa25a7 100644 --- a/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp +++ b/llvm/lib/Transforms/ObjCARC/ProvenanceAnalysis.cpp @@ -42,11 +42,17 @@ bool ProvenanceAnalysis::relatedSelect(const SelectInst *A, const Value *B) { // If the values are Selects with the same condition, we can do a more precise // check: just check for relations between the values on corresponding arms. - if (const SelectInst *SB = dyn_cast<SelectInst>(B)) + if (const SelectInst *SB = dyn_cast<SelectInst>(B)) { if (A->getCondition() == SB->getCondition()) return related(A->getTrueValue(), SB->getTrueValue()) || related(A->getFalseValue(), SB->getFalseValue()); + // Check both arms of B individually. Return false if neither arm is related + // to A. + if (!(related(SB->getTrueValue(), A) || related(SB->getFalseValue(), A))) + return false; + } + // Check both arms of the Select node individually. return related(A->getTrueValue(), B) || related(A->getFalseValue(), B); } |