i386.c (legitimize_tls_address): Generate tls_initial_exec_64_sun only when !TARGET_X32.
[gcc.git] / gcc / gimple-low.c
index 01aeb4940d38d103dabb7723540037815f6b962b..04d4275f75b7ec47676d1f85465c727541a10254 100644 (file)
@@ -112,10 +112,6 @@ lower_function_body (void)
   i = gsi_start (lowered_body);
   lower_gimple_bind (&i, &data);
 
-  /* Once the old body has been lowered, replace it with the new
-     lowered sequence.  */
-  gimple_set_body (current_function_decl, lowered_body);
-
   i = gsi_last (lowered_body);
 
   /* If the function falls off the end, we need a null return statement.
@@ -169,7 +165,7 @@ lower_function_body (void)
         and insert.  */
       disp_var = create_tmp_var (ptr_type_node, "setjmpvar");
       arg = build_addr (disp_label, current_function_decl);
-      t = implicit_built_in_decls[BUILT_IN_SETJMP_DISPATCHER];
+      t = builtin_decl_implicit (BUILT_IN_SETJMP_DISPATCHER);
       x = gimple_build_call (t, 1, arg);
       gimple_call_set_lhs (x, disp_var);
 
@@ -179,6 +175,10 @@ lower_function_body (void)
       gsi_insert_after (&i, x, GSI_CONTINUE_LINKING);
     }
 
+  /* Once the old body has been lowered, replace it with the new
+     lowered sequence.  */
+  gimple_set_body (current_function_decl, lowered_body);
+
   gcc_assert (data.block == DECL_INITIAL (current_function_decl));
   BLOCK_SUBBLOCKS (data.block)
     = blocks_nreverse (BLOCK_SUBBLOCKS (data.block));
@@ -203,7 +203,7 @@ struct gimple_opt_pass pass_lower_cf =
   PROP_gimple_lcf,                     /* properties_provided */
   0,                                   /* properties_destroyed */
   0,                                   /* todo_flags_start */
-  TODO_dump_func                       /* todo_flags_finish */
+  0                                    /* todo_flags_finish */
  }
 };
 
@@ -219,6 +219,10 @@ gimple_check_call_args (gimple stmt, tree fndecl)
   tree parms, p;
   unsigned int i, nargs;
 
+  /* Calls to internal functions always match their signature.  */
+  if (gimple_call_internal_p (stmt))
+    return true;
+
   nargs = gimple_call_num_args (stmt);
 
   /* Get argument types for verification.  */
@@ -236,15 +240,17 @@ gimple_check_call_args (gimple stmt, tree fndecl)
           i < nargs;
           i++, p = DECL_CHAIN (p))
        {
+         tree arg;
          /* We cannot distinguish a varargs function from the case
             of excess parameters, still deferring the inlining decision
             to the callee is possible.  */
          if (!p)
            break;
+         arg = gimple_call_arg (stmt, i);
          if (p == error_mark_node
-             || gimple_call_arg (stmt, i) == error_mark_node
-             || !fold_convertible_p (DECL_ARG_TYPE (p),
-                                     gimple_call_arg (stmt, i)))
+             || arg == error_mark_node
+             || (!types_compatible_p (DECL_ARG_TYPE (p), TREE_TYPE (arg))
+                 && !fold_convertible_p (DECL_ARG_TYPE (p), arg)))
             return false;
        }
     }
@@ -252,15 +258,17 @@ gimple_check_call_args (gimple stmt, tree fndecl)
     {
       for (i = 0, p = parms; i < nargs; i++, p = TREE_CHAIN (p))
        {
+         tree arg;
          /* If this is a varargs function defer inlining decision
             to callee.  */
          if (!p)
            break;
+         arg = gimple_call_arg (stmt, i);
          if (TREE_VALUE (p) == error_mark_node
-             || gimple_call_arg (stmt, i) == error_mark_node
+             || arg == error_mark_node
              || TREE_CODE (TREE_VALUE (p)) == VOID_TYPE
-             || !fold_convertible_p (TREE_VALUE (p),
-                                     gimple_call_arg (stmt, i)))
+             || (!types_compatible_p (TREE_VALUE (p), TREE_TYPE (arg))
+                 && !fold_convertible_p (TREE_VALUE (p), arg)))
             return false;
        }
     }
@@ -297,11 +305,11 @@ gimple_check_call_matching_types (gimple call_stmt, tree callee)
    do it explicitly.  DATA is passed through the recursion.  */
 
 static void
-lower_sequence (gimple_seq seq, struct lower_data *data)
+lower_sequence (gimple_seq *seq, struct lower_data *data)
 {
   gimple_stmt_iterator gsi;
 
-  for (gsi = gsi_start (seq); !gsi_end_p (gsi); )
+  for (gsi = gsi_start (*seq); !gsi_end_p (gsi); )
     lower_stmt (&gsi, data);
 }
 
@@ -316,11 +324,10 @@ lower_omp_directive (gimple_stmt_iterator *gsi, struct lower_data *data)
 
   stmt = gsi_stmt (*gsi);
 
