diff mbox

[MPX,2/X] Pointers Checker [18/25] CCP (Stack store/restore)

Message ID 20131118105440.GL21297@msticlxl57.ims.intel.com
State New
Headers show

Commit Message

Ilya Enkovich Nov. 18, 2013, 10:54 a.m. UTC
Hi,

Here is a patch to support BUILT_IN_CHKP_BNDRET and BUILT_IN_CHKP_BIND_BOUNDS in BUILT_IN_STACK_SAVE result uses.

Thanks,
Ilya
--
2013-11-15  Ilya Enkovich  <ilya.enkovich@intel.com>

	* tree-ssa-ccp.c (insert_clobber_before_stack_restore): Handle
	BUILT_IN_CHKP_BNDRET and BUILT_IN_CHKP_BIND_BOUNDS calls.

Comments

Jeff Law Nov. 20, 2013, 8:30 p.m. UTC | #1
On 11/18/13 03:54, Ilya Enkovich wrote:
> Hi,
>
> Here is a patch to support BUILT_IN_CHKP_BNDRET and BUILT_IN_CHKP_BIND_BOUNDS in BUILT_IN_STACK_SAVE result uses.
>
> Thanks,
> Ilya
> --
> 2013-11-15  Ilya Enkovich  <ilya.enkovich@intel.com>
>
> 	* tree-ssa-ccp.c (insert_clobber_before_stack_restore): Handle
> 	BUILT_IN_CHKP_BNDRET and BUILT_IN_CHKP_BIND_BOUNDS calls.
I've looked at this a few times, but I'm having trouble seeing why you 
need this code.  Can you please explain why you're doing this?

Sample code & dumps are helpful, as always:-)

jeff
Ilya Enkovich Nov. 20, 2013, 9:06 p.m. UTC | #2
2013/11/21 Jeff Law <law@redhat.com>:
> On 11/18/13 03:54, Ilya Enkovich wrote:
>>
>> Hi,
>>
>> Here is a patch to support BUILT_IN_CHKP_BNDRET and
>> BUILT_IN_CHKP_BIND_BOUNDS in BUILT_IN_STACK_SAVE result uses.
>>
>> Thanks,
>> Ilya
>> --
>> 2013-11-15  Ilya Enkovich  <ilya.enkovich@intel.com>
>>
>>         * tree-ssa-ccp.c (insert_clobber_before_stack_restore): Handle
>>         BUILT_IN_CHKP_BNDRET and BUILT_IN_CHKP_BIND_BOUNDS calls.
>
> I've looked at this a few times, but I'm having trouble seeing why you need
> this code.  Can you please explain why you're doing this?
>
> Sample code & dumps are helpful, as always:-)

The code in insert_clobber_before_stack_restore is trying to find
BUILT_IN_STACK_RESTORE call matching given BUILT_IN_STACK_SAVE call.
It does search by analyzing uses of BUILT_IN_STACK_SAVE lhs. It does
not expect any uses except BUILT_IN_STACK_RESTORE call, PHI nodes, SSA
name copy and debug statements.

In instrumented code additional possible users are
BUILT_IN_CHKP_BNDRET and BUILT_IN_CHKP_BIND_BOUNDS calls. The first
one gets bounds returned by BUILT_IN_STACK_RESTORE.  The second one
binds these bound with pointer to pass to BUILT_IN_STACK_SAVE. Also to
find BUILT_IN_STACK_SAVE we need to search in uses of
BUILT_IN_CHKP_BIND_BOUNDS result.

Thanks,
Ilya

>
> jeff
>
diff mbox

Patch

diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 50006ab..cfba927 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1774,7 +1774,7 @@  insert_clobber_before_stack_restore (tree saved_val, tree var,
 				     gimple_htab *visited)
 {
   gimple stmt, clobber_stmt;
-  tree clobber;
+  tree clobber, fndecl;
   imm_use_iterator iter;
   gimple_stmt_iterator i;
   gimple *slot;
@@ -1806,6 +1806,13 @@  insert_clobber_before_stack_restore (tree saved_val, tree var,
     else if (gimple_assign_ssa_name_copy_p (stmt))
       insert_clobber_before_stack_restore (gimple_assign_lhs (stmt), var,
 					   visited);
+    else if (gimple_call_builtin_p (stmt, BUILT_IN_CHKP_BIND_BOUNDS))
+      insert_clobber_before_stack_restore (gimple_call_lhs (stmt), var,
+					   visited);
+    else if (gimple_code (stmt) == GIMPLE_CALL
+	     && (fndecl = targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDRET))
+	     && gimple_call_fndecl (stmt) == fndecl)
+      continue;
     else
       gcc_assert (is_gimple_debug (stmt));
 }