aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2015-12-04 17:32:22 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2015-12-04 17:32:22 +0100
commit4e722cf1dc7dd6087ddf8f861e24a9d4ad4bbd6a (patch)
tree7c61ee5c07542943bbc86b68ac6dbd570016fb95 /gcc
parent83b58b6b0e75383fb01cd65b29a8fa1779050269 (diff)
downloadgcc-4e722cf1dc7dd6087ddf8f861e24a9d4ad4bbd6a.zip
gcc-4e722cf1dc7dd6087ddf8f861e24a9d4ad4bbd6a.tar.gz
gcc-4e722cf1dc7dd6087ddf8f861e24a9d4ad4bbd6a.tar.bz2
re PR tree-optimization/68680 (On-stack VLA does not cause instrumentation with -fstack-protector)
PR tree-optimization/68680 * calls.c (special_function_p): Return ECF_MAY_BE_ALLOCA for BUILT_IN_ALLOCA{,_WITH_ALIGN}. Don't check for __builtin_alloca by name. * gcc.target/i386/pr68680.c: New test. From-SVN: r231279
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/calls.c20
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.target/i386/pr68680.c15
4 files changed, 37 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 446e74b..b6ff6e1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2015-12-04 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/68680
+ * calls.c (special_function_p): Return ECF_MAY_BE_ALLOCA for
+ BUILT_IN_ALLOCA{,_WITH_ALIGN}. Don't check for __builtin_alloca
+ by name.
+
PR tree-optimization/68671
* tree-ssa-reassoc.c (maybe_optimize_range_tests): For basic
blocks starting with the successor of first bb we've modified
diff --git a/gcc/calls.c b/gcc/calls.c
index 6cbe019..1eb4ec7 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -502,12 +502,9 @@ special_function_p (const_tree fndecl, int flags)
/* We assume that alloca will always be called by name. It
makes no sense to pass it as a pointer-to-function to
anything that does not understand its behavior. */
- if (((IDENTIFIER_LENGTH (name_decl) == 6
- && name[0] == 'a'
- && ! strcmp (name, "alloca"))
- || (IDENTIFIER_LENGTH (name_decl) == 16
- && name[0] == '_'
- && ! strcmp (name, "__builtin_alloca"))))
+ if (IDENTIFIER_LENGTH (name_decl) == 6
+ && name[0] == 'a'
+ && ! strcmp (name, "alloca"))
flags |= ECF_MAY_BE_ALLOCA;
/* Disregard prefix _, __, __x or __builtin_. */
@@ -553,6 +550,17 @@ special_function_p (const_tree fndecl, int flags)
flags |= ECF_NORETURN;
}
+ if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+ switch (DECL_FUNCTION_CODE (fndecl))
+ {
+ case BUILT_IN_ALLOCA:
+ case BUILT_IN_ALLOCA_WITH_ALIGN:
+ flags |= ECF_MAY_BE_ALLOCA;
+ break;
+ default:
+ break;
+ }
+
return flags;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1a037e6..b36591a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2015-12-04 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/68680
+ * gcc.target/i386/pr68680.c: New test.
+
PR tree-optimization/68671
* gcc.dg/pr68671.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/pr68680.c b/gcc/testsuite/gcc.target/i386/pr68680.c
new file mode 100644
index 0000000..5524e15
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr68680.c
@@ -0,0 +1,15 @@
+/* PR tree-optimization/68680 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fstack-protector-strong" } */
+
+int foo (char *);
+
+int
+bar (unsigned long x)
+{
+ char a[x];
+ return foo (a);
+}
+
+/* Verify that this function is stack protected. */
+/* { dg-final { scan-assembler "stack_chk_fail" } } */