4747# interrupt handler which might execute.
4848
4949use strict;
50+ use warnings;
5051use Data::Dumper;
5152
5253# Configuration: set these as appropriate for your architecture/project.
@@ -182,7 +183,7 @@ sub trace {
182183
183184 if ($visited {$f }) {
184185 $visited {$f } = " R" if $visited {$f } eq " ?" ;
185- return ;
186+ return 0 ;
186187 }
187188
188189 $visited {$f } = " ?" ;
@@ -196,9 +197,10 @@ sub trace {
196197 my $t = $_ ;
197198
198199 $has_caller {$t } = 1;
199- trace($t );
200+ next unless trace($t );
200201
201- my $is = $total_cost {$t };
202+ warn " No cost found for $t " if (! defined $total_cost {$t });
203+ my $is = $total_cost {$t } || 0;
202204 my $d = $call_depth {$t };
203205
204206 $max_frame = $is if $is > $max_frame ;
@@ -209,6 +211,14 @@ sub trace {
209211 $call_depth {$f } = $max_depth + 1;
210212 $total_cost {$f } = $max_frame + ($frame_size {$f } || 0);
211213 $visited {$f } = " " if $visited {$f } eq " ?" ;
214+ return 1;
215+ }
216+
217+ sub main_cost {
218+ if (defined $global_name {" main" } && defined $total_cost {$global_name {" main" }}) {
219+ return $total_cost {$global_name {" main" }};
220+ }
221+ return 0;
212222}
213223
214224foreach (keys %call_graph ) { trace $_ ; }
@@ -251,9 +261,9 @@ sub trace {
251261
252262print " Peak execution estimate (main + worst-case IV):\n " ;
253263printf " main = %d , worst IV = %d , total = %d \n " ,
254- $total_cost { $global_name { " main " }} ,
264+ main_cost() ,
255265 $total_cost {" INTERRUPT" },
256- $total_cost { $global_name { " main " }} + $total_cost {" INTERRUPT" };
266+ main_cost() + $total_cost {" INTERRUPT" };
257267
258268print " \n " ;
259269
0 commit comments