Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333

2014-01-20 Thread Jan Hubicka
 +enum cgraph_inline_failed_flag_t
 +{
 +  CIF_FINAL_NORMAL = 0,
 +  CIF_FINAL_ERROR

The difference is that some errors will never go away, while others are 
temporary
and inliner may revisit them later and inline (such as when indirect call 
becomes direct).
So perhaps CIF_FINAL/CIF_NORMAL?
 +};
 +
  /* Structure containing additional information about an indirect call.  */
  
  struct GTY(()) cgraph_indirect_call_info
 @@ -774,6 +780,7 @@ void cgraph_unnest_node (struct cgraph_node *);
  enum availability cgraph_function_body_availability (struct cgraph_node *);
  void cgraph_add_new_function (tree, bool);
  const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
 +cgraph_inline_failed_flag_t cgraph_inline_failed_flag 
 (cgraph_inline_failed_t);

When you made them enum rather than flags, lets call it 
cgraph_inline_failed_type

OK with these changes,
thanks!
Honza
  
  void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
  void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
 diff --git a/gcc/cif-code.def b/gcc/cif-code.def
 index f1df5a0..5591f9a 100644
 --- a/gcc/cif-code.def
 +++ b/gcc/cif-code.def
 @@ -28,84 +28,98 @@ along with GCC see the file COPYING3.  If not see
 which is a NULL pointer.  */
  
  /* Inlining successful.  This must be the first code.  */
 -DEFCIFCODE(OK , NULL)
 +DEFCIFCODE(OK, CIF_FINAL_NORMAL, NULL)
  
  /* Inlining failed for an unspecified reason.  */
 -DEFCIFCODE(UNSPECIFIED , )
 +DEFCIFCODE(UNSPECIFIED, CIF_FINAL_ERROR, )
  
  /* Function has not be considered for inlining.  This is the code for
 functions that have not been rejected for inlining yet.  */
 -DEFCIFCODE(FUNCTION_NOT_CONSIDERED, N_(function not considered for 
 inlining))
 +DEFCIFCODE(FUNCTION_NOT_CONSIDERED, CIF_FINAL_NORMAL,
 +N_(function not considered for inlining))
  
  /* Caller is compiled with optimizations disabled.  */
 -DEFCIFCODE(FUNCTION_NOT_OPTIMIZED, N_(caller is not optimized))
 +DEFCIFCODE(FUNCTION_NOT_OPTIMIZED, CIF_FINAL_NORMAL,
 +N_(caller is not optimized))
  
  /* Inlining failed owing to unavailable function body.  */
 -DEFCIFCODE(BODY_NOT_AVAILABLE, N_(function body not available))
 +DEFCIFCODE(BODY_NOT_AVAILABLE, CIF_FINAL_ERROR,
 +N_(function body not available))
  
  /* Extern inline function that has been redefined.  */
 -DEFCIFCODE(REDEFINED_EXTERN_INLINE,
 +DEFCIFCODE(REDEFINED_EXTERN_INLINE, CIF_FINAL_NORMAL,
  N_(redefined extern inline functions are not considered for 
 inlining))
  
  /* Function is not inlinable.  */
 -DEFCIFCODE(FUNCTION_NOT_INLINABLE, N_(function not inlinable))
 +DEFCIFCODE(FUNCTION_NOT_INLINABLE, CIF_FINAL_ERROR,
 +N_(function not inlinable))
  
  /* Function is overwritable.  */
 -DEFCIFCODE(OVERWRITABLE, N_(function body can be overwritten at link time))
 +DEFCIFCODE(OVERWRITABLE, CIF_FINAL_ERROR,
 +N_(function body can be overwritten at link time))
  
  /* Function is not an inlining candidate.  */
 -DEFCIFCODE(FUNCTION_NOT_INLINE_CANDIDATE, N_(function not inline 
 candidate))
 +DEFCIFCODE(FUNCTION_NOT_INLINE_CANDIDATE, CIF_FINAL_NORMAL,
 +N_(function not inline candidate))
  
  /* Inlining failed because of various limit parameters.  */
 -DEFCIFCODE(LARGE_FUNCTION_GROWTH_LIMIT,
 +DEFCIFCODE(LARGE_FUNCTION_GROWTH_LIMIT, CIF_FINAL_NORMAL,
  N_(--param large-function-growth limit reached))
 -DEFCIFCODE(LARGE_STACK_FRAME_GROWTH_LIMIT,
 +DEFCIFCODE(LARGE_STACK_FRAME_GROWTH_LIMIT, CIF_FINAL_NORMAL,
  N_(--param large-stack-frame-growth limit reached))
 -DEFCIFCODE(MAX_INLINE_INSNS_SINGLE_LIMIT,
 +DEFCIFCODE(MAX_INLINE_INSNS_SINGLE_LIMIT, CIF_FINAL_NORMAL,
  N_(--param max-inline-insns-single limit reached))
 -DEFCIFCODE(MAX_INLINE_INSNS_AUTO_LIMIT,
 +DEFCIFCODE(MAX_INLINE_INSNS_AUTO_LIMIT, CIF_FINAL_NORMAL,
  N_(--param max-inline-insns-auto limit reached))
 -DEFCIFCODE(INLINE_UNIT_GROWTH_LIMIT,
 +DEFCIFCODE(INLINE_UNIT_GROWTH_LIMIT, CIF_FINAL_NORMAL,
  N_(--param inline-unit-growth limit reached))
  
  /* Recursive inlining.  */
 -DEFCIFCODE(RECURSIVE_INLINING, N_(recursive inlining))
 +DEFCIFCODE(RECURSIVE_INLINING, CIF_FINAL_NORMAL,
 +N_(recursive inlining))
  
  /* Call is unlikely.  */
 -DEFCIFCODE(UNLIKELY_CALL, N_(call is unlikely and code size would grow))
 +DEFCIFCODE(UNLIKELY_CALL, CIF_FINAL_NORMAL,
 +N_(call is unlikely and code size would grow))
  
  /* Function is not declared as inline.  */
 -DEFCIFCODE(NOT_DECLARED_INLINED,
 +DEFCIFCODE(NOT_DECLARED_INLINED, CIF_FINAL_NORMAL,
  N_(function not declared inline and code size would grow))
  
  /* Inlining suppressed due to size optimization.  */
 -DEFCIFCODE(OPTIMIZING_FOR_SIZE,
 +DEFCIFCODE(OPTIMIZING_FOR_SIZE, CIF_FINAL_NORMAL,
  N_(optimizing for size and code size would grow))
  
  /* Caller and callee disagree on the arguments.  */
 -DEFCIFCODE(MISMATCHED_ARGUMENTS, N_(mismatched arguments))
 

Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333

2014-01-20 Thread H.J. Lu
On Mon, Jan 20, 2014 at 12:09 PM, Jan Hubicka hubi...@ucw.cz wrote:
 +enum cgraph_inline_failed_flag_t
 +{
 +  CIF_FINAL_NORMAL = 0,
 +  CIF_FINAL_ERROR

 The difference is that some errors will never go away, while others are 
 temporary
 and inliner may revisit them later and inline (such as when indirect call 
 becomes direct).
 So perhaps CIF_FINAL/CIF_NORMAL?
 +};
 +
  /* Structure containing additional information about an indirect call.  */

  struct GTY(()) cgraph_indirect_call_info
 @@ -774,6 +780,7 @@ void cgraph_unnest_node (struct cgraph_node *);
  enum availability cgraph_function_body_availability (struct cgraph_node *);
  void cgraph_add_new_function (tree, bool);
  const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
 +cgraph_inline_failed_flag_t cgraph_inline_failed_flag 
 (cgraph_inline_failed_t);

 When you made them enum rather than flags, lets call it 
 cgraph_inline_failed_type

 OK with these changes,
 thanks!
 Honza


This is the patch I checked in.

Thanks.

-- 
H.J.
From aa4b937621ab22a176e04e5425c0577555f0578a Mon Sep 17 00:00:00 2001
From: H.J. Lu hjl.to...@gmail.com
Date: Mon, 13 Jan 2014 11:54:36 -0800
Subject: [PATCH] Update error handling during early_inlining

---
 gcc/ChangeLog   | 24 
 gcc/cgraph.c| 20 +-
 gcc/cgraph.h|  9 -
 gcc/cif-code.def| 66 -
 gcc/testsuite/ChangeLog |  5 +++
 gcc/testsuite/gcc.target/i386/pr59789.c | 22 +++
 gcc/tree-inline.c   |  3 +-
 7 files changed, 120 insertions(+), 29 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr59789.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7815479..1123b6d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,27 @@
+2014-01-20  H.J. Lu  hongjiu...@intel.com
+
+	PR middle-end/59789
+	* cgraph.c (cgraph_inline_failed_string): Add type to DEFCIFCODE.
+	(cgraph_inline_failed_type): New function.
+	* cgraph.h (DEFCIFCODE): Add type.
+	(cgraph_inline_failed_type_t): New enum.
+	(cgraph_inline_failed_type): New prototype.
+	* cif-code.def: Add CIF_FINAL_NORMAL to OK, FUNCTION_NOT_CONSIDERED,
+	FUNCTION_NOT_OPTIMIZED, REDEFINED_EXTERN_INLINE,
+	FUNCTION_NOT_INLINE_CANDIDATE, LARGE_FUNCTION_GROWTH_LIMIT,
+	LARGE_STACK_FRAME_GROWTH_LIMIT, MAX_INLINE_INSNS_SINGLE_LIMIT,
+	MAX_INLINE_INSNS_AUTO_LIMIT, INLINE_UNIT_GROWTH_LIMIT,
+	RECURSIVE_INLINING, UNLIKELY_CALL, NOT_DECLARED_INLINED,
+	OPTIMIZING_FOR_SIZE, ORIGINALLY_INDIRECT_CALL,
+	INDIRECT_UNKNOWN_CALL, USES_COMDAT_LOCAL. 
+	Add CIF_FINAL_ERROR to UNSPECIFIED, BODY_NOT_AVAILABLE,
+	FUNCTION_NOT_INLINABLE, OVERWRITABLE, MISMATCHED_ARGUMENTS,
+	EH_PERSONALITY, NON_CALL_EXCEPTIONS, TARGET_OPTION_MISMATCH,
+	OPTIMIZATION_MISMATCH.
+	* tree-inline.c (expand_call_inline): Emit errors during
+	early_inlining if cgraph_inline_failed_type returns
+	CIF_FINAL_ERROR.
+
 2014-01-20  Alex Velenko  alex.vele...@arm.com
 
 	* config/aarch64/aarch64-simd.md (vec_permmode): Add BE check.
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 92b31b9..ae1f43c 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1877,7 +1877,7 @@ const char*
 cgraph_inline_failed_string (cgraph_inline_failed_t reason)
 {
 #undef DEFCIFCODE
-#define DEFCIFCODE(code, string)	string,
+#define DEFCIFCODE(code, type, string)	string,
 
   static const char *cif_string_table[CIF_N_REASONS] = {
 #include cif-code.def
@@ -1889,6 +1889,24 @@ cgraph_inline_failed_string (cgraph_inline_failed_t reason)
   return cif_string_table[reason];
 }
 
+/* Return a type describing the failure REASON.  */
+
+cgraph_inline_failed_type_t
+cgraph_inline_failed_type (cgraph_inline_failed_t reason)
+{
+#undef DEFCIFCODE
+#define DEFCIFCODE(code, type, string)	type,
+
+  static cgraph_inline_failed_type_t cif_type_table[CIF_N_REASONS] = {
+#include cif-code.def
+  };
+
+  /* Signedness of an enum type is implementation defined, so cast it
+ to unsigned before testing. */
+  gcc_assert ((unsigned) reason  CIF_N_REASONS);
+  return cif_type_table[reason];
+}
+
 /* Names used to print out the availability enum.  */
 const char * const cgraph_availability_names[] =
   {unset, not_available, overwritable, available, local};
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 7ce5401..c763516 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -518,13 +518,19 @@ struct varpool_node_set_iterator
   unsigned index;
 };
 
-#define DEFCIFCODE(code, string)	CIF_ ## code,
+#define DEFCIFCODE(code, type, string)	CIF_ ## code,
 /* Reasons for inlining failures.  */
 enum cgraph_inline_failed_t {
 #include cif-code.def
   CIF_N_REASONS
 };
 
+enum cgraph_inline_failed_type_t
+{
+  CIF_FINAL_NORMAL = 0,
+  CIF_FINAL_ERROR
+};
+
 /* Structure containing additional information about an indirect call.  */
 
 struct GTY(()) cgraph_indirect_call_info
@@ -774,6 +780,7 @@ void cgraph_unnest_node (struct cgraph_node *);
 enum 

Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333

2014-01-17 Thread H.J. Lu
On Mon, Jan 13, 2014 at 12:11 PM, H.J. Lu hongjiu...@intel.com wrote:
 Hi,

 We should report some early inlining errors.  This patch is based on

 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57698#c7

 It adds report_early_inliner_always_inline_failure and uses it in
 expand_call_inline.  Tested on Linux/x86-64. OK to install?

 Thanks.


 H.J.
 
 commit 7b18b53d308b2c25bef5664be3e6544249d86bdc
 Author: H.J. Lu hjl.to...@gmail.com
 Date:   Mon Jan 13 11:54:36 2014 -0800

 Update error handling during early_inlining

 diff --git a/gcc/ChangeLog b/gcc/ChangeLog
 index 5c674bc..284bc66 100644
 --- a/gcc/ChangeLog
 +++ b/gcc/ChangeLog
 @@ -1,3 +1,12 @@
 +2014-01-13  Sriraman Tallam  tmsri...@google.com
 +   H.J. Lu  hongjiu...@intel.com
 +
 +   PR middle-end/59789
 +   * tree-inline.c (report_early_inliner_always_inline_failure): New
 +   function.
 +   (expand_call_inline): Emit errors during early_inlining if
 +   report_early_inliner_always_inline_failure returns true.
 +
  2014-01-10  DJ Delorie  d...@redhat.com

 * config/msp430/msp430.md (call_internal): Don't allow memory
 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
 index 459e365..2a7b3ca 100644
 --- a/gcc/testsuite/ChangeLog
 +++ b/gcc/testsuite/ChangeLog
 @@ -1,3 +1,8 @@
 +2014-01-13  H.J. Lu  hongjiu...@intel.com
 +
 +   PR middle-end/59789
 +   * gcc.target/i386/pr59789.c: New testcase.
 +
  2014-01-13  Jakub Jelinek  ja...@redhat.com

 PR tree-optimization/59387
 diff --git a/gcc/testsuite/gcc.target/i386/pr59789.c 
 b/gcc/testsuite/gcc.target/i386/pr59789.c
 new file mode 100644
 index 000..b476d6c
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/i386/pr59789.c
 @@ -0,0 +1,22 @@
 +/* { dg-do compile } */
 +/* { dg-require-effective-target ia32 } */
 +/* { dg-options -O -march=i686 } */
 +
 +#pragma GCC push_options
 +#pragma GCC target(sse2)
 +typedef int __v4si __attribute__ ((__vector_size__ (16)));
 +typedef long long __m128i __attribute__ ((__vector_size__ (16), 
 __may_alias__));
 +
 +extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, 
 __artificial__))
 +_mm_set_epi32 (int __q3, int __q2, int __q1, int __q0) /* { dg-error target 
 specific option mismatch } */
 +{
 +  return __extension__ (__m128i)(__v4si){ __q0, __q1, __q2, __q3 };
 +}
 +#pragma GCC pop_options
 +
 +
 +__m128i
 +f1(void) /* { dg-message warning: SSE vector return without SSE enabled 
 changes the ABI } */
 +{
 +  return _mm_set_epi32 (0, 0, 0, 0); /* { dg-error called from here } */
 +}
 diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
 index 22521b1..ce1e3af 100644
 --- a/gcc/tree-inline.c
 +++ b/gcc/tree-inline.c
 @@ -4046,6 +4046,32 @@ add_local_variables (struct function *callee, struct 
 function *caller,
}
  }

 +/* Should an error be reported when early inliner fails to inline an
 +   always_inline function?  That depends on the REASON.  */
 +
 +static inline bool
 +report_early_inliner_always_inline_failure (cgraph_inline_failed_t reason)
 +{
 +  /* Only the following reasons need to be reported when the early inliner
 + fails to inline an always_inline function.  Called from
 + expand_call_inline.  */
 +  switch (reason)
 +{
 +case CIF_BODY_NOT_AVAILABLE:
 +case CIF_FUNCTION_NOT_INLINABLE:
 +case CIF_OVERWRITABLE:
 +case CIF_MISMATCHED_ARGUMENTS:
 +case CIF_EH_PERSONALITY:
 +case CIF_UNSPECIFIED:
 +case CIF_NON_CALL_EXCEPTIONS:
 +case CIF_TARGET_OPTION_MISMATCH:
 +case CIF_OPTIMIZATION_MISMATCH:
 +  return true;
 +default:
 +  return false;
 +}
 +}
 +
  /* If STMT is a GIMPLE_CALL, replace it with its inline expansion.  */

  static bool
 @@ -4116,7 +4142,8 @@ expand_call_inline (basic_block bb, gimple stmt, 
 copy_body_data *id)
   /* During early inline pass, report only when optimization is
  not turned on.  */
(cgraph_global_info_ready
 - || !optimize)
 + || !optimize
 + || report_early_inliner_always_inline_failure (reason))
   /* PR 20090218-1_0.c. Body can be provided by another module. */
(reason != CIF_BODY_NOT_AVAILABLE || !flag_generate_lto))
 {

Hi Honza,

Can you take a look at this patch?

Thanks.

-- 
H.J.


Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333

2014-01-17 Thread Jan Hubicka
  diff --git a/gcc/ChangeLog b/gcc/ChangeLog
  index 5c674bc..284bc66 100644
  --- a/gcc/ChangeLog
  +++ b/gcc/ChangeLog
  @@ -1,3 +1,12 @@
  +2014-01-13  Sriraman Tallam  tmsri...@google.com
  +   H.J. Lu  hongjiu...@intel.com
  +
  +   PR middle-end/59789
  +   * tree-inline.c (report_early_inliner_always_inline_failure): New
  +   function.
  +   (expand_call_inline): Emit errors during early_inlining if
  +   report_early_inliner_always_inline_failure returns true.
  +
   2014-01-10  DJ Delorie  d...@redhat.com
 
  * config/msp430/msp430.md (call_internal): Don't allow memory
  diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
  index 459e365..2a7b3ca 100644
  --- a/gcc/testsuite/ChangeLog
  +++ b/gcc/testsuite/ChangeLog
  @@ -1,3 +1,8 @@
  +2014-01-13  H.J. Lu  hongjiu...@intel.com
  +
  +   PR middle-end/59789
  +   * gcc.target/i386/pr59789.c: New testcase.
  +
   2014-01-13  Jakub Jelinek  ja...@redhat.com
 
  PR tree-optimization/59387
  diff --git a/gcc/testsuite/gcc.target/i386/pr59789.c 
  b/gcc/testsuite/gcc.target/i386/pr59789.c
  new file mode 100644
  index 000..b476d6c
  --- /dev/null
  +++ b/gcc/testsuite/gcc.target/i386/pr59789.c
  @@ -0,0 +1,22 @@
  +/* { dg-do compile } */
  +/* { dg-require-effective-target ia32 } */
  +/* { dg-options -O -march=i686 } */
  +
  +#pragma GCC push_options
  +#pragma GCC target(sse2)
  +typedef int __v4si __attribute__ ((__vector_size__ (16)));
  +typedef long long __m128i __attribute__ ((__vector_size__ (16), 
  __may_alias__));
  +
  +extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, 
  __artificial__))
  +_mm_set_epi32 (int __q3, int __q2, int __q1, int __q0) /* { dg-error 
  target specific option mismatch } */
  +{
  +  return __extension__ (__m128i)(__v4si){ __q0, __q1, __q2, __q3 };
  +}
  +#pragma GCC pop_options
  +
  +
  +__m128i
  +f1(void) /* { dg-message warning: SSE vector return without SSE enabled 
  changes the ABI } */
  +{
  +  return _mm_set_epi32 (0, 0, 0, 0); /* { dg-error called from here } */
  +}
  diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
  index 22521b1..ce1e3af 100644
  --- a/gcc/tree-inline.c
  +++ b/gcc/tree-inline.c
  @@ -4046,6 +4046,32 @@ add_local_variables (struct function *callee, struct 
  function *caller,
 }
   }
 
  +/* Should an error be reported when early inliner fails to inline an
  +   always_inline function?  That depends on the REASON.  */
  +
  +static inline bool
  +report_early_inliner_always_inline_failure (cgraph_inline_failed_t reason)
  +{
  +  /* Only the following reasons need to be reported when the early inliner
  + fails to inline an always_inline function.  Called from
  + expand_call_inline.  */
  +  switch (reason)
  +{
  +case CIF_BODY_NOT_AVAILABLE:
  +case CIF_FUNCTION_NOT_INLINABLE:
  +case CIF_OVERWRITABLE:
  +case CIF_MISMATCHED_ARGUMENTS:
  +case CIF_EH_PERSONALITY:
  +case CIF_UNSPECIFIED:
  +case CIF_NON_CALL_EXCEPTIONS:
  +case CIF_TARGET_OPTION_MISMATCH:
  +case CIF_OPTIMIZATION_MISMATCH:
  +  return true;
  +default:
  +  return false;
  +}
  +}

This looks resonable, but since we have .def file specifying CIF codes, I would 
make
this as a flag in there. Perhaps something like CIF_FINAL_ERROR that marks 
those and
inliner can report them.

Honza


Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333

2014-01-17 Thread H.J. Lu
On Fri, Jan 17, 2014 at 7:35 AM, Jan Hubicka hubi...@ucw.cz wrote:
  diff --git a/gcc/ChangeLog b/gcc/ChangeLog
  index 5c674bc..284bc66 100644
  --- a/gcc/ChangeLog
  +++ b/gcc/ChangeLog
  @@ -1,3 +1,12 @@
  +2014-01-13  Sriraman Tallam  tmsri...@google.com
  +   H.J. Lu  hongjiu...@intel.com
  +
  +   PR middle-end/59789
  +   * tree-inline.c (report_early_inliner_always_inline_failure): New
  +   function.
  +   (expand_call_inline): Emit errors during early_inlining if
  +   report_early_inliner_always_inline_failure returns true.
  +
   2014-01-10  DJ Delorie  d...@redhat.com
 
  * config/msp430/msp430.md (call_internal): Don't allow memory
  diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
  index 459e365..2a7b3ca 100644
  --- a/gcc/testsuite/ChangeLog
  +++ b/gcc/testsuite/ChangeLog
  @@ -1,3 +1,8 @@
  +2014-01-13  H.J. Lu  hongjiu...@intel.com
  +
  +   PR middle-end/59789
  +   * gcc.target/i386/pr59789.c: New testcase.
  +
   2014-01-13  Jakub Jelinek  ja...@redhat.com
 
  PR tree-optimization/59387
  diff --git a/gcc/testsuite/gcc.target/i386/pr59789.c 
  b/gcc/testsuite/gcc.target/i386/pr59789.c
  new file mode 100644
  index 000..b476d6c
  --- /dev/null
  +++ b/gcc/testsuite/gcc.target/i386/pr59789.c
  @@ -0,0 +1,22 @@
  +/* { dg-do compile } */
  +/* { dg-require-effective-target ia32 } */
  +/* { dg-options -O -march=i686 } */
  +
  +#pragma GCC push_options
  +#pragma GCC target(sse2)
  +typedef int __v4si __attribute__ ((__vector_size__ (16)));
  +typedef long long __m128i __attribute__ ((__vector_size__ (16), 
  __may_alias__));
  +
  +extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, 
  __artificial__))
  +_mm_set_epi32 (int __q3, int __q2, int __q1, int __q0) /* { dg-error 
  target specific option mismatch } */
  +{
  +  return __extension__ (__m128i)(__v4si){ __q0, __q1, __q2, __q3 };
  +}
  +#pragma GCC pop_options
  +
  +
  +__m128i
  +f1(void) /* { dg-message warning: SSE vector return without SSE enabled 
  changes the ABI } */
  +{
  +  return _mm_set_epi32 (0, 0, 0, 0); /* { dg-error called from here } */
  +}
  diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
  index 22521b1..ce1e3af 100644
  --- a/gcc/tree-inline.c
  +++ b/gcc/tree-inline.c
  @@ -4046,6 +4046,32 @@ add_local_variables (struct function *callee, 
  struct function *caller,
 }
   }
 
  +/* Should an error be reported when early inliner fails to inline an
  +   always_inline function?  That depends on the REASON.  */
  +
  +static inline bool
  +report_early_inliner_always_inline_failure (cgraph_inline_failed_t reason)
  +{
  +  /* Only the following reasons need to be reported when the early inliner
  + fails to inline an always_inline function.  Called from
  + expand_call_inline.  */
  +  switch (reason)
  +{
  +case CIF_BODY_NOT_AVAILABLE:
  +case CIF_FUNCTION_NOT_INLINABLE:
  +case CIF_OVERWRITABLE:
  +case CIF_MISMATCHED_ARGUMENTS:
  +case CIF_EH_PERSONALITY:
  +case CIF_UNSPECIFIED:
  +case CIF_NON_CALL_EXCEPTIONS:
  +case CIF_TARGET_OPTION_MISMATCH:
  +case CIF_OPTIMIZATION_MISMATCH:
  +  return true;
  +default:
  +  return false;
  +}
  +}

 This looks resonable, but since we have .def file specifying CIF codes, I 
 would make
 this as a flag in there. Perhaps something like CIF_FINAL_ERROR that marks 
 those and
 inliner can report them.

