Skip to content
Snippets Groups Projects
Commit 6cc0969a authored by Anna Zaks's avatar Anna Zaks
Browse files

[analyser] Refactor shouldInline logic into a helper.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152677 91177308-0d34-0410-b5e6-96231b3b80d8
parent fc544e3d
No related branches found
No related tags found
No related merge requests found
...@@ -127,13 +127,29 @@ static unsigned getNumberStackFrames(const LocationContext *LCtx) { ...@@ -127,13 +127,29 @@ static unsigned getNumberStackFrames(const LocationContext *LCtx) {
return count; return count;
} }
// Determine if we should inline the call.
static bool shouldInline(const FunctionDecl *FD, ExplodedNode *Pred,
AnalysisManager &AMgr) {
AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(FD);
const CFG *CalleeCFG = CalleeADC->getCFG();
if (getNumberStackFrames(Pred->getLocationContext())
== AMgr.InlineMaxStackDepth)
return false;
if (CalleeCFG->getNumBlockIDs() > AMgr.InlineMaxFunctionSize)
return false;
return true;
}
bool ExprEngine::InlineCall(ExplodedNodeSet &Dst, bool ExprEngine::InlineCall(ExplodedNodeSet &Dst,
const CallExpr *CE, const CallExpr *CE,
ExplodedNode *Pred) { ExplodedNode *Pred) {
ProgramStateRef state = Pred->getState(); ProgramStateRef state = Pred->getState();
const Expr *Callee = CE->getCallee(); const Expr *Callee = CE->getCallee();
const FunctionDecl *FD = const FunctionDecl *FD =
state->getSVal(Callee, Pred->getLocationContext()).getAsFunctionDecl(); state->getSVal(Callee, Pred->getLocationContext()).getAsFunctionDecl();
if (!FD || !FD->hasBody(FD)) if (!FD || !FD->hasBody(FD))
return false; return false;
...@@ -142,16 +158,11 @@ bool ExprEngine::InlineCall(ExplodedNodeSet &Dst, ...@@ -142,16 +158,11 @@ bool ExprEngine::InlineCall(ExplodedNodeSet &Dst,
// FIXME: Handle C++. // FIXME: Handle C++.
break; break;
case Stmt::CallExprClass: { case Stmt::CallExprClass: {
if (getNumberStackFrames(Pred->getLocationContext()) if (!shouldInline(FD, Pred, AMgr))
== AMgr.InlineMaxStackDepth)
return false;
AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(FD);
const CFG *CalleeCFG = CalleeADC->getCFG();
if (CalleeCFG->getNumBlockIDs() > AMgr.InlineMaxFunctionSize)
return false; return false;
// Construct a new stack frame for the callee. // Construct a new stack frame for the callee.
AnalysisDeclContext *CalleeADC = AMgr.getAnalysisDeclContext(FD);
const StackFrameContext *CallerSFC = const StackFrameContext *CallerSFC =
Pred->getLocationContext()->getCurrentStackFrame(); Pred->getLocationContext()->getCurrentStackFrame();
const StackFrameContext *CalleeSFC = const StackFrameContext *CalleeSFC =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment