* Fix PR rtl-optimization/113140
@ 2024-01-09 9:16 Eric Botcazou
0 siblings, 0 replies; 2+ messages in thread
From: Eric Botcazou @ 2024-01-09 9:16 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 688 bytes --]
This is a small regression present on the mainline and 13 branch, although the
underlying problem has probably been there for ages, in the form of a segfault
during the delay slot scheduling pass, for a function that falls through to
exit without any RTL instruction generated for the end of function.
Tested on SPARC64/Linux, applied on the mainline and 13 branch.
2024-01-09 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/113140
* reorg.cc (fill_slots_from_thread): If we are to branch after the
last instruction of the function, create an end label.
2024-01-09 Eric Botcazou <ebotcazou@adacore.com>
* g++.dg/opt/delay-slot-2.C: New test.
--
Eric Botcazou
[-- Attachment #2: pr113140.diff --]
[-- Type: text/x-patch, Size: 1378 bytes --]
diff --git a/gcc/reorg.cc b/gcc/reorg.cc
index e85af7134f4..99228a22c69 100644
--- a/gcc/reorg.cc
+++ b/gcc/reorg.cc
@@ -2641,7 +2641,8 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition,
arithmetic insn after the jump insn and put the arithmetic insn in the
delay slot. If we can't do this, return. */
if (delay_list->is_empty () && likely
- && new_thread && !ANY_RETURN_P (new_thread)
+ && new_thread
+ && !ANY_RETURN_P (new_thread)
&& NONJUMP_INSN_P (new_thread)
&& !RTX_FRAME_RELATED_P (new_thread)
&& GET_CODE (PATTERN (new_thread)) != ASM_INPUT
@@ -2729,14 +2730,16 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition,
gcc_assert (thread_if_true);
- if (new_thread && simplejump_or_return_p (new_thread)
+ if (new_thread
+ && simplejump_or_return_p (new_thread)
&& redirect_with_delay_list_safe_p (insn,
JUMP_LABEL (new_thread),
*delay_list))
- new_thread = follow_jumps (JUMP_LABEL (new_thread), insn,
- &crossing);
+ new_thread = follow_jumps (JUMP_LABEL (new_thread), insn, &crossing);
- if (ANY_RETURN_P (new_thread))
+ if (!new_thread)
+ label = find_end_label (simple_return_rtx);
+ else if (ANY_RETURN_P (new_thread))
label = find_end_label (new_thread);
else if (LABEL_P (new_thread))
label = new_thread;
[-- Attachment #3: delay-slot-2.C --]
[-- Type: text/x-c++src, Size: 606 bytes --]
// PR rtl-optimization/113140
// Reduced testcase by Rainer Orth <ro@gcc.gnu.org>
// { dg-options "-O -w" }
int *m();
struct StaticValue {
long _val;
void setM(int *) { _val = 0; }
};
struct Value : StaticValue {
template <typename T> T *as();
};
Value *alloc();
struct Scoped {
Scoped() {
Value v;
ptr = alloc();
Value *__trans_tmp_1 = v.as<Value>();
ptr->setM(__trans_tmp_1 ? m() : 0);
}
Value *ptr;
};
struct QObjectMethod {
unsigned long long callInternal() const;
};
unsigned long long QObjectMethod::callInternal() const {
[] {
if (Scoped(); 0)
;
}();
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Fix PR rtl-optimization/113140
@ 2024-01-09 9:27 Eric Botcazou
0 siblings, 0 replies; 2+ messages in thread
From: Eric Botcazou @ 2024-01-09 9:27 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 688 bytes --]
This is a small regression present on the mainline and 13 branch, although the
underlying problem has probably been there for ages, in the form of a segfault
during the delay slot scheduling pass, for a function that falls through to
exit without any RTL instruction generated for the end of function.
Tested on SPARC64/Linux, applied on the mainline and 13 branch.
2024-01-09 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/113140
* reorg.cc (fill_slots_from_thread): If we are to branch after the
last instruction of the function, create an end label.
2024-01-09 Eric Botcazou <ebotcazou@adacore.com>
* g++.dg/opt/delay-slot-2.C: New test.
--
Eric Botcazou
[-- Attachment #2: pr113140.diff --]
[-- Type: text/x-patch, Size: 1378 bytes --]
diff --git a/gcc/reorg.cc b/gcc/reorg.cc
index e85af7134f4..99228a22c69 100644
--- a/gcc/reorg.cc
+++ b/gcc/reorg.cc
@@ -2641,7 +2641,8 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition,
arithmetic insn after the jump insn and put the arithmetic insn in the
delay slot. If we can't do this, return. */
if (delay_list->is_empty () && likely
- && new_thread && !ANY_RETURN_P (new_thread)
+ && new_thread
+ && !ANY_RETURN_P (new_thread)
&& NONJUMP_INSN_P (new_thread)
&& !RTX_FRAME_RELATED_P (new_thread)
&& GET_CODE (PATTERN (new_thread)) != ASM_INPUT
@@ -2729,14 +2730,16 @@ fill_slots_from_thread (rtx_jump_insn *insn, rtx condition,
gcc_assert (thread_if_true);
- if (new_thread && simplejump_or_return_p (new_thread)
+ if (new_thread
+ && simplejump_or_return_p (new_thread)
&& redirect_with_delay_list_safe_p (insn,
JUMP_LABEL (new_thread),
*delay_list))
- new_thread = follow_jumps (JUMP_LABEL (new_thread), insn,
- &crossing);
+ new_thread = follow_jumps (JUMP_LABEL (new_thread), insn, &crossing);
- if (ANY_RETURN_P (new_thread))
+ if (!new_thread)
+ label = find_end_label (simple_return_rtx);
+ else if (ANY_RETURN_P (new_thread))
label = find_end_label (new_thread);
else if (LABEL_P (new_thread))
label = new_thread;
[-- Attachment #3: delay-slot-2.C --]
[-- Type: text/x-c++src, Size: 606 bytes --]
// PR rtl-optimization/113140
// Reduced testcase by Rainer Orth <ro@gcc.gnu.org>
// { dg-options "-O -w" }
int *m();
struct StaticValue {
long _val;
void setM(int *) { _val = 0; }
};
struct Value : StaticValue {
template <typename T> T *as();
};
Value *alloc();
struct Scoped {
Scoped() {
Value v;
ptr = alloc();
Value *__trans_tmp_1 = v.as<Value>();
ptr->setM(__trans_tmp_1 ? m() : 0);
}
Value *ptr;
};
struct QObjectMethod {
unsigned long long callInternal() const;
};
unsigned long long QObjectMethod::callInternal() const {
[] {
if (Scoped(); 0)
;
}();
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-09 9:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09 9:16 Fix PR rtl-optimization/113140 Eric Botcazou
2024-01-09 9:27 Eric Botcazou
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).