aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/VectorUtils.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2020-12-02 13:35:05 -0500
committerSanjay Patel <spatel@rotateright.com>2020-12-02 13:39:33 -0500
commit9d6d24c25056c17db56cf1ef5124f82eb18afc2c (patch)
treedd0928d067a3aebb5da189d69988b4a2b1b11beb /llvm/lib/Analysis/VectorUtils.cpp
parent1f525ece4abfb6077d73e34acac0666855d19052 (diff)
downloadllvm-9d6d24c25056c17db56cf1ef5124f82eb18afc2c.zip
llvm-9d6d24c25056c17db56cf1ef5124f82eb18afc2c.tar.gz
llvm-9d6d24c25056c17db56cf1ef5124f82eb18afc2c.tar.bz2
[JumpThreading][VectorUtils] avoid infinite loop on unreachable IR
https://llvm.org/PR48362 It's possible that we could stub this out sooner somewhere within JumpThreading, but I'm not sure how to do that, and then we would still have potential danger in other callers. I can't find a way to trigger this using 'instsimplify', however, because that already has a bailout on unreachable blocks.
Diffstat (limited to 'llvm/lib/Analysis/VectorUtils.cpp')
-rw-r--r--llvm/lib/Analysis/VectorUtils.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp
index bd69055..9072697 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -290,6 +290,10 @@ Value *llvm::findScalarElement(Value *V, unsigned EltNo) {
if (EltNo == IIElt)
return III->getOperand(1);
+ // Guard against infinite loop on malformed, unreachable IR.
+ if (III == III->getOperand(0))
+ return nullptr;
+
// Otherwise, the insertelement doesn't modify the value, recurse on its
// vector input.
return findScalarElement(III->getOperand(0), EltNo);