From: "Seongbae Park" <seongbae.park@gmail.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH]: PR inline-asm/28686 missing check for asm_clobbered at -O0
Date: Sat, 03 Feb 2007 00:58:00 -0000 [thread overview]
Message-ID: <ab3a61990702021658w4dc049cap53de8010a7d8626e@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 972 bytes --]
This is a follow-up on PR28686.
At -O0, checking for regs_asm_clobbered code in global_alloc() isn't executed,
missing the error message when the hard frame pointer is clobbered
in asm, while -fno-omit-frame-pointer.
This patch refactors the code a bit, and fixes PR28686 at -O0
by issuing an error message for conflicting requirement
between -fno-omit-frame-pointer and the clobber of the frame pointer.
The refactoring was done in this way for the possibility of making
ELIMINABLE_REGSETS and NO_GLOBAL_ALLOC_REGS non-global.
Bootstrapped and regtested on i686 and IA64. OK for mainline ?
2007-02-02 Seongbae Park <seongbae.park@gmail.com>
* global.c (compute_regsets): New function.
(global_alloc): Refactored ELIMINABLE_REGSET
and NO_GLOBAL_ALLOC_REGS computation out.
(rest_of_handle_global_alloc): Call compute_regsets()
for non-optimizing case.
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
[-- Attachment #2: 28686-O0.diff.txt --]
[-- Type: text/plain, Size: 5555 bytes --]
Index: gcc/global.c
===================================================================
--- gcc/global.c (revision 121524)
+++ gcc/global.c (working copy)
@@ -326,35 +326,46 @@ static void make_accurate_live_analysis
\f
-/* Perform allocation of pseudo-registers not allocated by local_alloc.
-
- Return value is nonzero if reload failed
- and we must not do any more for this function. */
+/* Compute ELIMINABLE_REGSET and NO_GLOBAL_ALLOC_REGS,
+ and while doing so, update REGS_EVER_LIVE as well.
+ This function takes ASM_CLOBBERED array as an input,
+ and writes to only those three parameters passed.
+
+ The formal parameter LIVE_REGS (the actual parameter is expected
+ to be REGS_EVER_LIVE) is a set of hard registers
+ that are actually used within the function.
+ This function only records hard registers that are clobbered
+ by asm statements in LIVE_REGS.
+
+ The formal parameter ELIM_SET (the actual parameter is expected
+ to be ELIMINABLE_REGSET) is a set of hard registers
+ whose reference can be eliminated usually
+ by replacing it with some other expression.
+
+ The formal parameter NO_GLOBAL_SET (the actual parameter is expected
+ to be NO_GLOBAL_ALLOC_REGS) is a set of hard registers
+ that are not safe to use across blocks. */
-static int
-global_alloc (void)
+static void
+compute_regsets (char asm_clobbered[FIRST_PSEUDO_REGISTER],
+ char live_regs[FIRST_PSEUDO_REGISTER],
+ HARD_REG_SET elim_set,
+ HARD_REG_SET no_global_set)
{
- int retval;
#ifdef ELIMINABLE_REGS
static const struct {const int from, to; } eliminables[] = ELIMINABLE_REGS;
#endif
+ size_t i;
int need_fp
= (! flag_omit_frame_pointer
|| (current_function_calls_alloca && EXIT_IGNORE_STACK)
|| FRAME_POINTER_REQUIRED);
- size_t i;
- rtx x;
-
- make_accurate_live_analysis ();
-
- max_allocno = 0;
-
/* A machine may have certain hard registers that
are safe to use only within a basic block. */
- CLEAR_HARD_REG_SET (no_global_alloc_regs);
- CLEAR_HARD_REG_SET (eliminable_regset);
+ CLEAR_HARD_REG_SET (no_global_set);
+ CLEAR_HARD_REG_SET (elim_set);
/* Build the regset of all eliminable registers and show we can't use those
that we already know won't be eliminated. */
@@ -365,45 +376,63 @@ global_alloc (void)
= (! CAN_ELIMINATE (eliminables[i].from, eliminables[i].to)
|| (eliminables[i].to == STACK_POINTER_REGNUM && need_fp));
- if (!regs_asm_clobbered[eliminables[i].from])
+ if (!asm_clobbered[eliminables[i].from])
{
- SET_HARD_REG_BIT (eliminable_regset, eliminables[i].from);
+ SET_HARD_REG_BIT (elim_set, eliminables[i].from);
if (cannot_elim)
- SET_HARD_REG_BIT (no_global_alloc_regs, eliminables[i].from);
+ SET_HARD_REG_BIT (no_global_set, eliminables[i].from);
}
else if (cannot_elim)
error ("%s cannot be used in asm here",
reg_names[eliminables[i].from]);
else
- regs_ever_live[eliminables[i].from] = 1;
+ live_regs[eliminables[i].from] = 1;
}
#if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
- if (!regs_asm_clobbered[HARD_FRAME_POINTER_REGNUM])
+ if (!asm_clobbered[HARD_FRAME_POINTER_REGNUM])
{
- SET_HARD_REG_BIT (eliminable_regset, HARD_FRAME_POINTER_REGNUM);
+ SET_HARD_REG_BIT (elim_set, HARD_FRAME_POINTER_REGNUM);
if (need_fp)
- SET_HARD_REG_BIT (no_global_alloc_regs, HARD_FRAME_POINTER_REGNUM);
+ SET_HARD_REG_BIT (no_global_set, HARD_FRAME_POINTER_REGNUM);
}
else if (need_fp)
error ("%s cannot be used in asm here",
reg_names[HARD_FRAME_POINTER_REGNUM]);
else
- regs_ever_live[HARD_FRAME_POINTER_REGNUM] = 1;
+ live_regs[HARD_FRAME_POINTER_REGNUM] = 1;
#endif
#else
- if (!regs_asm_clobbered[FRAME_POINTER_REGNUM])
+ if (!asm_clobbered[FRAME_POINTER_REGNUM])
{
- SET_HARD_REG_BIT (eliminable_regset, FRAME_POINTER_REGNUM);
+ SET_HARD_REG_BIT (elim_set, FRAME_POINTER_REGNUM);
if (need_fp)
- SET_HARD_REG_BIT (no_global_alloc_regs, FRAME_POINTER_REGNUM);
+ SET_HARD_REG_BIT (no_global_set, FRAME_POINTER_REGNUM);
}
else if (need_fp)
error ("%s cannot be used in asm here", reg_names[FRAME_POINTER_REGNUM]);
else
- regs_ever_live[FRAME_POINTER_REGNUM] = 1;
+ live_regs[FRAME_POINTER_REGNUM] = 1;
#endif
+}
+
+/* Perform allocation of pseudo-registers not allocated by local_alloc.
+
+ Return value is nonzero if reload failed
+ and we must not do any more for this function. */
+
+static int
+global_alloc (void)
+{
+ int retval;
+ size_t i;
+ rtx x;
+
+ make_accurate_live_analysis ();
+
+ compute_regsets (regs_asm_clobbered, regs_ever_live,
+ eliminable_regset, no_global_alloc_regs);
/* Track which registers have already been used. Start with registers
explicitly in the rtl, then registers allocated by local register
@@ -460,6 +489,7 @@ global_alloc (void)
reg_may_share[r2] = r1;
}
+ max_allocno = 0;
for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
/* Note that reg_live_length[i] < 0 indicates a "constant" reg
that we are supposed to refrain from putting in a hard reg.
@@ -2516,6 +2546,8 @@ rest_of_handle_global_alloc (void)
failure = global_alloc ();
else
{
+ compute_regsets (regs_asm_clobbered, regs_ever_live,
+ eliminable_regset, no_global_alloc_regs);
build_insn_chain (get_insns ());
failure = reload (get_insns (), 0);
}
next reply other threads:[~2007-02-03 0:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-03 0:58 Seongbae Park [this message]
2007-02-03 1:00 ` Seongbae Park
2007-02-06 16:25 ` Ian Lance Taylor
2007-02-06 19:44 ` Seongbae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab3a61990702021658w4dc049cap53de8010a7d8626e@mail.gmail.com \
--to=seongbae.park@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).