Bug 59553 - emit_library_call_value_1 generates usage of virtual_outgoing_args_rtx when virtuals_instantiated is 1
Summary: emit_library_call_value_1 generates usage of virtual_outgoing_args_rtx when v...
Status: RESOLVED DUPLICATE of bug 52773
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-19 00:45 UTC by Alexey Makhalov
Modified: 2022-01-10 10:12 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
patch to fix that problem (407 bytes, patch)
2013-12-19 00:45 UTC, Alexey Makhalov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Makhalov 2013-12-19 00:45:31 UTC
Created attachment 31476 [details]
patch to fix that problem

I'm porting gcc on some target.
I have following macroses:
#define ACCUMULATE_OUTGOING_ARGS 0
#define PUSH_ARGS 1
#define PUSH_ARGS_REVERSED 0

As you can see it's rarely case.

I got following ICE:
webizer.c: In function 'configure2':
webizer.c:30:1: internal compiler error: in replace_pseudos_in, at reload1.c:576
 }
 ^
0x8386eea replace_pseudos_in
	../../gcc-4.8.2/gcc/reload1.c:575
0x8386eae replace_pseudos_in
	../../gcc-4.8.2/gcc/reload1.c:592
0x8386eae replace_pseudos_in
	../../gcc-4.8.2/gcc/reload1.c:592
0x8386eae replace_pseudos_in
	../../gcc-4.8.2/gcc/reload1.c:592
0x839160f reload(rtx_def*, int)
	../../gcc-4.8.2/gcc/reload1.c:1185
0x82cb8eb do_reload
	../../gcc-4.8.2/gcc/ira.c:4679
0x82cb8eb rest_of_handle_reload
	../../gcc-4.8.2/gcc/ira.c:4779


replace_pseudos_in was trying to replace virtual-outgoing-args in that instruction:

(call_insn/u 121 601 124 4 (parallel [
            (set (reg:SI 0 r0)
                (call (mem:SI (symbol_ref:SI ("__lshrsi3") [flags 0x41]) [0 S4 A32])
                    (const_int 8 [0x8])))
        ]) 38 {call_value_insn_sym}
     (expr_list:REG_EH_REGION (const_int -2147483648 [0x80000000])
        (nil))
    (expr_list:REG_DEP_TRUE (use (mem:SI (plus:SI (reg/f:SI 16 virtual-outgoing-args)
                    (scratch:SI)) [0 S4 A32]))
        (expr_list:REG_DEP_TRUE (use (mem:SI (plus:SI (reg/f:SI 16 virtual-outgoing-args)
                        (scratch:SI)) [0 S4 A32]))
            (nil))))

I found a place where gcc emits this call and expr list:
calls.c:4053 (emit_library_call_value_1)
At that moment virtuals_instantiated was equal 1.
So that is an error, because forbidden to use virtual regs when virtuals_instantiated is nonzero.

I decide to make changes similar to calls.c:3915 (to use SP + OFFSET)
It works for me.

--- calls.c	2013-12-19 00:16:59.857462118 -0800
+++ calls.c	2013-12-19 00:39:03.780723916 -0800
@@ -4050,8 +4050,14 @@
 	       auto-increment causes confusion.  So we merely indicate
 	       that we access something with a known mode somewhere on
 	       the stack.  */
-	    use = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
-				gen_rtx_SCRATCH (Pmode));
+	    if (virtuals_instantiated)
+	      use = gen_rtx_PLUS (Pmode, 
+			          plus_constant (Pmode, stack_pointer_rtx,
+				  		 STACK_POINTER_OFFSET),
+				  gen_rtx_SCRATCH (Pmode));
+	    else
+	      use = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
+				  gen_rtx_SCRATCH (Pmode));
 	  use = gen_rtx_MEM (argvec[argnum].mode, use);
 	  use = gen_rtx_USE (VOIDmode, use);
 	  call_fusage = gen_rtx_EXPR_LIST (VOIDmode, use, call_fusage);
 

Thanks.
Alexey
Comment 1 Andrew Pinski 2022-01-10 10:12:50 UTC
An almost exact dup of bug 52773 which was fixed in GCC 5 by r5-6559. The fix uses stack_pointer_rtx always instead of virtual_outgoing_args_rtx.

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