This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] For -O0 avoid putting user vars with methods in its type into registers (PR debug/39485)
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Mar 2009 16:22:36 +0100
- Subject: Re: [PATCH] For -O0 avoid putting user vars with methods in its type into registers (PR debug/39485)
- References: <20090318151847.GN4561@tyan-ft48-01.lab.bos.redhat.com>
On Wed, Mar 18, 2009 at 4:18 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> On the gdb testcase g++ 4.4 regresses from 4.3, as it puts a register
> variable into a register even at -O0, which makes it impossible to call
> methods on it from the debugger. ?The following patch just disregards
> the register keyword in that case in use_register_for_decl. ?Vars with types
> without methods will still be put into registers sometimes.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2009-03-18 ?Jakub Jelinek ?<jakub@redhat.com>
>
> ? ? ? ?PR debug/39485
> ? ? ? ?* function.c (use_register_for_decl): When not optimizing, disregard
> ? ? ? ?register keyword for variables with types containing methods.
>
> --- gcc/function.c.jj ? 2009-03-17 16:32:43.000000000 +0100
> +++ gcc/function.c ? ? ?2009-03-18 09:46:46.000000000 +0100
> @@ -1942,7 +1942,28 @@ use_register_for_decl (const_tree decl)
> ? if (DECL_IGNORED_P (decl))
> ? ? return true;
>
> - ?return (optimize || DECL_REGISTER (decl));
> + ?if (optimize)
> + ? ?return true;
> +
> + ?if (!DECL_REGISTER (decl))
> + ? ?return false;
> +
> + ?switch (TREE_CODE (TREE_TYPE (decl)))
> + ? ?{
> + ? ?case RECORD_TYPE:
> + ? ?case UNION_TYPE:
> + ? ?case QUAL_UNION_TYPE:
> + ? ? ?/* When not optimizing, disregard register keyword for variables with
> + ? ? ? ?types containing methods, otherwise the methods won't be callable
> + ? ? ? ?from the debugger. ?*/
> + ? ? ?if (TYPE_METHODS (TREE_TYPE (decl)))
> + ? ? ? return false;
> + ? ? ?break;
> + ? ?default:
> + ? ? ?break;
> + ? ?}
> +
> + ?return true;
> ?}
>
> ?/* Return true if TYPE should be passed by invisible reference. ?*/
>
> ? ? ? ?Jakub
>