For this testcase, we get CIF_TARGET_OPTION_MISMATCH.
Do you want to add a new flag so that inliner can use for
other errors?


-- 
H.J.


Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333

2014-01-17 Thread Jan Hubicka
 For this testcase, we get CIF_TARGET_OPTION_MISMATCH.
 Do you want to add a new flag so that inliner can use for
 other errors?

Just add flags parameter to DEFCIFCODE in cif-code.def
and flag those that are final and should be output already
in early inlining.
This way we will not forget to include new codes as we introduce them.

Honza
 
 
 -- 
 H.J.


Re: PATCH: PR middle-end/59789: [4.9 Regression] ICE in in convert_move, at expr.c:333

2014-01-17 Thread H.J. Lu
On Fri, Jan 17, 2014 at 8:42 AM, Jan Hubicka hubi...@ucw.cz wrote:
 For this testcase, we get CIF_TARGET_OPTION_MISMATCH.
 Do you want to add a new flag so that inliner can use for
 other errors?

 Just add flags parameter to DEFCIFCODE in cif-code.def
 and flag those that are final and should be output already
 in early inlining.
 This way we will not forget to include new codes as we introduce them.


Like this?  OK for trunk?

Thanks.


-- 
H.J.
From abb55ed09f4d493046b3dd6a27e7df0d1587fa72 Mon Sep 17 00:00:00 2001
From: H.J. Lu hjl.to...@gmail.com
Date: Mon, 13 Jan 2014 11:54:36 -0800
Subject: [PATCH] Update error handling during early_inlining

