From daab0a298ce55e0d282c8d37ff06d1f8e9f1c9e8 Mon Sep 17 00:00:00 2001 From: Florian Brandner Date: Wed, 5 Oct 2016 14:54:36 +0200 Subject: [PATCH] odisplay/otawa: fix crash when instruction cache information is absent --- otawa/src/odisplay/display_CFGOutput.cpp | 2 +- otawa/src/prog/BBRatioDisplayer.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/otawa/src/odisplay/display_CFGOutput.cpp b/otawa/src/odisplay/display_CFGOutput.cpp index 811d729..1a91eed 100644 --- a/otawa/src/odisplay/display_CFGOutput.cpp +++ b/otawa/src/odisplay/display_CFGOutput.cpp @@ -264,7 +264,7 @@ void CFGOutput::genBBInfo(CFG *cfg, BasicBlock *bb, Output& out) { } genstruct::AllocatedTable *lbs = BB_LBLOCKS(bb); - if (lbs->count()) { + if (lbs && lbs->count()) { out << "---\nInstruction Cache:\n"; for(int i = 0; i < lbs->count(); i++) { LBlock *lb = lbs->get(i); diff --git a/otawa/src/prog/BBRatioDisplayer.cpp b/otawa/src/prog/BBRatioDisplayer.cpp index e1616c7..f5548fd 100644 --- a/otawa/src/prog/BBRatioDisplayer.cpp +++ b/otawa/src/prog/BBRatioDisplayer.cpp @@ -151,15 +151,18 @@ void BBRatioDisplayer::processBB(WorkSpace *fw, CFG *cfg, BasicBlock *bb) { return; // accumulate instruction cache miss costs. - const hard::Cache *inst_cache = hard::CACHE_CONFIGURATION(fw)->instCache(); - int cache_penalty = inst_cache->missPenalty(); int cache_total = 0; genstruct::AllocatedTable *lbs = BB_LBLOCKS(bb); - for(int i = 0; i < lbs->count(); i++) + if (lbs) { - LBlock *lb = lbs->get(i); - ilp::Var *miss_var = MISS_VAR(lb); - cache_total += (int)system->valueOf(miss_var) * cache_penalty; + const hard::Cache *inst_cache = hard::CACHE_CONFIGURATION(fw)->instCache(); + int cache_penalty = inst_cache->missPenalty(); + for(int i = 0; i < lbs->count(); i++) + { + LBlock *lb = lbs->get(i); + ilp::Var *miss_var = MISS_VAR(lb); + cache_total += (int)system->valueOf(miss_var) * cache_penalty; + } } // accumulate data cache miss costs.