[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 rsandifo at gcc dot gnu.org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #12 from rsandifo at gcc dot gnu.org --- Fixed on trunk.
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 --- Comment #11 from rsandifo at gcc dot gnu.org --- Author: rsandifo Date: Fri Jan 15 14:41:10 2016 New Revision: 232428 URL: https://gcc.gnu.org/viewcvs?rev=232428&root=gcc&view=rev Log: PR 69246: Invalid REG_ARGS_SIZE for sibcalls The problem in this PR was that we were treating a sibcall as popping arguments, leading to a negative REG_ARGS_SIZE. It doesn't really make sense to treat sibcalls as popping since (a) they're deallocating the caller's stack, not ours, and (b) there are no optabs for popping sibcalls (any more). Tested on x86_64-linux-gnu. gcc/ PR middle-end/69246 * calls.c (emit_call_1): Force n_popped to zero for sibcalls. gcc/testsuite/ PR middle-end/69246 * gcc.target/i386/pr69246.c: New test. Added: trunk/gcc/testsuite/gcc.target/i386/pr69246.c Modified: trunk/gcc/ChangeLog trunk/gcc/calls.c trunk/gcc/testsuite/ChangeLog
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 --- Comment #10 from Jakub Jelinek --- Created attachment 37342 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37342&action=edit gcc6-pr69246.patch Untested fix that cures the testcase.
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 Richard Biener changed: What|Removed |Added Priority|P3 |P1
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 --- Comment #9 from Richard Henderson --- There wouldn't be anything wrong with REG_ARGS_SIZE on a call_pop pattern in and of itself -- in fact I'd expect it. I don't know if it's worth generating one for a sibcall; it might be easier to treat it the same as a normal call, or it might be just as easy to drop the note. However, there's something whacky about *this* instance. From the .expand dump, (call_insn/j 8 7 9 2 (call (mem:QI (reg/f:SI 89) [0 *a.0_2 S1 A8]) (const_int 4 [0x4])) z.c:8 -1 (expr_list:REG_CALL_DECL (nil) (expr_list:REG_ARGS_SIZE (const_int -4 [0xfffc]) (nil))) This number is supposed to be the number of bytes accumulated for a call site. It should *never* be a negative number.
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 --- Comment #8 from rsandifo at gcc dot gnu.org --- (In reply to rsand...@gcc.gnu.org from comment #7) > I think the problem with the old code was that we were using > a non-sibcall expander for an ECF_SIBCALL call. I.e. we generated > an insn that had the stack adjustment, was marked SIBLING_CALL_P, > and matched *sibcall_pop, but we generated it through call_pop > rather than (the nonexistent) sibcall_pop. > > Perhaps I should instead have kept the calls.c support for > sibcall_pop and sibcall_value_pop and defined corresponding > expanders for x86. Hmm, now I'm not so sure. Defining and using sibcall(_value)_pop does fix the bug, but it prevents the frame pointer from being eliminated, whereas call_pop exists for precisely the opposite reason: For machines where @code{RETURN_POPS_ARGS} can be nonzero, the use of these patterns increases the number of functions for which the frame pointer can be eliminated, if desired. So with current trunk we get a plain jump: foo: jmp *a whereas using *sibcall(_value)_pop gives: foo: pushl %ebp movl%esp, %ebp leave jmp *a (like the pre-patch compiler). So maybe we should go with Segher's patch and delete the *sibcall(_value)_pop patterns?
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 rsandifo at gcc dot gnu.org changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rsandifo at gcc dot gnu.org --- Comment #7 from rsandifo at gcc dot gnu.org --- I think the problem with the old code was that we were using a non-sibcall expander for an ECF_SIBCALL call. I.e. we generated an insn that had the stack adjustment, was marked SIBLING_CALL_P, and matched *sibcall_pop, but we generated it through call_pop rather than (the nonexistent) sibcall_pop. Perhaps I should instead have kept the calls.c support for sibcall_pop and sibcall_value_pop and defined corresponding expanders for x86.
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 Jakub Jelinek changed: What|Removed |Added CC||rth at gcc dot gnu.org --- Comment #6 from Jakub Jelinek --- That note is used for unwind info purposes. /* Indicates the cumulative offset of the stack pointer accounting for pushed arguments. This will only be generated when ACCUMULATE_OUTGOING_ARGS is false. */ I wonder if calls that pop args can be seen also with ACCUMULATE_OUTGOING_ARGS (if yes, then the comment above might not be exact). In any case, the notes are emitted either when ACCUMULATE_OUTGOING_ARGS is false and the call is noreturn, or for calls that pop args.
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 --- Comment #5 from Segher Boessenkool --- The following patch does the trick, if having REG_ARGS_SIZE on sibcalls is correct that is. I couldn't find any documentation on REG_ARGS_SIZE. --- 8< --- diff --git a/gcc/combine.c b/gcc/combine.c index d088031..65091e2 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -13690,7 +13690,8 @@ distribute_notes (rtx notes, rtx_insn *from_insn, rtx_in gcc_assert (old_size != args_size || (CALL_P (i3) && !ACCUMULATE_OUTGOING_ARGS - && find_reg_note (i3, REG_NORETURN, NULL_RTX))); + && (find_reg_note (i3, REG_NORETURN, NULL_RTX) + || SIBLING_CALL_P (i3; } break; --- 8< ---
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 Jakub Jelinek changed: What|Removed |Added CC||uros at gcc dot gnu.org --- Comment #4 from Jakub Jelinek --- Anyway, before the mentioned commit, the call insn used a parallel with stack adjustment, which is likely why the combiner didn't try to touch it, but now it doesn't (supposedly because it is a tail call?). Thus, wondering if the change was desirable for the stdcall calls (dropping the stack adjustment from the sibcall patterns), whether they can be sibcalls at all, and whether distribute_notes just shouldn't accept REG_ARGS_SIZE on any sibcalls.
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 --- Comment #3 from Jakub Jelinek --- Cleaned up simplified testcase: typedef void (__attribute__ ((stdcall)) *T) (int); T a; void __attribute__ ((stdcall)) foo (int x) { a (x); }
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 --- Comment #2 from Jakub Jelinek --- Also, ICEs both in C and C++.
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2016-01-12 CC||jakub at gcc dot gnu.org, ||rsandifo at gcc dot gnu.org, ||segher at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Jakub Jelinek --- Started with r227143. Just -m32 -O2 -is enough to reproduce.
[Bug rtl-optimization/69246] [6 Regression] ICE in distribute_notes, at combine.c:13693 on i686-linux-gnu
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69246 Richard Biener changed: What|Removed |Added Component|tree-optimization |rtl-optimization Target Milestone|--- |6.0