---
 gcc/ChangeLog   | 24 
 gcc/cgraph.c| 20 +-
 gcc/cgraph.h|  9 -
 gcc/cif-code.def| 66 -
 gcc/testsuite/ChangeLog |  5 +++
 gcc/testsuite/gcc.target/i386/pr59789.c | 22 +++
 gcc/tree-inline.c   |  3 +-
 7 files changed, 120 insertions(+), 29 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr59789.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index df6e491..eb55a89 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,29 @@
 2014-01-17  H.J. Lu  hongjiu...@intel.com
 
+	PR middle-end/59789
+	* cgraph.c (cgraph_inline_failed_string): Add flag to DEFCIFCODE.
+	(cgraph_inline_failed_flag): New function.
+	* cgraph.h (DEFCIFCODE): Add flag.
+	(cgraph_inline_failed_flag_t): New enum.
+	(cgraph_inline_failed_flag): New prototype.
+	* cif-code.def: Add CIF_FINAL_NORMAL to OK, FUNCTION_NOT_CONSIDERED,
+	FUNCTION_NOT_OPTIMIZED, REDEFINED_EXTERN_INLINE,
+	FUNCTION_NOT_INLINE_CANDIDATE, LARGE_FUNCTION_GROWTH_LIMIT,
+	LARGE_STACK_FRAME_GROWTH_LIMIT, MAX_INLINE_INSNS_SINGLE_LIMIT,
+	MAX_INLINE_INSNS_AUTO_LIMIT, INLINE_UNIT_GROWTH_LIMIT,
+	RECURSIVE_INLINING, UNLIKELY_CALL, NOT_DECLARED_INLINED,
+	OPTIMIZING_FOR_SIZE, ORIGINALLY_INDIRECT_CALL,
+	INDIRECT_UNKNOWN_CALL, USES_COMDAT_LOCAL. 
+	Add CIF_FINAL_ERROR to UNSPECIFIED, BODY_NOT_AVAILABLE,
+	FUNCTION_NOT_INLINABLE, OVERWRITABLE, MISMATCHED_ARGUMENTS,
+	EH_PERSONALITY, NON_CALL_EXCEPTIONS, TARGET_OPTION_MISMATCH,
+	OPTIMIZATION_MISMATCH.
+	* tree-inline.c (expand_call_inline): Emit errors during
+	early_inlining if cgraph_inline_failed_flag returns
+	CIF_FINAL_ERROR.
+
+2014-01-17  H.J. Lu  hongjiu...@intel.com
+
 	* config/i386/i386-c.c (ix86_target_macros_internal): Handle
 	PROCESSOR_INTEL.  Treat like PROCESSOR_GENERIC.
 	* config/i386/i386.c (intel_memcpy): New.  Duplicate slm_memcpy.
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 92b31b9..156b6ee 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1877,7 +1877,7 @@ const char*
 cgraph_inline_failed_string (cgraph_inline_failed_t reason)
 {
 #undef DEFCIFCODE
-#define DEFCIFCODE(code, string)	string,
+#define DEFCIFCODE(code, flag, string)	string,
 
   static const char *cif_string_table[CIF_N_REASONS] = {
 #include cif-code.def
@@ -1889,6 +1889,24 @@ cgraph_inline_failed_string (cgraph_inline_failed_t reason)
   return cif_string_table[reason];
 }
 
+/* Return a flag describing the failure REASON.  */
+
+cgraph_inline_failed_flag_t
+cgraph_inline_failed_flag (cgraph_inline_failed_t reason)
+{
+#undef DEFCIFCODE
+#define DEFCIFCODE(code, flag, string)	flag,
+
+  static cgraph_inline_failed_flag_t cif_flag_table[CIF_N_REASONS] = {
+#include cif-code.def
+  };
+
+  /* Signedness of an enum type is implementation defined, so cast it
+ to unsigned before testing. */
+  gcc_assert ((unsigned) reason  CIF_N_REASONS);
+  return cif_flag_table[reason];
+}
+
 /* Names used to print out the availability enum.  */
 const char * const cgraph_availability_names[] =
   {unset, not_available, overwritable, available, local};
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 7ce5401..6b5ae8e 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -518,13 +518,19 @@ struct varpool_node_set_iterator
   unsigned index;
 };
 
-#define DEFCIFCODE(code, string)	CIF_ ## code,
+#define DEFCIFCODE(code, flag, string)	CIF_ ## code,
 /* Reasons for inlining failures.  */
 enum cgraph_inline_failed_t {
 #include cif-code.def
   CIF_N_REASONS
 };
 
+enum cgraph_inline_failed_flag_t
+{
+  CIF_FINAL_NORMAL = 0,
+  CIF_FINAL_ERROR
+};
+
 /* Structure containing additional information about an indirect call.  */
 
 struct GTY(()) cgraph_indirect_call_info
@@ -774,6 +780,7 @@ void cgraph_unnest_node (struct cgraph_node *);
 enum availability cgraph_function_body_availability (struct cgraph_node *);
 void cgraph_add_new_function (tree, bool);
 const char* cgraph_inline_failed_string (cgraph_inline_failed_t);
+cgraph_inline_failed_flag_t cgraph_inline_failed_flag (cgraph_inline_failed_t);
 
 void cgraph_set_nothrow_flag (struct cgraph_node *, bool);
 void cgraph_set_const_flag (struct cgraph_node *, bool, bool);
diff --git a/gcc/cif-code.def b/gcc/cif-code.def
index f1df5a0..5591f9a 100644