Bug 36100 - [4.4 Regression] always_inline attribute is broken at -O0
Summary: [4.4 Regression] always_inline attribute is broken at -O0
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 blocker
Target Milestone: 4.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid, wrong-code
: 36118 (view as bug list)
Depends on: 36108
Blocks: 36102
  Show dependency treegraph
 
Reported: 2008-05-01 16:40 UTC by H.J. Lu
Modified: 2008-05-07 17:02 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-05-05 04:51:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2008-05-01 16:40:02 UTC
[hjl@gnu-6 gcc]$ cat /tmp/y.c 
typedef long long __v2di __attribute__ ((__vector_size__ (16)));

typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_xor_si128 (__m128i __A, __m128i __B)
{
  return (__m128i)__builtin_ia32_pxor128 ((__v2di)__A, (__v2di)__B);
}

int
main ()
{
  __m128i x, y;
  x = _mm_xor_si128 (x, y);
  return 0;
}
[hjl@gnu-6 gcc]$ ./xgcc -B./ -m32 /tmp/y.c -msse2
/tmp/cc4NF1Gd.o: In function `main':
y.c:(.text+0x24): undefined reference to `_mm_xor_si128'
collect2: ld returned 1 exit status
[hjl@gnu-6 gcc]$ 

This may be caused by revision 134859

http://gcc.gnu.org/ml/gcc-cvs/2008-05/msg00019.html
Comment 1 H.J. Lu 2008-05-01 18:57:43 UTC
Revert revision 134859 fixed this regression.
Comment 2 H.J. Lu 2008-05-01 19:32:56 UTC
pass_apply_inline is replaced with pass_ipa_inline.  But pass_ipa_inline is
never used at -O0.
Comment 3 Jan Hubicka 2008-05-02 11:09:08 UTC
Subject: Bug 36100

Author: hubicka
Date: Fri May  2 11:08:22 2008
New Revision: 134885

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134885
Log:

	PR bootstrap/36100
	* ipa-inline.c (inline_generate_summary): Make static.
	(inline_transform): Do not call inlining at -O0; make static.
	* passes.c (execute_todo): Add sanity check.
	(execute_one_ipa_transform_pass): Execute proper flags.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-inline.c
    trunk/gcc/passes.c

Comment 4 Jan Hubicka 2008-05-02 11:11:37 UTC
Subject: Re:  [4.4 Regression] always_inline attribute is broken at -O0

Hi,
I am testing the following patch that restores inlining at -O0.

Index: tree-pass.h
===================================================================
*** tree-pass.h	(revision 134885)
--- tree-pass.h	(working copy)
*************** extern struct rtl_opt_pass pass_final;
*** 501,506 ****
--- 501,507 ----
  extern struct rtl_opt_pass pass_rtl_seqabstr;
  extern struct gimple_opt_pass pass_release_ssa_names;
  extern struct gimple_opt_pass pass_early_inline;
+ extern struct gimple_opt_pass pass_O0_always_inline;
  extern struct gimple_opt_pass pass_inline_parameters;
  extern struct gimple_opt_pass pass_all_early_optimizations;
  extern struct gimple_opt_pass pass_update_address_taken;
Index: ipa-inline.c
===================================================================
*** ipa-inline.c	(revision 134885)
--- ipa-inline.c	(working copy)
*************** inline_transform (struct cgraph_node *no
*** 1588,1601 ****
        todo = optimize_inline_calls (current_function_decl);
        timevar_pop (TV_INTEGRATION);
      }
-   /* In non-unit-at-a-time we must mark all referenced functions as needed.  */
-   if (!flag_unit_at_a_time)
-     {
-       struct cgraph_edge *e;
-       for (e = node->callees; e; e = e->next_callee)
- 	if (e->callee->analyzed)
-           cgraph_mark_needed_node (e->callee);
-     }
    return todo | execute_fixup_cfg ();
  }
  
--- 1588,1593 ----
*************** struct ipa_opt_pass pass_ipa_inline = 
*** 1628,1631 ****
--- 1620,1681 ----
   NULL,					/* variable_transform */
  };
  
+ 
+ /* When inlining shall be performed.  */
+ static bool
+ cgraph_gate_O0_always_inline (void)
+ {
+   return !optimize || !flag_unit_at_a_time;
+ }
+ 
+ static unsigned int
+ cgraph_O0_always_inline (void)
+ {
+   struct cgraph_node *node = cgraph_node (current_function_decl);
+   unsigned int todo = 0;
+   bool inlined;
+ 
+   if (sorrycount || errorcount)
+     return 0;
+   /* We might need the body of this function so that we can expand
+      it inline somewhere else.  */
+   inlined = cgraph_decide_inlining_incrementally (node, INLINE_SPEED, 0);
+   if (cgraph_preserve_function_body_p (current_function_decl))
+     save_inline_function_body (node);
+   if (inlined || warn_inline)
+     {
+       timevar_push (TV_INTEGRATION);
+       todo = optimize_inline_calls (current_function_decl);
+       timevar_pop (TV_INTEGRATION);
+     }
+   /* In non-unit-at-a-time we must mark all referenced functions as needed.  */
+   if (!flag_unit_at_a_time)
+     {
+       struct cgraph_edge *e;
+       for (e = node->callees; e; e = e->next_callee)
+ 	if (e->callee->analyzed)
+           cgraph_mark_needed_node (e->callee);
+     }
+   return todo;
+ }
+ 
+ struct gimple_opt_pass pass_O0_always_inline = 
+ {
+  {
+   GIMPLE_PASS,
+   "always_inline",			/* name */
+   cgraph_gate_O0_always_inline,		/* gate */
+   cgraph_O0_always_inline,		/* execute */
+   NULL,					/* sub */
+   NULL,					/* next */
+   0,					/* static_pass_number */
+   TV_INLINE_HEURISTICS,			/* tv_id */
+   0,	                                /* properties_required */
+   PROP_cfg,				/* properties_provided */
+   0,					/* properties_destroyed */
+   0,					/* todo_flags_start */
+   TODO_dump_func    			/* todo_flags_finish */
+  }
+ };
+ 
  #include "gt-ipa-inline.h"
