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

omar ahmed via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 28 11:51:23 PST 2020


omarahmed added a comment.

I tried to use loopInfo on the algorithm but it has much problems , I have came with 2 approaches :
the first is that if we found a cycle we add the BB in the cycle in a allCyclesBBs vector and after we return from containCycleUtil with all the BBs that makes cycles then loop on the allCyclesBBs vector in the containsCycle function and get the information of the loop with getloopfor as we was doing or ask this inside the containCycleUtil and make this function return us if there was a cycle with no maxTripCount
the second is that we do this dfs in a stack style and if we find a cycle we ask for loop info and do the same checks as before like maxtripCount
I don't know which of them is better ?

also the algorithm sometimes in cases moves on BBs 2 times like this case here :

  define i32* @external_sink_ret2_nrw(i32* %n0, i32* %r0, i32* %w0) {
  entry:
    %tobool = icmp ne i32* %n0, null
    br i1 %tobool, label %if.end, label %if.then
  
  if.then:                                          ; preds = %entry
    %tobool2 = icmp ne i32* %n0, null
    br i1 %tobool2, label %return, label %if.end
  
  if.end:                                           ; preds = %entry
    br label %return
  
  return:                                           ; preds = %if.end, %if.then
    ret i32* %w0
  }

so I think if we keep not only the visiting time but the start time = visitingTime and finish time of each node we have visited then we can detect a cycle if we reach a node with no finishTime that means that this node we have visited but not returned from it to make it finish , so this makes the complexity in all the situations O( N+E )

another question Is it normal to make global variables as I have not found any in the code ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74691





More information about the llvm-commits mailing list