public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/66334] New: cleanup block fails to initialize EBX
@ 2015-05-29 2:50 hjl.tools at gmail dot com
2015-05-29 2:56 ` [Bug middle-end/66334] " hjl.tools at gmail dot com
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-29 2:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
Bug ID: 66334
Summary: cleanup block fails to initialize EBX
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
CC: ubizjak at gmail dot com
Target Milestone: ---
Target: i?86-linux
[hjl@gnu-tools-1 tmp]$ cat x.i
extern int foo (int);
extern void exit (int __status) __attribute__ ((__nothrow__ )) __attribute__
((__noreturn__));
struct __pthread_cleanup_frame
{
void (*__cancel_routine) (void *);
void *__cancel_arg;
int __do_it;
int __cancel_type;
};
extern __inline void
__pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame)
{
if (__frame->__do_it)
__frame->__cancel_routine (__frame->__cancel_arg);
}
static int cl_called;
static void
cl (void *arg)
{
++cl_called;
}
void *
tf_usleep (void *arg)
{
do { struct __pthread_cleanup_frame __clframe __attribute__ ((__cleanup__
(__pthread_cleanup_routine))) = { .__cancel_routine = (cl), .__cancel_arg = (
((void *)0)), .__do_it = 1 };;
foo (arg == ((void *)0) ? (0x7fffffffL * 2UL + 1UL) : 0);
__clframe.__do_it = (0); } while (0);
exit (1);
}
[hjl@gnu-tools-1 tmp]$ /usr/gcc-6.0.0-pie/bin/gcc -fexceptions
-fasynchronous-unwind-tables -m32 -S -O2 /tmp/x.i -fpic
[hjl@gnu-tools-1 tmp]$ cat x.s
.file "x.i"
.section .text.unlikely,"ax",@progbits
.LCOLDB0:
.text
.LHOTB0:
.p2align 4,,15
.type cl, @function
cl:
.LFB1:
.cfi_startproc
call __x86.get_pc_thunk.ax
addl $_GLOBAL_OFFSET_TABLE_, %eax
addl $1, cl_called@GOTOFF(%eax)
ret
.cfi_endproc
.LFE1:
.size cl, .-cl
.section .text.unlikely
.LCOLDE0:
.text
.LHOTE0:
.section .text.unlikely
.LCOLDB1:
.text
.LHOTB1:
.p2align 4,,15
.globl __pthread_cleanup_routine
.type __pthread_cleanup_routine, @function
__pthread_cleanup_routine:
.LFB0:
.cfi_startproc
movl 4(%esp), %eax
movl 8(%eax), %edx
testl %edx, %edx
jne .L5
rep ret
.p2align 4,,10
.p2align 3
.L5:
movl 4(%eax), %edx
movl %edx, 4(%esp)
jmp *(%eax)
.cfi_endproc
.LFE0:
.size __pthread_cleanup_routine, .-__pthread_cleanup_routine
.section .text.unlikely
.LCOLDE1:
.text
.LHOTE1:
.section .text.unlikely
.LCOLDB2:
.text
.LHOTB2:
.p2align 4,,15
.globl tf_usleep
.type tf_usleep, @function
tf_usleep:
.LFB2:
.cfi_startproc
.cfi_personality 0x9b,DW.ref.__gcc_personality_v0
.cfi_lsda 0x1b,.LLSDA2
pushl %ebp
.cfi_def_cfa_offset 8
.cfi_offset 5, -8
xorl %eax, %eax
movl %esp, %ebp
.cfi_def_cfa_register 5
pushl %esi
pushl %ebx
.cfi_offset 6, -12
.cfi_offset 3, -16
movl 8(%ebp), %edx
subl $12, %esp
call __x86.get_pc_thunk.bx
addl $_GLOBAL_OFFSET_TABLE_, %ebx
testl %edx, %edx
sete %al
negl %eax
pushl %eax
.LEHB0:
.cfi_escape 0x2e,0x10
call foo@PLT
.LEHE0:
movl $1, (%esp)
call exit@PLT
.L8:
subl $12, %esp
movl %eax, %esi
pushl $0
call cl
movl %esi, (%esp)
.LEHB1:
call _Unwind_Resume@PLT
.LEHE1:
.cfi_endproc
.LFE2:
.globl __gcc_personality_v0
.section .gcc_except_table,"a",@progbits
.LLSDA2:
.byte 0xff
.byte 0xff
.byte 0x1
.uleb128 .LLSDACSE2-.LLSDACSB2
.LLSDACSB2:
.uleb128 .LEHB0-.LFB2
.uleb128 .LEHE0-.LEHB0
.uleb128 .L8-.LFB2
.uleb128 0
.uleb128 .LEHB1-.LFB2
.uleb128 .LEHE1-.LEHB1
.uleb128 0
.uleb128 0
.LLSDACSE2:
.text
.size tf_usleep, .-tf_usleep
.section .text.unlikely
.LCOLDE2:
.text
.LHOTE2:
.local cl_called
.comm cl_called,4,4
.section
.text.__x86.get_pc_thunk.ax,"axG",@progbits,__x86.get_pc_thunk.ax,comdat
.globl __x86.get_pc_thunk.ax
.hidden __x86.get_pc_thunk.ax
.type __x86.get_pc_thunk.ax, @function
__x86.get_pc_thunk.ax:
.LFB4:
.cfi_startproc
movl (%esp), %eax
ret
.cfi_endproc
.LFE4:
.section
.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
.globl __x86.get_pc_thunk.bx
.hidden __x86.get_pc_thunk.bx
.type __x86.get_pc_thunk.bx, @function
__x86.get_pc_thunk.bx:
.LFB5:
.cfi_startproc
movl (%esp), %ebx
ret
.cfi_endproc
.LFE5:
.hidden DW.ref.__gcc_personality_v0
.weak DW.ref.__gcc_personality_v0
.section
.data.DW.ref.__gcc_personality_v0,"awG",@progbits,DW.ref.__gcc_personality_v0,comdat
.align 4
.type DW.ref.__gcc_personality_v0, @object
.size DW.ref.__gcc_personality_v0, 4
DW.ref.__gcc_personality_v0:
.long __gcc_personality_v0
.ident "GCC: (GNU) 6.0.0 20150528 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-tools-1 tmp]$
The problem is
.L8:
subl $12, %esp
movl %eax, %esi
pushl $0
call cl
movl %esi, (%esp)
.LEHB1:
call _Unwind_Resume@PLT
.LEHE1:
This cleanup block is called via
.section .gcc_except_table,"a",@progbits
.LLSDA2:
.byte 0xff
.byte 0xff
.byte 0x1
.uleb128 .LLSDACSE2-.LLSDACSB2
.LLSDACSB2:
.uleb128 .LEHB0-.LFB2
.uleb128 .LEHE0-.LEHB0
.uleb128 .L8-.LFB2
.uleb128 0
.uleb128 .LEHB1-.LFB2
.uleb128 .LEHE1-.LEHB1
.uleb128 0
.uleb128 0
.LLSDACSE2:
When the cleanup block is entered, EBX isn't valid. In PIC, the cleanup
block must initialize EBX before branching to PLT.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
@ 2015-05-29 2:56 ` hjl.tools at gmail dot com
2015-05-29 20:37 ` hjl.tools at gmail dot com
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-29 2:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
Run-time testcases are nptl/tst-cancelx4.c and nptl/tst-cancelx5.c
in glibc when compiled with -fPIE -pie on Linux/x86.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
2015-05-29 2:56 ` [Bug middle-end/66334] " hjl.tools at gmail dot com
@ 2015-05-29 20:37 ` hjl.tools at gmail dot com
2015-05-29 21:54 ` hjl.tools at gmail dot com
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-29 20:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-05-29
CC| |vmakarov at redhat dot com
Ever confirmed|0 |1
--- Comment #2 from H.J. Lu <hjl.tools at gmail dot com> ---
After IRA,
(insn 34 33 35 5 (set (reg:SI 3 bx)
(reg:SI 87)) 86 {*movsi_internal}
(expr_list:REG_DEAD (reg:SI 87)
(nil)))
(call_insn 35 34 36 5 (call (mem:QI (symbol_ref:SI ("_Unwind_Resume") [flags
0x41] <function_decl 0x7f1f9f3005e8 __builtin_unwind_resume>) [0
__builtin_unwind_resume S1 A8])
(const_int 16 [0x10])) 649 {*call}
(expr_list:REG_DEAD (reg:SI 3 bx)
(expr_list:REG_CALL_DECL (symbol_ref:SI ("_Unwind_Resume") [flags 0x41]
<function_decl 0x7f1f9f3005e8 __builtin_unwind_resume>)
(expr_list:REG_ARGS_SIZE (const_int 16 [0x10])
(expr_list:REG_NORETURN (const_int 0 [0])
(nil)))))
(expr_list (use (reg:SI 3 bx))
(nil)))
LRA removed:
(insn 34 33 35 5 (set (reg:SI 3 bx)
(reg:SI 87)) 86 {*movsi_internal}
(expr_list:REG_DEAD (reg:SI 87)
(nil)))
LRA should recognize that BUILT_IN_UNWIND_RESUME and initialize EBX.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
2015-05-29 2:56 ` [Bug middle-end/66334] " hjl.tools at gmail dot com
2015-05-29 20:37 ` hjl.tools at gmail dot com
@ 2015-05-29 21:54 ` hjl.tools at gmail dot com
2015-05-29 21:55 ` hjl.tools at gmail dot com
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-29 21:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
This seems to work:
diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index 085411e..a0c6171 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -979,8 +979,7 @@ process_bb_lives (basic_block bb, int &curr_point, bool
dead_insn_p)
allocate such regs in this case. */
if (!cfun->has_nonlocal_label && bb_has_abnormal_call_pred (bb))
for (px = 0; px < FIRST_PSEUDO_REGISTER; px++)
- if (call_used_regs[px])
- make_hard_regno_born (px, false);
+ make_hard_regno_born (px, false);
}
bool live_change_p = false;
Vladimir, what is the correct fix?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (2 preceding siblings ...)
2015-05-29 21:54 ` hjl.tools at gmail dot com
@ 2015-05-29 21:55 ` hjl.tools at gmail dot com
2015-05-31 13:16 ` hjl.tools at gmail dot com
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-29 21:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |6.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (3 preceding siblings ...)
2015-05-29 21:55 ` hjl.tools at gmail dot com
@ 2015-05-31 13:16 ` hjl.tools at gmail dot com
2015-06-01 14:21 ` hjl.tools at gmail dot com
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-05-31 13:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to H.J. Lu from comment #4)
> This seems to work:
>
> diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
> index 085411e..a0c6171 100644
> --- a/gcc/lra-lives.c
> +++ b/gcc/lra-lives.c
> @@ -979,8 +979,7 @@ process_bb_lives (basic_block bb, int &curr_point, bool
> dead_insn_p)
> allocate such regs in this case. */
> if (!cfun->has_nonlocal_label && bb_has_abnormal_call_pred (bb))
> for (px = 0; px < FIRST_PSEUDO_REGISTER; px++)
> - if (call_used_regs[px])
> - make_hard_regno_born (px, false);
> + make_hard_regno_born (px, false);
> }
>
> bool live_change_p = false;
>
> Vladimir, what is the correct fix?
process_bb_node_lives in ira-lives.c has the same issue.
>From gcc-bugs-return-487656-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sun May 31 13:34:23 2015
Return-Path: <gcc-bugs-return-487656-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 75111 invoked by alias); 31 May 2015 13:34:22 -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 75062 invoked by uid 48); 31 May 2015 13:34:18 -0000
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/66349] ICE on valid code at -O1, -O2 and -O3 on x86_64-linux-gnu in dfs_enumerate_from, at cfganal.c:1195
Date: Sun, 31 May 2015 13:34:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: hjl.tools at gmail dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc target_milestone everconfirmed
Message-ID: <bug-66349-4-QjoRhJDVX5@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66349-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66349-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-05/txt/msg02496.txt.bz2
Content-length: 611
https://gcc.gnu.org/bugzilla/show_bug.cgi?idf349
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-05-31
CC| |rguenther at suse dot de
Target Milestone|--- |6.0
Ever confirmed|0 |1
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
It was caused by r223861.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (4 preceding siblings ...)
2015-05-31 13:16 ` hjl.tools at gmail dot com
@ 2015-06-01 14:21 ` hjl.tools at gmail dot com
2015-07-03 17:25 ` vmakarov at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-06-01 14:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
Should we do something special if a basic block calls BUILT_IN_UNWIND_RESUME?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (5 preceding siblings ...)
2015-06-01 14:21 ` hjl.tools at gmail dot com
@ 2015-07-03 17:25 ` vmakarov at gcc dot gnu.org
2015-07-03 18:42 ` hjl.tools at gmail dot com
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: vmakarov at gcc dot gnu.org @ 2015-07-03 17:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
Vladimir Makarov <vmakarov at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vmakarov at gcc dot gnu.org
--- Comment #7 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #2)
> After IRA,
>
> (insn 34 33 35 5 (set (reg:SI 3 bx)
> (reg:SI 87)) 86 {*movsi_internal}
> (expr_list:REG_DEAD (reg:SI 87)
> (nil)))
> (call_insn 35 34 36 5 (call (mem:QI (symbol_ref:SI ("_Unwind_Resume") [flags
> 0x41] <function_decl 0x7f1f9f3005e8 __builtin_unwind_resume>) [0
> __builtin_unwind_resume S1 A8])
> (const_int 16 [0x10])) 649 {*call}
> (expr_list:REG_DEAD (reg:SI 3 bx)
> (expr_list:REG_CALL_DECL (symbol_ref:SI ("_Unwind_Resume") [flags
> 0x41] <function_decl 0x7f1f9f3005e8 __builtin_unwind_resume>)
> (expr_list:REG_ARGS_SIZE (const_int 16 [0x10])
> (expr_list:REG_NORETURN (const_int 0 [0])
> (nil)))))
> (expr_list (use (reg:SI 3 bx))
> (nil)))
>
> LRA removed:
>
> (insn 34 33 35 5 (set (reg:SI 3 bx)
> (reg:SI 87)) 86 {*movsi_internal}
> (expr_list:REG_DEAD (reg:SI 87)
> (nil)))
>
> LRA should recognize that BUILT_IN_UNWIND_RESUME and initialize EBX.
I've looked at this. Insn 34 is transformed into
ebx=ebx
as pseudo 87 gets ebx. At the very end. LRA removes the useless insn.
Therefore there is no insn setting ebx.
H.J., is it really a problem?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (6 preceding siblings ...)
2015-07-03 17:25 ` vmakarov at gcc dot gnu.org
@ 2015-07-03 18:42 ` hjl.tools at gmail dot com
2015-07-03 21:04 ` vmakarov at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-07-03 18:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Vladimir Makarov from comment #7)
> I've looked at this. Insn 34 is transformed into
>
> ebx=ebx
>
> as pseudo 87 gets ebx. At the very end. LRA removes the useless insn.
> Therefore there is no insn setting ebx.
>
> H.J., is it really a problem?
The problem is although ebx, which is used for PIC, is callee saved, but
ebx has junk when called from BUILT_IN_UNWIND_RESUME. LRA should
reinitialize it.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (7 preceding siblings ...)
2015-07-03 18:42 ` hjl.tools at gmail dot com
@ 2015-07-03 21:04 ` vmakarov at gcc dot gnu.org
2015-07-04 13:57 ` hjl.tools at gmail dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: vmakarov at gcc dot gnu.org @ 2015-07-03 21:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #9 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #8)
> (In reply to Vladimir Makarov from comment #7)
> > I've looked at this. Insn 34 is transformed into
> >
> > ebx=ebx
> >
> > as pseudo 87 gets ebx. At the very end. LRA removes the useless insn.
> > Therefore there is no insn setting ebx.
> >
> > H.J., is it really a problem?
>
> The problem is although ebx, which is used for PIC, is callee saved, but
> ebx has junk when called from BUILT_IN_UNWIND_RESUME. LRA should
> reinitialize it.
I see. It would be nice that eh machinary saved ebx. But even if it is done,
we would have compatibility problem with already existing code. So there is no
other way than fixing it GCC.
I guess it is a continuation of work to use PIC hard reg by introducing PIC
pseudo. PIC pseudo should conflict with PIC hard reg because ebx can be
corrupted in this case. So in general your solution proposal is right but it
needs more details.
I will work on the patch and commit it on next week.
Thanks.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (8 preceding siblings ...)
2015-07-03 21:04 ` vmakarov at gcc dot gnu.org
@ 2015-07-04 13:57 ` hjl.tools at gmail dot com
2015-07-07 19:35 ` vmakarov at gcc dot gnu.org
2015-07-08 15:05 ` vmakarov at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: hjl.tools at gmail dot com @ 2015-07-04 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Vladimir Makarov from comment #9)
>
> I will work on the patch and commit it on next week.
>
> Thanks.
I tried this patch:
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ab377c74f283f3db51b4e250b9c7acecc32e8ff8
It seems to work.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (9 preceding siblings ...)
2015-07-04 13:57 ` hjl.tools at gmail dot com
@ 2015-07-07 19:35 ` vmakarov at gcc dot gnu.org
2015-07-08 15:05 ` vmakarov at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: vmakarov at gcc dot gnu.org @ 2015-07-07 19:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #11 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #10)
> (In reply to Vladimir Makarov from comment #9)
> >
> > I will work on the patch and commit it on next week.
> >
> > Thanks.
>
> I tried this patch:
>
> https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;
> h=ab377c74f283f3db51b4e250b9c7acecc32e8ff8
>
> It seems to work.
Thanks, H.J. Your patch fixes given problem but I'd like to play more safe.
May be there are some analogous situations with explicit ebx setting.
So I am going to submit the following patch today or tomorrow.
Index: ChangeLog
===================================================================
--- ChangeLog (revision 225200)
+++ ChangeLog (working copy)
@@ -1,3 +1,10 @@
+2015-07-06 Vladimir Makarov <vmakarov@redhat.com>
+
+ PR middle-end/66334
+ * ira-lives.c (process_bb_node_lives): Make conflicts with PIC
+ hard regno live at the start of BB with incoming abnormal edges.
+ * lra-lives.c (process_bb_lives): Ditto.
+
2015-06-30 Vladimir Makarov <vmakarov@redhat.com>
PR debug/66691
Index: ira-lives.c
===================================================================
--- ira-lives.c (revision 225134)
+++ ira-lives.c (working copy)
@@ -1346,7 +1346,21 @@ process_bb_node_lives (ira_loop_tree_nod
allocate such regs in this case. */
if (!cfun->has_nonlocal_label && bb_has_abnormal_call_pred (bb))
for (px = 0; px < FIRST_PSEUDO_REGISTER; px++)
- if (call_used_regs[px])
+ if (call_used_regs[px]
+#ifdef REAL_PIC_OFFSET_TABLE_REGNUM
+ /* We should create a conflict of PIC pseudo with
+ PIC hard reg as PIC hard reg can have a wrong
+ value after jump described by the abnormal edge.
+ In this case we can not allocate PIC hard reg to
+ PIC pseudo as PIC pseudo will also have a wrong
+ value. This code is not critical as LRA can fix
+ it but it is better to have the right allocation
+ earlier. */
+ || (px == REAL_PIC_OFFSET_TABLE_REGNUM
+ && pic_offset_table_rtx != NULL_RTX
+ && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER)
+#endif
+ )
make_hard_regno_born (px);
}
Index: lra-lives.c
===================================================================
--- lra-lives.c (revision 225200)
+++ lra-lives.c (working copy)
@@ -957,7 +957,18 @@ process_bb_lives (basic_block bb, int &c
allocate such regs in this case. */
if (!cfun->has_nonlocal_label && bb_has_abnormal_call_pred (bb))
for (px = 0; px < FIRST_PSEUDO_REGISTER; px++)
- if (call_used_regs[px])
+ if (call_used_regs[px]
+#ifdef REAL_PIC_OFFSET_TABLE_REGNUM
+ /* We should create a conflict of PIC pseudo with PIC
+ hard reg as PIC hard reg can have a wrong value after
+ jump described by the abnormal edge. In this case we
+ can not allocate PIC hard reg to PIC pseudo as PIC
+ pseudo will also have a wrong value. */
+ || (px == REAL_PIC_OFFSET_TABLE_REGNUM
+ && pic_offset_table_rtx != NULL_RTX
+ && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER)
+#endif
+ )
make_hard_regno_born (px, false);
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug middle-end/66334] cleanup block fails to initialize EBX
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
` (10 preceding siblings ...)
2015-07-07 19:35 ` vmakarov at gcc dot gnu.org
@ 2015-07-08 15:05 ` vmakarov at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: vmakarov at gcc dot gnu.org @ 2015-07-08 15:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66334
--- Comment #12 from Vladimir Makarov <vmakarov at gcc dot gnu.org> ---
Author: vmakarov
Date: Wed Jul 8 15:04:54 2015
New Revision: 225561
URL: https://gcc.gnu.org/viewcvs?rev=225561&root=gcc&view=rev
Log:
2015-07-08 Vladimir Makarov <vmakarov@redhat.com>
PR middle-end/66334
* ira-lives.c (process_bb_node_lives): Make conflicts with PIC
hard regno live at the start of BB with incoming abnormal edges.
* lra-lives.c (process_bb_lives): Ditto.
2015-07-08 Vladimir Makarov <vmakarov@redhat.com>
PR middle-end/66334
* gcc.target/i386/pr66334.c: New.
Added:
trunk/gcc/testsuite/gcc.target/i386/pr66334.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/ira-lives.c
trunk/gcc/lra-lives.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2015-07-08 15:05 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-29 2:50 [Bug middle-end/66334] New: cleanup block fails to initialize EBX hjl.tools at gmail dot com
2015-05-29 2:56 ` [Bug middle-end/66334] " hjl.tools at gmail dot com
2015-05-29 20:37 ` hjl.tools at gmail dot com
2015-05-29 21:54 ` hjl.tools at gmail dot com
2015-05-29 21:55 ` hjl.tools at gmail dot com
2015-05-31 13:16 ` hjl.tools at gmail dot com
2015-06-01 14:21 ` hjl.tools at gmail dot com
2015-07-03 17:25 ` vmakarov at gcc dot gnu.org
2015-07-03 18:42 ` hjl.tools at gmail dot com
2015-07-03 21:04 ` vmakarov at gcc dot gnu.org
2015-07-04 13:57 ` hjl.tools at gmail dot com
2015-07-07 19:35 ` vmakarov at gcc dot gnu.org
2015-07-08 15:05 ` vmakarov 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).