Fwd: [tree, fortran] Patch: make --enable-mapped-location build

Andrew Pinski pinskia@gmail.com
Sat Aug 25 01:52:00 GMT 2007


Tom forgot to CC the fortran mailing list also.

-- Pinski

---------- Forwarded message ----------
From: Tom Tromey <tromey@redhat.com>
Date: Aug 24, 2007 1:24 PM
Subject: [tree, fortran] Patch: make --enable-mapped-location build
To: Gcc Patch List <gcc-patches@gcc.gnu.org>


This patch makes --enable-mapped-location build again.  The test
results aren't great, but of course there's no
--enable-mapped-location baseline to test against, and I didn't look
into them yet.

I changed the meaning of EXPR_FILENAME and EXPR_LINENO a little.  They
can only be used as lvalues when --disable-mapped-location.  I think
this is ok because with mapped locations this use doesn't make sense,
and plus this is more or less already the case in the code.

Bootstrapped without --enable-mapped-location and regtested on x86 FC6.

Ok?

Tom

Index: ChangeLog
from  Tom Tromey  <tromey@redhat.com>

        * tree.h (EXPR_FILENAME): Separated USE_MAPPED_LOCATION variant.
        (EXPR_LINENO): Likewise.
        (expr_locus, set_expr_locus, expr_filename, expr_lineno): Declare
        separately for USE_MAPPED_LOCATION.
        * tree.c (expr_filename): Separated USE_MAPPED_LOCATION variant.
        Changed return type.
        (expr_lineno): Likewise.
        * gimplify.c (tree_to_gimple_tuple): Use SET_EXPR_LOCUS.
        * cfgexpand.c (expand_gimple_cond_expr): Use location_from_locus.
        (expand_gimple_basic_block): Likewise.
        * input.h (location_from_locus): New macro.
        * final.c (final_scan_insn): Use expanded_location.

Index: fortran/ChangeLog
from  Tom Tromey  <tromey@redhat.com>

        * scanner.c (gfc_next_char_literal): Use gfc_linebuf_linenum.
        * gfortran.h (gfc_linebuf_linenum): New macro.

Index: tree.c
===================================================================
--- tree.c      (revision 127744)
+++ tree.c      (working copy)
@@ -3509,8 +3509,10 @@
 {
 #ifdef USE_MAPPED_LOCATION
   if (GIMPLE_STMT_P (node))
-    return &GIMPLE_STMT_LOCUS (node);
-  return EXPR_P (node) ? &node->exp.locus : (location_t *) NULL;
+    return (source_location *) CONST_CAST (&GIMPLE_STMT_LOCUS (node));
+  return (source_location *) CONST_CAST (EXPR_P (node)
+                                        ? &node->exp.locus
+                                        : (location_t *) NULL);
 #else
   if (GIMPLE_STMT_P (node))
     return GIMPLE_STMT_LOCUS (node);
@@ -3552,33 +3554,44 @@
 #endif
 }

-const char **
+#ifdef USE_MAPPED_LOCATION
+
+const char *
 expr_filename (const_tree node)
 {
-#ifdef USE_MAPPED_LOCATION
   if (GIMPLE_STMT_P (node))
-    return &LOCATION_FILE (GIMPLE_STMT_LOCUS (node));
-  return &LOCATION_FILE (EXPR_CHECK (node)->exp.locus);
+    return LOCATION_FILE (GIMPLE_STMT_LOCUS (node));
+  return LOCATION_FILE (EXPR_CHECK (node)->exp.locus);
+}
+
+int
+expr_lineno (const_tree node)
+{
+  if (GIMPLE_STMT_P (node))
+    return LOCATION_LINE (GIMPLE_STMT_LOCUS (node));
+  return LOCATION_LINE (EXPR_CHECK (node)->exp.locus);
+}
+
 #else
+
+const char **
+expr_filename (const_tree node)
+{
   if (GIMPLE_STMT_P (node))
     return &GIMPLE_STMT_LOCUS (node)->file;
   return &(EXPR_CHECK (node)->exp.locus->file);
-#endif
 }

 int *
 expr_lineno (const_tree node)
 {
-#ifdef USE_MAPPED_LOCATION
   if (GIMPLE_STMT_P (node))
-    return &LOCATION_LINE (GIMPLE_STMT_LOCUS (node));
-  return &LOCATION_LINE (EXPR_CHECK (node)->exp.locus);
-#else
-  if (GIMPLE_STMT_P (node))
     return &GIMPLE_STMT_LOCUS (node)->line;
   return &EXPR_CHECK (node)->exp.locus->line;
+}
+
 #endif
-}
+

 /* Return a declaration like DDECL except that its DECL_ATTRIBUTES
    is ATTRIBUTE.  */
