URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [dbgcnt.def] - Rev 304
Go to most recent revision | Compare with Previous | Blame | View Log
/* This file contains the list of the debug counter for GCC.Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.This file is part of GCC.GCC is free software; you can redistribute it and/or modify it underthe terms of the GNU General Public License as published by the FreeSoftware Foundation; either version 3, or (at your option) any laterversion.GCC is distributed in the hope that it will be useful, but WITHOUT ANYWARRANTY; without even the implied warranty of MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licensefor more details.You should have received a copy of the GNU General Public Licensealong with GCC; see the file COPYING3. If not see<http://www.gnu.org/licenses/>. *//* A debug counter provides you a way to count an eventand return false after the counter has exceeded the thresholdspecified by the option.What is it used for ?This is primarily used to speed up the search for the bad transformationan optimization pass does. By doing a binary search on N,you can quickly narrow down to one transformationwhich is bad, or which triggers the bad behavior downstream(usually in the form of the badly generated code).How does it work ?Every time dbg_cnt(named-counter) is called,the counter is incremented for the named-counter.And the incremented value is compared against the threshold (limit)specified by the option.dbg_cnt () returns true if it is at or below threshold, and false if above.How to add a new one ?To add a new counter, simply add an entry below with some descriptive name,and add call(s) to dbg_cnt(your-counter-name) in appropriate places.Usually, you want to control at the finest granularityany particular transformation can happen.e.g. for each instruction in a dead code elimination,or for each copy instruction in register coalescing,or constant-propagation for each insn,or a block straightening, etc.See dce.c for an example. With the dbg_cnt () call in dce.c,now a developer can use -fdbg-cnt=dce:Nto stop doing the dead code elimination after N times.How to use it ?By default, all limits are UINT_MAX.Since debug count is unsigned int, <= UINT_MAX returns true always.i.e. dbg_cnt() returns true always regardless of the counter value(although it still counts the event).Use -fdbg-cnt=counter1:N,counter2:M,...which sets the limit for counter1 to N, and the limit for counter2 to M, etc.e.g. setting a limit to zero will make dbg_cnt () return false *always*.The following shell file can then be used to binary search forexact transformation that causes the bug. A second shell scriptshould be written, say "tryTest", which exits with 1 if thecompiled program fails and exits with 0 if the program succeeds.This shell script should take 1 parameter, the value to be passedto set the counter of the compilation command in tryTest. Then,assuming that the following script is called binarySearch,the command:binarySearch tryTestwill automatically find the highest value of the counter for whichthe program fails. If tryTest never fails, binarySearch willproduce unpredictable results as it will try to find an upper boundthat does not exist.When dbgcnt does hits the limit, it writes a comment in the currentdump_file of the form:***dbgcnt: limit reached for %s.***Assuming that the dump file is logging the analysis/transformationsit is making, this pinpoints the exact position in the log filewhere the problem transformation is being logged.=====================================#!/bin/bashwhile getopts "l:u:i:" optdocase $opt inl) lb="$OPTARG";;u) ub="$OPTARG";;i) init="$OPTARG";;?) usage; exit 3;;esacdoneshift $(($OPTIND - 1))echo $@cmd=${1+"${@}"}lb=${lb:=0}init=${init:=100}$cmd $lblb_val=$?if [ -z "$ub" ]; then# find the upper boundub=$(($init + $lb))truewhile [ $? -eq $lb_val ]; doub=$(($ub * 10))#ub=`expr $ub \* 10`$cmd $ubdonefiecho command: $cmdtruewhile [ `expr $ub - $lb` -gt 1 ]; dotry=$(($lb + ( $ub - $lb ) / 2))$cmd $tryif [ $? -eq $lb_val ]; thenlb=$tryelseub=$tryfidoneecho lbound: $lbecho ubound: $ub=====================================*//* Debug counter definitions. */DEBUG_COUNTER (auto_inc_dec)DEBUG_COUNTER (ccp)DEBUG_COUNTER (cfg_cleanup)DEBUG_COUNTER (cse2_move2add)DEBUG_COUNTER (cprop)DEBUG_COUNTER (dce)DEBUG_COUNTER (dce_fast)DEBUG_COUNTER (dce_ud)DEBUG_COUNTER (delete_trivial_dead)DEBUG_COUNTER (df_byte_scan)DEBUG_COUNTER (dse)DEBUG_COUNTER (dse1)DEBUG_COUNTER (dse2)DEBUG_COUNTER (gcse2_delete)DEBUG_COUNTER (global_alloc_at_func)DEBUG_COUNTER (global_alloc_at_reg)DEBUG_COUNTER (hoist)DEBUG_COUNTER (ia64_sched2)DEBUG_COUNTER (if_conversion)DEBUG_COUNTER (if_after_combine)DEBUG_COUNTER (if_after_reload)DEBUG_COUNTER (local_alloc_for_sched)DEBUG_COUNTER (postreload_cse)DEBUG_COUNTER (pre)DEBUG_COUNTER (pre_insn)DEBUG_COUNTER (treepre_insert)DEBUG_COUNTER (sched2_func)DEBUG_COUNTER (sched_block)DEBUG_COUNTER (sched_func)DEBUG_COUNTER (sched_insn)DEBUG_COUNTER (sched_region)DEBUG_COUNTER (sel_sched_cnt)DEBUG_COUNTER (sel_sched_region_cnt)DEBUG_COUNTER (sel_sched_insn_cnt)DEBUG_COUNTER (sms_sched_loop)DEBUG_COUNTER (store_motion)DEBUG_COUNTER (split_for_sched2)DEBUG_COUNTER (tail_call)
Go to most recent revision | Compare with Previous | Blame | View Log
