This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Optionally trap on impossible devirtualization
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jan Hubicka <hubicka at ucw dot cz>
- Date: Mon, 28 Apr 2014 11:10:41 +0200
- Subject: Re: [PATCH] Optionally trap on impossible devirtualization
- Authentication-results: sourceware.org; auth=none
- References: <20140425153529 dot GI12215 at virgil dot suse> <CAFiYyc0mUb0Q9ZS-LPkuDpBxXOb6QnqENri742Q7GLRDt0GUoA at mail dot gmail dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Apr 28, 2014 at 11:05:06AM +0200, Richard Biener wrote:
> On Fri, Apr 25, 2014 at 5:35 PM, Martin Jambor <email@example.com> wrote:
> > Hi,
> > the patch below might be useful for testcase preparation and debugging
> > compiler bugs such as PR 60965. When
> > -ftrap-on-impossible-devirtualization is supplied on the command line,
> > it makes the devirtualization produce __builtin_trap instead of
> > __builtin_unreachable when it comes to the conclusion that there is no
> > legal target of a virtual call.
> > Apart from dealing with our bugs, it may be even useful to debug
> > compiled programs when a user triggers some sort of illegal
> > devirtualization, typically by missing a type check somewhere.
> > Currently the compiled program might simply take a wrong branch, with
> > the patch it will abort.
> > Bootstrapped and tested (with the option on) on x86_64-linux, I have
> > also successfully LTO built Firefox with it. If I add some
> > documentation, would like to see this in trunk?
> It's useful for debugging, so yes. Not sure about the option name though.
> Maybe we should have a generic -ftrap-on-unreachable flag instead
> and handle all __builtin_unreachable () like that (for example by
> folding or by simply make __builtin_unreachable () alias to __builtin_trap ()).
-fsanitize=unreachable should already do that. With
it should fold __builtin_unreachable () to __builtin_trap (), otherwise
to __ubsan_handle_builtin_unreachable () call.
So, from this POV, the new option is redundant.