Index: tree.h
===================================================================
--- tree.h      (revision 127744)
+++ tree.h      (working copy)
@@ -1591,8 +1591,16 @@
 #define EXPR_HAS_LOCATION(NODE) expr_has_location ((NODE))
 #define EXPR_LOCUS(NODE) expr_locus ((NODE))
 #define SET_EXPR_LOCUS(NODE, FROM) set_expr_locus ((NODE), (FROM))
+
+#ifdef USE_MAPPED_LOCATION
+#define EXPR_FILENAME(NODE) (expr_filename ((NODE)))
+#define EXPR_LINENO(NODE) (expr_lineno ((NODE)))
+#else
+/* Note that these can only be used as lvalues when
+   #!USE_MAPPED_LOCATION.  */
 #define EXPR_FILENAME(NODE) *(expr_filename ((NODE)))
 #define EXPR_LINENO(NODE) *(expr_lineno ((NODE)))
+#endif

 /* True if a tree is an expression or statement that can have a
    location.  */
@@ -4824,22 +4832,19 @@
 extern location_t expr_location (const_tree);
 extern void set_expr_location (tree, location_t);
 extern bool expr_has_location (const_tree);
-extern
+
 #ifdef USE_MAPPED_LOCATION
-source_location *
+extern source_locus *expr_locus (const_tree);
+extern void set_expr_locus (tree, source_location *);
+extern const char *expr_filename (const_tree);
+extern int expr_lineno (const_tree);
 #else
-source_locus
-#endif
-expr_locus (const_tree);
-extern void set_expr_locus (tree,
-#ifdef USE_MAPPED_LOCATION
-                            source_location *loc
-#else
-                           source_locus loc
-#endif
-                          );
+extern source_locus expr_locus (const_tree);
+extern void set_expr_locus (tree, source_locus loc);
 extern const char **expr_filename (const_tree);
 extern int *expr_lineno (const_tree);
+#endif
+
 extern tree *tree_block (tree);
 extern tree *generic_tree_operand (tree, int);
 extern tree *generic_tree_type (tree);
Index: final.c
===================================================================
--- final.c     (revision 127744)
+++ final.c     (working copy)
@@ -2092,7 +2092,7 @@

            if (string[0])
              {
-               location_t loc;
+               expanded_location loc;

                if (! app_on)
                  {
@@ -2100,7 +2100,7 @@
                    app_on = 1;
                  }
 #ifdef USE_MAPPED_LOCATION
-               loc = ASM_INPUT_SOURCE_LOCATION (body);
+               loc = expand_location (ASM_INPUT_SOURCE_LOCATION (body));
 #else
                loc.file = ASM_INPUT_SOURCE_FILE (body);
                loc.line = ASM_INPUT_SOURCE_LINE (body);
@@ -2124,6 +2124,7 @@
            rtx *ops = alloca (noperands * sizeof (rtx));
            const char *string;
            location_t loc;
+           expanded_location expanded;

            /* There's no telling what that did to the condition codes.  */
            CC_STATUS_INIT;
@@ -2133,6 +2134,7 @@
            /* Inhibit dieing on what would otherwise be compiler bugs.  */
            insn_noperands = noperands;
            this_is_asm_operands = insn;
+           expanded = expand_location (loc);

 #ifdef FINAL_PRESCAN_INSN
            FINAL_PRESCAN_INSN (insn, ops, insn_noperands);
@@ -2146,12 +2148,12 @@
                    fputs (ASM_APP_ON, file);
                    app_on = 1;
                  }
-               if (loc.file && loc.line)
+               if (expanded.file && expanded.line)
                  fprintf (asm_out_file, "%s %i \"%s\" 1\n",
-                          ASM_COMMENT_START, loc.line, loc.file);
+                          ASM_COMMENT_START, expanded.line, expanded.file);
                output_asm_insn (string, ops);
 #if HAVE_AS_LINE_ZERO
-               if (loc.file && loc.line)
+               if (expanded.file && expanded.line)
                  fprintf (asm_out_file, "%s 0 \"\" 2\n", ASM_COMMENT_START);
 #endif
              }
Index: input.h
===================================================================
--- input.h     (revision 127744)
+++ input.h     (working copy)
@@ -50,6 +50,8 @@
 typedef source_location location_t; /* deprecated typedef */
 typedef source_location source_locus; /* to be removed */

+#define location_from_locus(LOCUS) (LOCUS)
+
 #else /* ! USE_MAPPED_LOCATION */

 struct location_s GTY(())
@@ -69,6 +71,8 @@
 extern location_t unknown_location;
 #define UNKNOWN_LOCATION unknown_location

+#define location_from_locus(LOCUS) (* (LOCUS))
+
 #endif /* ! USE_MAPPED_LOCATION */

 struct file_stack
