Fix a stack overflow in ScalarEvolution.
authorJohannes Reifferscheid <jreiffers@google.com>
Wed, 3 Aug 2022 05:07:55 +0000 (07:07 +0200)
committerJohannes Reifferscheid <jreiffers@google.com>
Wed, 3 Aug 2022 09:08:01 +0000 (11:08 +0200)
commit7ae5d00afaf39fae78e411cb44f665e1dc52b356
tree02f9035e1d0b79e312df9171f7348993c48a5809
parentf4b9c0735e339b177d98fe69cf210eea00c0af62
Fix a stack overflow in ScalarEvolution.

Unfortunately, this overflow is extremely hard to reproduce reliably (in fact, I was unable to do so). The issue is that:

- getOperandsToCreate sometimes skips creating an SCEV for the LHS
- then, createSCEV is called for the BinaryOp
- ... which calls getNoWrapFlagsFromUB
- ... which under certain circumstances calls isSCEVExprNeverPoison
- ... which under certain circumstances requires the SCEVs of all operands

For certain deep dependency trees, this causes a stack overflow.

Reviewed By: bkramer, fhahn

Differential Revision: https://reviews.llvm.org/D129745
llvm/lib/Analysis/ScalarEvolution.cpp