New user self-registration is disabled due to spam. For an account please email bugs-admin@lists.llvm.org with your e-mail address and full name.

Bug 36105 - Infinite loop in -callsite-splitting
Summary: Infinite loop in -callsite-splitting
Status: RESOLVED FIXED
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: unspecified
Hardware: PC Linux
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-26 01:11 PST by Mikael Holmén
Modified: 2018-01-26 05:35 PST (History)
3 users (show)

See Also:
Fixed By Commit(s): rL323515


Attachments
reproducer (550 bytes, text/plain)
2018-01-26 01:11 PST, Mikael Holmén
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikael Holmén 2018-01-26 01:11:00 PST
Created attachment 19755 [details]
reproducer

Running

 opt -S -o - foo.ll -callsite-splitting

we get stuck and loop forever in function recordConditions in CallSitesplitting.cpp:

/// Record ICmp conditions relevant to any argument in CS following Pred's
/// single successors. If there are conflicting conditions along a path, like
/// x == 1 and x == 0, the first condition will be used.
static void recordConditions(CallSite CS, BasicBlock *Pred,
                             ConditionsTy &Conditions) {
  recordCondition(CS, Pred, CS.getInstruction()->getParent(), Conditions);
  BasicBlock *From = Pred;
  BasicBlock *To = Pred;
  SmallPtrSet<BasicBlock *, 4> Visited = {From};
  while (!Visited.count(From->getSinglePredecessor()) &&
         (From = From->getSinglePredecessor())) {
    recordCondition(CS, From, To, Conditions);
    To = From;
  }
}

It looks suspicious to me that Visited isn't updated in the loop.
Comment 1 Florian Hahn 2018-01-26 02:38:47 PST
Thanks, I've updated the code to properly track the visited nodes https://reviews.llvm.org/rL323515
Comment 2 Mikael Holmén 2018-01-26 03:26:03 PST
(In reply to Florian Hahn from comment #1)
> Thanks, I've updated the code to properly track the visited nodes
> https://reviews.llvm.org/rL323515

Thanks!
Comment 3 Florian Hahn 2018-01-26 03:27:18 PST
I think we should try to get this in the release branch too. I would like to wait till tomorrow with that though, so Jun can have a look before that.
Comment 4 Jun Bum Lim 2018-01-26 05:35:24 PST
The fix looks good to me. 
Thanks Florian.