[PATCH] D42442: [ValueTracking] add an assert to prevent infinite recursion

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 14:54:34 PST 2018


spatel created this revision.
spatel added reviewers: davide, efriedma, anna.
Herald added a subscriber: mcrosier.

We're getting bug reports:
https://bugs.llvm.org/show_bug.cgi?id=35807
https://bugs.llvm.org/show_bug.cgi?id=35840
https://bugs.llvm.org/show_bug.cgi?id=36045
...where we blow up the stack in value tracking because other passes are sending in selects that have an operand that is itself the select.

As I understand it, we want to uncover these bugs in passes that use value tracking because it signals a potential efficiency improvement for them when dealing with dead code or other corner cases.

Therefore, we are not planning to bail out in value tracking for this situation, but at least we can assert immediately, so we'll get a better backtrace in future bug reports. Note that the immediate effect of this assert will be that we are even more likely to get bug reports because the assert precedes other bailouts while matching select patterns.


https://reviews.llvm.org/D42442

Files:
  lib/Analysis/ValueTracking.cpp


Index: lib/Analysis/ValueTracking.cpp
===================================================================
--- lib/Analysis/ValueTracking.cpp
+++ lib/Analysis/ValueTracking.cpp
@@ -4581,6 +4581,9 @@
   Value *CmpRHS = CmpI->getOperand(1);
   Value *TrueVal = SI->getTrueValue();
   Value *FalseVal = SI->getFalseValue();
+  assert(SI != TrueVal && SI != FalseVal &&
+         "Trying to match select pattern for select that refers to itself");
+
   FastMathFlags FMF;
   if (isa<FPMathOperator>(CmpI))
     FMF = CmpI->getFastMathFlags();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42442.131144.patch
Type: text/x-patch
Size: 538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180123/61cf67a9/attachment.bin>


More information about the llvm-commits mailing list