* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
@ 2022-06-15 9:13 ` rguenth at gcc dot gnu.org
2022-06-16 14:03 ` marxin at gcc dot gnu.org
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-15 9:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.4
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
2022-06-15 9:13 ` [Bug target/105980] " rguenth at gcc dot gnu.org
@ 2022-06-16 14:03 ` marxin at gcc dot gnu.org
2022-06-17 10:21 ` ubizjak at gmail dot com
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-16 14:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
CC| |andi-gcc at firstfloor dot org,
| |marxin at gcc dot gnu.org
Last reconfirmed| |2022-06-16
Ever confirmed|0 |1
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Reduced to something like:
struct A {
virtual ~A();
};
struct B : virtual A {};
void bar() { B(); }
It's there since the beginning as we emitted an invalid assembly:
/tmp/ccw0I6Qv.s:178: Error: `.LTHUNK0@GOTOFF(%bh)' is not a valid base/index
expression
/tmp/ccw0I6Qv.s:235: Error: `.LTHUNK1@GOTOFF(%bh)' is not a valid base/index
expression
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
2022-06-15 9:13 ` [Bug target/105980] " rguenth at gcc dot gnu.org
2022-06-16 14:03 ` marxin at gcc dot gnu.org
@ 2022-06-17 10:21 ` ubizjak at gmail dot com
2022-07-25 16:00 ` rguenth at gcc dot gnu.org
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: ubizjak at gmail dot com @ 2022-06-17 10:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
emit_move_insn in this part of ix86_output_mi_thunk:
21464 if (!sibcall_insn_operand (fnaddr, word_mode))
21465 {
21466 tmp = gen_rtx_REG (word_mode, tmp_regno);
21467 if (GET_MODE (fnaddr) != word_mode)
21468 fnaddr = gen_rtx_ZERO_EXTEND (word_mode, fnaddr);
21469 emit_move_insn (tmp, fnaddr);
21470 fnaddr = tmp;
21471 }
is creating RTX with pseudos when trying to move fnaddr:
(symbol_ref:SI ("*.LTHUNK0") [flags 0x3] <function_decl 0x7fffea325700
*.LTHUNK0>)
to a temporary register:
(insn 6 5 7 (set (reg:SI 82)
(plus:SI (reg:SI 82)
(const:SI (unspec:SI [
(symbol_ref:SI ("*.LTHUNK0") [flags 0x3] <function_decl
0x7fffea325700 *.LTHUNK0>)
] UNSPEC_GOTOFF)))) "pr105980.C":4:8 -1
(nil))
(insn 7 6 8 (set (reg:SI 2 cx)
(reg:SI 82)) "pr105980.C":4:8 -1
(expr_list:REG_EQUAL (symbol_ref:SI ("*.LTHUNK0") [flags 0x3]
<function_decl 0x7fffea325700 *.LTHUNK0>)
(nil)))
This won't fly when we are in the final pass, way late after reload.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (2 preceding siblings ...)
2022-06-17 10:21 ` ubizjak at gmail dot com
@ 2022-07-25 16:00 ` rguenth at gcc dot gnu.org
2022-07-29 13:46 ` jakub at gcc dot gnu.org
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-25 16:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Priority|P3 |P2
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (3 preceding siblings ...)
2022-07-25 16:00 ` rguenth at gcc dot gnu.org
@ 2022-07-29 13:46 ` jakub at gcc dot gnu.org
2022-07-29 18:41 ` hjl.tools at gmail dot com
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-07-29 13:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If we follow what other backends do in *_output_mi_thunk, it would be
--- gcc/config/i386/i386.cc.jj 2022-07-26 10:32:23.373275765 +0200
+++ gcc/config/i386/i386.cc 2022-07-29 15:25:26.023555541 +0200
@@ -21396,6 +21396,7 @@ x86_output_mi_thunk (FILE *file, tree th
tmp_regno = CX_REG;
}
+ reload_completed = 1;
emit_note (NOTE_INSN_PROLOGUE_END);
/* CET is enabled, insert EB instruction. */
@@ -21561,6 +21562,9 @@ x86_output_mi_thunk (FILE *file, tree th
final (insn, file, 1);
final_end_function ();
assemble_end_function (thunk_fndecl, fnname);
+
+ /* Stop pretending to be a post-reload pass. */
+ reload_completed = 0;
}
static void
Unfortunately, that doesn't help much, the next problem is that it needs
pic_offset_table_rtx as a hard register, so we probably before
tmp = gen_rtx_REG (word_mode, tmp_regno);
if (GET_MODE (fnaddr) != word_mode)
fnaddr = gen_rtx_ZERO_EXTEND (word_mode, fnaddr);
emit_move_insn (tmp, fnaddr);
fnaddr = tmp;
in the above mentioned snippet need to do something like:
if (flag_pic && !TARGET_64BIT && !TARGET_MACHO && SYMBOLIC_CONST
(fnaddr))
{
pic_offset_table_rtx = gen_reg_RTX (Pmode, some_suitable_reg);
ix86_init_pic_reg ();
}
or something similar. But unsure about the exact conditions,
insert_insn_on_edge will likely not work either etc.
So it likely needs emit_insn (gen_set_got (reg)) etc. directly.
}
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (4 preceding siblings ...)
2022-07-29 13:46 ` jakub at gcc dot gnu.org
@ 2022-07-29 18:41 ` hjl.tools at gmail dot com
2022-07-29 20:10 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: hjl.tools at gmail dot com @ 2022-07-29 18:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
--- Comment #4 from H.J. Lu <hjl.tools at gmail dot com> ---
We don't have available scratch registers in 32-bit mode for
x86_output_mi_thunk.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (5 preceding siblings ...)
2022-07-29 18:41 ` hjl.tools at gmail dot com
@ 2022-07-29 20:10 ` jakub at gcc dot gnu.org
2022-07-29 20:37 ` hjl.tools at gmail dot com
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-07-29 20:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
So, shall we temporarily disable -mforce-indirect-call during the mi thunk
output?
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (6 preceding siblings ...)
2022-07-29 20:10 ` jakub at gcc dot gnu.org
@ 2022-07-29 20:37 ` hjl.tools at gmail dot com
2023-01-16 18:02 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: hjl.tools at gmail dot com @ 2022-07-29 20:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Jakub Jelinek from comment #5)
> So, shall we temporarily disable -mforce-indirect-call during the mi thunk
> output?
Something like this
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index e03f86d4a23..394fcac53a2 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -21382,6 +21382,7 @@ x86_output_mi_thunk (FILE *file, tree thunk_fndecl,
HOST_WIDE_INT delta,
rtx this_reg, tmp, fnaddr;
unsigned int tmp_regno;
rtx_insn *insn;
+ int saved_flag_force_indirect_call = flag_force_indirect_call;
if (TARGET_64BIT)
tmp_regno = R10_REG;
@@ -21394,6 +21395,9 @@ x86_output_mi_thunk (FILE *file, tree thunk_fndecl,
HOST_WIDE_INT delta,
tmp_regno = DX_REG;
else
tmp_regno = CX_REG;
+
+ if (flag_pic)
+ flag_force_indirect_call = 0;
}
emit_note (NOTE_INSN_PROLOGUE_END);
@@ -21561,6 +21565,8 @@ x86_output_mi_thunk (FILE *file, tree thunk_fndecl,
HOST_WIDE_INT delta,
final (insn, file, 1);
final_end_function ();
assemble_end_function (thunk_fndecl, fnname);
+
+ flag_force_indirect_call = saved_flag_force_indirect_call;
}
static void
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (7 preceding siblings ...)
2022-07-29 20:37 ` hjl.tools at gmail dot com
@ 2023-01-16 18:02 ` jakub at gcc dot gnu.org
2023-01-16 19:00 ` hjl.tools at gmail dot com
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-16 18:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Can you post it to gcc-patches?
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (8 preceding siblings ...)
2023-01-16 18:02 ` jakub at gcc dot gnu.org
@ 2023-01-16 19:00 ` hjl.tools at gmail dot com
2023-01-16 22:11 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: hjl.tools at gmail dot com @ 2023-01-16 19:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> ---
A patch is posted at
https://gcc.gnu.org/pipermail/gcc-patches/2023-January/610035.html
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (9 preceding siblings ...)
2023-01-16 19:00 ` hjl.tools at gmail dot com
@ 2023-01-16 22:11 ` cvs-commit at gcc dot gnu.org
2023-03-24 16:15 ` [Bug target/105980] [11/12 " jakub at gcc dot gnu.org
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-16 22:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:
https://gcc.gnu.org/g:a396a123596d82d4a2f14dc43a382cb17826411c
commit r13-5218-ga396a123596d82d4a2f14dc43a382cb17826411c
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jan 16 10:45:41 2023 -0800
x86: Disable -mforce-indirect-call for PIC in 32-bit mode
-mforce-indirect-call generates invalid instruction in 32-bit MI thunk
since there are no available scratch registers in 32-bit PIC mode.
Disable -mforce-indirect-call for PIC in 32-bit mode when generating
MI thunk.
gcc/
PR target/105980
* config/i386/i386.cc (x86_output_mi_thunk): Disable
-mforce-indirect-call for PIC in 32-bit mode.
gcc/testsuite/
PR target/105980
* g++.target/i386/pr105980.C: New test.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (10 preceding siblings ...)
2023-01-16 22:11 ` cvs-commit at gcc dot gnu.org
@ 2023-03-24 16:15 ` jakub at gcc dot gnu.org
2023-04-27 13:18 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-03-24 16:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12/13 Regression] ICE |[11/12 Regression] ICE in
|in final_scan_insn_1, at |final_scan_insn_1, at
|final.cc:2811 |final.cc:2811
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11/12 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (11 preceding siblings ...)
2023-03-24 16:15 ` [Bug target/105980] [11/12 " jakub at gcc dot gnu.org
@ 2023-04-27 13:18 ` cvs-commit at gcc dot gnu.org
2023-05-29 10:07 ` [Bug target/105980] [11 " jakub at gcc dot gnu.org
2024-02-10 18:19 ` fxcoudert at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-27 13:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:37da428922e5cb548430aa00482d6a4c7aa8f8b2
commit r12-9479-g37da428922e5cb548430aa00482d6a4c7aa8f8b2
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Mon Jan 16 10:45:41 2023 -0800
x86: Disable -mforce-indirect-call for PIC in 32-bit mode
-mforce-indirect-call generates invalid instruction in 32-bit MI thunk
since there are no available scratch registers in 32-bit PIC mode.
Disable -mforce-indirect-call for PIC in 32-bit mode when generating
MI thunk.
gcc/
PR target/105980
* config/i386/i386.cc (x86_output_mi_thunk): Disable
-mforce-indirect-call for PIC in 32-bit mode.
gcc/testsuite/
PR target/105980
* g++.target/i386/pr105980.C: New test.
(cherry picked from commit a396a123596d82d4a2f14dc43a382cb17826411c)
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (12 preceding siblings ...)
2023-04-27 13:18 ` cvs-commit at gcc dot gnu.org
@ 2023-05-29 10:07 ` jakub at gcc dot gnu.org
2024-02-10 18:19 ` fxcoudert at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.4 |11.5
--- Comment #12 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug target/105980] [11 Regression] ICE in final_scan_insn_1, at final.cc:2811
2022-06-14 17:53 [Bug c++/105980] New: [11/12/13 Regression] ICE in final_scan_insn_1, at final.cc:2811 gscfq@t-online.de
` (13 preceding siblings ...)
2023-05-29 10:07 ` [Bug target/105980] [11 " jakub at gcc dot gnu.org
@ 2024-02-10 18:19 ` fxcoudert at gcc dot gnu.org
14 siblings, 0 replies; 16+ messages in thread
From: fxcoudert at gcc dot gnu.org @ 2024-02-10 18:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105980
Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu.org
--- Comment #13 from Francois-Xavier Coudert <fxcoudert at gcc dot gnu.org> ---
The new test fails on darwin, with an ICE. Reported at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111342
^ permalink raw reply [flat|nested] 16+ messages in thread