]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/final.c
aclocal.m4: Substitute INSTALL.
[thirdparty/gcc.git] / gcc / final.c
index 0f2afd97020c0744660f7cef940535070b42d3a5..624e2113f19e675e29cf26a24310159f4695c8a1 100644 (file)
@@ -734,6 +734,8 @@ shorten_branches (first)
       if (GET_CODE (insn) == NOTE || GET_CODE (insn) == BARRIER
          || GET_CODE (insn) == CODE_LABEL)
        continue;
+      if (INSN_DELETED_P (insn))
+       continue;
 
       body = PATTERN (insn);
       if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
@@ -746,9 +748,11 @@ shorten_branches (first)
          insn_lengths[uid] = (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC)
                               * GET_MODE_SIZE (GET_MODE (body)));
 
-         /* Account for possible alignment.  */
-         insn_lengths[uid]
-           += unitsize - (insn_current_address & (unitsize - 1));
+         /* We don't know what address the ADDR_VEC/ADDR_DIFF_VEC will end
+            up at after branch shortening.  As a result, it is impossible
+            to determine how much padding we need at this point.  Therefore,
+            assume worst possible alignment.  */
+         insn_lengths[uid] += unitsize - 1;
 #else
          ;
 #endif
@@ -951,9 +955,9 @@ final_start_function (first, file, optimize)
     last_linenum = high_block_linenum = high_function_linenum
       = NOTE_LINE_NUMBER (first);
 
-#ifdef DWARF2_DEBUGGING_INFO
+#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
   /* Output DWARF definition of the function.  */
-  if (write_symbols == DWARF2_DEBUG)
+  if (dwarf2out_do_frame ())
     dwarf2out_begin_prologue ();
 #endif
 
@@ -988,6 +992,11 @@ final_start_function (first, file, optimize)
     profile_function (file);
 #endif /* PROFILE_BEFORE_PROLOGUE */
 
+#if defined (DWARF2_UNWIND_INFO) && defined (HAVE_prologue)
+  if (dwarf2out_do_frame ())
+    dwarf2out_frame_debug (NULL_RTX);
+#endif
+
 #ifdef FUNCTION_PROLOGUE
   /* First output the function prologue: code to set up the stack frame.  */
   FUNCTION_PROLOGUE (file, get_frame_size ());
@@ -1011,8 +1020,8 @@ final_start_function (first, file, optimize)
      of the function name.  */
   if (profile_block_flag)
     {
-      bb_func_label_num =
-       add_bb_string ((*decl_printable_name) (current_function_decl, 2), FALSE);
+      bb_func_label_num
+       add_bb_string ((*decl_printable_name) (current_function_decl, 2), FALSE);
     }
 }
 
@@ -1046,7 +1055,7 @@ profile_function (file)
   ASM_OUTPUT_INTERNAL_LABEL (file, "LP", profile_label_no);
   assemble_integer (const0_rtx, LONG_TYPE_SIZE / BITS_PER_UNIT, 1);
 
-  text_section ();
+  function_section (current_function_decl);
 
 #if defined(STRUCT_VALUE_INCOMING_REGNUM) && defined(ASM_OUTPUT_REG_PUSH)
   if (sval)
@@ -1138,8 +1147,8 @@ final_end_function (first, file, optimize)
     dwarfout_end_epilogue ();
 #endif
 
-#ifdef DWARF2_DEBUGGING_INFO
-  if (write_symbols == DWARF2_DEBUG)
+#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
+  if (dwarf2out_do_frame ())
     dwarf2out_end_epilogue ();
 #endif
 
@@ -1261,10 +1270,6 @@ final (first, file, optimize, prescan)
   last_ignored_compare = 0;
   new_block = 1;
 
-#if defined (DWARF2_DEBUGGING_INFO) && defined (HAVE_prologue)
-  dwarf2out_frame_debug (NULL_RTX);
-#endif
-
   check_exception_handler_labels ();
 
   /* Make a map indicating which line numbers appear in this function.
@@ -1584,6 +1589,12 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
         is true.  */    
       if (NEXT_INSN (insn))
        ASM_OUTPUT_ALIGN_CODE (file);
