diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-27 18:03:57 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-07-27 18:03:57 +0000 |
commit | 75564e35147dd6e36b864946298b6a35417bb9e6 (patch) | |
tree | 7dcc5a04ba801ed7c9350851541a1e7b1b6d324b /lib/Transforms | |
parent | 2e319870f17a090e47540e2a821eac33c495bf59 (diff) | |
download | external_llvm-75564e35147dd6e36b864946298b6a35417bb9e6.zip external_llvm-75564e35147dd6e36b864946298b6a35417bb9e6.tar.gz external_llvm-75564e35147dd6e36b864946298b6a35417bb9e6.tar.bz2 |
fix infinite loop in instcombine in the presence of a (malformed) self-referencing select inst.
This can happen as long as the instruction is not reachable. Instcombine does generate these unreachable malformed selects when doing RAUW
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineSelect.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineSelect.cpp b/lib/Transforms/InstCombine/InstCombineSelect.cpp index bdd97a8..291e800 100644 --- a/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -881,12 +881,16 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) { if (SelectInst *TrueSI = dyn_cast<SelectInst>(TrueVal)) { if (TrueSI->getCondition() == CondVal) { + if (SI.getTrueValue() == TrueSI->getTrueValue()) + return 0; SI.setOperand(1, TrueSI->getTrueValue()); return &SI; } } if (SelectInst *FalseSI = dyn_cast<SelectInst>(FalseVal)) { if (FalseSI->getCondition() == CondVal) { + if (SI.getFalseValue() == FalseSI->getFalseValue()) + return 0; SI.setOperand(2, FalseSI->getFalseValue()); return &SI; } |