Index: passes.c
===================================================================
*** passes.c	(revision 134885)
--- passes.c	(working copy)
*************** init_optimization_passes (void)
*** 553,558 ****
--- 553,559 ----
    /* These passes are run after IPA passes on every function that is being
       output to the assembler file.  */
    p = &all_passes;
+   NEXT_PASS (pass_O0_always_inline);
    NEXT_PASS (pass_all_optimizations);
      {
        struct opt_pass **p = &pass_all_optimizations.pass.sub;
Comment 5 H.J. Lu 2008-05-02 12:59:33 UTC
Gcc can't bootstrap due to PR 36108. Jan, you should revert revision 134865
when you do testing.
Comment 6 Jan Hubicka 2008-05-02 21:44:50 UTC
Subject: Re:  [4.4 Regression] always_inline attribute is broken at -O0

Just for record, I am still testing the patch.
The testing scripts I used broke in a way that they ended up testing
empty patches (this is obviously why the original patch passed at first
place ;), so I had to start over.

Honza
Comment 7 H.J. Lu 2008-05-02 21:49:33 UTC
FYI, revision 134889 has following regressions on Linux/ia32:

FAIL: g++.dg/opt/pr30965.C scan-tree-dump-times optimized ";; Function" 2
FAIL: gcc.c-torture/execute/va-arg-pack-1.c compilation,  -O0 
FAIL: gcc.dg/attr-alwaysinline.c scan-assembler-not sabrina
FAIL: gcc.dg/winline-4.c  (test for warnings, line 4)
FAIL: gcc.dg/winline-4.c  (test for warnings, line 7)
FAIL: gcc.dg/torture/nested-fn-1.c  -O0  scan-assembler-not should_not_appear
FAIL: gcc.target/i386/20060512-1.c (test for excess errors)
FAIL: gcc.target/i386/20060512-3.c (test for excess errors)

I think they are all related to revision 134859.
Comment 8 Jan Hubicka 2008-05-02 21:59:35 UTC
Subject: Re:  [4.4 Regression] always_inline attribute is broken at -O0

> FAIL: g++.dg/opt/pr30965.C scan-tree-dump-times optimized ";; Function" 2
> FAIL: gcc.c-torture/execute/va-arg-pack-1.c compilation,  -O0 
> FAIL: gcc.dg/attr-alwaysinline.c scan-assembler-not sabrina
> FAIL: gcc.dg/winline-4.c  (test for warnings, line 4)
> FAIL: gcc.dg/winline-4.c  (test for warnings, line 7)
> FAIL: gcc.dg/torture/nested-fn-1.c  -O0  scan-assembler-not should_not_appear
> FAIL: gcc.target/i386/20060512-1.c (test for excess errors)
> FAIL: gcc.target/i386/20060512-3.c (test for excess errors)

All C failures I get with the patch applied are the following:
FAIL: gcc.c-torture/compile/packed-1.c  -O2  (test for excess errors)
FAIL: gcc.dg/torture/builtin-math-4.c  -O0  (test for excess errors)
FAIL: gcc.dg/torture/builtin-math-4.c  -O1  (test for excess errors)
FAIL: gcc.dg/torture/builtin-math-4.c  -O2  (test for excess errors)
FAIL: gcc.dg/torture/builtin-math-4.c  -O3 -fomit-frame-pointer  (test for excess errors)
FAIL: gcc.dg/torture/builtin-math-4.c  -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
FAIL: gcc.dg/torture/builtin-math-4.c  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for excess errors)
FAIL: gcc.dg/torture/builtin-math-4.c  -O3 -g  (test for excess errors)
FAIL: gcc.dg/torture/builtin-math-4.c  -Os  (test for excess errors)
FAIL: gcc.dg/tree-prof/pr34999.c compilation,  -fprofile-use -D_PROFILE_USE

So hopefully all of those are fixed now. 
I will look into pr30965.C now.

My apologizes for the breakage.  Testing empty patches is obviously easy
job :(

Honza
Comment 9 H.J. Lu 2008-05-04 15:35:23 UTC
*** Bug 36118 has been marked as a duplicate of this bug. ***
Comment 10 Andrew Pinski 2008-05-05 06:14:14 UTC
Fixed by http://gcc.gnu.org/ml/gcc-cvs/2008-05/msg00102.html .
Comment 11 Hans-Peter Nilsson 2008-05-07 16:55:48 UTC
This is not resolved.  I still see
FAIL: g++.dg/tree-ssa/pr19637.C scan-tree-dump-times dom1 "return 1;" 3
for cris-elf and it's been a few days.
I'm reopening this PR to properly track progress.
Comment 12 Hans-Peter Nilsson 2008-05-07 17:02:15 UTC
(In reply to comment #11)
> This is not resolved.  I still see
> FAIL: g++.dg/tree-ssa/pr19637.C scan-tree-dump-times dom1 "return 1;" 3

Oops, different PR, sorry for the noise.