diff options
author | Qing Zhao <qing.zhao@oracle.com> | 2018-08-15 16:33:52 +0000 |
---|---|---|
committer | Qing Zhao <qinzhao@gcc.gnu.org> | 2018-08-15 16:33:52 +0000 |
commit | b99d7d976ba2475f038ea1406a1fb9a8fb6c4f5a (patch) | |
tree | 2bf0f327db2e0b2b64117f2d2b16c5e708530946 /gcc | |
parent | 0cd020ae59e1131b8d7e23424c319c493745f0f8 (diff) | |
download | gcc-b99d7d976ba2475f038ea1406a1fb9a8fb6c4f5a.zip gcc-b99d7d976ba2475f038ea1406a1fb9a8fb6c4f5a.tar.gz gcc-b99d7d976ba2475f038ea1406a1fb9a8fb6c4f5a.tar.bz2 |
Do not expand the call to memcmp at all when overflow is detected.
From-SVN: r263563
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/builtins.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/strcmpopt_6.c | 6 |
4 files changed, 21 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8ca8b56..e575b55 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-08-15 Qing Zhao <qing.zhao@oracle.com> + + PR testsuite/86519 + * builtins.c (expand_builtin_memcmp): Do not expand the call + when overflow is detected. + 2018-08-15 Martin Sebor <msebor@redhat.com> PR tree-optimization/71625 diff --git a/gcc/builtins.c b/gcc/builtins.c index 867d153..6716aab 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -4481,11 +4481,16 @@ expand_builtin_memcmp (tree exp, rtx target, bool result_eq) /*objsize=*/NULL_TREE); } + /* If the specified length exceeds the size of either object, + call the function. */ + if (!no_overflow) + return NULL_RTX; + /* Due to the performance benefit, always inline the calls first when result_eq is false. */ rtx result = NULL_RTX; - if (!result_eq && fcode != BUILT_IN_BCMP && no_overflow) + if (!result_eq && fcode != BUILT_IN_BCMP) { result = inline_expand_builtin_string_cmp (exp, target); if (result) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0bcf92f..bd167b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-08-15 Qing Zhao <qing.zhao@oracle.com> + + PR testsuite/86519 + * gcc.dg/strcmpopt_6.c: Scan the assembly file instead of + the .expand file. + 2018-08-15 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org> * gcc.dg/wmain.c: New test. diff --git a/gcc/testsuite/gcc.dg/strcmpopt_6.c b/gcc/testsuite/gcc.dg/strcmpopt_6.c index 964b9e4..4c6de02 100644 --- a/gcc/testsuite/gcc.dg/strcmpopt_6.c +++ b/gcc/testsuite/gcc.dg/strcmpopt_6.c @@ -1,7 +1,7 @@ /* When the specified length exceeds one of the arguments of the call to memcmp, the call to memcmp should NOT be inlined. */ -/* { dg-do run } */ -/* { dg-options "-O2 -fdump-rtl-expand -Wno-stringop-overflow" } */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wno-stringop-overflow" } */ typedef struct { char s[8]; int x; } S; @@ -33,4 +33,4 @@ int main (void) } -/* { dg-final { scan-rtl-dump-times "__builtin_memcmp" 6 "expand" } } */ +/* { dg-final { scan-assembler-times "memcmp" 2 } } */ |