[PATCH] D74691: [Attributor] Detect possibly unbounded cycles in functions

omar ahmed via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 22:58:24 PST 2020


omarahmed updated this revision to Diff 248395.
omarahmed added a comment.

[Attributor]Detect possibly unbounded cycles in functions

This patch changes the approach of containsCycle function of looping on
the CFG by depth_first to another approach as the depth_first function approach detects if-then-else part in
functions as a loop and that result in wrong behaviour, so the new approach detects cycles by using a recursive function that dfs on the CFG from the entry block and detects a cycle when we go in a recursive calls chain and visit one of the nodes of the chain.
This new approach also saves the processed nodes so not compute them two times thus enhancing the complexity of the algorithm to be O(N+E).
The approach also doesn't visit statically unreachable blocks so that also enhances the complexity.
This patch also uses maxTripCount to detect if a function has a cycle,then we check
further whether the cycle is a bounded loop cycle.
Loops with maximum trip count are considered bounded, any other cycle not.
It also contains some fixed tests and some added tests contain bounded and
unbounded loops.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74691/new/

https://reviews.llvm.org/D74691

Files:
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/test/Transforms/Attributor/read_write_returned_arguments_scc.ll
  llvm/test/Transforms/Attributor/willreturn.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74691.248395.patch
Type: text/x-patch
Size: 16240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200305/c44f55be/attachment-0001.bin>


More information about the llvm-commits mailing list