Index: gimplify.c
===================================================================
--- gimplify.c  (revision 127744)
+++ gimplify.c  (working copy)
@@ -3569,7 +3569,7 @@
         /* The set to base above overwrites the CODE.  */
         TREE_SET_CODE ((tree) gs, GIMPLE_MODIFY_STMT);

-        gs->locus = EXPR_LOCUS (*tp);
+       SET_EXPR_LOCUS ((tree) gs, EXPR_LOCUS (*tp));
         gs->operands[0] = TREE_OPERAND (*tp, 0);
         gs->operands[1] = TREE_OPERAND (*tp, 1);
         gs->block = TREE_BLOCK (*tp);
Index: cfgexpand.c
===================================================================
--- cfgexpand.c (revision 127744)
+++ cfgexpand.c (working copy)
@@ -1312,7 +1312,7 @@
       add_reg_br_prob_note (last, true_edge->probability);
       maybe_dump_rtl_for_tree_stmt (stmt, last);
       if (true_edge->goto_locus)
-       set_curr_insn_source_location (*true_edge->goto_locus);
+       set_curr_insn_source_location (location_from_locus
(true_edge->goto_locus));
       false_edge->flags |= EDGE_FALLTHRU;
       return NULL;
     }
@@ -1322,7 +1322,7 @@
       add_reg_br_prob_note (last, false_edge->probability);
       maybe_dump_rtl_for_tree_stmt (stmt, last);
       if (false_edge->goto_locus)
-       set_curr_insn_source_location (*false_edge->goto_locus);
+       set_curr_insn_source_location (location_from_locus
(false_edge->goto_locus));
       true_edge->flags |= EDGE_FALLTHRU;
       return NULL;
     }
@@ -1353,7 +1353,7 @@
   maybe_dump_rtl_for_tree_stmt (stmt, last2);

   if (false_edge->goto_locus)
-    set_curr_insn_source_location (*false_edge->goto_locus);
+    set_curr_insn_source_location (location_from_locus
(false_edge->goto_locus));

   return new_bb;
 }
@@ -1620,7 +1620,7 @@
     {
       emit_jump (label_rtx_for_bb (e->dest));
       if (e->goto_locus)
-        set_curr_insn_source_location (*e->goto_locus);
+        set_curr_insn_source_location (location_from_locus (e->goto_locus));
       e->flags &= ~EDGE_FALLTHRU;
     }

Index: fortran/gfortran.h
===================================================================
--- fortran/gfortran.h  (revision 127744)
+++ fortran/gfortran.h  (working copy)
@@ -746,6 +746,12 @@

 #define gfc_linebuf_header_size (offsetof (gfc_linebuf, line))

+#ifdef USE_MAPPED_LOCATION
+#define gfc_linebuf_linenum(LBUF) (LOCATION_LINE ((LBUF)->location))
+#else
+#define gfc_linebuf_linenum(LBUF) ((LBUF)->linenum)
+#endif
+
 typedef struct
 {
   char *nextc;
Index: fortran/scanner.c
===================================================================
--- fortran/scanner.c   (revision 127744)
+++ fortran/scanner.c   (working copy)
@@ -710,7 +710,7 @@
       /* We've got a continuation line.  If we are on the very next line after
         the last continuation, increment the continuation line count and
         check whether the limit has been exceeded.  */
-      if (gfc_current_locus.lb->linenum == continue_line + 1)
+      if (gfc_linebuf_linenum (gfc_current_locus.lb) == continue_line + 1)
        {
          if (++continue_count == gfc_option.max_continue_free)
            {
@@ -719,7 +719,7 @@
                             "statement at %C", gfc_option.max_continue_free);
            }
        }
-      continue_line = gfc_current_locus.lb->linenum;
+      continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);

       /* Now find where it continues. First eat any comment lines.  */
       openmp_cond_flag = skip_free_comments ();
@@ -831,7 +831,7 @@
       /* We've got a continuation line.  If we are on the very next line after
         the last continuation, increment the continuation line count and
         check whether the limit has been exceeded.  */
-      if (gfc_current_locus.lb->linenum == continue_line + 1)
+      if (gfc_linebuf_linenum (gfc_current_locus.lb) == continue_line + 1)
        {
          if (++continue_count == gfc_option.max_continue_fixed)
            {
@@ -842,8 +842,8 @@
            }
        }

-      if (continue_line < gfc_current_locus.lb->linenum)
-       continue_line = gfc_current_locus.lb->linenum;
+      if (continue_line < gfc_linebuf_linenum (gfc_current_locus.lb))
+       continue_line = gfc_linebuf_linenum (gfc_current_locus.lb);
     }

   /* Ready to read first character of continuation line, which might



More information about the Fortran mailing list