[PATCH] D63046: [Attributor] Deduce "willreturn" function attribute

Hideto Ueno via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 9 21:57:10 PDT 2019


uenoku added a comment.

In D63046#1535804 <https://reviews.llvm.org/D63046#1535804>, @nicholas wrote:

> > The current algorithm can deduce only for very simple cases.
> > 
> > - A function doesn't have any loop.
> > - A function doesn't have any recursion.
>
> What about functions that exit the program, throw an exception, or longjmp?




- longjump shouldn't be "willreturn" but I've found that the current implementation might deduce "willreturn" (llvm.eh.sjlj.longjmp is intrinsic but it has noreturn).

I'll fix it to check norecurse.



================
Comment at: llvm/lib/Transforms/IPO/Attributor.cpp:1109
+
+// Helper function that checks whether a function has any loop.
+bool containsLoop(Function &F) {
----------------
nicholas wrote:
> Loop is commonly assumed to mean "natural loop", where there is one block (the header) which dominates the other blocks in the loop (the loop body). What you're looking for here is a more general thing called a cycle (equivalent to looking for a backedge). That also explains why you need your own function and can't reuse LoopInfo.
> Loop is commonly assumed to mean "natural loop", where there is one block (the header) which dominates the other blocks in the loop (the loop body). What you're looking for here is a more general thing called a cycle (equivalent to looking for a backedge).

OK, I rename it.

> That also explains why you need your own function and can't reuse LoopInfo.

LoopInfo doesn't contain an irreducible loop (maybe endless loop) so I check the cycle manually for now.
I'm going to use LoopInfo to check (i) whether a function has an irreducible loop and (ii) whether all loops are guaranteed to terminate.




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

https://reviews.llvm.org/D63046





More information about the llvm-commits mailing list