Hi,<br><br>Yes. Yes it would. That's a good idea and in fact we only ever need to visit any single OR once and once only. We can use a simple set to track this. <br><br>I don't think we even need any other limit - this would limit the number of function invocations to O(bitwidth) as after that many ORs we're guaranteed to hit a bailout. <br><br>James<br><div class="gmail_quote"><div dir="ltr">On Mon, 4 Jan 2016 at 19:48, Joerg Sonnenberger via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jan 04, 2016 at 05:39:27PM +0000, James Molloy via llvm-commits wrote:<br>
> jmolloy created this revision.<br>
> jmolloy added a reviewer: joerg.<br>
> jmolloy added a subscriber: llvm-commits.<br>
> jmolloy set the repository for this revision to rL LLVM.<br>
><br>
> It is possible to create an IR pattern that results in exponential execution<br>
> time in CollectBitParts, by making a tree where every OR refers to one other OR via *both*<br>
> operands:<br>
><br>
>   for (i = 0; i < N; ++i)<br>
>       b |= b >> 1;  // Causes 2^N executions of CollectBitParts!<br>
><br>
> To defend against this (and because ORs are the only node that cause us to<br>
> fork control flow) we keep a counter alive between all invocations of<br>
> CollectBitParts, expected to be initialized to bitwidth(b).<br>
<br>
Can we memoise the expression tree instead we have already processed<br>
instead / additionally? Some form of limit for CPU time / memory use<br>
would still be needed, but that would cut the problem down as well,<br>
wouldn't it?<br>
<br>
Joerg<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>