From 3ff3025ceb78a1438dd52aca6ee5bb8c8394a4fa Mon Sep 17 00:00:00 2001 From: Simmo Saan Date: Thu, 7 Nov 2024 12:30:20 +0200 Subject: [PATCH] Fix finding of fixed loop unrolling for dynamic --- src/common/framework/myCFG.ml | 1 + src/util/cilCfg.ml | 5 ++++- src/util/loopUnrolling.ml | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/framework/myCFG.ml b/src/common/framework/myCFG.ml index c91d393504..e5f6176f5c 100644 --- a/src/common/framework/myCFG.ml +++ b/src/common/framework/myCFG.ml @@ -85,4 +85,5 @@ sig end (* TODO: move back to LoopUnrolling, now here to break dependency cycle *) +let factor0: int Cilfacade.StmtH.t = Cilfacade.StmtH.create 100 let factorH: int NodeH.t = NodeH.create 100 diff --git a/src/util/cilCfg.ml b/src/util/cilCfg.ml index 0692996ce4..06a29152eb 100644 --- a/src/util/cilCfg.ml +++ b/src/util/cilCfg.ml @@ -43,9 +43,12 @@ let createCFG (fileAST: file) = iterGlobals fileAST (fun glob -> match glob with | GFun(fd,_) -> + if (get_int "exp.unrolling-factor")>0 || AutoTune0.isActivated "loopUnrollHeuristic" then LoopUnrolling.unroll_loops fd loops; (* must be done before prepareCFG, otherwise cannot find breaks *) prepareCFG fd; computeCFGInfo fd true; - if (get_int "exp.unrolling-factor")>0 || AutoTune0.isActivated "loopUnrollHeuristic" then LoopUnrolling.unroll_loops fd loops; + Cilfacade.StmtH.iter (fun stmt factor -> + MyCFG.NodeH.add MyCFG.factorH (Statement (fst (CfgTools.find_real_stmt stmt))) factor (* must be done after computeCFGInfo, otherwise no succs *) + ) MyCFG.factor0 | _ -> () ); if get_bool "dbg.run_cil_check" then assert (Check.checkFile [] fileAST); \ No newline at end of file diff --git a/src/util/loopUnrolling.ml b/src/util/loopUnrolling.ml index 03c746dfe0..ceecac51dd 100644 --- a/src/util/loopUnrolling.ml +++ b/src/util/loopUnrolling.ml @@ -456,7 +456,8 @@ class loopUnrollingVisitor (func, totalLoops) = object nests <- nests - 1; Logs.debug "nests: %i" nests; let factor = loop_unrolling_factor stmt func totalLoops in if factor > 0 then ( - MyCFG.NodeH.add MyCFG.factorH (Statement (fst (CfgTools.find_real_stmt stmt))) factor; + (* MyCFG.NodeH.add MyCFG.factorH (Statement (fst (CfgTools.find_real_stmt stmt))) factor; *) + Cilfacade.StmtH.add MyCFG.factor0 stmt factor; Logs.info "unrolling loop at %a with factor %d" CilType.Location.pretty loc factor; annotateArrays b; stmt