public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/68036] New: ICE on valid code at -Os and above on x86_64-linux-gnu
@ 2015-10-20 22:01 su at cs dot ucdavis.edu
  2015-10-21  8:11 ` [Bug tree-optimization/68036] [6 Regression] " mpolacek at gcc dot gnu.org
  2015-10-21  9:31 ` mpolacek at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: su at cs dot ucdavis.edu @ 2015-10-20 22:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68036

            Bug ID: 68036
           Summary: ICE on valid code at -Os and above on x86_64-linux-gnu
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu
  Target Milestone: ---

The following code causes an ICE when compiled with the current gcc trunk at
-Os and above on x86_64-linux-gnu in both 32-bit and 64-bit modes.

It is a regression from 5.2.x.


$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 6.0.0 20151020 (experimental) [trunk revision 229078] (GCC) 
$ 
$ gcc-trunk -O1 -c small.c
$ gcc-5.2 -Os -c small.c
$ 
$ gcc-trunk -Os -c small.c
small.c: In function ‘fn1’:
small.c:4:1: internal compiler error: Segmentation fault
 fn1 ()
 ^
0xad1c3f crash_signal
        ../../gcc-trunk/gcc/toplev.c:353
0x825b65 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        ../../gcc-trunk/gcc/tree.h:3055
0x825b65 tree_single_nonnegative_warnv_p(tree_node*, bool*, int)
        ../../gcc-trunk/gcc/fold-const.c:13025
0x884092 gimple_phi_nonnegative_warnv_p
        ../../gcc-trunk/gcc/gimple-fold.c:6239
0x884092 gimple_stmt_nonnegative_warnv_p(gimple*, bool*, int)
        ../../gcc-trunk/gcc/gimple-fold.c:6264
0x825da4 tree_expr_nonnegative_p(tree_node*)
        ../../gcc-trunk/gcc/fold-const.c:13325
0xe5c007 gimple_simplify_108
        /tmp/objdir/gcc/gimple-match.c:5116
0xe5ccd3 gimple_simplify_TRUNC_MOD_EXPR
        /tmp/objdir/gcc/gimple-match.c:24762
0xe259a5 gimple_simplify
        /tmp/objdir/gcc/gimple-match.c:34389
0xe2772f gimple_resimplify2(gimple**, code_helper*, tree_node*, tree_node**,
tree_node* (*)(tree_node*))
        ../../gcc-trunk/gcc/gimple-match-head.c:193
0xe6d583 gimple_simplify(gimple*, code_helper*, tree_node**, gimple**,
tree_node* (*)(tree_node*), tree_node* (*)(tree_node*))
        ../../gcc-trunk/gcc/gimple-match-head.c:668
0x88ca51 fold_stmt_1
        ../../gcc-trunk/gcc/gimple-fold.c:3605
0xb0dc64 replace_uses_by(tree_node*, tree_node*)
        ../../gcc-trunk/gcc/tree-cfg.c:1835
0xb0ebac gimple_merge_blocks
        ../../gcc-trunk/gcc/tree-cfg.c:1921
0x70a9a5 merge_blocks(basic_block_def*, basic_block_def*)
        ../../gcc-trunk/gcc/cfghooks.c:776
0xb180fd cleanup_tree_cfg_bb
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:654
0xb18cf8 cleanup_tree_cfg_1
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:686
0xb18cf8 cleanup_tree_cfg_noloop
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:738
0xb18cf8 cleanup_tree_cfg()
        ../../gcc-trunk/gcc/tree-cfgcleanup.c:793
0xa0afc4 execute_function_todo
        ../../gcc-trunk/gcc/passes.c:1920
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
$ 


--------------------------------------


int a, b, c, d, e, j; 

void
fn1 ()
{
  int f = 0;
  for (; j;)
    {
      int g;
      if (a)
        for (;; g++)
          {
            int h = -1;
            if (d)
              {
                while (f < h)
                  {
                    for (; c;)
                      g = 0;
                    b = 0;
                  }
                int i = 0;
                e = g % i;
              }
          }
      for (; f >= 0; f--)
        ;
    }
}
>From gcc-bugs-return-500127-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Oct 20 22:55:26 2015
Return-Path: <gcc-bugs-return-500127-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 35988 invoked by alias); 20 Oct 2015 22:55:25 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 35934 invoked by uid 48); 20 Oct 2015 22:55:20 -0000
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/68037] New: x86 interrupt attribute doesn't work with DRAP
Date: Tue, 20 Oct 2015 22:55:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.3.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: hjl.tools at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone cf_gcctarget
Message-ID: <bug-68037-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-10/txt/msg01682.txt.bz2
Content-length: 7004

https://gcc.gnu.org/bugzilla/show_bug.cgi?idh037

            Bug ID: 68037
           Summary: x86 interrupt attribute doesn't work with DRAP
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: julia.koval at intel dot com
  Target Milestone: ---
            Target: x86

