From: "H.J. Lu" <hongjiu.lu@intel.com>
To: gcc-patches@gcc.gnu.org
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Eric Botcazou <ebotcazou@adacore.com>,
Bernd Schmidt <bernds@codesourcery.com>
Subject: [x32] PATCH: Remove ix86_promote_function_mode
Date: Mon, 20 Jun 2011 13:55:00 -0000 [thread overview]
Message-ID: <20110620135115.GA11874@lucon.org> (raw)
Promote pointers to Pmode when passing/returning in registers is
a security concern. This patch removes ix86_promote_function_mode,
which exposes:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47725
There are 2 different patches for PR 47725:
http://gcc.gnu.org/ml/gcc-patches/2011-02/threads.html#01018
One checks zero/sign extended hard registers in cant_combine_insn_p
and the other changes assign_parm_setup_reg to copy the hard register
first before extending it. This patch changes cant_combine_insn_p.
H.J.
----
commit 6202f3601f5b2a5a41b60425f1206681823ecaa9
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun Jun 19 19:24:11 2011 -0700
Remove ix86_promote_function_mode.
2011-06-19 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/47725
PR target/48085
* calls.c (precompute_register_parameters): Don't convert
pointer to TLS symbol if needed.
* combine.c (cant_combine_insn_p): Check zero/sign extended
hard registers.
* config/i386/i386.c (ix86_promote_function_mode): Removed.
(TARGET_PROMOTE_FUNCTION_MODE): Likewise.
diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 564e123..6619f2f 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,16 @@
+2011-06-19 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR middle-end/47725
+ PR target/48085
+ * calls.c (precompute_register_parameters): Don't convert
+ pointer to TLS symbol if needed.
+
+ * combine.c (cant_combine_insn_p): Check zero/sign extended
+ hard registers.
+
+ * config/i386/i386.c (ix86_promote_function_mode): Removed.
+ (TARGET_PROMOTE_FUNCTION_MODE): Likewise.
+
2011-06-15 H.J. Lu <hongjiu.lu@intel.com>
PR middle-end/48016
diff --git a/gcc/calls.c b/gcc/calls.c
index 5a00d95..3d9a03f 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -706,13 +706,7 @@ precompute_register_parameters (int num_actuals, struct arg_data *args,
pseudo now. TLS symbols sometimes need a call to resolve. */
if (CONSTANT_P (args[i].value)
&& !targetm.legitimate_constant_p (args[i].mode, args[i].value))
- {
- if (GET_MODE (args[i].value) != args[i].mode)
- args[i].value = convert_to_mode (args[i].mode,
- args[i].value,
- args[i].unsignedp);
- args[i].value = force_reg (args[i].mode, args[i].value);
- }
+ args[i].value = force_reg (args[i].mode, args[i].value);
/* If we are to promote the function arg to a wider mode,
do it now. */
diff --git a/gcc/combine.c b/gcc/combine.c
index d3574a3..5512649 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -2168,6 +2168,12 @@ cant_combine_insn_p (rtx insn)
return 0;
src = SET_SRC (set);
dest = SET_DEST (set);
+ if (GET_CODE (src) == ZERO_EXTEND
+ || GET_CODE (src) == SIGN_EXTEND)
+ src = XEXP (src, 0);
+ if (GET_CODE (dest) == ZERO_EXTEND
+ || GET_CODE (dest) == SIGN_EXTEND)
+ dest = XEXP (dest, 0);
if (GET_CODE (src) == SUBREG)
src = SUBREG_REG (src);
if (GET_CODE (dest) == SUBREG)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index fa5ae97..104767b 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7050,23 +7050,6 @@ ix86_function_value (const_tree valtype, const_tree fntype_or_decl,
return ix86_function_value_1 (valtype, fntype_or_decl, orig_mode, mode);
}
-/* Pointer function arguments and return values are promoted to
- Pmode. */
-
-static enum machine_mode
-ix86_promote_function_mode (const_tree type, enum machine_mode mode,
- int *punsignedp, const_tree fntype,
- int for_return)
-{
- if (for_return != 1 && type != NULL_TREE && POINTER_TYPE_P (type))
- {
- *punsignedp = POINTERS_EXTEND_UNSIGNED;
- return Pmode;
- }
- return default_promote_function_mode (type, mode, punsignedp, fntype,
- for_return);
-}
-
rtx
ix86_libcall_value (enum machine_mode mode)
{
@@ -35132,9 +35115,6 @@ ix86_autovectorize_vector_sizes (void)
#undef TARGET_FUNCTION_VALUE_REGNO_P
#define TARGET_FUNCTION_VALUE_REGNO_P ix86_function_value_regno_p
-#undef TARGET_PROMOTE_FUNCTION_MODE
-#define TARGET_PROMOTE_FUNCTION_MODE ix86_promote_function_mode
-
#undef TARGET_SECONDARY_RELOAD
#define TARGET_SECONDARY_RELOAD ix86_secondary_reload
next reply other threads:[~2011-06-20 13:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-20 13:55 H.J. Lu [this message]
2011-06-20 13:57 ` Bernd Schmidt
2011-06-20 14:13 ` H.J. Lu
2011-06-20 14:41 ` H. Peter Anvin
2011-06-20 14:44 ` Jeff Law
2011-06-20 15:11 ` H.J. Lu
2011-06-20 14:46 ` H.J. Lu
2011-06-20 15:28 ` H. Peter Anvin
2011-06-20 22:58 ` Richard Henderson
2011-06-21 0:33 ` H. Peter Anvin
2011-06-21 0:34 ` Richard Henderson
2011-06-21 1:15 ` H. Peter Anvin
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=20110620135115.GA11874@lucon.org \
--to=hongjiu.lu@intel.com \
--cc=bernds@codesourcery.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hjl.tools@gmail.com \
--cc=hpa@zytor.com \
/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).