[DTrace-devel] [PATCH 03/10] Exclude %r0 from automatic register allocation

Kris Van Hees kris.van.hees at oracle.com
Fri Mar 18 23:11:39 UTC 2022


On Fri, Mar 18, 2022 at 05:06:10PM -0400, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> with
> 
> On 3/18/22 3:04 PM, Kris Van Hees via DTrace-devel wrote:
> > The %r0 register is used as a scratch register in various parts of the
> > coe gneerator and should therefore not be among the registers that can
> 
> s/coe/code/
> s/gneerator/generator/

Thanks.

> > be allocated when dt_regset_alloc() is called.
> So this patch should also:
> *) in dt_cg.c, remove those dozens of dt_regset_xalloc() calls along with
> their corresponding frees
> *) in dt_regset.h, remove dt_regset_xalloc()
> *) in dt_regset.c, make dt_regset_xalloc() static

No, no, and no :)  We still want to be able to alloc and free %r0 explicitly.
But perhaps I should add an explicit check to ensure that we do not alloc %r0
when it is already in use.  I will do that.

> > This patch also offers a minor improvement in the regset debugging
> > output, reporting in-use registers by number rather than with a 'x'
> > in the register list.
> Well, this change unnecessarily throws away active/spill info.

Ah bah, that is true.  I'll fix that (possibly by printing two lists).

> > Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> > ---
> >   libdtrace/dt_regset.c | 10 +++++-----
> >   1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/libdtrace/dt_regset.c b/libdtrace/dt_regset.c
> > index 11f0fdc1..143c5c24 100644
> > --- a/libdtrace/dt_regset.c
> > +++ b/libdtrace/dt_regset.c
> > @@ -1,6 +1,6 @@
> >   /*
> >    * Oracle Linux DTrace.
> > - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
> > + * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
> >    * Licensed under the Universal Permissive License v 1.0 as shown at
> >    * http://oss.oracle.com/licenses/upl.
> >    */
> > @@ -62,14 +62,14 @@ dt_regset_alloc(dt_regset_t *drp)
> >   {
> >   	int reg;
> > -	for (reg = drp->dr_size - 1; reg >= 0; reg--) {
> > +	for (reg = drp->dr_size - 1; reg > 0; reg--) {
> >   		if (BT_TEST(drp->dr_active, reg) == 0) {
> >   			BT_SET(drp->dr_active, reg);
> >   			return reg;
> >   		}
> >   	}
> > -	for (reg = drp->dr_size - 1; reg >= 0; reg--) {
> > +	for (reg = drp->dr_size - 1; reg > 0; reg--) {
> >   		if (BT_TEST(drp->dr_spilled, reg) == 0) {
> >   			drp->dr_spill_store(reg);
> >   			BT_SET(drp->dr_spilled, reg);
> > @@ -157,8 +157,8 @@ dt_regset_dump(dt_regset_t *drp, const char *pref)
> >   	fprintf(stderr, "%s: Regset: ", pref);
> >   	for (reg = 0; reg < drp->dr_size; reg++) {
> > -		fprintf(stderr, "%c", BT_TEST(drp->dr_active, reg) ? 'x' :
> > -				      BT_TEST(drp->dr_spilled, reg) ? 's' :
> > +		fprintf(stderr, "%c", BT_TEST(drp->dr_active, reg) ? '0' + reg:
> > +				      BT_TEST(drp->dr_spilled, reg) ? '0' + reg:
> >   				      '.');
> >   	}
> >   	fprintf(stderr, "\n");
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list