123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101openGobConfigopenGoblintCilletisActivateda=get_bool"ana.autotune.enabled"&&List.mema@@get_string_list"ana.autotune.activated"(*Collect stats to be able to make decisions*)typecomplexityFactors={mutablefunctions:int;(*function definitions. Does not include extern functions, but functions that get added by goblint (e.g. bsearch or __VERIFIER_nondet_pointer (sv-comp))*)mutablefunctionCalls:int;(*places where functions are called*)mutableloops:int;mutableloopBreaks:int;(*Breaks and continues. Cil converts the loop conditions to a break. Only set if collection is done before prepareCFG, afterwards they are replaced by GOTOs*)mutablecontrolFlowStatements:int;(*Return, Goto, break, continue, if, switch. Includes at least one (implicit) return in each function*)mutableexpressions:int;(* recursively. e.g. x = x + 1 has 4 expressions*)mutableinstructions:int;(*function calls and assignments*)mutableintegralVars:(int*int);(*global, local. Does not consider the types that a pointer/array contains*)mutablearrayVars:(int*int);mutablepointerVars:(int*int);}letprintFactorsf=Logs.debug"functions: %d"f.functions;Logs.debug"functionCalls: %d"f.functionCalls;Logs.debug"loops: %d"f.loops;Logs.debug"loopBreaks: %d"f.loopBreaks;Logs.debug"controlFlowStatements: %d"f.controlFlowStatements;Logs.debug"expressions: %d"f.expressions;Logs.debug"instructions: %d"f.instructions;Logs.debug"integralVars: (%d,%d)"(fstf.integralVars)(sndf.integralVars);Logs.debug"arrayVars: (%d,%d)"(fstf.arrayVars)(sndf.arrayVars);Logs.debug"pointerVars: (%d,%d)"(fstf.pointerVars)(sndf.pointerVars)classcollectComplexityFactorsVisitor(factors)=objectinheritnopCilVisitormethod!vfunc_=factors.functions<-factors.functions+1;DoChildrenmethod!vvdecvar=letincVar(g,l)=ifvar.vglobthen(g+1,l)else(g,l+1)in(ifisIntegralTypevar.vtypethenfactors.integralVars<-incVarfactors.integralVarselseifisPointerTypevar.vtypethenfactors.pointerVars<-incVarfactors.pointerVarselseifisArrayTypevar.vtypethenfactors.arrayVars<-incVarfactors.arrayVars);DoChildrenmethod!vexpr_=factors.expressions<-factors.expressions+1;DoChildrenmethod!vinst=function|Set_->factors.instructions<-factors.instructions+1;DoChildren|Call(Some_,_,_,_,_)->factors.instructions<-factors.instructions+2;(*Count function call and assignment of the result seperately *)factors.functionCalls<-factors.functionCalls+1;DoChildren|Call_->factors.instructions<-factors.instructions+1;factors.functionCalls<-factors.functionCalls+1;DoChildren|_->DoChildrenmethod!vstmtstmt=matchstmt.skindwith|Loop_->factors.controlFlowStatements<-factors.controlFlowStatements+1;factors.loops<-factors.loops+1;DoChildren|If_|Switch_|Goto_|ComputedGoto_|Return_->factors.controlFlowStatements<-factors.controlFlowStatements+1;DoChildren|Break_|Continue_->factors.controlFlowStatements<-factors.controlFlowStatements+1;factors.loopBreaks<-factors.loopBreaks+1;DoChildren|_->DoChildrenendletcollectFactorsvisitActionvisitedObject=letfactors={functions=0;functionCalls=0;loops=0;loopBreaks=0;controlFlowStatements=0;expressions=0;instructions=0;integralVars=(0,0);arrayVars=(0,0);pointerVars=(0,0);}inletvisitor=newcollectComplexityFactorsVisitor(factors)inignore(visitActionvisitorvisitedObject);factorsletis_large_arrayt=matchCil.unrollTypetwith|TArray(_,e,_)->beginmatchCil.lenOfArrayewith(* TODO: Cil.lenOfArray but with Z.t? *)|i->i>10*get_int"ana.base.arrays.unrolling-factor"|exceptionCil.LenOfArray->falseend|_->false