diff options
author | Peter Szecsi <szepet95@gmail.com> | 2017-08-21 16:32:57 +0000 |
---|---|---|
committer | Peter Szecsi <szepet95@gmail.com> | 2017-08-21 16:32:57 +0000 |
commit | 3c3e1b0b54ceda8572e270cc02cb16c2e0c86163 (patch) | |
tree | 68da855be7da69bb737ef14c41c522452c521310 /clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | |
parent | bf6c9bb84b75072bcbb60ce66b06082c427fcb29 (diff) | |
download | bcm5719-llvm-3c3e1b0b54ceda8572e270cc02cb16c2e0c86163.tar.gz bcm5719-llvm-3c3e1b0b54ceda8572e270cc02cb16c2e0c86163.zip |
[StaticAnalyzer] LoopUnrolling: Track a LoopStack in order to completely unroll specific loops
The LoopExit CFG information provides the opportunity to not mark the loops but
having a stack which tracks if a loop is unrolled or not. So in case of
simulating a loop we just add it and the information if it meets the
requirements to be unrolled to the top of the stack.
Differential Revision: https://reviews.llvm.org/D35684
llvm-svn: 311346
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngine.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 43b067b6d2b..3629d72cf7d 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -519,10 +519,13 @@ void ExprEngine::ProcessLoopExit(const Stmt* S, ExplodedNode *Pred) { ExplodedNodeSet Dst; Dst.Add(Pred); NodeBuilder Bldr(Pred, Dst, *currBldrCtx); + ProgramStateRef NewState = Pred->getState(); - LoopExit PP(S, Pred->getLocationContext()); - Bldr.generateNode(PP, Pred->getState(), Pred); + if(AMgr.options.shouldUnrollLoops()) + NewState = processLoopEnd(S, NewState); + LoopExit PP(S, Pred->getLocationContext()); + Bldr.generateNode(PP, NewState, Pred); // Enqueue the new nodes onto the work list. Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx); } @@ -1519,22 +1522,17 @@ void ExprEngine::processCFGBlockEntrance(const BlockEdge &L, PrettyStackTraceLocationContext CrashInfo(Pred->getLocationContext()); // If we reach a loop which has a known bound (and meets // other constraints) then consider completely unrolling it. - if (AMgr.options.shouldUnrollLoops()) { - const CFGBlock *ActualBlock = nodeBuilder.getContext().getBlock(); - const Stmt *Term = ActualBlock->getTerminator(); - if (Term && shouldCompletelyUnroll(Term, AMgr.getASTContext(), Pred)) { - ProgramStateRef UnrolledState = markLoopAsUnrolled( - Term, Pred->getState(), - cast<FunctionDecl>(Pred->getStackFrame()->getDecl())); - if (UnrolledState != Pred->getState()) - nodeBuilder.generateNode(UnrolledState, Pred); - return; + if(AMgr.options.shouldUnrollLoops()) { + const Stmt *Term = nodeBuilder.getContext().getBlock()->getTerminator(); + if (Term) { + ProgramStateRef NewState = updateLoopStack(Term, AMgr.getASTContext(), + Pred); + if (NewState != Pred->getState()){ + Pred = nodeBuilder.generateNode(NewState, Pred); + } } - - if (ActualBlock->empty()) - return; - - if (isUnrolledLoopBlock(ActualBlock, Pred, AMgr)) + // Is we are inside an unrolled loop then no need the check the counters. + if(isUnrolledState(Pred->getState())) return; } |