This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[CHKP] Fix for PR79988
- From: Alexander Ivchenko <aivchenk at gmail dot com>
- To: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 20 Apr 2017 14:15:52 +0200
- Subject: [CHKP] Fix for PR79988
- Authentication-results: sourceware.org; auth=none
Hi Ilya,
The patch below is basically what Richard proposed in Bugzilla. This
approach should produce the correct code for any address spaces,
because it will just strip the address space part of the pointer in
all bnd* instructions; Since we will do that consistently, all checks
should be consistent and correct. What do you think?
gcc/testsuite/ChangeLog:
* gcc.target/i386/mpx/PR79988.c: New test.
gcc/ChangeLog:
* tree-chkp.c (chkp_gimple_call_builtin_p):
Remove gimple_call_builtin_p call to avoid the call
of gimple_builtin_call_types_compatible_p. this will
strip the checks for address spaces, which can be skipped
without loosing the functionality
diff --git a/gcc/testsuite/gcc.target/i386/mpx/PR79988.c
b/gcc/testsuite/gcc.target/i386/mpx/PR79988.c
new file mode 100644
index 0000000..a6e43eb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/PR79988.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
+
+void foo(unsigned char * __seg_gs *pointer_gs) {
+ pointer_gs[5] = 0;
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index b1ff218..1f7184d 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -433,7 +433,9 @@ chkp_gimple_call_builtin_p (gimple *call,
enum built_in_function code)
{
tree fndecl;
- if (gimple_call_builtin_p (call, BUILT_IN_MD)
+ if (is_gimple_call (call)
+ && (fndecl = gimple_call_fndecl (call)) != NULL
+ && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD
&& (fndecl = targetm.builtin_chkp_function (code))
&& (DECL_FUNCTION_CODE (gimple_call_fndecl (call))
== DECL_FUNCTION_CODE (fndecl)))