* [1/2] i386 ROP mitigation: make more of regrename callable
@ 2015-11-13 20:33 Bernd Schmidt
2015-11-16 11:54 ` Eric Botcazou
0 siblings, 1 reply; 4+ messages in thread
From: Bernd Schmidt @ 2015-11-13 20:33 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 165 bytes --]
This just creates a new function in regrename.c, which I need for the
2/2 patch that I'll submit in a moment.
Bootstrapped and tested on x86_64-linux. Ok?
Bernd
[-- Attachment #2: rop0.diff --]
[-- Type: text/x-patch, Size: 2913 bytes --]
* regrename.h (regrename_find_superclass): Declare.
(regrename_find_superclass): New function, code moved from ...
(rename_chains): ... here. Call it.
diff --git a/gcc/regrename.c b/gcc/regrename.c
index c328c1b..788c8fd 100644
--- a/gcc/regrename.c
+++ b/gcc/regrename.c
@@ -409,6 +416,33 @@ find_rename_reg (du_head_p this_head, enum reg_class super_class,
return best_new_reg;
}
+/* Iterate over elements in the chain HEAD in order to:
+ 1. Count number of uses, storing it in *PN_USES.
+ 2. Narrow the set of registers we can use for renaming, adding
+ unavailable registers to *PUNAVAILABLE, which must be
+ initialized by the caller.
+ 3. Compute the superunion of register classes in this chain
+ and return it. */
+reg_class
+regrename_find_superclass (du_head_p head, int *pn_uses,
+ HARD_REG_SET *punavailable)
+{
+ int n_uses = 0;
+ reg_class super_class = NO_REGS;
+ for (du_chain *tmp = head->first; tmp; tmp = tmp->next_use)
+ {
+ if (DEBUG_INSN_P (tmp->insn))
+ continue;
+ n_uses++;
+ IOR_COMPL_HARD_REG_SET (*punavailable,
+ reg_class_contents[tmp->cl]);
+ super_class
+ = reg_class_superunion[(int) super_class][(int) tmp->cl];
+ }
+ *pn_uses = n_uses;
+ return super_class;
+}
+
/* Perform register renaming on the current function. */
static void
rename_chains (void)
@@ -432,10 +466,8 @@ rename_chains (void)
{
int best_new_reg;
int n_uses;
- struct du_chain *tmp;
HARD_REG_SET this_unavailable;
int reg = this_head->regno;
- enum reg_class super_class = NO_REGS;
if (this_head->cannot_rename)
continue;
@@ -449,23 +481,8 @@ rename_chains (void)
COPY_HARD_REG_SET (this_unavailable, unavailable);
- /* Iterate over elements in the chain in order to:
- 1. Count number of uses, and narrow the set of registers we can
- use for renaming.
- 2. Compute the superunion of register classes in this chain. */
- n_uses = 0;
- super_class = NO_REGS;
- for (tmp = this_head->first; tmp; tmp = tmp->next_use)
- {
- if (DEBUG_INSN_P (tmp->insn))
- continue;
- n_uses++;
- IOR_COMPL_HARD_REG_SET (this_unavailable,
- reg_class_contents[tmp->cl]);
- super_class
- = reg_class_superunion[(int) super_class][(int) tmp->cl];
- }
-
+ reg_class super_class = regrename_find_superclass (this_head, &n_uses,
+ &this_unavailable);
if (n_uses < 2)
continue;
diff --git a/gcc/regrename.h b/gcc/regrename.h
index bbe156d..f9f9481 100644
--- a/gcc/regrename.h
+++ b/gcc/regrename.h
@@ -92,5 +96,7 @@ extern du_head_p regrename_chain_from_id (unsigned int);
extern int find_rename_reg (du_head_p, enum reg_class, HARD_REG_SET *, int,
bool);
extern bool regrename_do_replace (du_head_p, int);
+extern reg_class regrename_find_superclass (du_head_p, int *,
+ HARD_REG_SET *);
#endif
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [1/2] i386 ROP mitigation: make more of regrename callable
2015-11-13 20:33 [1/2] i386 ROP mitigation: make more of regrename callable Bernd Schmidt
@ 2015-11-16 11:54 ` Eric Botcazou
2015-11-16 12:07 ` Bernd Schmidt
0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2015-11-16 11:54 UTC (permalink / raw)
To: Bernd Schmidt; +Cc: gcc-patches
> Bootstrapped and tested on x86_64-linux. Ok?
OK once the 2/2 patch is also approved.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [1/2] i386 ROP mitigation: make more of regrename callable
2015-11-16 11:54 ` Eric Botcazou
@ 2015-11-16 12:07 ` Bernd Schmidt
2015-11-16 12:14 ` Eric Botcazou
0 siblings, 1 reply; 4+ messages in thread
From: Bernd Schmidt @ 2015-11-16 12:07 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
On 11/16/2015 12:54 PM, Eric Botcazou wrote:
>> Bootstrapped and tested on x86_64-linux. Ok?
>
> OK once the 2/2 patch is also approved.
Thank you. The 2/2 has a small regrename piece to add target_data
fields, are you OK with that as well? I'm assuming Uros will take a look
at the rest.
Bernd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [1/2] i386 ROP mitigation: make more of regrename callable
2015-11-16 12:07 ` Bernd Schmidt
@ 2015-11-16 12:14 ` Eric Botcazou
0 siblings, 0 replies; 4+ messages in thread
From: Eric Botcazou @ 2015-11-16 12:14 UTC (permalink / raw)
To: Bernd Schmidt; +Cc: gcc-patches
> Thank you. The 2/2 has a small regrename piece to add target_data
> fields, are you OK with that as well?
Sure.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-16 12:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-13 20:33 [1/2] i386 ROP mitigation: make more of regrename callable Bernd Schmidt
2015-11-16 11:54 ` Eric Botcazou
2015-11-16 12:07 ` Bernd Schmidt
2015-11-16 12:14 ` 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).