-  lower_sequence (gimple_omp_body (stmt), data);
-  gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
-  gsi_insert_seq_before (gsi, gimple_omp_body (stmt), GSI_SAME_STMT);
+  lower_sequence (gimple_omp_body_ptr (stmt), data);
+  gsi_insert_seq_after (gsi, gimple_omp_body (stmt), GSI_CONTINUE_LINKING);
   gimple_omp_set_body (stmt, NULL);
-  gsi_remove (gsi, false);
+  gsi_next (gsi);
 }
 
 
@@ -368,10 +375,10 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
     case GIMPLE_TRY:
       {
        bool try_cannot_fallthru;
-       lower_sequence (gimple_try_eval (stmt), data);
+       lower_sequence (gimple_try_eval_ptr (stmt), data);
        try_cannot_fallthru = data->cannot_fallthru;
        data->cannot_fallthru = false;
-       lower_sequence (gimple_try_cleanup (stmt), data);
+       lower_sequence (gimple_try_cleanup_ptr (stmt), data);
        /* See gimple_stmt_may_fallthru for the rationale.  */
        if (gimple_try_kind (stmt) == GIMPLE_TRY_FINALLY)
          {
@@ -384,12 +391,17 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
 
     case GIMPLE_CATCH:
       data->cannot_fallthru = false;
-      lower_sequence (gimple_catch_handler (stmt), data);
+      lower_sequence (gimple_catch_handler_ptr (stmt), data);
       break;
 
     case GIMPLE_EH_FILTER:
       data->cannot_fallthru = false;
-      lower_sequence (gimple_eh_filter_failure (stmt), data);
+      lower_sequence (gimple_eh_filter_failure_ptr (stmt), data);
+      break;
+
+    case GIMPLE_EH_ELSE:
+      lower_sequence (gimple_eh_else_n_body_ptr (stmt), data);
+      lower_sequence (gimple_eh_else_e_body_ptr (stmt), data);
       break;
 
     case GIMPLE_NOP:
@@ -442,6 +454,10 @@ lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data)
       data->cannot_fallthru = false;
       return;
 
+    case GIMPLE_TRANSACTION:
+      lower_sequence (gimple_transaction_body_ptr (stmt), data);
+      break;
+
     default:
       gcc_unreachable ();
     }
@@ -488,7 +504,7 @@ lower_gimple_bind (gimple_stmt_iterator *gsi, struct lower_data *data)
     }
 
   record_vars (gimple_bind_vars (stmt));
-  lower_sequence (gimple_bind_body (stmt), data);
+  lower_sequence (gimple_bind_body_ptr (stmt), data);
 
   if (new_block)
     {
@@ -568,7 +584,7 @@ gimple_try_catch_may_fallthru (gimple stmt)
   if (gimple_seq_may_fallthru (gimple_try_eval (stmt)))
     return true;
 
-  i = gsi_start (gimple_try_cleanup (stmt));
+  i = gsi_start (*gimple_try_cleanup_ptr (stmt));
   switch (gimple_code (gsi_stmt (i)))
     {
     case GIMPLE_CATCH:
@@ -723,6 +739,10 @@ gimple_stmt_may_fallthru (gimple stmt)
       return (gimple_seq_may_fallthru (gimple_try_eval (stmt))
              && gimple_seq_may_fallthru (gimple_try_cleanup (stmt)));
 
+    case GIMPLE_EH_ELSE:
+      return (gimple_seq_may_fallthru (gimple_eh_else_n_body (stmt))
+             || gimple_seq_may_fallthru (gimple_eh_else_e_body (stmt)));
+
     case GIMPLE_CALL:
       /* Functions that do not return do not fall through.  */
       return (gimple_call_flags (stmt) & ECF_NORETURN) == 0;
@@ -857,7 +877,7 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi)
 
   /* Build '__builtin_setjmp_setup (BUF, NEXT_LABEL)' and insert.  */
   arg = build_addr (next_label, current_function_decl);
-  t = implicit_built_in_decls[BUILT_IN_SETJMP_SETUP];
+  t = builtin_decl_implicit (BUILT_IN_SETJMP_SETUP);
   g = gimple_build_call (t, 2, gimple_call_arg (stmt, 0), arg);
   gimple_set_location (g, loc);
   gimple_set_block (g, gimple_block (stmt));
@@ -882,7 +902,7 @@ lower_builtin_setjmp (gimple_stmt_iterator *gsi)
 
   /* Build '__builtin_setjmp_receiver (NEXT_LABEL)' and insert.  */
   arg = build_addr (next_label, current_function_decl);
-  t = implicit_built_in_decls[BUILT_IN_SETJMP_RECEIVER];
+  t = builtin_decl_implicit (BUILT_IN_SETJMP_RECEIVER);
   g = gimple_build_call (t, 1, arg);
   gimple_set_location (g, loc);
   gimple_set_block (g, gimple_block (stmt));