ix86_expand_prologue has

 /* Emit prologue code to adjust stack alignment and setup DRAP, in case
     of DRAP is needed and stack realignment is really needed after reload */
  if (stack_realign_drap)
    {
      int align_bytes = crtl->stack_alignment_needed / BITS_PER_UNIT;

      /* Only need to push parameter pointer reg if it is caller saved.  */
      if (!call_used_regs[REGNO (crtl->drap_reg)])
        {
          /* Push arg pointer reg */
          insn = emit_insn (gen_push (crtl->drap_reg));
          RTX_FRAME_RELATED_P (insn) = 1;
        }

      /* Grab the argument pointer.  */
      t = plus_constant (Pmode, stack_pointer_rtx, m->fs.sp_offset);
      insn = emit_insn (gen_rtx_SET (crtl->drap_reg, t));
      RTX_FRAME_RELATED_P (insn) = 1;
      m->fs.cfa_reg = crtl->drap_reg;
      m->fs.cfa_offset = 0;

      /* Align the stack.  */
      insn = emit_insn (ix86_gen_andsp (stack_pointer_rtx,
                                        stack_pointer_rtx,
                                        GEN_INT (-align_bytes)));
      RTX_FRAME_RELATED_P (insn) = 1;

      /* Replicate the return address on the stack so that return
         address can be reached via (argp - 1) slot.  This is needed
         to implement macro RETURN_ADDR_RTX and intrinsic function
         expand_builtin_return_addr etc.  */
      t = plus_constant (Pmode, crtl->drap_reg, -UNITS_PER_WORD);
      t = gen_frame_mem (word_mode, t);
      insn = emit_insn (gen_push (t));
      RTX_FRAME_RELATED_P (insn) = 1;

It doesn't work with interrupt attribute:

[hjl@gnu-6 interrupt-9]$ cat bar.i
typedef unsigned int uword_t __attribute__ ((mode (__word__)));

uword_t error;
uword_t ip;

struct interrupt_frame
{
  uword_t ip;
  uword_t cs;
  uword_t flags;
};

__attribute__((interrupt))
void
fn (struct interrupt_frame *frame)
{
  if (ip != frame->ip)
    __builtin_abort ();
}
[hjl@gnu-6 interrupt-9]$ /export/build/gnu/gcc-x32/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-x32/build-x86_64-linux/gcc/ -O2   -S bar.i
[hjl@gnu-6 interrupt-9]$ cat bar.s
        .file   "bar.i"
        .text
        .p2align 4,,15
        .globl  fn
        .type   fn, @function
fn:
.LFB0:
        .cfi_startproc
        pushq   %r13
        .cfi_def_cfa_offset 16
        .cfi_offset 13, -16
        leaq    16(%rsp), %r13
        .cfi_def_cfa 13, 0
        andq    $-16, %rsp
        pushq   -8(%r13)
        pushq   %rbp
        .cfi_escape 0x10,0x6,0x2,0x76,0
        movq    %rsp, %rbp
        pushq   %r11
        pushq   %r10
        pushq   %r9
        pushq   %r8
        pushq   %rdi
        pushq   %rsi
        pushq   %rcx
        pushq   %rdx
        pushq   %rax
        subq    $264, %rsp
        .cfi_escape 0x10,0xb,0x2,0x76,0x78
        .cfi_escape 0x10,0xa,0x2,0x76,0x70
        .cfi_escape 0x10,0x9,0x2,0x76,0x68
        .cfi_escape 0x10,0x8,0x2,0x76,0x60
        .cfi_escape 0x10,0x5,0x2,0x76,0x58
        .cfi_escape 0x10,0x4,0x2,0x76,0x50
        .cfi_escape 0x10,0x2,0x2,0x76,0x48
        .cfi_escape 0x10,0x1,0x2,0x76,0x40
        .cfi_escape 0x10,0,0x3,0x76,0xb8,0x7f
        movq    ip(%rip), %rax
        cmpq    %rax, 8(%rbp)
                        ^^^^^
RBP doesn't point to the interrupt data on stack.

        movups  %xmm0, -328(%rbp)
        .cfi_escape 0x10,0x11,0x3,0x76,0xb8,0x7d
        movups  %xmm1, -312(%rbp)
        .cfi_escape 0x10,0x12,0x3,0x76,0xc8,0x7d
        movups  %xmm2, -296(%rbp)
        .cfi_escape 0x10,0x13,0x3,0x76,0xd8,0x7d
        movups  %xmm3, -280(%rbp)
        .cfi_escape 0x10,0x14,0x3,0x76,0xe8,0x7d
        movups  %xmm4, -264(%rbp)
        .cfi_escape 0x10,0x15,0x3,0x76,0xf8,0x7d
        movups  %xmm5, -248(%rbp)
        .cfi_escape 0x10,0x16,0x3,0x76,0x88,0x7e
        movups  %xmm6, -232(%rbp)
        .cfi_escape 0x10,0x17,0x3,0x76,0x98,0x7e
        movups  %xmm7, -216(%rbp)
        .cfi_escape 0x10,0x18,0x3,0x76,0xa8,0x7e
        movups  %xmm8, -200(%rbp)
        .cfi_escape 0x10,0x19,0x3,0x76,0xb8,0x7e
        movups  %xmm9, -184(%rbp)
        .cfi_escape 0x10,0x1a,0x3,0x76,0xc8,0x7e
        movups  %xmm10, -168(%rbp)
        .cfi_escape 0x10,0x1b,0x3,0x76,0xd8,0x7e
        movups  %xmm11, -152(%rbp)
        .cfi_escape 0x10,0x1c,0x3,0x76,0xe8,0x7e
        movups  %xmm12, -136(%rbp)
        .cfi_escape 0x10,0x1d,0x3,0x76,0xf8,0x7e
        movups  %xmm13, -120(%rbp)
        .cfi_escape 0x10,0x1e,0x3,0x76,0x88,0x7f
        movups  %xmm14, -104(%rbp)
        .cfi_escape 0x10,0x1f,0x3,0x76,0x98,0x7f
        movups  %xmm15, -88(%rbp)
        .cfi_escape 0x10,0x20,0x3,0x76,0xa8,0x7f
        jne     .L5
        movups  -328(%rbp), %xmm0
        movups  -312(%rbp), %xmm1
        movups  -296(%rbp), %xmm2
        movups  -280(%rbp), %xmm3
        movups  -264(%rbp), %xmm4
        movups  -248(%rbp), %xmm5
        movups  -232(%rbp), %xmm6
        movups  -216(%rbp), %xmm7
        movups  -200(%rbp), %xmm8
        movups  -184(%rbp), %xmm9
        movups  -168(%rbp), %xmm10
        movups  -152(%rbp), %xmm11
        movups  -136(%rbp), %xmm12
        movups  -120(%rbp), %xmm13
        movups  -104(%rbp), %xmm14
        movups  -88(%rbp), %xmm15
        addq    $264, %rsp
        .cfi_remember_state
        .cfi_restore 31
        .cfi_restore 30
        .cfi_restore 29
        .cfi_restore 28
        .cfi_restore 27
        .cfi_restore 26
        .cfi_restore 25
        .cfi_restore 24
        .cfi_restore 23
        .cfi_restore 22
        .cfi_restore 21
        .cfi_restore 20
        .cfi_restore 19
        .cfi_restore 18
        .cfi_restore 17
        popq    %rax
        popq    %rdx
        popq    %rcx
        popq    %rsi
        popq    %rdi
        popq    %r8
        popq    %r9
        popq    %r10
        popq    %r11
        popq    %rbp
        leaq    -16(%r13), %rsp
        .cfi_def_cfa 7, 16
        popq    %r13
        .cfi_def_cfa_offset 8
        iret
.L5:
        .cfi_restore_state
        call    abort
        .cfi_endproc
.LFE0:
        .size   fn, .-fn
        .comm   ip,8,8
        .comm   error,8,8
        .ident  "GCC: (GNU) 6.0.0 20151020 (experimental)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-6 interrupt-9]$

We need something like

/* Can't use DRAP in interrupt function.  */
if (cfun->machine->func_type != TYPE_NORMAL)
  sorry ("Dynamic Realign Argument Pointer (DRAP) not supported in "
         "interrupt service routine.  This may be worked around by "
         "adding -maccumulate-outgoing-args.");

in ix86_expand_prologue.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/68036] [6 Regression] ICE on valid code at -Os and above on x86_64-linux-gnu
  2015-10-20 22:01 [Bug tree-optimization/68036] New: ICE on valid code at -Os and above on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2015-10-21  8:11 ` mpolacek at gcc dot gnu.org
  2015-10-21  9:31 ` mpolacek at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-10-21  8:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68036

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-valid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-10-21
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |6.0
            Summary|ICE on valid code at -Os    |[6 Regression] ICE on valid
                   |and above on                |code at -Os and above on
                   |x86_64-linux-gnu            |x86_64-linux-gnu
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/68036] [6 Regression] ICE on valid code at -Os and above on x86_64-linux-gnu
  2015-10-20 22:01 [Bug tree-optimization/68036] New: ICE on valid code at -Os and above on x86_64-linux-gnu su at cs dot ucdavis.edu
  2015-10-21  8:11 ` [Bug tree-optimization/68036] [6 Regression] " mpolacek at gcc dot gnu.org
@ 2015-10-21  9:31 ` mpolacek at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-10-21  9:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68036

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Wait, this should be already fixed.

*** This bug has been marked as a duplicate of bug 68031 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-21  9:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-20 22:01 [Bug tree-optimization/68036] New: ICE on valid code at -Os and above on x86_64-linux-gnu su at cs dot ucdavis.edu
2015-10-21  8:11 ` [Bug tree-optimization/68036] [6 Regression] " mpolacek at gcc dot gnu.org
2015-10-21  9:31 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).