From d51151b2f4284ee26ceca0944a34b7763335eee4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 9 Feb 2015 22:23:58 +0100 Subject: [PATCH] re PR sanitizer/64981 (-fsanitize=address cant expand __builtin_ia32_rdtsc) PR sanitizer/64981 * builtins.c (expand_builtin): Call targetm.expand_builtin for BUILT_IN_MD builtins regardless of asan_intercepted_p. * gcc.dg/asan/pr64981.c: New test. From-SVN: r220551 --- gcc/ChangeLog | 6 ++++++ gcc/builtins.c | 6 +++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/asan/pr64981.c | 12 ++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr64981.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2791de6c4f8..328c37d0303 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-02-09 Jakub Jelinek + + PR sanitizer/64981 + * builtins.c (expand_builtin): Call targetm.expand_builtin + for BUILT_IN_MD builtins regardless of asan_intercepted_p. + 2015-02-08 Jan Hubicka PR ipa/61548 diff --git a/gcc/builtins.c b/gcc/builtins.c index 3ddaddc1ab0..8f3c0bc22b3 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5960,6 +5960,9 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, machine_mode target_mode = TYPE_MODE (TREE_TYPE (exp)); int flags; + if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) + return targetm.expand_builtin (exp, target, subtarget, mode, ignore); + /* When ASan is enabled, we don't want to expand some memory/string builtins and rely on libsanitizer's hooks. This allows us to avoid redundant checks and be sure, that possible overflow will be detected @@ -5968,9 +5971,6 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, if ((flag_sanitize & SANITIZE_ADDRESS) && asan_intercepted_p (fcode)) return expand_call (exp, target, ignore); - if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) - return targetm.expand_builtin (exp, target, subtarget, mode, ignore); - /* When not optimizing, generate calls to library functions for a certain set of builtins. */ if (!optimize diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3d14e6041b8..67f1e8e5355 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-02-09 Jakub Jelinek + + PR sanitizer/64981 + * gcc.dg/asan/pr64981.c: New test. + 2015-02-09 Marek Polacek PR c/64856 diff --git a/gcc/testsuite/gcc.dg/asan/pr64981.c b/gcc/testsuite/gcc.dg/asan/pr64981.c new file mode 100644 index 00000000000..85e34794e4e --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr64981.c @@ -0,0 +1,12 @@ +/* PR sanitizer/64981 */ +/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-fsanitize=address -march=x86-64" } */ + +int +main () +{ + __builtin_ia32_rdtsc (); + return 0; +} + +/* { dg-final { scan-assembler-not "__builtin_ia32_rdtsc" } } */ -- 2.30.2