Skip to content

Commit

Permalink
odisplay/otawa: fix crash when instruction cache information is absent
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Brandner committed Oct 5, 2016
1 parent ebc4eed commit daab0a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion otawa/src/odisplay/display_CFGOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void CFGOutput::genBBInfo(CFG *cfg, BasicBlock *bb, Output& out) {
}

genstruct::AllocatedTable<LBlock *> *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);
Expand Down
15 changes: 9 additions & 6 deletions otawa/src/prog/BBRatioDisplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LBlock *> *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.
Expand Down

0 comments on commit daab0a2

Please sign in to comment.