+#endif
+#if defined (DWARF2_UNWIND_INFO) && !defined (ACCUMULATE_OUTGOING_ARGS)
+       /* If we push arguments, we need to check all insns for stack
+          adjustments.  */
+       if (dwarf2out_do_frame ())
+         dwarf2out_frame_debug (insn);
 #endif
       break;
 
@@ -1651,7 +1662,7 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
 
     default:
       {
-       register rtx body = PATTERN (insn);
+       register rtx body = PATTERN (insn), set;
        int insn_code_number;
        char *template;
        rtx note;
@@ -1853,6 +1864,8 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
        body = PATTERN (insn);
 
 #ifdef HAVE_cc0
+       set = single_set(insn);
+
        /* Check for redundant test and compare instructions
           (when the condition codes are already set up as desired).
           This is done only when optimizing; if not optimizing,
@@ -1863,7 +1876,9 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
 
        if (optimize)
          {
+#if 0
            rtx set = single_set(insn);
+#endif
 
            if (set
                && GET_CODE (SET_DEST (set)) == CC0
@@ -1978,20 +1993,20 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
           handle conditional moves (if this machine has either one).  */
 
        if (cc_status.flags != 0
-           && GET_CODE (body) == SET)
+           && set != 0)
          {
            rtx cond_rtx, then_rtx, else_rtx;
            
            if (GET_CODE (insn) != JUMP_INSN
-               && GET_CODE (SET_SRC (body)) == IF_THEN_ELSE)
+               && GET_CODE (SET_SRC (set)) == IF_THEN_ELSE)
              {
-               cond_rtx = XEXP (SET_SRC (body), 0);
-               then_rtx = XEXP (SET_SRC (body), 1);
-               else_rtx = XEXP (SET_SRC (body), 2);
+               cond_rtx = XEXP (SET_SRC (set), 0);
+               then_rtx = XEXP (SET_SRC (set), 1);
+               else_rtx = XEXP (SET_SRC (set), 2);
              }
            else
              {
-               cond_rtx = SET_SRC (body);
+               cond_rtx = SET_SRC (set);
                then_rtx = const_true_rtx;
                else_rtx = const0_rtx;
              }
@@ -2014,12 +2029,12 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
                    break;
                  result = alter_cond (cond_rtx);
                  if (result == 1)
-                   validate_change (insn, &SET_SRC (body), then_rtx, 0);
+                   validate_change (insn, &SET_SRC (set), then_rtx, 0);
                  else if (result == -1)
-                   validate_change (insn, &SET_SRC (body), else_rtx, 0);
+                   validate_change (insn, &SET_SRC (set), else_rtx, 0);
                  else if (result == 2)
                    INSN_CODE (insn) = -1;
-                 if (SET_DEST (body) == SET_SRC (body))
+                 if (SET_DEST (set) == SET_SRC (set))
                    {
                      PUT_CODE (insn, NOTE);
                      NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED;
@@ -2162,12 +2177,21 @@ final_scan_insn (insn, file, optimize, prescan, nopeepholes)
 
        output_asm_insn (template, recog_operand);
 
-#if defined (DWARF2_DEBUGGING_INFO) && defined (HAVE_prologue)
+#if defined (DWARF2_UNWIND_INFO)
+#if !defined (ACCUMULATE_OUTGOING_ARGS)
+       /* If we push arguments, we need to check all insns for stack
+          adjustments.  */
+       if (dwarf2out_do_frame ())
+         dwarf2out_frame_debug (insn);
+#else
+#if defined (HAVE_prologue)
        /* If this insn is part of the prologue, emit DWARF v2
           call frame info.  */
-       if (write_symbols == DWARF2_DEBUG && RTX_FRAME_RELATED_P (insn))
+       if (RTX_FRAME_RELATED_P (insn) && dwarf2out_do_frame ())
          dwarf2out_frame_debug (insn);
 #endif
+#endif
+#endif
 
 #if 0
        /* It's not at all clear why we did this and doing so interferes