@@ -177,34 +177,13 @@ extern void dump_insn_1 (insn_t, int);
extern void dump_insn (insn_t);
extern void debug_insn (insn_t);
-extern void sel_prepare_string_for_dot_label (char *);
-
/* When this flag is on, we are dumping to the .dot file.
When it is off, we are dumping to log. */
extern bool sched_dump_to_dot_p;
-
-/* This macro acts like printf but dumps information to the .dot file.
- Used when dumping control flow. */
-#define sel_print_to_dot(...) \
- do { \
- int __j = 1 + 2 * snprintf (NULL, 0, __VA_ARGS__); \
- char *__s = XALLOCAVEC (char, __j); \
- snprintf (__s, __j, __VA_ARGS__); \
- sel_prepare_string_for_dot_label (__s); \
- fprintf (sched_dump, "%s", __s); \
- } while (0)
-
-/* This macro acts like printf but dumps to the sched_dump file. */
-#define sel_print(...) \
- do { \
- if (sched_dump_to_dot_p) \
- sel_print_to_dot (__VA_ARGS__); \
- else \
- fprintf (sched_dump, __VA_ARGS__); \
- } while (0)
/* Functions from sel-sched-dump.c. */
+extern void sel_print (const char *fmt, ...) ATTRIBUTE_PRINTF_1;
extern const char * sel_print_insn (const_rtx, int);
extern void free_sel_dump_data (void);
@@ -566,7 +566,7 @@ replace_str_in_buf (char *buf, const cha
}
/* Replace characters in BUF that have special meaning in .dot file. */
-void
+static void
sel_prepare_string_for_dot_label (char *buf)
{
static char specials_from[7][2] = { "<", ">", "{", "|", "}", "\"",
@@ -579,6 +579,28 @@ sel_prepare_string_for_dot_label (char *
replace_str_in_buf (buf, specials_from[i], specials_to[i]);
}
+/* This function acts like printf but dumps to the sched_dump file. */
+void
+sel_print (const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ if (sched_dump_to_dot_p)
+ {
+ char *message;
+ if (vasprintf (&message, fmt, ap) >= 0 && message != NULL)
+ {
+ message = (char *) xrealloc (message, 2 * strlen (message) + 1);
+ sel_prepare_string_for_dot_label (message);
+ fprintf (sched_dump, "%s", message);
+ free (message);
+ }
+ }
+ else
+ vfprintf (sched_dump, fmt, ap);
+ va_end (ap);
+}
+
/* Dump INSN with FLAGS. */
static void
sel_dump_cfg_insn (insn_t insn, int flags)