Microblaze: Fixed missing save of r18 in fast_interrupt.

Message ID BY5PR02MB70411214D075757F40D9E052D6C40@BY5PR02MB7041.namprd02.prod.outlook.com
State New
Headers show
Series
  • Microblaze: Fixed missing save of r18 in fast_interrupt.
Related show

Commit Message

Nagaraju Mekala April 4, 2020, 9:18 a.m.
Hello All,

Fixed missing save of r18 in fast_interrupt.
Register 18 is used as a clobber register, and must be stored when entering a fast_interrupt. Before this fix, register 18 was only saved if it was used directly in the interrupt function.
    
However, if the fast_interrupt function called a function that used r18, the register would not be saved, and thus be mangled upon returning from the interrupt.
    
Changelog
        2020-04-04  Klaus Petersen <klauspetersen@gmail.com>
         * gcc/config/microblaze/microblaze.c: Check for fast_interrupt in
            microblaze_must_save_register.

        Signed-off-by: Klaus Petersen <klauspetersen@gmail.com>

        Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>


Attached is the patch.

Thanks
Nagaraju

Comments

Michael Eager April 4, 2020, 6:16 p.m. | #1
OK to apply.

On 4/4/20 2:18 AM, Nagaraju Mekala wrote:
> Hello All,

> 

> Fixed missing save of r18 in fast_interrupt.

> Register 18 is used as a clobber register, and must be stored when entering a fast_interrupt. Before this fix, register 18 was only saved if it was used directly in the interrupt function.

>      

> However, if the fast_interrupt function called a function that used r18, the register would not be saved, and thus be mangled upon returning from the interrupt.

>      

> Changelog

>          2020-04-04  Klaus Petersen <klauspetersen@gmail.com>

>           * gcc/config/microblaze/microblaze.c: Check for fast_interrupt in

>              microblaze_must_save_register.

> 

>          Signed-off-by: Klaus Petersen <klauspetersen@gmail.com>

>          Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>

> 

> diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c

> index b4754b1..67e393d 100644

> --- a/gcc/config/microblaze/microblaze.c

> +++ b/gcc/config/microblaze/microblaze.c

> @@ -2035,7 +2035,7 @@ microblaze_must_save_register (int regno)

>       {

>         if (df_regs_ever_live_p (regno)

>            || regno == MB_ABI_MSR_SAVE_REG

> -         || (interrupt_handler

> +         || ((interrupt_handler || fast_interrupt)

>                 && (regno == MB_ABI_ASM_TEMP_REGNUM

>                    || regno == MB_ABI_EXCEPTION_RETURN_ADDR_REGNUM)))

>          return 1;

> 

> Attached is the patch.

> 

> Thanks

> Nagaraju

> 


-- 
Michael Eager    eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306
Jason Merrill via Gcc-patches April 5, 2020, 4:14 p.m. | #2
On Sat, 2020-04-04 at 11:16 -0700, Michael Eager wrote:
> OK to apply.

> 

> On 4/4/20 2:18 AM, Nagaraju Mekala wrote:

> > Hello All,

> > 

> > Fixed missing save of r18 in fast_interrupt.

> > Register 18 is used as a clobber register, and must be stored when entering a

> > fast_interrupt. Before this fix, register 18 was only saved if it was used

> > directly in the interrupt function.

> >      

> > However, if the fast_interrupt function called a function that used r18, the

> > register would not be saved, and thus be mangled upon returning from the

> > interrupt.

> >      

> > Changelog

> >          2020-04-04  Klaus Petersen <klauspetersen@gmail.com>

> >           * gcc/config/microblaze/microblaze.c: Check for fast_interrupt in

> >              microblaze_must_save_register.

> > 

> >          Signed-off-by: Klaus Petersen <klauspetersen@gmail.com>

> >          Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>

Fixed up the ChangeLog and trailing whitespace nits and pushed to the trunk.

THanks,
jeff
Nagaraju Mekala April 5, 2020, 4:17 p.m. | #3
> -----Original Message-----

> From: Jeff Law <law@redhat.com>

> Sent: Sunday, April 5, 2020 9:45 PM

> To: Michael Eager <eager@eagercon.com>; Nagaraju Mekala

> <nmekala@xilinx.com>; gcc-patches@gcc.gnu.org

> Cc: Sadanand Mutyala <sadanan@xilinx.com>; klauspetersen@gmail.com

> Subject: Re: [PATCH]Microblaze: Fixed missing save of r18 in fast_interrupt.

> 

> On Sat, 2020-04-04 at 11:16 -0700, Michael Eager wrote:

> > OK to apply.

Thank you.

> > On 4/4/20 2:18 AM, Nagaraju Mekala wrote:

> > > Hello All,

> > >

> > > Fixed missing save of r18 in fast_interrupt.

> > > Register 18 is used as a clobber register, and must be stored when

> > > entering a fast_interrupt. Before this fix, register 18 was only

> > > saved if it was used directly in the interrupt function.

> > >

> > > However, if the fast_interrupt function called a function that used

> > > r18, the register would not be saved, and thus be mangled upon

> > > returning from the interrupt.

> > >

> > > Changelog

> > >          2020-04-04  Klaus Petersen <klauspetersen@gmail.com>

> > >           * gcc/config/microblaze/microblaze.c: Check for fast_interrupt in

> > >              microblaze_must_save_register.

> > >

> > >          Signed-off-by: Klaus Petersen <klauspetersen@gmail.com>

> > >          Signed-off-by :Nagaraju Mekala <nmekala@xilix.com>

> Fixed up the ChangeLog and trailing whitespace nits and pushed to the trunk.

Thank you. I will take care of it from next time.
- Nagaraju
> THanks,

> jeff

>

Patch

diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
index b4754b1..67e393d 100644
--- a/gcc/config/microblaze/microblaze.c
+++ b/gcc/config/microblaze/microblaze.c
@@ -2035,7 +2035,7 @@  microblaze_must_save_register (int regno)
     {
       if (df_regs_ever_live_p (regno) 
          || regno == MB_ABI_MSR_SAVE_REG
-         || (interrupt_handler
+         || ((interrupt_handler || fast_interrupt)       
               && (regno == MB_ABI_ASM_TEMP_REGNUM
                  || regno == MB_ABI_EXCEPTION_RETURN_ADDR_REGNUM)))
        return 1;