[llvm-dev] ScalarEvolution class returns no valid loop exit count

benedikt steinmeier via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 27 13:14:33 PST 2018


Hi,

I have problems to estimate the loop exit count of a simple loop with the
ScalarEvolution class.

simple loop:
......
    int a = 0;
    for(int i; i < 10; ++i){
        a = a + 1;
    };
......

For the loop analyzation I use the ScalarEvolution class with the following
initialization:
......
void analysis(Function* func)
    DominatorTree DT = DominatorTree();
    DT.recalculate(*func);
    DT.updateDFSNumbers();

    LoopInfoBase<BasicBlock, Loop> LIB;
    LIB.releaseMemory();
    LIB.analyze(DT);

    for(auto&bb :*func){
        Loop * L = LIB.getLoopFor(&bb);
        if(L != nullptr){
            AssumptionCache AC = AssumptionCache(*bb.getParent());
            Triple MT(llvm::sys::getDefaultTargetTriple());
            TargetLibraryInfoImpl TLII(MT);
            TargetLibraryInfoWrapperPass TLI =
TargetLibraryInfoWrapperPass(TLII);

            LoopInfo LI = LoopInfo(DT);
            LI.analyze(DT);

            *ScalarEvolution SE = ScalarEvolution(*func, TLI.getTLI(),AC,
DT, LI);*
            BasicBlock * exitingblock = L->getUniqueExitBlock();
            const SCEV * exitingcount = SE.getExitCount (L,exitblock );
        }
    }
}
......

Unfortunately I get this result by printing the SCEV exitingcount variable:
***COULDNOTCOMPUTE***

It has been tested that the exitingblock of the loop was calculated
successfully.
The LLVM IR is parsed and analysed without the usual pass framework. For
this reason
the use of the getAnalysis<ScalarEvolution>() is not possible. The question
is wether there
is something I`m doing wrong during the initialization of the
ScalarEvolution class? Or is
the use of LLVM analysis classes without the passmanager framework not
possible?

Best regards!
Benedikt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181127/c2fe6cdb/attachment.html>


More information about the llvm-dev mailing list