[PATCH] D15857: [InstCombine] Defend against worst-case exponential execution time

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 4 09:39:27 PST 2016


jmolloy created this revision.
jmolloy added a reviewer: joerg.
jmolloy added a subscriber: llvm-commits.
jmolloy set the repository for this revision to rL LLVM.

It is possible to create an IR pattern that results in exponential execution
time in CollectBitParts, by making a tree where every OR refers to one other OR via *both*
operands:

  for (i = 0; i < N; ++i)
      b |= b >> 1;  // Causes 2^N executions of CollectBitParts!

To defend against this (and because ORs are the only node that cause us to
fork control flow) we keep a counter alive between all invocations of
CollectBitParts, expected to be initialized to bitwidth(b).

Repository:
  rL LLVM

http://reviews.llvm.org/D15857

Files:
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  test/Transforms/InstCombine/bitreverse-hang.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15857.43894.patch
Type: text/x-patch
Size: 5682 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160104/99c6fcc2/attachment.bin>


More information about the llvm-commits mailing list