Advertisement
Guest User

Untitled

a guest
Dec 31st, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.67 KB | None | 0 0
  1. diff -pruN gcc-4.6.2-clean/gcc/cgraph.c gcc-4.6.2-cdepn/gcc/cgraph.c
  2. --- gcc-4.6.2-clean/gcc/cgraph.c 2011-06-06 14:16:35.000000000 -0300
  3. +++ gcc-4.6.2-cdepn/gcc/cgraph.c 2012-05-19 19:04:03.470561109 -0300
  4. @@ -990,7 +990,8 @@ initialize_inline_failed (struct cgraph_
  5.  
  6. static struct cgraph_edge *
  7. cgraph_create_edge_1 (struct cgraph_node *caller, struct cgraph_node *callee,
  8. - gimple call_stmt, gcov_type count, int freq, int nest)
  9. + gimple call_stmt, gcov_type count, int freq,
  10. + int nest, location_t call_location)
  11. {
  12. struct cgraph_edge *edge;
  13.  
  14. @@ -1043,6 +1044,7 @@ cgraph_create_edge_1 (struct cgraph_node
  15.  
  16. edge->indirect_info = NULL;
  17. edge->indirect_inlining_edge = 0;
  18. + edge->call_location = call_location;
  19.  
  20. return edge;
  21. }
  22. @@ -1054,7 +1056,8 @@ cgraph_create_edge (struct cgraph_node *
  23. gimple call_stmt, gcov_type count, int freq, int nest)
  24. {
  25. struct cgraph_edge *edge = cgraph_create_edge_1 (caller, callee, call_stmt,
  26. - count, freq, nest);
  27. + count, freq,
  28. + nest, input_location);
  29.  
  30. edge->indirect_unknown_callee = 0;
  31. initialize_inline_failed (edge);
  32. @@ -1093,7 +1096,8 @@ cgraph_create_indirect_edge (struct cgra
  33. gcov_type count, int freq, int nest)
  34. {
  35. struct cgraph_edge *edge = cgraph_create_edge_1 (caller, NULL, call_stmt,
  36. - count, freq, nest);
  37. + count, freq,
  38. + nest, input_location);
  39.  
  40. edge->indirect_unknown_callee = 1;
  41. initialize_inline_failed (edge);
  42. diff -pruN gcc-4.6.2-clean/gcc/cgraph.h gcc-4.6.2-cdepn/gcc/cgraph.h
  43. --- gcc-4.6.2-clean/gcc/cgraph.h 2011-03-04 15:49:23.000000000 -0300
  44. +++ gcc-4.6.2-cdepn/gcc/cgraph.h 2012-05-19 19:04:03.338557458 -0300
  45. @@ -443,6 +443,9 @@ struct GTY((chain_next ("%h.next_caller"
  46. unsigned int call_stmt_cannot_inline_p : 1;
  47. /* Can this call throw externally? */
  48. unsigned int can_throw_external : 1;
  49. +
  50. + /* CodeViz: Location the call occurred at */
  51. + location_t call_location;
  52. };
  53.  
  54. #define CGRAPH_FREQ_BASE 1000
  55. diff -pruN gcc-4.6.2-clean/gcc/cgraphunit.c gcc-4.6.2-cdepn/gcc/cgraphunit.c
  56. --- gcc-4.6.2-clean/gcc/cgraphunit.c 2011-03-11 10:27:26.000000000 -0300
  57. +++ gcc-4.6.2-cdepn/gcc/cgraphunit.c 2012-05-19 19:04:03.070550009 -0300
  58. @@ -772,12 +772,17 @@ cgraph_output_pending_asms (void)
  59. cgraph_asm_nodes = NULL;
  60. }
  61.  
  62. +extern int cdepn_dump;
  63. /* Analyze the function scheduled to be output. */
  64. static void
  65. cgraph_analyze_function (struct cgraph_node *node)
  66. {
  67. tree save = current_function_decl;
  68. tree decl = node->decl;
  69. + tree thisTree, calleeTree;
  70. + FILE *fnref_f;
  71. + struct cgraph_edge *calleeEdge;
  72. + expanded_location xloc;
  73.  
  74. current_function_decl = decl;
  75. push_cfun (DECL_STRUCT_FUNCTION (decl));
  76. @@ -802,10 +807,39 @@ cgraph_analyze_function (struct cgraph_n
  77.  
  78. pop_cfun ();
  79. current_function_decl = save;
  80. +
  81. + if (cdepn_dump) {
  82. + /* CodeViz: Output information on this node */
  83. + thisTree = node->decl;
  84. + if ((fnref_f = cdepn_open(NULL)))
  85. + {
  86. + fprintf(fnref_f,"F {%s} {%s:%d}\n",
  87. + lang_hooks.decl_printable_name (thisTree, 2),
  88. + DECL_SOURCE_FILE (thisTree), DECL_SOURCE_LINE (thisTree));
  89. +
  90. + }
  91. +
  92. + /* CodeViz: Output information on all functions this node calls */
  93. + for (calleeEdge = node->callees; calleeEdge;
  94. + calleeEdge = calleeEdge->next_callee) {
  95. + calleeTree = calleeEdge->callee->decl;
  96. + if (thisTree != NULL &&
  97. + calleeTree != NULL &&
  98. + (fnref_f = cdepn_open(NULL)) != NULL)
  99. + {
  100. + xloc = expand_location(calleeEdge->call_location);
  101. + fprintf(fnref_f, "C {%s} {%s:%d} {%s}\n",
  102. + lang_hooks.decl_printable_name (thisTree, 2),
  103. + xloc.file, xloc.line,
  104. + lang_hooks.decl_printable_name (calleeTree, 2));
  105. + }
  106. + else
  107. + printf("CODEVIZ: Unexpected NULL encountered\n");
  108. + }
  109. + }
  110. }
  111.  
  112. /* Process attributes common for vars and functions. */
  113. -
  114. static void
  115. process_common_attributes (tree decl)
  116. {
  117. diff -pruN gcc-4.6.2-clean/gcc/toplev.c gcc-4.6.2-cdepn/gcc/toplev.c
  118. --- gcc-4.6.2-clean/gcc/toplev.c 2011-02-03 06:29:03.000000000 -0200
  119. +++ gcc-4.6.2-cdepn/gcc/toplev.c 2012-05-19 19:04:03.070550009 -0300
  120. @@ -1907,6 +1907,53 @@ do_compile (void)
  121. timevar_print (stderr);
  122. }
  123.  
  124. +/*
  125. + * codeviz: Open the cdepn file. This is called with a filename by main()
  126. + * and with just NULL for every other instance to return just the handle
  127. + */
  128. +FILE *g_fnref_f = NULL;
  129. +char cdepnfile[256] = "--wonthappen--";
  130. +int cdepn_dump = 0;
  131. +
  132. +FILE *cdepn_open(char *filename) {
  133. + struct stat cdepnstat;
  134. + int errval;
  135. + time_t currtime;
  136. + if (filename && g_fnref_f == NULL) {
  137. + strcpy(cdepnfile, filename);
  138. + strcat(cdepnfile, ".cdepn");
  139. +
  140. + /*
  141. + * Decide whether to open write or append. There appears to be a weird
  142. + * bug that decides to open the file twice, overwriting all the cdepn
  143. + * information put there before
  144. + */
  145. + errval = stat(cdepnfile, &cdepnstat);
  146. + currtime = time(NULL);
  147. + if (errval == -1 || currtime - cdepnstat.st_mtime > 5) {
  148. + g_fnref_f = fopen(cdepnfile, "w");
  149. + fprintf(stderr, "opened dep file %s\n",cdepnfile);
  150. + } else {
  151. + g_fnref_f = fopen(cdepnfile, "a");
  152. + fprintf(stderr, "append dep file %s\n",cdepnfile);
  153. + }
  154. +
  155. + fflush(stderr);
  156. + }
  157. +
  158. + return g_fnref_f;
  159. +}
  160. +
  161. +void cdepn_close(void) {
  162. + if (g_fnref_f) fclose(g_fnref_f);
  163. + g_fnref_f = NULL;
  164. +}
  165. +
  166. +int cdepn_checkprint(void *fncheck) {
  167. + return 1;
  168. + /*return (void *)fncheck == (void *)decl_name; */
  169. +}
  170. +
  171. /* Entry point of cc1, cc1plus, jc1, f771, etc.
  172. Exit code is FATAL_EXIT_CODE if can't open files or if there were
  173. any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
  174. @@ -1959,8 +2006,14 @@ toplev_main (int argc, char **argv)
  175. print_plugins_help (stderr, "");
  176.  
  177. /* Exit early if we can (e.g. -help). */
  178. - if (!exit_after_options)
  179. + if (!exit_after_options) {
  180. + cdepn_dump = ((getenv("CDEPN_SUPPRESS")) ? 0 : 1);
  181. + if (cdepn_dump)
  182. + cdepn_open(main_input_filename);
  183. do_compile ();
  184. + if (cdepn_dump)
  185. + cdepn_close();
  186. + }
  187.  
  188. if (warningcount || errorcount)
  189. print_ignored_options ();
  190. diff -pruN gcc-4.6.2-clean/gcc/tree.h gcc-4.6.2-cdepn/gcc/tree.h
  191. --- gcc-4.6.2-clean/gcc/tree.h 2011-10-06 16:57:52.000000000 -0300
  192. +++ gcc-4.6.2-cdepn/gcc/tree.h 2012-05-19 19:04:03.594564570 -0300
  193. @@ -5724,4 +5724,11 @@ is_lang_specific (tree t)
  194. /* In gimple-low.c. */
  195. extern bool block_may_fallthru (const_tree);
  196.  
  197. +/*
  198. + * CodeViz functions to get the output file handle for cdepn files
  199. + */
  200. +FILE *cdepn_open(char *filename);
  201. +void cdepn_close(void);
  202. +int cdepn_checkprint(void *fncheck);
  203. +
  204. #endif /* GCC_TREE_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement