Hi,

Here is a patch to disable tail recursion transformation when bounds are passed 
by call.  The reason is BUILT_IN_CHKP_ARG_BND which should always get default 
SSA_NAME of PARM_DECL as an argument.
Thanks,
Ilya
--
2013-11-15  Ilya Enkovich  <ilya.enkov...@intel.com>

        * tree-tailcall.c: Include tree-chkp.h.
        (suitable_for_tail_opt_p): Disable tail
        recursion for instrumented functions with bounded args.


diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c
index 185bf16..59845950 100644
--- a/gcc/tree-tailcall.c
+++ b/gcc/tree-tailcall.c
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cfgloop.h"
 #include "common/common-target.h"
 #include "ipa-utils.h"
+#include "tree-chkp.h"
 
 /* The file implements the tail recursion elimination.  It is also used to
    analyze the tail calls in general, passing the results to the rtl level
@@ -141,6 +142,20 @@ suitable_for_tail_opt_p (void)
   if (cfun->stdarg)
     return false;
 
+  /* Tail recursion elimination may cause arg_bnd builtins to be called
+     not for PARM_DECL which is not allowed now.  Avoid optimization
+     in such cases for now.  */
+  if (chkp_function_instrumented_p (current_function_decl))
+    {
+      tree param;
+
+      for (param = DECL_ARGUMENTS (current_function_decl);
+          param;
+          param = DECL_CHAIN (param))
+       if (BOUNDED_P (param))
+         return false;
+    }
+
   return true;
 }
 /* Returns false when the function is not suitable for tail call optimization

Reply via email to