summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-06-21 15:17:24 +0000
committerSanjay Patel <spatel@rotateright.com>2019-06-21 15:17:24 +0000
commitddb9093684062b6552b338ff754c674e79a55826 (patch)
treefacb10df7bf9ef0e646e987b6e6b5ced7aacfed5 /llvm/lib/Transforms
parente0eb66bbff5e4307c54e4f5c52e711b4b1b05126 (diff)
downloadbcm5719-llvm-ddb9093684062b6552b338ff754c674e79a55826.tar.gz
bcm5719-llvm-ddb9093684062b6552b338ff754c674e79a55826.zip
[GVNSink] prevent crashing on mismatched instructions (PR42346)
Patch based on suggestion by James Molloy (@jmolloy) in: https://bugs.llvm.org/show_bug.cgi?id=42346 llvm-svn: 364062
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/GVNSink.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index bf5ec47fbbb..735f68329af 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -713,6 +713,15 @@ Optional<SinkingInstructionCandidate> GVNSink::analyzeInstructionForSinking(
// FIXME: If any of these fail, we should partition up the candidates to
// try and continue making progress.
Instruction *I0 = NewInsts[0];
+
+ // If all instructions that are going to participate don't have the same
+ // number of operands, we can't do any useful PHI analysis for all operands.
+ auto hasDifferentNumOperands = [&I0](Instruction *I) {
+ return I->getNumOperands() != I0->getNumOperands();
+ };
+ if (any_of(NewInsts, hasDifferentNumOperands))
+ return None;
+
for (unsigned OpNum = 0, E = I0->getNumOperands(); OpNum != E; ++OpNum) {
ModelledPHI PHI(NewInsts, OpNum, ActivePreds);
if (PHI.areAllIncomingValuesSame())
OpenPOWER on IntegriCloud