[llvm-commits] [llvm] r80695 - /llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp

Duncan Sands baldrick at free.fr
Tue Sep 1 12:59:33 PDT 2009


Hi Chris,

> simpler solution to iterator invalidation "problem" found
> by expensive checking.

nice try, I tried it too :)  Sadly, it's not enough to beat the
expensive checking :(

> +    for (CallGraphNode::iterator I = CGN->begin(), E = CGN->end(); I != E; ){
>        // If this call site is null, then the function pass deleted the call
> -      // entirely and the WeakVH nulled it out.
> +      // entirely and the WeakVH nulled it out.  
>        if (I->first == 0 ||
>            // If we've already seen this call site, then the FunctionPass RAUW'd
>            // one call with another, which resulted in two "uses" in the edge
> @@ -168,13 +163,13 @@

Suppose I was the last element.  Then since at this point you just
deleted the last element, I is now a "singular" iterator.

>          E = CGN->end();
>          continue;

Here you do "I != E", comparing a singular iterator with E.  The
expensive checking thinks doing a comparison (or anything else,
such as assignment) with a singular iterator is naughty, and barfs.
Because of this issue you are pretty much forced to check if I+1==E
before doing the deletion, which is the essence of what my patch did.
I don't like my patch either, but there you go.

Ciao,

Duncan.

PS: With your patch applied:

FAIL: /home/duncan/LLVM/llvm.top/llvm/test/Transforms/Inline/crash.ll
Failed with signal(SIGABRT) at line 1
while running:  llvm-as < 
/home/duncan/LLVM/llvm.top/llvm/test/Transforms/Inline/crash.ll |  opt 
-inline -argpromotion -instcombine -disable-output
/usr/include/c++/4.4/debug/safe_iterator.h:460:error: attempt to compare 
a singular iterator to a past-the-end iterator.


FAIL: 
/home/duncan/LLVM/llvm.top/llvm/test/Transforms/LoopIndexSplit/non-iv-cmp-operand.ll 
for PR4471
Failed with signal(SIGABRT) at line 1
while running:  llvm-as < 
/home/duncan/LLVM/llvm.top/llvm/test/Transforms/LoopIndexSplit/non-iv-cmp-operand.ll 
|  opt -inline -reassociate -loop-rotate -loop-index-split -indvars 
-simplifycfg -verify
/usr/include/c++/4.4/debug/safe_iterator.h:460:error: attempt to compare 
a singular iterator to a past-the-end iterator.



More information about the llvm-commits mailing list