Revision 27bfd83c

b/tcg/tcg.c
450 450
            s->nb_temps++;
451 451
        }
452 452
    }
453

  
454
#if defined(CONFIG_DEBUG_TCG)
455
    s->temps_in_use++;
456
#endif
453 457
    return idx;
454 458
}
455 459

  
......
475 479
    TCGTemp *ts;
476 480
    int k;
477 481

  
482
#if defined(CONFIG_DEBUG_TCG)
483
    s->temps_in_use--;
484
    if (s->temps_in_use < 0) {
485
        fprintf(stderr, "More temporaries freed than allocated!\n");
486
    }
487
#endif
488

  
478 489
    assert(idx >= s->nb_globals && idx < s->nb_temps);
479 490
    ts = &s->temps[idx];
480 491
    assert(ts->temp_allocated != 0);
......
528 539
    return t0;
529 540
}
530 541

  
542
#if defined(CONFIG_DEBUG_TCG)
543
void tcg_clear_temp_count(void)
544
{
545
    TCGContext *s = &tcg_ctx;
546
    s->temps_in_use = 0;
547
}
548

  
549
int tcg_check_temp_count(void)
550
{
551
    TCGContext *s = &tcg_ctx;
552
    if (s->temps_in_use) {
553
        /* Clear the count so that we don't give another
554
         * warning immediately next time around.
555
         */
556
        s->temps_in_use = 0;
557
        return 1;
558
    }
559
    return 0;
560
}
561
#endif
562

  
531 563
void tcg_register_helper(void *func, const char *name)
532 564
{
533 565
    TCGContext *s = &tcg_ctx;
b/tcg/tcg.h
323 323
    int64_t restore_count;
324 324
    int64_t restore_time;
325 325
#endif
326

  
327
#ifdef CONFIG_DEBUG_TCG
328
    int temps_in_use;
329
#endif
326 330
};
327 331

  
328 332
extern TCGContext tcg_ctx;
......
392 396
void tcg_temp_free_i64(TCGv_i64 arg);
393 397
char *tcg_get_arg_str_i64(TCGContext *s, char *buf, int buf_size, TCGv_i64 arg);
394 398

  
399
#if defined(CONFIG_DEBUG_TCG)
400
/* If you call tcg_clear_temp_count() at the start of a section of
401
 * code which is not supposed to leak any TCG temporaries, then
402
 * calling tcg_check_temp_count() at the end of the section will
403
 * return 1 if the section did in fact leak a temporary.
404
 */
405
void tcg_clear_temp_count(void);
406
int tcg_check_temp_count(void);
407
#else
408
#define tcg_clear_temp_count() do { } while (0)
409
#define tcg_check_temp_count() 0
410
#endif
411

  
395 412
void tcg_dump_info(FILE *f, fprintf_function cpu_fprintf);
396 413

  
397 414
#define TCG_CT_ALIAS  0x80

Also available in: Unified diff