]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix dumping of call cost in tail recursion optimization
authorJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Tue, 11 Aug 2009 19:21:25 +0000 (19:21 +0000)
committerJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Tue, 11 Aug 2009 19:21:25 +0000 (19:21 +0000)
When tail recursion optimization is detected (i.e. a jump to the
beginning of the function without creating a new stack frame),
Callgrind collects this as real call (ie. calculates inclusive
call costs), but forgot to dump the call information (the call
type is still left as a jump).
Fixed by also dump call information if inclusive cost is >0.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10780

callgrind/dump.c

index 488775afd4b7d44142480a2d3714a5b44ed099d8..58b3953b1ee4d4a8726f8da0f6706256a70205c5 100644 (file)
@@ -832,7 +832,8 @@ static Bool fprint_bbcc(Int fd, BBCC* bbcc, AddrPos* last)
     if (bb->jmp[jmp].instr == instr) {
        jcc_count=0;
        for(jcc=bbcc->jmp[jmp].jcc_list; jcc; jcc=jcc->next_from)
-           if ((jcc->jmpkind != Ijk_Call) && (jcc->call_counter >0))
+           if (((jcc->jmpkind != Ijk_Call) && (jcc->call_counter >0)) ||
+               (!CLG_(is_zero_cost)( CLG_(sets).full, jcc->cost )))
              jcc_count++;
 
        if (jcc_count>0) {    
@@ -845,7 +846,8 @@ static Bool fprint_bbcc(Int fd, BBCC* bbcc, AddrPos* last)
            fprint_apos(fd, &(currCost->p), last, bbcc->cxt->fn[0]->file);
            something_written = True;
            for(jcc=bbcc->jmp[jmp].jcc_list; jcc; jcc=jcc->next_from) {
-               if ((jcc->jmpkind != Ijk_Call) && (jcc->call_counter >0))
+               if (((jcc->jmpkind != Ijk_Call) && (jcc->call_counter >0)) ||
+                   (!CLG_(is_zero_cost)( CLG_(sets).full, jcc->cost )))
                    fprint_jcc(fd, jcc, &(currCost->p), last, ecounter);
            }
        }