flow.c 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905
  1. /* Data flow analysis for GNU compiler.
  2. Copyright (C) 1987, 1988 Free Software Foundation, Inc.
  3. This file is part of GNU CC.
  4. GNU CC is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY. No author or distributor
  6. accepts responsibility to anyone for the consequences of using it
  7. or for whether it serves any particular purpose or works at all,
  8. unless he says so in writing. Refer to the GNU CC General Public
  9. License for full details.
  10. Everyone is granted permission to copy, modify and redistribute
  11. GNU CC, but only under the conditions described in the
  12. GNU CC General Public License. A copy of this license is
  13. supposed to have been given to you along with GNU CC so you
  14. can know your rights and responsibilities. It should be in a
  15. file named COPYING. Among other things, the copyright notice
  16. and this notice must be preserved on all copies. */
  17. /* This file contains the data flow analysis pass of the compiler.
  18. It computes data flow information
  19. which tells combine_instructions which insns to consider combining
  20. and controls register allocation.
  21. Additional data flow information that is too bulky to record
  22. is generated during the analysis, and is used at that time to
  23. create autoincrement and autodecrement addressing.
  24. The first step is dividing the function into basic blocks.
  25. find_basic_blocks does this. Then life_analysis determines
  26. where each register is live and where it is dead.
  27. ** find_basic_blocks **
  28. find_basic_blocks divides the current function's rtl
  29. into basic blocks. It records the beginnings and ends of the
  30. basic blocks in the vectors basic_block_head and basic_block_end,
  31. and the number of blocks in n_basic_blocks.
  32. find_basic_blocks also finds any unreachable loops
  33. and deletes them.
  34. ** life_analysis **
  35. life_analysis is called immediately after find_basic_blocks.
  36. It uses the basic block information to determine where each
  37. hard or pseudo register is live.
  38. ** live-register info **
  39. The information about where each register is live is in two parts:
  40. the REG_NOTES of insns, and the vector basic_block_live_at_start.
  41. basic_block_live_at_start has an element for each basic block,
  42. and the element is a bit-vector with a bit for each hard or pseudo
  43. register. The bit is 1 if the register is live at the beginning
  44. of the basic block.
  45. To each insn's REG_NOTES is added an element for each register
  46. that is live before the insn or set by the insn, but is dead
  47. after the insn.
  48. To determine which registers are live after any insn, one can
  49. start from the beginning of the basic block and scan insns, noting
  50. which registers are set by each insn and which die there.
  51. ** Other actions of life_analysis **
  52. life_analysis sets up the LOG_LINKS fields of insns because the
  53. information needed to do so is readily available.
  54. life_analysis deletes insns whose only effect is to store a value
  55. that is never used.
  56. life_analysis notices cases where a reference to a register as
  57. a memory address can be combined with a preceding or following
  58. incrementation or decrementation of the register. The separate
  59. instruction to increment or decrement is deleted and the address
  60. is changed to a POST_INC or similar rtx.
  61. Each time an incrementing or decrementing address is created,
  62. a REG_INC element is added to the insn's REG_NOTES list.
  63. life_analysis fills in certain vectors containing information about
  64. register usage: reg_n_refs, reg_n_deaths, reg_n_sets,
  65. reg_live_length, reg_crosses_call and reg_basic_block. */
  66. #include <stdio.h>
  67. #include "config.h"
  68. #include "rtl.h"
  69. #include "basic-block.h"
  70. #include "regs.h"
  71. #include "hard-reg-set.h"
  72. #include "flags.h"
  73. /* Get the basic block number of an insn.
  74. This info should not be expected to remain available
  75. after the end of life_analysis. */
  76. #define BLOCK_NUM(INSN) uid_block_number[INSN_UID (INSN)]
  77. /* This is where the BLOCK_NUM values are really stored.
  78. This is set up by find_basic_blocks and used there and in life_analysis,
  79. and then freed. */
  80. static short *uid_block_number;
  81. /* INSN_VOLATILE (insn) is 1 if the insn refers to anything volatile. */
  82. #define INSN_VOLATILE(INSN) uid_volatile[INSN_UID (INSN)]
  83. static char *uid_volatile;
  84. /* Number of basic blocks in the current function. */
  85. int n_basic_blocks;
  86. /* Maximum register number used in this function, plus one. */
  87. int max_regno;
  88. /* Indexed by n, gives number of basic block that (REG n) is used in.
  89. Or gives -2 if (REG n) is used in more than one basic block.
  90. Or -1 if it has not yet been seen so no basic block is known.
  91. This information remains valid for the rest of the compilation
  92. of the current function; it is used to control register allocation. */
  93. short *reg_basic_block;
  94. /* Indexed by n, gives number of times (REG n) is used or set, each
  95. weighted by its loop-depth.
  96. This information remains valid for the rest of the compilation
  97. of the current function; it is used to control register allocation. */
  98. short *reg_n_refs;
  99. /* Indexed by n, gives number of times (REG n) is set.
  100. This information remains valid for the rest of the compilation
  101. of the current function; it is used to control register allocation. */
  102. short *reg_n_sets;
  103. /* Indexed by N, gives number of places register N dies.
  104. This information remains valid for the rest of the compilation
  105. of the current function; it is used to control register allocation. */
  106. short *reg_n_deaths;
  107. /* Indexed by N, gives 1 if that reg is live across any CALL_INSNs.
  108. This information remains valid for the rest of the compilation
  109. of the current function; it is used to control register allocation. */
  110. char *reg_crosses_call;
  111. /* Total number of instructions at which (REG n) is live.
  112. The larger this is, the less priority (REG n) gets for
  113. allocation in a real register.
  114. This information remains valid for the rest of the compilation
  115. of the current function; it is used to control register allocation.
  116. local-alloc.c may alter this number to change the priority.
  117. Negative values are special.
  118. -1 is used to mark a pseudo reg which has a constant or memory equivalent
  119. and is used infrequently enough that it should not get a hard register.
  120. -2 is used to mark a pseudo reg for a parameter, when a frame pointer
  121. is not required. global-alloc.c makes an allocno for this but does
  122. not try to assign a hard register to it. */
  123. int *reg_live_length;
  124. /* Element N is the next insn that uses (hard or pseudo) register number N
  125. within the current basic block; or zero, if there is no such insn.
  126. This is valid only during the final backward scan in propagate_block. */
  127. static rtx *reg_next_use;
  128. /* Size of a regset for the current function,
  129. in (1) bytes and (2) elements. */
  130. int regset_bytes;
  131. int regset_size;
  132. /* Element N is first insn in basic block N.
  133. This info lasts until we finish compiling the function. */
  134. rtx *basic_block_head;
  135. /* Element N is last insn in basic block N.
  136. This info lasts until we finish compiling the function. */
  137. rtx *basic_block_end;
  138. /* Element N is a regset describing the registers live
  139. at the start of basic block N.
  140. This info lasts until we finish compiling the function. */
  141. regset *basic_block_live_at_start;
  142. /* Regset of regs live when calls to `setjmp'-like functions happen. */
  143. regset regs_live_at_setjmp;
  144. /* Element N is nonzero if control can drop into basic block N
  145. from the preceding basic block. Freed after life_analysis. */
  146. static char *basic_block_drops_in;
  147. /* Element N is depth within loops of basic block number N.
  148. Freed after life_analysis. */
  149. static short *basic_block_loop_depth;
  150. /* Element N nonzero if basic block N can actually be reached.
  151. Vector exists only during find_basic_blocks. */
  152. static char *block_live_static;
  153. /* Depth within loops of basic block being scanned for lifetime analysis,
  154. plus one. This is the weight attached to references to registers. */
  155. static int loop_depth;
  156. /* Define AUTO_INC_DEC if machine has any kind of incrementing
  157. or decrementing addressing. */
  158. #ifdef HAVE_PRE_DECREMENT
  159. #define AUTO_INC_DEC
  160. #endif
  161. #ifdef HAVE_PRE_INCREMENT
  162. #define AUTO_INC_DEC
  163. #endif
  164. #ifdef HAVE_POST_DECREMENT
  165. #define AUTO_INC_DEC
  166. #endif
  167. #ifdef HAVE_POST_INCREMENT
  168. #define AUTO_INC_DEC
  169. #endif
  170. /* Forward declarations */
  171. static void find_basic_blocks ();
  172. static void life_analysis ();
  173. static void mark_label_ref ();
  174. void allocate_for_life_analysis (); /* Used also in stupid_life_analysis */
  175. static void init_regset_vector ();
  176. static void propagate_block ();
  177. static void mark_set_regs ();
  178. static void mark_used_regs ();
  179. static int insn_dead_p ();
  180. static int try_pre_increment ();
  181. static int try_pre_increment_1 ();
  182. static rtx find_use_as_address ();
  183. static int volatile_refs_p ();
  184. void dump_flow_info ();
  185. /* Find basic blocks of the current function and perform data flow analysis.
  186. F is the first insn of the function and NREGS the number of register numbers
  187. in use. */
  188. void
  189. flow_analysis (f, nregs, file)
  190. rtx f;
  191. int nregs;
  192. FILE *file;
  193. {
  194. register rtx insn;
  195. register int i;
  196. register int max_uid = 0;
  197. /* Count the basic blocks. Also find maximum insn uid value used. */
  198. {
  199. register RTX_CODE prev_code = JUMP_INSN;
  200. register RTX_CODE code;
  201. for (insn = f, i = 0; insn; insn = NEXT_INSN (insn))
  202. {
  203. code = GET_CODE (insn);
  204. if (INSN_UID (insn) > max_uid)
  205. max_uid = INSN_UID (insn);
  206. if (code == CODE_LABEL
  207. || (prev_code != INSN && prev_code != CALL_INSN
  208. && prev_code != CODE_LABEL
  209. && (code == INSN || code == CALL_INSN || code == JUMP_INSN)))
  210. i++;
  211. if (code != NOTE)
  212. prev_code = code;
  213. }
  214. }
  215. /* Allocate some tables that last till end of compiling this function
  216. and some needed only in find_basic_blocks and life_analysis. */
  217. n_basic_blocks = i;
  218. basic_block_head = (rtx *) oballoc (n_basic_blocks * sizeof (rtx));
  219. basic_block_end = (rtx *) oballoc (n_basic_blocks * sizeof (rtx));
  220. basic_block_drops_in = (char *) alloca (n_basic_blocks);
  221. basic_block_loop_depth = (short *) alloca (n_basic_blocks * sizeof (short));
  222. uid_block_number = (short *) alloca ((max_uid + 1) * sizeof (short));
  223. uid_volatile = (char *) alloca (max_uid + 1);
  224. bzero (uid_volatile, max_uid + 1);
  225. find_basic_blocks (f);
  226. life_analysis (f, nregs);
  227. if (file)
  228. dump_flow_info (file);
  229. basic_block_drops_in = 0;
  230. uid_block_number = 0;
  231. basic_block_loop_depth = 0;
  232. }
  233. /* Find all basic blocks of the function whose first insn is F.
  234. Store the correct data in the tables that describe the basic blocks,
  235. set up the chains of references for each CODE_LABEL, and
  236. delete any entire basic blocks that cannot be reached. */
  237. static void
  238. find_basic_blocks (f)
  239. rtx f;
  240. {
  241. register rtx insn;
  242. register int i;
  243. /* Initialize the ref chain of each label to 0. */
  244. /* Record where all the blocks start and end and their depth in loops. */
  245. /* For each insn, record the block it is in. */
  246. {
  247. register RTX_CODE prev_code = JUMP_INSN;
  248. register RTX_CODE code;
  249. int depth = 1;
  250. for (insn = f, i = -1; insn; insn = NEXT_INSN (insn))
  251. {
  252. code = GET_CODE (insn);
  253. if (code == NOTE)
  254. {
  255. if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_BEG)
  256. depth++;
  257. else if (NOTE_LINE_NUMBER (insn) == NOTE_INSN_LOOP_END)
  258. depth--;
  259. }
  260. else if (code == CODE_LABEL
  261. || (prev_code != INSN && prev_code != CALL_INSN
  262. && prev_code != CODE_LABEL
  263. && (code == INSN || code == CALL_INSN || code == JUMP_INSN)))
  264. {
  265. basic_block_head[++i] = insn;
  266. basic_block_end[i] = insn;
  267. basic_block_loop_depth[i] = depth;
  268. if (code == CODE_LABEL)
  269. LABEL_REFS (insn) = insn;
  270. }
  271. else if (code == INSN || code == CALL_INSN || code == JUMP_INSN)
  272. basic_block_end[i] = insn;
  273. BLOCK_NUM (insn) = i;
  274. if (code != NOTE)
  275. prev_code = code;
  276. }
  277. }
  278. /* Record which basic blocks control can drop in to. */
  279. {
  280. register int i;
  281. for (i = 0; i < n_basic_blocks; i++)
  282. {
  283. register rtx insn = PREV_INSN (basic_block_head[i]);
  284. /* TEMP1 is used to avoid a bug in Sequent's compiler. */
  285. register int temp1;
  286. while (insn && GET_CODE (insn) == NOTE)
  287. insn = PREV_INSN (insn);
  288. temp1 = insn && GET_CODE (insn) != BARRIER;
  289. basic_block_drops_in[i] = temp1;
  290. }
  291. }
  292. /* Now find which basic blocks can actually be reached
  293. and put all jump insns' LABEL_REFS onto the ref-chains
  294. of their target labels. */
  295. if (n_basic_blocks > 0)
  296. {
  297. register char *block_live = (char *) alloca (n_basic_blocks);
  298. register char *block_marked = (char *) alloca (n_basic_blocks);
  299. int something_marked = 1;
  300. /* Initialize with just block 0 reachable and no blocks marked. */
  301. bzero (block_live, n_basic_blocks);
  302. bzero (block_marked, n_basic_blocks);
  303. block_live[0] = 1;
  304. block_live_static = block_live;
  305. /* Pass over all blocks, marking each block that is reachable
  306. and has not yet been marked.
  307. Keep doing this until, in one pass, no blocks have been marked.
  308. Then blocks_live and blocks_marked are identical and correct.
  309. In addition, all jumps actually reachable have been marked. */
  310. while (something_marked)
  311. {
  312. something_marked = 0;
  313. for (i = 0; i < n_basic_blocks; i++)
  314. if (block_live[i] && !block_marked[i])
  315. {
  316. block_marked[i] = 1;
  317. something_marked = 1;
  318. if (i + 1 < n_basic_blocks && basic_block_drops_in[i + 1])
  319. block_live[i + 1] = 1;
  320. insn = basic_block_end[i];
  321. if (GET_CODE (insn) == JUMP_INSN)
  322. mark_label_ref (PATTERN (insn), insn, 0);
  323. }
  324. }
  325. /* Now delete the code for any basic blocks that can't be reached.
  326. They can occur because jump_optimize does not recognize
  327. unreachable loops as unreachable. */
  328. for (i = 0; i < n_basic_blocks; i++)
  329. if (!block_live[i])
  330. {
  331. insn = basic_block_head[i];
  332. while (1)
  333. {
  334. if (GET_CODE (insn) == BARRIER)
  335. abort ();
  336. if (GET_CODE (insn) != NOTE)
  337. {
  338. PUT_CODE (insn, NOTE);
  339. NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  340. NOTE_SOURCE_FILE (insn) = 0;
  341. }
  342. if (insn == basic_block_end[i])
  343. {
  344. /* BARRIERs are between basic blocks, not part of one.
  345. Delete a BARRIER if the preceding jump is deleted.
  346. We cannot alter a BARRIER into a NOTE
  347. because it is too short; but we can really delete
  348. it because it is not part of a basic block. */
  349. if (NEXT_INSN (insn) != 0
  350. && GET_CODE (NEXT_INSN (insn)) == BARRIER)
  351. delete_insn (NEXT_INSN (insn));
  352. break;
  353. }
  354. insn = NEXT_INSN (insn);
  355. }
  356. /* Each time we delete some basic blocks,
  357. see if there is a jump around them that is
  358. being turned into a no-op. If so, delete it. */
  359. if (block_live[i - 1])
  360. {
  361. register int j;
  362. for (j = i; j < n_basic_blocks; j++)
  363. if (block_live[j])
  364. {
  365. insn = basic_block_end[i - 1];
  366. if (GET_CODE (insn) == JUMP_INSN
  367. && JUMP_LABEL (insn) != 0
  368. && INSN_UID (JUMP_LABEL (insn)) != 0
  369. && BLOCK_NUM (JUMP_LABEL (insn)) == j)
  370. {
  371. PUT_CODE (insn, NOTE);
  372. NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  373. NOTE_SOURCE_FILE (insn) = 0;
  374. if (GET_CODE (NEXT_INSN (insn)) != BARRIER)
  375. abort ();
  376. delete_insn (NEXT_INSN (insn));
  377. }
  378. break;
  379. }
  380. }
  381. }
  382. }
  383. }
  384. /* Check expression X for label references;
  385. if one is found, add INSN to the label's chain of references.
  386. CHECKDUP means check for and avoid creating duplicate references
  387. from the same insn. Such duplicates do no serious harm but
  388. can slow life analysis. CHECKDUP is set only when duplicates
  389. are likely. */
  390. static void
  391. mark_label_ref (x, insn, checkdup)
  392. rtx x, insn;
  393. int checkdup;
  394. {
  395. register RTX_CODE code = GET_CODE (x);
  396. register int i;
  397. register char *fmt;
  398. if (code == LABEL_REF)
  399. {
  400. register rtx label = XEXP (x, 0);
  401. register rtx y;
  402. if (GET_CODE (label) != CODE_LABEL)
  403. return;
  404. /* If the label was never emitted, this insn is junk,
  405. but avoid a crash trying to refer to BLOCK_NUM (label).
  406. This can happen as a result of a syntax error
  407. and a diagnostic has already been printed. */
  408. if (INSN_UID (label) == 0)
  409. return;
  410. CONTAINING_INSN (x) = insn;
  411. /* if CHECKDUP is set, check for duplicate ref from same insn
  412. and don't insert. */
  413. if (checkdup)
  414. for (y = LABEL_REFS (label); y != label; y = LABEL_NEXTREF (y))
  415. if (CONTAINING_INSN (y) == insn)
  416. return;
  417. LABEL_NEXTREF (x) = LABEL_REFS (label);
  418. LABEL_REFS (label) = x;
  419. block_live_static[BLOCK_NUM (label)] = 1;
  420. return;
  421. }
  422. fmt = GET_RTX_FORMAT (code);
  423. for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  424. {
  425. if (fmt[i] == 'e')
  426. mark_label_ref (XEXP (x, i), insn, 0);
  427. if (fmt[i] == 'E')
  428. {
  429. register int j;
  430. for (j = 0; j < XVECLEN (x, i); j++)
  431. mark_label_ref (XVECEXP (x, i, j), insn, 1);
  432. }
  433. }
  434. }
  435. /* Determine the which registers are live at the start of each
  436. basic block of the function whose first insn is F.
  437. NREGS is the number of registers used in F.
  438. We allocate the vector basic_block_live_at_start
  439. and the regsets that it points to, and fill them with the data.
  440. regset_size and regset_bytes are also set here. */
  441. static void
  442. life_analysis (f, nregs)
  443. rtx f;
  444. int nregs;
  445. {
  446. register regset tem;
  447. int first_pass;
  448. int changed;
  449. /* For each basic block, a bitmask of regs
  450. live on exit from the block. */
  451. regset *basic_block_live_at_end;
  452. /* For each basic block, a bitmask of regs
  453. live on entry to a successor-block of this block.
  454. If this does not match basic_block_live_at_end,
  455. that must be updated, and the block must be rescanned. */
  456. regset *basic_block_new_live_at_end;
  457. /* For each basic block, a bitmask of regs
  458. whose liveness at the end of the basic block
  459. can make a difference in which regs are live on entry to the block.
  460. These are the regs that are set within the basic block,
  461. possibly excluding those that are used after they are set. */
  462. regset *basic_block_significant;
  463. register int i;
  464. rtx insn;
  465. max_regno = nregs;
  466. bzero (regs_ever_live, sizeof regs_ever_live);
  467. /* Allocate and zero out many data structures
  468. that will record the data from lifetime analysis. */
  469. allocate_for_life_analysis ();
  470. reg_next_use = (rtx *) alloca (nregs * sizeof (rtx));
  471. bzero (reg_next_use, nregs * sizeof (rtx));
  472. /* Set up several regset-vectors used internally within this function.
  473. Their meanings are documented above, with their declarations. */
  474. basic_block_live_at_end = (regset *) alloca (n_basic_blocks * sizeof (regset));
  475. tem = (regset) alloca (n_basic_blocks * regset_bytes);
  476. bzero (tem, n_basic_blocks * regset_bytes);
  477. init_regset_vector (basic_block_live_at_end, tem, n_basic_blocks, regset_bytes);
  478. basic_block_new_live_at_end = (regset *) alloca (n_basic_blocks * sizeof (regset));
  479. tem = (regset) alloca (n_basic_blocks * regset_bytes);
  480. bzero (tem, n_basic_blocks * regset_bytes);
  481. init_regset_vector (basic_block_new_live_at_end, tem, n_basic_blocks, regset_bytes);
  482. basic_block_significant = (regset *) alloca (n_basic_blocks * sizeof (regset));
  483. tem = (regset) alloca (n_basic_blocks * regset_bytes);
  484. bzero (tem, n_basic_blocks * regset_bytes);
  485. init_regset_vector (basic_block_significant, tem, n_basic_blocks, regset_bytes);
  486. /* Record which insns refer to any volatile memory. */
  487. for (insn = f; insn; insn = NEXT_INSN (insn))
  488. if (GET_CODE (insn) == INSN || GET_CODE (insn) == JUMP_INSN
  489. || GET_CODE (insn) == CALL_INSN)
  490. INSN_VOLATILE (insn) = volatile_refs_p (PATTERN (insn));
  491. if (n_basic_blocks > 0)
  492. #ifdef EXIT_IGNORE_STACK
  493. if (! (EXIT_IGNORE_STACK) || ! frame_pointer_needed)
  494. #endif
  495. {
  496. /* If exiting needs the right stack value,
  497. consider the stack pointer live at the end of the function. */
  498. basic_block_live_at_end[n_basic_blocks - 1]
  499. [STACK_POINTER_REGNUM / REGSET_ELT_BITS]
  500. |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
  501. basic_block_new_live_at_end[n_basic_blocks - 1]
  502. [STACK_POINTER_REGNUM / REGSET_ELT_BITS]
  503. |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
  504. }
  505. /* Propagate life info through the basic blocks
  506. around the graph of basic blocks.
  507. This is a relaxation process: each time a new register
  508. is live at the end of the basic block, we must scan the block
  509. to determine which registers are, as a consequence, live at the beginning
  510. of that block. These registers must then be marked live at the ends
  511. of all the blocks that can transfer control to that block.
  512. The process continues until it reaches a fixed point. */
  513. first_pass = 1;
  514. changed = 1;
  515. while (changed)
  516. {
  517. changed = 0;
  518. for (i = n_basic_blocks - 1; i >= 0; i--)
  519. {
  520. int consider = first_pass;
  521. int must_rescan = first_pass;
  522. register int j;
  523. /* Set CONSIDER if this block needs thinking about at all
  524. (that is, if the regs live now at the end of it
  525. are not the same as were live at the end of it when
  526. we last thought about it).
  527. Set must_rescan if it needs to be thought about
  528. instruction by instruction (that is, if any additional
  529. reg that is live at the end now but was not live there before
  530. is one of the significant regs of this basic block). */
  531. for (j = 0; j < regset_size; j++)
  532. {
  533. register int x = basic_block_new_live_at_end[i][j]
  534. & ~basic_block_live_at_end[i][j];
  535. if (x)
  536. consider = 1;
  537. if (x & basic_block_significant[i][j])
  538. {
  539. must_rescan = 1;
  540. consider = 1;
  541. break;
  542. }
  543. }
  544. if (! consider)
  545. continue;
  546. /* The live_at_start of this block may be changing,
  547. so another pass will be required after this one. */
  548. changed = 1;
  549. if (! must_rescan)
  550. {
  551. /* No complete rescan needed;
  552. just record those variables newly known live at end
  553. as live at start as well. */
  554. for (j = 0; j < regset_size; j++)
  555. {
  556. register int x = basic_block_new_live_at_end[i][j]
  557. & ~basic_block_live_at_end[i][j];
  558. basic_block_live_at_start[i][j] |= x;
  559. basic_block_live_at_end[i][j] |= x;
  560. }
  561. }
  562. else
  563. {
  564. /* Update the basic_block_live_at_start
  565. by propagation backwards through the block. */
  566. bcopy (basic_block_new_live_at_end[i],
  567. basic_block_live_at_end[i], regset_bytes);
  568. bcopy (basic_block_live_at_end[i],
  569. basic_block_live_at_start[i], regset_bytes);
  570. propagate_block (basic_block_live_at_start[i],
  571. basic_block_head[i], basic_block_end[i], 0,
  572. first_pass ? basic_block_significant[i] : 0,
  573. i);
  574. }
  575. {
  576. register rtx jump, head;
  577. /* Update the basic_block_new_live_at_end's of the block
  578. that falls through into this one (if any). */
  579. head = basic_block_head[i];
  580. jump = PREV_INSN (head);
  581. if (basic_block_drops_in[i])
  582. {
  583. register from_block = BLOCK_NUM (jump);
  584. register int j;
  585. for (j = 0; j < regset_size; j++)
  586. basic_block_new_live_at_end[from_block][j]
  587. |= basic_block_live_at_start[i][j];
  588. }
  589. /* Update the basic_block_new_live_at_end's of
  590. all the blocks that jump to this one. */
  591. if (GET_CODE (head) == CODE_LABEL)
  592. for (jump = LABEL_REFS (head);
  593. jump != head;
  594. jump = LABEL_NEXTREF (jump))
  595. {
  596. register from_block = BLOCK_NUM (CONTAINING_INSN (jump));
  597. register int j;
  598. for (j = 0; j < regset_size; j++)
  599. basic_block_new_live_at_end[from_block][j]
  600. |= basic_block_live_at_start[i][j];
  601. }
  602. }
  603. }
  604. first_pass = 0;
  605. }
  606. /* Process the regs live at the beginning of the function.
  607. Mark them as not local to any one basic block. */
  608. if (n_basic_blocks > 0)
  609. for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
  610. if (basic_block_live_at_start[0][i / REGSET_ELT_BITS]
  611. & (1 << (i % REGSET_ELT_BITS)))
  612. reg_basic_block[i] = -2;
  613. /* Now the life information is accurate.
  614. Make one more pass over each basic block
  615. to delete dead stores, create autoincrement addressing
  616. and record how many times each register is used, is set, or dies.
  617. To save time, we operate directly in basic_block_live_at_end[i],
  618. thus destroying it (in fact, converting it into a copy of
  619. basic_block_live_at_start[i]). This is ok now because
  620. basic_block_live_at_end[i] is no longer used past this point. */
  621. for (i = 0; i < n_basic_blocks; i++)
  622. {
  623. propagate_block (basic_block_live_at_end[i],
  624. basic_block_head[i], basic_block_end[i], 1, 0, i);
  625. }
  626. }
  627. /* Subroutines of life analysis. */
  628. /* Allocate the permanent data structures that represent the results
  629. of life analysis. Not static since used also for stupid life analysis. */
  630. void
  631. allocate_for_life_analysis ()
  632. {
  633. register int i;
  634. register regset tem;
  635. regset_size = ((max_regno + REGSET_ELT_BITS - 1) / REGSET_ELT_BITS);
  636. regset_bytes = regset_size * sizeof (*(regset)0);
  637. reg_n_refs = (short *) oballoc (max_regno * sizeof (short));
  638. bzero (reg_n_refs, max_regno * sizeof (short));
  639. reg_n_sets = (short *) oballoc (max_regno * sizeof (short));
  640. bzero (reg_n_sets, max_regno * sizeof (short));
  641. reg_n_deaths = (short *) oballoc (max_regno * sizeof (short));
  642. bzero (reg_n_deaths, max_regno * sizeof (short));
  643. reg_live_length = (int *) oballoc (max_regno * sizeof (int));
  644. bzero (reg_live_length, max_regno * sizeof (int));
  645. reg_crosses_call = (char *) oballoc (max_regno);
  646. bzero (reg_crosses_call, max_regno);
  647. reg_basic_block = (short *) oballoc (max_regno * sizeof (short));
  648. for (i = 0; i < max_regno; i++)
  649. reg_basic_block[i] = -1;
  650. basic_block_live_at_start = (regset *) oballoc (n_basic_blocks * sizeof (regset));
  651. tem = (regset) oballoc (n_basic_blocks * regset_bytes);
  652. bzero (tem, n_basic_blocks * regset_bytes);
  653. init_regset_vector (basic_block_live_at_start, tem, n_basic_blocks, regset_bytes);
  654. regs_live_at_setjmp = (regset) oballoc (regset_bytes);
  655. bzero (regs_live_at_setjmp, regset_bytes);
  656. }
  657. /* Make each element of VECTOR point at a regset,
  658. taking the space for all those regsets from SPACE.
  659. SPACE is of type regset, but it is really as long as NELTS regsets.
  660. BYTES_PER_ELT is the number of bytes in one regset. */
  661. static void
  662. init_regset_vector (vector, space, nelts, bytes_per_elt)
  663. regset *vector;
  664. regset space;
  665. int nelts;
  666. int bytes_per_elt;
  667. {
  668. register int i;
  669. register regset p = space;
  670. for (i = 0; i < nelts; i++)
  671. {
  672. vector[i] = p;
  673. p += bytes_per_elt / sizeof (*p);
  674. }
  675. }
  676. /* Compute the registers live at the beginning of a basic block
  677. from those live at the end.
  678. When called, OLD contains those live at the end.
  679. On return, it contains those live at the beginning.
  680. FIRST and LAST are the first and last insns of the basic block.
  681. FINAL is nonzero if we are doing the final pass which is not
  682. for computing the life info (since that has already been done)
  683. but for acting on it. On this pass, we delete dead stores,
  684. set up the logical links and dead-variables lists of instructions,
  685. and merge instructions for autoincrement and autodecrement addresses.
  686. SIGNIFICANT is nonzero only the first time for each basic block.
  687. If it is nonzero, it points to a regset in which we store
  688. a 1 for each register that is set within the block.
  689. BNUM is the number of the basic block. */
  690. static void
  691. propagate_block (old, first, last, final, significant, bnum)
  692. register regset old;
  693. rtx first;
  694. rtx last;
  695. int final;
  696. regset significant;
  697. int bnum;
  698. {
  699. register rtx insn;
  700. rtx prev;
  701. regset live;
  702. regset dead;
  703. /* The following variables are used only if FINAL is nonzero. */
  704. /* This vector gets one element for each reg that has been live
  705. at any point in the basic block that has been scanned so far.
  706. SOMETIMES_MAX says how many elements are in use so far.
  707. In each element, OFFSET is the byte-number within a regset
  708. for the register described by the element, and BIT is a mask
  709. for that register's bit within the byte. */
  710. register struct foo { short offset; short bit; } *regs_sometimes_live;
  711. int sometimes_max = 0;
  712. /* This regset has 1 for each reg that we have seen live so far.
  713. It and REGS_SOMETIMES_LIVE are updated together. */
  714. regset maxlive;
  715. loop_depth = basic_block_loop_depth[bnum];
  716. dead = (regset) alloca (regset_bytes);
  717. live = (regset) alloca (regset_bytes);
  718. if (final)
  719. {
  720. register int i, offset, bit;
  721. maxlive = (regset) alloca (regset_bytes);
  722. bcopy (old, maxlive, regset_bytes);
  723. regs_sometimes_live
  724. = (struct foo *) alloca (max_regno * sizeof (struct foo));
  725. /* Process the regs live at the end of the block.
  726. Enter them in MAXLIVE and REGS_SOMETIMES_LIVE.
  727. Also mark them as not local to any one basic block. */
  728. for (offset = 0, i = 0; offset < regset_size; offset++)
  729. for (bit = 1; bit; bit <<= 1, i++)
  730. {
  731. if (i == max_regno)
  732. break;
  733. if (old[offset] & bit)
  734. {
  735. reg_basic_block[i] = -2;
  736. regs_sometimes_live[sometimes_max].offset = offset;
  737. regs_sometimes_live[sometimes_max].bit = i % REGSET_ELT_BITS;
  738. sometimes_max++;
  739. }
  740. }
  741. }
  742. /* Scan the block an insn at a time from end to beginning. */
  743. for (insn = last; ; insn = prev)
  744. {
  745. prev = PREV_INSN (insn);
  746. /* If this is a call to `setjmp' et al,
  747. warn if any non-volatile datum is live. */
  748. if (final && GET_CODE (insn) == NOTE
  749. && NOTE_LINE_NUMBER (insn) == NOTE_INSN_SETJMP)
  750. {
  751. int i;
  752. for (i = 0; i < regset_size; i++)
  753. regs_live_at_setjmp[i] |= old[i];
  754. }
  755. /* Update the life-status of regs for this insn.
  756. First DEAD gets which regs are set in this insn
  757. then LIVE gets which regs are used in this insn.
  758. Then the regs live before the insn
  759. are those live after, with DEAD regs turned off,
  760. and then LIVE regs turned on. */
  761. if (GET_CODE (insn) == INSN
  762. || GET_CODE (insn) == JUMP_INSN
  763. || GET_CODE (insn) == CALL_INSN)
  764. {
  765. register int i;
  766. rtx note = find_reg_note (insn, REG_RETVAL, 0);
  767. /* If an instruction consists of just dead store(s) on final pass,
  768. "delete" it by turning it into a NOTE of type NOTE_INSN_DELETED.
  769. We could really delete it with delete_insn, but that
  770. can cause trouble for first or last insn in a basic block. */
  771. if (final && insn_dead_p (PATTERN (insn), old, 1)
  772. /* Don't delete something that refers to volatile storage! */
  773. && ! INSN_VOLATILE (insn))
  774. {
  775. PUT_CODE (insn, NOTE);
  776. NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  777. NOTE_SOURCE_FILE (insn) = 0;
  778. /* If this insn is copying the return value from a library call,
  779. delete the entire library call. */
  780. if (note)
  781. {
  782. rtx first = XEXP (note, 0);
  783. rtx prev = insn;
  784. while (first->volatil)
  785. first = NEXT_INSN (first);
  786. while (prev != first)
  787. {
  788. prev = PREV_INSN (prev);
  789. PUT_CODE (prev, NOTE);
  790. NOTE_LINE_NUMBER (prev) = NOTE_INSN_DELETED;
  791. NOTE_SOURCE_FILE (prev) = 0;
  792. }
  793. }
  794. goto flushed;
  795. }
  796. for (i = 0; i < regset_size; i++)
  797. {
  798. dead[i] = 0; /* Faster than bzero here */
  799. live[i] = 0; /* since regset_size is usually small */
  800. }
  801. /* See if this is an increment or decrement that can be
  802. merged into a following memory address. */
  803. #ifdef AUTO_INC_DEC
  804. {
  805. register rtx x = PATTERN (insn);
  806. /* Does this instruction increment or decrement a register? */
  807. if (final && GET_CODE (x) == SET
  808. && GET_CODE (SET_DEST (x)) == REG
  809. && (GET_CODE (SET_SRC (x)) == PLUS
  810. || GET_CODE (SET_SRC (x)) == MINUS)
  811. && XEXP (SET_SRC (x), 0) == SET_DEST (x)
  812. && GET_CODE (XEXP (SET_SRC (x), 1)) == CONST_INT
  813. /* Ok, look for a following memory ref we can combine with.
  814. If one is found, change the memory ref to a PRE_INC
  815. or PRE_DEC, cancel this insn, and return 1.
  816. Return 0 if nothing has been done. */
  817. && try_pre_increment_1 (insn))
  818. goto flushed;
  819. }
  820. #endif /* AUTO_INC_DEC */
  821. /* If this is not the final pass, and this insn is copying the
  822. value of a library call and it's dead, don't scan the
  823. insns that perform the library call, so that the call's
  824. arguments are not marked live. */
  825. if (note && insn_dead_p (PATTERN (insn), old, 1))
  826. insn = XEXP (note, 0);
  827. else
  828. {
  829. /* LIVE gets the regs used in INSN; DEAD gets those set by it. */
  830. mark_set_regs (old, dead, PATTERN (insn), final ? insn : 0,
  831. significant);
  832. mark_used_regs (old, live, PATTERN (insn), final, insn);
  833. /* Update OLD for the registers used or set. */
  834. for (i = 0; i < regset_size; i++)
  835. {
  836. old[i] &= ~dead[i];
  837. old[i] |= live[i];
  838. }
  839. if (GET_CODE (insn) == CALL_INSN)
  840. {
  841. register int i;
  842. /* Each call clobbers all call-clobbered regs.
  843. Note that the function-value reg is one of these, and
  844. mark_set_regs has already had a chance to handle it. */
  845. for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
  846. if (call_used_regs[i])
  847. old[i / REGSET_ELT_BITS]
  848. &= ~(1 << (i % REGSET_ELT_BITS));
  849. /* The stack ptr is used (honorarily) by a CALL insn. */
  850. old[STACK_POINTER_REGNUM / REGSET_ELT_BITS]
  851. |= (1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS));
  852. if (final)
  853. {
  854. /* Any regs live at the time of a call instruction
  855. must not go in a register clobbered by calls.
  856. Find all regs now live and record this for them. */
  857. register struct foo *p = regs_sometimes_live;
  858. for (i = 0; i < sometimes_max; i++, p++)
  859. {
  860. if (old[p->offset]
  861. & (1 << p->bit))
  862. reg_crosses_call[p->offset * REGSET_ELT_BITS + p->bit] = 1;
  863. }
  864. }
  865. }
  866. }
  867. /* On final pass, add any additional sometimes-live regs
  868. into MAXLIVE and REGS_SOMETIMES_LIVE.
  869. Also update counts of how many insns each reg is live at. */
  870. if (final)
  871. {
  872. for (i = 0; i < regset_size; i++)
  873. {
  874. register int diff = live[i] & ~maxlive[i];
  875. if (diff)
  876. {
  877. register int regno;
  878. maxlive[i] |= diff;
  879. for (regno = 0; diff && regno < REGSET_ELT_BITS; regno++)
  880. if (diff & (1 << regno))
  881. {
  882. regs_sometimes_live[sometimes_max].offset = i;
  883. regs_sometimes_live[sometimes_max].bit = regno;
  884. diff &= ~ (1 << regno);
  885. sometimes_max++;
  886. }
  887. }
  888. }
  889. {
  890. register struct foo *p = regs_sometimes_live;
  891. for (i = 0; i < sometimes_max; i++, p++)
  892. {
  893. if (old[p->offset] & (1 << p->bit))
  894. reg_live_length[p->offset * REGSET_ELT_BITS + p->bit]++;
  895. }
  896. }
  897. }
  898. }
  899. flushed: ;
  900. if (insn == first)
  901. break;
  902. }
  903. }
  904. /* Return 1 if X (the body of an insn, or part of it) is just dead stores
  905. (SET expressions whose destinations are registers dead after the insn).
  906. NEEDED is the regset that says which regs are alive after the insn. */
  907. static int
  908. insn_dead_p (x, needed, strict_low_ok)
  909. rtx x;
  910. regset needed;
  911. int strict_low_ok;
  912. {
  913. register RTX_CODE code = GET_CODE (x);
  914. #if 0
  915. /* Make sure insns to set the stack pointer are never deleted. */
  916. needed[STACK_POINTER_REGNUM / REGSET_ELT_BITS]
  917. |= 1 << (STACK_POINTER_REGNUM % REGSET_ELT_BITS);
  918. #endif
  919. /* If setting something that's a reg or part of one,
  920. see if that register's altered value will be live. */
  921. if (code == SET)
  922. {
  923. register rtx r = SET_DEST (x);
  924. /* A SET that is a subroutine call cannot be dead. */
  925. if (GET_CODE (SET_SRC (x)) == CALL)
  926. return 0;
  927. while (GET_CODE (r) == SUBREG
  928. || (strict_low_ok && GET_CODE (r) == STRICT_LOW_PART)
  929. || GET_CODE (r) == ZERO_EXTRACT
  930. || GET_CODE (r) == SIGN_EXTRACT)
  931. r = SUBREG_REG (r);
  932. if (GET_CODE (r) == REG)
  933. {
  934. register int regno = REGNO (r);
  935. register int offset = regno / REGSET_ELT_BITS;
  936. register int bit = 1 << (regno % REGSET_ELT_BITS);
  937. return (needed[offset] & bit) == 0;
  938. }
  939. }
  940. /* If performing several activities,
  941. insn is dead if each activity is individually dead.
  942. Also, CLOBBERs and USEs can be ignored; a CLOBBER or USE
  943. that's inside a PARALLEL doesn't make the insn worth keeping. */
  944. else if (code == PARALLEL)
  945. {
  946. register int i = XVECLEN (x, 0);
  947. for (i--; i >= 0; i--)
  948. {
  949. rtx elt = XVECEXP (x, 0, i);
  950. if (!insn_dead_p (elt, needed, strict_low_ok)
  951. && GET_CODE (elt) != CLOBBER
  952. && GET_CODE (elt) != USE)
  953. return 0;
  954. }
  955. return 1;
  956. }
  957. /* We do not check CLOBBER or USE here.
  958. An insn consisting of just a CLOBBER or just a USE
  959. should not be deleted. */
  960. return 0;
  961. }
  962. /* Return 1 if register REGNO was used before it was set.
  963. In other words, if it is live at function entry. */
  964. int
  965. regno_uninitialized (regno)
  966. int regno;
  967. {
  968. return (basic_block_live_at_start[0][regno / REGSET_ELT_BITS]
  969. & (1 << (regno % REGSET_ELT_BITS)));
  970. }
  971. /* 1 if register REGNO was alive at a place where `setjmp' was called
  972. and was set more than once. Such regs may be clobbered by `longjmp'. */
  973. int
  974. regno_clobbered_at_setjmp (regno)
  975. int regno;
  976. {
  977. return (reg_n_sets[regno] > 1
  978. && (regs_live_at_setjmp[regno / REGSET_ELT_BITS]
  979. & (1 << (regno % REGSET_ELT_BITS))));
  980. }
  981. /* Process the registers that are set within X.
  982. Their bits are set to 1 in the regset DEAD,
  983. because they are dead prior to this insn.
  984. If INSN is nonzero, it is the insn being processed
  985. and the fact that it is nonzero implies this is the FINAL pass
  986. in propagate_block. In this case, various info about register
  987. usage is stored, LOG_LINKS fields of insns are set up. */
  988. static void mark_set_1 ();
  989. static void
  990. mark_set_regs (needed, dead, x, insn, significant)
  991. regset needed;
  992. regset dead;
  993. rtx x;
  994. rtx insn;
  995. regset significant;
  996. {
  997. register RTX_CODE code = GET_CODE (x);
  998. if (code == SET || code == CLOBBER)
  999. mark_set_1 (needed, dead, x, insn, significant);
  1000. else if (code == PARALLEL)
  1001. {
  1002. register int i;
  1003. for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
  1004. {
  1005. code = GET_CODE (XVECEXP (x, 0, i));
  1006. if (code == SET || code == CLOBBER)
  1007. mark_set_1 (needed, dead, XVECEXP (x, 0, i), insn, significant);
  1008. }
  1009. }
  1010. }
  1011. /* Process a single SET rtx, X. */
  1012. static void
  1013. mark_set_1 (needed, dead, x, insn, significant)
  1014. regset needed;
  1015. regset dead;
  1016. rtx x;
  1017. rtx insn;
  1018. regset significant;
  1019. {
  1020. register int regno;
  1021. register rtx reg = SET_DEST (x);
  1022. if (reg == 0)
  1023. return;
  1024. if (GET_CODE (reg) == SUBREG)
  1025. {
  1026. /* Modifying just one hardware register
  1027. of a multi-register value does not count as "setting"
  1028. for live-dead analysis. Parts of the previous value
  1029. might still be significant below this insn. */
  1030. if (REG_SIZE (SUBREG_REG (reg)) > REG_SIZE (reg))
  1031. return;
  1032. reg = SUBREG_REG (reg);
  1033. }
  1034. if (GET_CODE (reg) == REG
  1035. && (regno = REGNO (reg), regno != FRAME_POINTER_REGNUM)
  1036. && regno != ARG_POINTER_REGNUM)
  1037. /* && regno != STACK_POINTER_REGNUM) -- let's try without this. */
  1038. {
  1039. register int offset = regno / REGSET_ELT_BITS;
  1040. register int bit = 1 << (regno % REGSET_ELT_BITS);
  1041. int is_needed = 0;
  1042. /* Mark the reg being set as dead before this insn. */
  1043. dead[offset] |= bit;
  1044. /* Mark it as a significant register for this basic block. */
  1045. if (significant)
  1046. significant[offset] |= bit;
  1047. /* A hard reg in a wide mode may really be multiple registers.
  1048. If so, mark all of them just like the first. */
  1049. if (regno < FIRST_PSEUDO_REGISTER)
  1050. {
  1051. int n = HARD_REGNO_NREGS (regno, GET_MODE (reg));
  1052. while (--n > 0)
  1053. {
  1054. dead[(regno + n) / REGSET_ELT_BITS]
  1055. |= 1 << ((regno + n) % REGSET_ELT_BITS);
  1056. if (significant)
  1057. significant[(regno + n) / REGSET_ELT_BITS]
  1058. |= 1 << ((regno + n) % REGSET_ELT_BITS);
  1059. is_needed |= (needed[(regno + n) / REGSET_ELT_BITS]
  1060. & 1 << ((regno + n) % REGSET_ELT_BITS));
  1061. }
  1062. }
  1063. /* Additional data to record if this is the final pass. */
  1064. if (insn)
  1065. {
  1066. register rtx y = reg_next_use[regno];
  1067. register int blocknum = BLOCK_NUM (insn);
  1068. /* If this is a hard reg, record this function uses the reg. */
  1069. if (regno < FIRST_PSEUDO_REGISTER)
  1070. {
  1071. register int i;
  1072. i = HARD_REGNO_NREGS (regno, GET_MODE (reg));
  1073. do
  1074. regs_ever_live[regno + --i] = 1;
  1075. while (i > 0);
  1076. }
  1077. /* Keep track of which basic blocks each reg appears in. */
  1078. if (reg_basic_block[regno] == -1)
  1079. reg_basic_block[regno] = blocknum;
  1080. else if (reg_basic_block[regno] != blocknum)
  1081. reg_basic_block[regno] = -2;
  1082. /* Count (weighted) references, stores, etc. */
  1083. reg_n_refs[regno] += loop_depth;
  1084. reg_n_sets[regno]++;
  1085. /* The next use is no longer "next", since a store intervenes. */
  1086. reg_next_use[regno] = 0;
  1087. /* The insns where a reg is live are normally counted elsewhere,
  1088. but we want the count to include the insn where the reg is set,
  1089. and the normal counting mechanism would not count it. */
  1090. reg_live_length[regno]++;
  1091. if ((needed[offset] & bit) || is_needed)
  1092. {
  1093. /* Make a logical link from the next following insn
  1094. that uses this register, back to this insn.
  1095. The following insns have already been processed. */
  1096. if (y && (BLOCK_NUM (y) == blocknum))
  1097. LOG_LINKS (y)
  1098. = gen_rtx (INSN_LIST, VOIDmode, insn, LOG_LINKS (y));
  1099. }
  1100. else
  1101. {
  1102. /* Note that dead stores have already been deleted when possible
  1103. If we get here, we have found a dead store that cannot
  1104. be eliminated (because the same insn does something useful).
  1105. Indicate this by marking the reg being set as dying here. */
  1106. REG_NOTES (insn)
  1107. = gen_rtx (EXPR_LIST, REG_DEAD,
  1108. reg, REG_NOTES (insn));
  1109. }
  1110. }
  1111. }
  1112. }
  1113. /* Scan expression X and store a 1-bit in LIVE for each reg it uses.
  1114. This is done assuming the registers needed from X
  1115. are those that have 1-bits in NEEDED.
  1116. On the final pass, FINAL is 1. This means try for autoincrement
  1117. and count the uses and deaths of each pseudo-reg.
  1118. INSN is the containing instruction. */
  1119. static void
  1120. mark_used_regs (needed, live, x, final, insn)
  1121. regset needed;
  1122. regset live;
  1123. rtx x;
  1124. rtx insn;
  1125. int final;
  1126. {
  1127. register RTX_CODE code;
  1128. register int regno;
  1129. retry:
  1130. code = GET_CODE (x);
  1131. switch (code)
  1132. {
  1133. case LABEL_REF:
  1134. case SYMBOL_REF:
  1135. case CONST_INT:
  1136. case CONST:
  1137. case CC0:
  1138. case PC:
  1139. case CLOBBER:
  1140. return;
  1141. #if defined (HAVE_POST_INCREMENT) || defined (HAVE_POST_DECREMENT)
  1142. case MEM:
  1143. /* Here we detect use of an index register which might
  1144. be good for postincrement or postdecrement. */
  1145. if (final)
  1146. {
  1147. rtx addr = XEXP (x, 0);
  1148. register int size = GET_MODE_SIZE (GET_MODE (x));
  1149. if (GET_CODE (addr) == REG)
  1150. {
  1151. register rtx y;
  1152. regno = REGNO (addr);
  1153. /* Is the next use an increment that might make auto-increment? */
  1154. y = reg_next_use[regno];
  1155. if (y && GET_CODE (PATTERN (y)) == SET
  1156. && BLOCK_NUM (y) == BLOCK_NUM (insn)
  1157. /* Can't add side effects to jumps; if reg is spilled and
  1158. reloaded, there's no way to store back the altered value. */
  1159. && GET_CODE (insn) != JUMP_INSN
  1160. && (y = SET_SRC (PATTERN (y)),
  1161. (0
  1162. #ifdef HAVE_POST_INCREMENT
  1163. || GET_CODE (y) == PLUS
  1164. #endif
  1165. #ifdef HAVE_POST_DECREMENT
  1166. || GET_CODE (y) == MINUS
  1167. #endif
  1168. )
  1169. && XEXP (y, 0) == addr
  1170. && GET_CODE (XEXP (y, 1)) == CONST_INT
  1171. && INTVAL (XEXP (y, 1)) == size)
  1172. && dead_or_set_p (reg_next_use[regno], addr))
  1173. {
  1174. rtx use = find_use_as_address (PATTERN (insn), addr, 0);
  1175. /* Make sure this register appears only once in this insn. */
  1176. if (use != 0 && use != (rtx) 1)
  1177. {
  1178. /* We have found a suitable auto-increment:
  1179. do POST_INC around the register here,
  1180. and patch out the increment instruction that follows. */
  1181. XEXP (x, 0)
  1182. = gen_rtx (GET_CODE (y) == PLUS ? POST_INC : POST_DEC,
  1183. Pmode, addr);
  1184. /* Record that this insn has an implicit side effect. */
  1185. REG_NOTES (insn)
  1186. = gen_rtx (EXPR_LIST, REG_INC, addr, REG_NOTES (insn));
  1187. /* Modify the old increment-insn to simply copy
  1188. the already-incremented value of our register. */
  1189. y = reg_next_use[regno];
  1190. SET_SRC (PATTERN (y)) = addr;
  1191. /* If that makes it a no-op (copying the register
  1192. into itself) then change it to a simpler no-op
  1193. so it won't appear to be a "use" and a "set"
  1194. of this register. */
  1195. if (SET_DEST (PATTERN (y)) == addr)
  1196. PATTERN (y) = gen_rtx (USE, VOIDmode, const0_rtx);
  1197. /* Count an extra reference to the reg for the increment.
  1198. When a reg is incremented.
  1199. spilling it is worse, so we want to make that
  1200. less likely. */
  1201. reg_n_refs[regno] += loop_depth;
  1202. /* Count the increment as a setting of the register,
  1203. even though it isn't a SET in rtl. */
  1204. reg_n_sets[regno]++;
  1205. }
  1206. }
  1207. }
  1208. }
  1209. break;
  1210. #endif /* HAVE_POST_INCREMENT or HAVE_POST_DECREMENT */
  1211. case REG:
  1212. /* See a register other than being set
  1213. => mark it as needed. */
  1214. regno = REGNO (x);
  1215. if (regno != FRAME_POINTER_REGNUM
  1216. && regno != ARG_POINTER_REGNUM)
  1217. /* && regno != STACK_POINTER_REGNUM) -- let's try without this. */
  1218. {
  1219. register int offset = regno / REGSET_ELT_BITS;
  1220. register int bit = 1 << (regno % REGSET_ELT_BITS);
  1221. int is_needed = 0;
  1222. live[offset] |= bit;
  1223. /* A hard reg in a wide mode may really be multiple registers.
  1224. If so, mark all of them just like the first. */
  1225. if (regno < FIRST_PSEUDO_REGISTER)
  1226. {
  1227. int n = HARD_REGNO_NREGS (regno, GET_MODE (x));
  1228. while (--n > 0)
  1229. {
  1230. live[(regno + n) / REGSET_ELT_BITS]
  1231. |= 1 << ((regno + n) % REGSET_ELT_BITS);
  1232. is_needed |= (needed[(regno + n) / REGSET_ELT_BITS]
  1233. & 1 << ((regno + n) % REGSET_ELT_BITS));
  1234. }
  1235. }
  1236. if (final)
  1237. {
  1238. register int blocknum = BLOCK_NUM (insn);
  1239. /* If a hard reg is being used,
  1240. record that this function does use it. */
  1241. if (regno < FIRST_PSEUDO_REGISTER)
  1242. {
  1243. register int i;
  1244. i = HARD_REGNO_NREGS (regno, GET_MODE (x));
  1245. do
  1246. regs_ever_live[regno + --i] = 1;
  1247. while (i > 0);
  1248. }
  1249. /* Keep track of which basic block each reg appears in. */
  1250. if (reg_basic_block[regno] == -1)
  1251. reg_basic_block[regno] = blocknum;
  1252. else if (reg_basic_block[regno] != blocknum)
  1253. reg_basic_block[regno] = -2;
  1254. /* Record where each reg is used
  1255. so when the reg is set we know the next insn that uses it. */
  1256. reg_next_use[regno] = insn;
  1257. /* Count (weighted) number of uses of each reg. */
  1258. reg_n_refs[regno] += loop_depth;
  1259. /* Record and count the insns in which a reg dies.
  1260. If it is used in this insn and was dead below the insn
  1261. then it dies in this insn. */
  1262. if (!(needed[offset] & bit) && !is_needed
  1263. && ! find_regno_note (insn, REG_DEAD, regno))
  1264. {
  1265. REG_NOTES (insn)
  1266. = gen_rtx (EXPR_LIST, REG_DEAD, x, REG_NOTES (insn));
  1267. reg_n_deaths[regno]++;
  1268. }
  1269. }
  1270. }
  1271. return;
  1272. case SET:
  1273. {
  1274. register rtx testreg = SET_DEST (x);
  1275. int mark_dest = 0;
  1276. /* Storing in STRICT_LOW_PART is like storing in a reg
  1277. in that this SET might be dead, so ignore it in TESTREG.
  1278. but in some other ways it is like using the reg. */
  1279. /* Storing in a SUBREG or a bit field is like storing the entire
  1280. register in that if the register's value is not used
  1281. then this SET is not needed. */
  1282. while (GET_CODE (testreg) == STRICT_LOW_PART
  1283. || GET_CODE (testreg) == ZERO_EXTRACT
  1284. || GET_CODE (testreg) == SIGN_EXTRACT
  1285. || GET_CODE (testreg) == SUBREG)
  1286. {
  1287. /* Modifying a single register in an alternate mode
  1288. does not use any of the old value. But these other
  1289. ways of storing in a register do use the old value. */
  1290. if (GET_CODE (testreg) == SUBREG
  1291. && !(REG_SIZE (SUBREG_REG (testreg)) > REG_SIZE (testreg)))
  1292. ;
  1293. else
  1294. mark_dest = 1;
  1295. testreg = XEXP (testreg, 0);
  1296. }
  1297. /* If this is a store into a register,
  1298. recursively scan the only value being stored,
  1299. and only if the register's value is live after this insn.
  1300. If the value being computed here would never be used
  1301. then the values it uses don't need to be computed either. */
  1302. if (GET_CODE (testreg) == REG
  1303. && (regno = REGNO (testreg), regno != FRAME_POINTER_REGNUM)
  1304. && regno != ARG_POINTER_REGNUM)
  1305. /* && regno != STACK_POINTER_REGNUM) -- let's try without this. */
  1306. {
  1307. register int offset = regno / REGSET_ELT_BITS;
  1308. register int bit = 1 << (regno % REGSET_ELT_BITS);
  1309. if ((needed[offset] & bit)
  1310. /* If insn refers to volatile, we mustn't delete it,
  1311. so its inputs are all needed. */
  1312. || INSN_VOLATILE (insn))
  1313. {
  1314. mark_used_regs (needed, live, SET_SRC (x), final, insn);
  1315. if (mark_dest)
  1316. mark_used_regs (needed, live, SET_DEST (x), final, insn);
  1317. }
  1318. return;
  1319. }
  1320. }
  1321. break;
  1322. }
  1323. /* Recursively scan the operands of this expression. */
  1324. {
  1325. register char *fmt = GET_RTX_FORMAT (code);
  1326. register int i;
  1327. for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1328. {
  1329. if (fmt[i] == 'e')
  1330. {
  1331. /* Tail recursive case: save a function call level. */
  1332. if (i == 0)
  1333. {
  1334. x = XEXP (x, 0);
  1335. goto retry;
  1336. }
  1337. mark_used_regs (needed, live, XEXP (x, i), final, insn);
  1338. }
  1339. if (fmt[i] == 'E')
  1340. {
  1341. register int j;
  1342. for (j = 0; j < XVECLEN (x, i); j++)
  1343. mark_used_regs (needed, live, XVECEXP (x, i, j), final, insn);
  1344. }
  1345. }
  1346. }
  1347. }
  1348. /* Nonzero if X contains any volatile memory references
  1349. or volatile ASM_OPERANDS expressions. */
  1350. static int
  1351. volatile_refs_p (x)
  1352. rtx x;
  1353. {
  1354. register RTX_CODE code;
  1355. code = GET_CODE (x);
  1356. switch (code)
  1357. {
  1358. case LABEL_REF:
  1359. case SYMBOL_REF:
  1360. case CONST_INT:
  1361. case CONST:
  1362. case CC0:
  1363. case PC:
  1364. case CLOBBER:
  1365. case REG:
  1366. return 0;
  1367. case CALL:
  1368. return 1;
  1369. case MEM:
  1370. case ASM_OPERANDS:
  1371. if (x->volatil)
  1372. return 1;
  1373. }
  1374. /* Recursively scan the operands of this expression. */
  1375. {
  1376. register char *fmt = GET_RTX_FORMAT (code);
  1377. register int i;
  1378. for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1379. {
  1380. if (fmt[i] == 'e')
  1381. {
  1382. if (volatile_refs_p (XEXP (x, i)))
  1383. return 1;
  1384. }
  1385. if (fmt[i] == 'E')
  1386. {
  1387. register int j;
  1388. for (j = 0; j < XVECLEN (x, i); j++)
  1389. if (volatile_refs_p (XVECEXP (x, i, j)))
  1390. return 1;
  1391. }
  1392. }
  1393. }
  1394. return 0;
  1395. }
  1396. #ifdef AUTO_INC_DEC
  1397. static int
  1398. try_pre_increment_1 (insn)
  1399. rtx insn;
  1400. {
  1401. /* Find the next use of this reg. If in same basic block,
  1402. make it do pre-increment or pre-decrement if appropriate. */
  1403. rtx x = PATTERN (insn);
  1404. int amount = ((GET_CODE (SET_SRC (x)) == PLUS ? 1 : -1)
  1405. * INTVAL (XEXP (SET_SRC (x), 1)));
  1406. int regno = REGNO (SET_DEST (x));
  1407. rtx y = reg_next_use[regno];
  1408. if (y != 0
  1409. && BLOCK_NUM (y) == BLOCK_NUM (insn)
  1410. && try_pre_increment (y, SET_DEST (PATTERN (insn)),
  1411. amount))
  1412. {
  1413. /* We have found a suitable auto-increment
  1414. and already changed insn Y to do it.
  1415. So flush this increment-instruction. */
  1416. PUT_CODE (insn, NOTE);
  1417. NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
  1418. NOTE_SOURCE_FILE (insn) = 0;
  1419. /* Count a reference to this reg for the increment
  1420. insn we are deleting. When a reg is incremented.
  1421. spilling it is worse, so we want to make that
  1422. less likely. */
  1423. reg_n_refs[regno] += loop_depth;
  1424. reg_n_sets[regno]++;
  1425. return 1;
  1426. }
  1427. return 0;
  1428. }
  1429. /* Try to change INSN so that it does pre-increment or pre-decrement
  1430. addressing on register REG in order to add AMOUNT to REG.
  1431. AMOUNT is negative for pre-decrement.
  1432. Returns 1 if the change could be made.
  1433. This checks all about the validity of the result of modifying INSN. */
  1434. static int
  1435. try_pre_increment (insn, reg, amount)
  1436. rtx insn, reg;
  1437. int amount;
  1438. {
  1439. register rtx use;
  1440. /* Nonzero if we can try to make a pre-increment or pre-decrement.
  1441. For example, addl $4,r1; movl (r1),... can become movl +(r1),... */
  1442. int pre_ok = 0;
  1443. /* Nonzero if we can try to make a post-increment or post-decrement.
  1444. For example, addl $4,r1; movl -4(r1),... can become movl (r1)+,...
  1445. It is possible for both PRE_OK and POST_OK to be nonzero if the machine
  1446. supports both pre-inc and post-inc, or both pre-dec and post-dec. */
  1447. int post_ok = 0;
  1448. /* Nonzero if the opportunity actually requires post-inc or post-dec. */
  1449. int do_post = 0;
  1450. /* From the sign of increment, see which possibilities are conceivable
  1451. on this target machine. */
  1452. #ifdef HAVE_PRE_INCREMENT
  1453. if (amount > 0)
  1454. pre_ok = 1;
  1455. #endif
  1456. #ifdef HAVE_POST_INCREMENT
  1457. if (amount > 0)
  1458. post_ok = 1;
  1459. #endif
  1460. #ifdef HAVE_PRE_DECREMENT
  1461. if (amount < 0)
  1462. pre_ok = 1;
  1463. #endif
  1464. #ifdef HAVE_POST_DECREMENT
  1465. if (amount < 0)
  1466. post_ok = 1;
  1467. #endif
  1468. if (! (pre_ok || post_ok))
  1469. return 0;
  1470. /* It is not safe to add a side effect to a jump insn
  1471. because if the incremented register is spilled and must be reloaded
  1472. there would be no way to store the incremented value back in memory. */
  1473. if (GET_CODE (insn) == JUMP_INSN)
  1474. return 0;
  1475. use = 0;
  1476. if (pre_ok)
  1477. use = find_use_as_address (PATTERN (insn), reg, 0);
  1478. if (post_ok && (use == 0 || use == (rtx) 1))
  1479. {
  1480. use = find_use_as_address (PATTERN (insn), reg, -amount);
  1481. do_post = 1;
  1482. }
  1483. if (use == 0 || use == (rtx) 1)
  1484. return 0;
  1485. if (GET_MODE_SIZE (GET_MODE (use)) != (amount > 0 ? amount : - amount))
  1486. return 0;
  1487. XEXP (use, 0) = gen_rtx (amount > 0
  1488. ? (do_post ? POST_INC : PRE_INC)
  1489. : (do_post ? POST_DEC : PRE_DEC),
  1490. Pmode, reg);
  1491. /* Record that this insn now has an implicit side effect on X. */
  1492. REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_INC, reg, REG_NOTES (insn));
  1493. return 1;
  1494. }
  1495. #endif /* AUTO_INC_DEC */
  1496. /* Find the place in the rtx X where REG is used as a memory address.
  1497. Return the MEM rtx that so uses it.
  1498. If PLUSCONST is nonzero, search instead for a memory address equivalent to
  1499. (plus REG (const_int PLUSCONST)).
  1500. If such an address does not appear, return 0.
  1501. If REG appears more than once, or is used other than in such an address,
  1502. return (rtx)1. */
  1503. static rtx
  1504. find_use_as_address (x, reg, plusconst)
  1505. register rtx x;
  1506. rtx reg;
  1507. int plusconst;
  1508. {
  1509. enum rtx_code code = GET_CODE (x);
  1510. char *fmt = GET_RTX_FORMAT (code);
  1511. register int i;
  1512. register rtx value = 0;
  1513. register rtx tem;
  1514. if (code == MEM && XEXP (x, 0) == reg && plusconst == 0)
  1515. return x;
  1516. if (code == MEM && GET_CODE (XEXP (x, 0)) == PLUS
  1517. && XEXP (XEXP (x, 0), 0) == reg
  1518. && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT
  1519. && INTVAL (XEXP (XEXP (x, 0), 1)) == plusconst)
  1520. return x;
  1521. if (code == SIGN_EXTRACT || code == ZERO_EXTRACT)
  1522. {
  1523. /* If REG occurs inside a MEM used in a bit-field reference,
  1524. that is unacceptable. */
  1525. if (find_use_as_address (XEXP (x, 0), reg, 0) != 0)
  1526. return (rtx) 1;
  1527. }
  1528. if (x == reg)
  1529. return (rtx) 1;
  1530. for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
  1531. {
  1532. if (fmt[i] == 'e')
  1533. {
  1534. tem = find_use_as_address (XEXP (x, i), reg, plusconst);
  1535. if (value == 0)
  1536. value = tem;
  1537. else if (tem != 0)
  1538. return (rtx) 1;
  1539. }
  1540. if (fmt[i] == 'E')
  1541. {
  1542. register int j;
  1543. for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  1544. {
  1545. tem = find_use_as_address (XVECEXP (x, i, j), reg, plusconst);
  1546. if (value == 0)
  1547. value = tem;
  1548. else if (tem != 0)
  1549. return (rtx) 1;
  1550. }
  1551. }
  1552. }
  1553. return value;
  1554. }
  1555. /* Write information about registers and basic blocks into FILE.
  1556. This is part of making a debugging dump. */
  1557. void
  1558. dump_flow_info (file)
  1559. FILE *file;
  1560. {
  1561. register int i;
  1562. static char *reg_class_names[] = REG_CLASS_NAMES;
  1563. fprintf (file, "%d registers.\n", max_regno);
  1564. for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
  1565. if (reg_n_refs[i])
  1566. {
  1567. enum reg_class class;
  1568. fprintf (file, "\nRegister %d used %d times across %d insns",
  1569. i, reg_n_refs[i], reg_live_length[i]);
  1570. if (reg_basic_block[i] >= 0)
  1571. fprintf (file, " in block %d", reg_basic_block[i]);
  1572. if (reg_n_deaths[i] != 1)
  1573. fprintf (file, "; dies in %d places", reg_n_deaths[i]);
  1574. if (reg_crosses_call[i])
  1575. fprintf (file, "; crosses calls");
  1576. if (PSEUDO_REGNO_BYTES (i) != UNITS_PER_WORD)
  1577. fprintf (file, "; %d bytes", PSEUDO_REGNO_BYTES (i));
  1578. class = reg_preferred_class (i);
  1579. if (class != GENERAL_REGS)
  1580. {
  1581. if (reg_preferred_or_nothing (i))
  1582. fprintf (file, "; %s or none", reg_class_names[(int) class]);
  1583. else
  1584. fprintf (file, "; pref %s", reg_class_names[(int) class]);
  1585. }
  1586. if (REGNO_POINTER_FLAG (i))
  1587. fprintf (file, "; pointer");
  1588. fprintf (file, ".\n");
  1589. }
  1590. fprintf (file, "\n%d basic blocks.\n", n_basic_blocks);
  1591. for (i = 0; i < n_basic_blocks; i++)
  1592. {
  1593. register rtx head, jump;
  1594. register int regno;
  1595. fprintf (file, "\nBasic block %d: first insn %d, last %d.\n",
  1596. i,
  1597. INSN_UID (basic_block_head[i]),
  1598. INSN_UID (basic_block_end[i]));
  1599. /* The control flow graph's storage is freed
  1600. now when flow_analysis returns.
  1601. Don't try to print it if it is gone. */
  1602. if (basic_block_drops_in)
  1603. {
  1604. fprintf (file, "Reached from blocks: ");
  1605. head = basic_block_head[i];
  1606. if (GET_CODE (head) == CODE_LABEL)
  1607. for (jump = LABEL_REFS (head);
  1608. jump != head;
  1609. jump = LABEL_NEXTREF (jump))
  1610. {
  1611. register from_block = BLOCK_NUM (CONTAINING_INSN (jump));
  1612. fprintf (file, " %d", from_block);
  1613. }
  1614. if (basic_block_drops_in[i])
  1615. fprintf (file, " previous");
  1616. }
  1617. fprintf (file, "\nRegisters live at start:");
  1618. for (regno = 0; regno < max_regno; regno++)
  1619. {
  1620. register int offset = regno / REGSET_ELT_BITS;
  1621. register int bit = 1 << (regno % REGSET_ELT_BITS);
  1622. if (basic_block_live_at_start[i][offset] & bit)
  1623. fprintf (file, " %d", regno);
  1624. }
  1625. fprintf (file, "\n");
  1626. }
  1627. fprintf (file, "\n");
  1628. }