From: Jakub Jelinek <jakub@redhat.com>
To: Konstantin Serebryany <konstantin.s.serebryany@gmail.com>
Cc: Wei Mi <wmi@google.com>, GCC Patches <gcc-patches@gcc.gnu.org>,
David Li <davidxl@google.com>,
Diego Novillo <dnovillo@google.com>,
Kostya Serebryany <kcc@google.com>,
Dodji Seketeli <dseketel@redhat.com>
Subject: Re: [PATCH] asan_test.cc from llvm
Date: Fri, 30 Nov 2012 10:22:00 -0000 [thread overview]
Message-ID: <20121130101420.GE2315@tucnak.redhat.com> (raw)
In-Reply-To: <CAGQ9bdycNNqNZ1K2fU-cSJPcr4gp6J7Fa+v5DF2VavEcHeCHwg@mail.gmail.com>
On Fri, Nov 30, 2012 at 01:32:52PM +0400, Konstantin Serebryany wrote:
> Ideally, I would like to limit the differences from upstream.
> I'll put some of your changes upstream, for others I'd ask you to
> consider other choices.
>
> -#include "gtest/gtest.h"
> +#include "dejagnu-gtest.h"
>
> Maybe like this?
>
> #if ASAN_USE_DEJAGNU_GTEST
> #include "dejagnu-gtest.h"
> #else
> #include "gtest/gtest.h"
> #endif
Sure, I'm fine with that.
> Can we have gcc_asan_test.C which will #include the unchanged (modulo
> the comment header) asan_test.cc
> and have dejagnu lines there?
>
> Like this:
> // { dg-do run { target { mmap && pthread } } }
> ...
> #include asan_test.cc
Yeah, I can do that, advantage will be that the testcase is named the same,
asan.exp currently runs only *.C testcases (so that *.cc is left to helper
files etc.). So there will be a small asan_test.C with the dg markup.
> +#elif defined(__SANITIZE_ADDRESS__)
> + bool asan = 1;
>
> I'll put this upstream.
Thanks, if GCC ever introduces the __has_feature magic macro, it can be
dropped, but for now... Note elsewhere I'm using the __SANITIZE_ADDRESS__
define as a test whether this is for GCC or other compilers, because
I believe clang defines __GNUC__ macro or similar, I'd need to
#if defined (__GNUC__) && !defined (__clang__) or something?
> +#ifdef __SANITIZE_ADDRESS__
> + // Avoid this test during dejagnu testing, it is too expensive
> + if (getenv ("GCC_TEST_RUN_EXPENSIVE") == NULL)
> + return;
> +#endif
>
> I'd prefer to simply put this w/o ifdef.
Then even in llvm the expensive test won't run unless you put
GCC_TEST_RUN_EXPENSIVE=1 into environment. That would be weird
for a llvm testcase to use GCC in the name. Alternative would be
to use some other env var name, like
ASAN_TEST_RUN_EXPENSIVE, and I could adjust asan.exp to set that
env var, or it could be a macro instead, guarding the whole test,
#ifndef ASAN_AVOID_EXPENSIVE_TESTS
(TEST(AddressSanitizer, ManyThreadsTest) {
...
}
#endif
and I could in asan_test.C add:
// { dg-additional-options "-DASAN_AVOID_EXPENSIVE_TESTS" { target { ! run_expensive_tests } } }
Or, if you want even upstream to avoid it by default, it could
be a positive test, #ifdef ASAN_RUN_EXPENSIVE_TESTS or similar.
>
> -# error "please define ASAN_HAS_BLACKLIST"
> +//# error "please define ASAN_HAS_BLACKLIST"
>
> You can add -DASAN_HAS_BLACKLIST=0 to the command line.
> If/when gcc gets blacklist support, we'll redefine it to 1
Okay.
> +#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
>
> this is upstreamable
>
> +#ifdef __GNUC__
> +# define break_optimization(arg) __asm__ __volatile__ ("" : : "r"
> (arg) : "memory")
> +#endif
> +
>
> That's a nice piece of magic, let me use this too.
For pointers/integers it can be even as simple as
__asm__ ("" : "+g" (val));
making compiler forget about val, obviously that doesn't work for
aggregates. Anyway, the reason for the macro is both that I wanted to
avoid compiling in another file, and for LTO it wouldn't work anyway.
BTW, I had to add -Wno-unused-but-set-variable option because without
that there was a warning about one of the variables, I think it was
stack_string in StrLenOOBTest. Adding (void) stack_string; somewhere
would shut it up.
Jakub
next prev parent reply other threads:[~2012-11-30 10:15 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-28 9:15 [PATCH] asan unit tests from llvm lit-test Wei Mi
2012-11-28 10:10 ` Konstantin Serebryany
2012-11-28 10:25 ` Jakub Jelinek
2012-11-28 10:41 ` Konstantin Serebryany
2012-11-28 11:03 ` Jakub Jelinek
2012-11-28 11:14 ` Konstantin Serebryany
2012-11-29 20:59 ` [PATCH] asan_test.cc from llvm Jakub Jelinek
2012-11-30 9:35 ` Konstantin Serebryany
2012-11-30 10:22 ` Jakub Jelinek [this message]
2012-11-30 10:55 ` Konstantin Serebryany
2012-11-30 14:52 ` Jakub Jelinek
2012-11-30 16:06 ` Jakub Jelinek
[not found] ` <CAKOQZ8y70goUL91pQJt_S=8W+Dn5VTZ5oRphvGuFwMMh41mkLg@mail.gmail.com>
2012-11-30 16:34 ` Jakub Jelinek
2012-12-03 7:07 ` Konstantin Serebryany
2012-12-03 9:18 ` Jakub Jelinek
2012-12-03 9:52 ` Konstantin Serebryany
2012-12-03 11:05 ` Jakub Jelinek
2012-12-03 11:42 ` Konstantin Serebryany
2012-11-28 11:25 ` [PATCH] asan unit tests from llvm lit-test Jakub Jelinek
2012-11-28 11:39 ` Konstantin Serebryany
2012-11-28 10:14 ` Jakub Jelinek
2012-11-30 21:05 ` Wei Mi
2012-12-03 7:16 ` Konstantin Serebryany
2012-12-03 11:01 ` Jakub Jelinek
2012-12-03 18:33 ` Wei Mi
2012-12-03 18:49 ` Konstantin Serebryany
2012-12-03 19:44 ` Jakub Jelinek
2012-12-03 19:09 ` Mike Stump
2012-12-03 19:37 ` Jakub Jelinek
2012-12-03 19:50 ` Mike Stump
[not found] ` <CAN=P9pgjjq66KS2DVkuOSeH2ejQPDcyKhwz5MdKyE3RB64E=xw@mail.gmail.com>
2012-12-04 7:34 ` Jakub Jelinek
2012-12-04 18:01 ` Wei Mi
2012-12-05 12:29 ` [PATCH] asan unit tests from llvm lit-test incremental changes Jakub Jelinek
2012-12-12 21:32 ` Dodji Seketeli
2012-12-12 21:31 ` Jakub Jelinek
2012-12-13 7:44 ` Konstantin Serebryany
2012-12-13 8:37 ` Jakub Jelinek
2012-12-13 10:23 ` Konstantin Serebryany
2012-12-13 15:22 ` Jakub Jelinek
2012-12-05 23:29 ` [asan] Fix up dg-set-target-env-var Jakub Jelinek
2012-12-06 0:23 ` Mike Stump
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121130101420.GE2315@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=davidxl@google.com \
--cc=dnovillo@google.com \
--cc=dseketel@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kcc@google.com \
--cc=konstantin.s.serebryany@gmail.com \
--cc=wmi@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).