diff mbox

[U-Boot] powerpc/mpc85xx:Add GCC flag -fno-delete-null-pointer-checks

Message ID 1430978853-10337-1-git-send-email-prabhakar@freescale.com
State Not Applicable
Delegated to: York Sun
Headers show

Commit Message

Prabhakar Kushwaha May 7, 2015, 6:07 a.m. UTC
-fdelete-null-pointer-checks flag controls global dataflow analyses and
 eliminate useless checks for null pointers; It assume that if a pointer is
 checked after it has already been dereferenced, it cannot be null.
 This flag is enabled by default.

 gcc v4.9 has more optimizations added to this option. Hence it is very
 aggressive with GCC v4.9 series. Add -fno-delete-null-pointer-checks to
 disable the optimization

Signed-off-by: Rohit Dharmakan <rohitarulraj@freescale.com>
Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
---
 arch/powerpc/cpu/mpc85xx/config.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

York Sun May 20, 2015, 5:10 p.m. UTC | #1
Scott,

Please comment on this patch.

York

On 05/06/2015 11:07 PM, Prabhakar Kushwaha wrote:
>  -fdelete-null-pointer-checks flag controls global dataflow analyses and
>  eliminate useless checks for null pointers; It assume that if a pointer is
>  checked after it has already been dereferenced, it cannot be null.
>  This flag is enabled by default.
> 
>  gcc v4.9 has more optimizations added to this option. Hence it is very
>  aggressive with GCC v4.9 series. Add -fno-delete-null-pointer-checks to
>  disable the optimization
> 
> Signed-off-by: Rohit Dharmakan <rohitarulraj@freescale.com>
> Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
> ---
>  arch/powerpc/cpu/mpc85xx/config.mk | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk
> index 72c964c..2aedd24 100644
> --- a/arch/powerpc/cpu/mpc85xx/config.mk
> +++ b/arch/powerpc/cpu/mpc85xx/config.mk
> @@ -5,7 +5,8 @@
>  # SPDX-License-Identifier:	GPL-2.0+
>  #
>  
> -PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
> +PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string \
> +					-fno-delete-null-pointer-checks
>  
>  # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
>  # see "[PATCH,rs6000] make -mno-spe work as expected" on
>
Scott Wood May 20, 2015, 5:33 p.m. UTC | #2
On Wed, 2015-05-20 at 10:10 -0700, York Sun wrote:
> Scott,
> 
> Please comment on this patch.
> 
> York

I think this should be set treewide (as Linux does), not just for
mpc85xx.  But use cc-option to make sure that the compiler supports the
option.

-Scott

> 
> On 05/06/2015 11:07 PM, Prabhakar Kushwaha wrote:
> >  -fdelete-null-pointer-checks flag controls global dataflow analyses and
> >  eliminate useless checks for null pointers; It assume that if a pointer is
> >  checked after it has already been dereferenced, it cannot be null.
> >  This flag is enabled by default.
> > 
> >  gcc v4.9 has more optimizations added to this option. Hence it is very
> >  aggressive with GCC v4.9 series. Add -fno-delete-null-pointer-checks to
> >  disable the optimization
> > 
> > Signed-off-by: Rohit Dharmakan <rohitarulraj@freescale.com>
> > Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
> > ---
> >  arch/powerpc/cpu/mpc85xx/config.mk | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk
> > index 72c964c..2aedd24 100644
> > --- a/arch/powerpc/cpu/mpc85xx/config.mk
> > +++ b/arch/powerpc/cpu/mpc85xx/config.mk
> > @@ -5,7 +5,8 @@
> >  # SPDX-License-Identifier:	GPL-2.0+
> >  #
> >  
> > -PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
> > +PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string \
> > +					-fno-delete-null-pointer-checks
> >  
> >  # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
> >  # see "[PATCH,rs6000] make -mno-spe work as expected" on
> >
Prabhakar Kushwaha June 30, 2015, 4:18 a.m. UTC | #3
Hi Simon, Tom,

-fdelete-null-pointer-checks flag controls global dataflow analyses and  eliminate useless checks for null pointers; It assume that if a pointer is  checked after it has already been dereferenced, it cannot be null.  This flag is enabled by default.
 gcc v4.9 has more optimizations added to this option. Hence it is very  aggressive with GCC v4.9 series. It is also well documented in the GCC v4.9 release notes:
https://gcc.gnu.org/gcc-4.9/porting_to.html

There is possibility after moving to gcc-4.9 some platform may/may not work properly. 
I tested this patch for freescale powerpc platforms. 
But It may needs be taken care by all architecture like ARM, powerpc. If this is the case; this flag should be in top level Makefile (not sure) 

Regards,
Prabhakar

> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Wednesday, May 20, 2015 11:04 PM
> To: Sun York-R58495
> Cc: Kushwaha Prabhakar-B32579; u-boot@lists.denx.de; Dharmakan Rohit-
> B30502
> Subject: Re: [PATCH] powerpc/mpc85xx:Add GCC flag -fno-delete-null-
> pointer-checks
> 
> On Wed, 2015-05-20 at 10:10 -0700, York Sun wrote:
> > Scott,
> >
> > Please comment on this patch.
> >
> > York
> 
> I think this should be set treewide (as Linux does), not just for mpc85xx.  But
> use cc-option to make sure that the compiler supports the option.
> 
> -Scott
> 
> >
> > On 05/06/2015 11:07 PM, Prabhakar Kushwaha wrote:
> > >  -fdelete-null-pointer-checks flag controls global dataflow analyses
> > > and  eliminate useless checks for null pointers; It assume that if a
> > > pointer is  checked after it has already been dereferenced, it cannot be
> null.
> > >  This flag is enabled by default.
> > >
> > >  gcc v4.9 has more optimizations added to this option. Hence it is
> > > very  aggressive with GCC v4.9 series. Add
> > > -fno-delete-null-pointer-checks to  disable the optimization
> > >
> > > Signed-off-by: Rohit Dharmakan <rohitarulraj@freescale.com>
> > > Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
> > > ---
> > >  arch/powerpc/cpu/mpc85xx/config.mk | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/powerpc/cpu/mpc85xx/config.mk
> > > b/arch/powerpc/cpu/mpc85xx/config.mk
> > > index 72c964c..2aedd24 100644
> > > --- a/arch/powerpc/cpu/mpc85xx/config.mk
> > > +++ b/arch/powerpc/cpu/mpc85xx/config.mk
> > > @@ -5,7 +5,8 @@
> > >  # SPDX-License-Identifier:	GPL-2.0+
> > >  #
> > >
> > > -PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
> > > +PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string \
> > > +					-fno-delete-null-pointer-checks
> > >
> > >  # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;  #
> > > see "[PATCH,rs6000] make -mno-spe work as expected" on
> > >
>
Simon Glass June 30, 2015, 2:58 p.m. UTC | #4
Hi,

On 29 June 2015 at 22:18, Kushwaha Prabhakar <prabhakar@freescale.com> wrote:
> Hi Simon, Tom,
>
> -fdelete-null-pointer-checks flag controls global dataflow analyses and  eliminate useless checks for null pointers; It assume that if a pointer is  checked after it has already been dereferenced, it cannot be null.  This flag is enabled by default.
>  gcc v4.9 has more optimizations added to this option. Hence it is very  aggressive with GCC v4.9 series. It is also well documented in the GCC v4.9 release notes:
> https://gcc.gnu.org/gcc-4.9/porting_to.html
>
> There is possibility after moving to gcc-4.9 some platform may/may not work properly.
> I tested this patch for freescale powerpc platforms.
> But It may needs be taken care by all architecture like ARM, powerpc. If this is the case; this flag should be in top level Makefile (not sure)
>

I suspect a top-level option would be best, perhaps near this one in Makefile:

KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)

Regards,
Simon

> Regards,
> Prabhakar
>
>> -----Original Message-----
>> From: Wood Scott-B07421
>> Sent: Wednesday, May 20, 2015 11:04 PM
>> To: Sun York-R58495
>> Cc: Kushwaha Prabhakar-B32579; u-boot@lists.denx.de; Dharmakan Rohit-
>> B30502
>> Subject: Re: [PATCH] powerpc/mpc85xx:Add GCC flag -fno-delete-null-
>> pointer-checks
>>
>> On Wed, 2015-05-20 at 10:10 -0700, York Sun wrote:
>> > Scott,
>> >
>> > Please comment on this patch.
>> >
>> > York
>>
>> I think this should be set treewide (as Linux does), not just for mpc85xx.  But
>> use cc-option to make sure that the compiler supports the option.
>>
>> -Scott
>>
>> >
>> > On 05/06/2015 11:07 PM, Prabhakar Kushwaha wrote:
>> > >  -fdelete-null-pointer-checks flag controls global dataflow analyses
>> > > and  eliminate useless checks for null pointers; It assume that if a
>> > > pointer is  checked after it has already been dereferenced, it cannot be
>> null.
>> > >  This flag is enabled by default.
>> > >
>> > >  gcc v4.9 has more optimizations added to this option. Hence it is
>> > > very  aggressive with GCC v4.9 series. Add
>> > > -fno-delete-null-pointer-checks to  disable the optimization
>> > >
>> > > Signed-off-by: Rohit Dharmakan <rohitarulraj@freescale.com>
>> > > Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
>> > > ---
>> > >  arch/powerpc/cpu/mpc85xx/config.mk | 3 ++-
>> > >  1 file changed, 2 insertions(+), 1 deletion(-)
>> > >
>> > > diff --git a/arch/powerpc/cpu/mpc85xx/config.mk
>> > > b/arch/powerpc/cpu/mpc85xx/config.mk
>> > > index 72c964c..2aedd24 100644
>> > > --- a/arch/powerpc/cpu/mpc85xx/config.mk
>> > > +++ b/arch/powerpc/cpu/mpc85xx/config.mk
>> > > @@ -5,7 +5,8 @@
>> > >  # SPDX-License-Identifier:       GPL-2.0+
>> > >  #
>> > >
>> > > -PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
>> > > +PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string \
>> > > +                                 -fno-delete-null-pointer-checks
>> > >
>> > >  # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;  #
>> > > see "[PATCH,rs6000] make -mno-spe work as expected" on
>> > >
>>
>
Tom Rini June 30, 2015, 6:22 p.m. UTC | #5
On Tue, Jun 30, 2015 at 08:58:26AM -0600, Simon Glass wrote:
> Hi,
> 
> On 29 June 2015 at 22:18, Kushwaha Prabhakar <prabhakar@freescale.com> wrote:
> > Hi Simon, Tom,
> >
> > -fdelete-null-pointer-checks flag controls global dataflow analyses and  eliminate useless checks for null pointers; It assume that if a pointer is  checked after it has already been dereferenced, it cannot be null.  This flag is enabled by default.
> >  gcc v4.9 has more optimizations added to this option. Hence it is very  aggressive with GCC v4.9 series. It is also well documented in the GCC v4.9 release notes:
> > https://gcc.gnu.org/gcc-4.9/porting_to.html
> >
> > There is possibility after moving to gcc-4.9 some platform may/may not work properly.
> > I tested this patch for freescale powerpc platforms.
> > But It may needs be taken care by all architecture like ARM, powerpc. If this is the case; this flag should be in top level Makefile (not sure)
> >
> 
> I suspect a top-level option would be best, perhaps near this one in Makefile:
> 
> KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)

I also agree with Scott and Simon, default, top level, using cc-option
just like the Linux kernel please, thanks!
Prabhakar Kushwaha July 1, 2015, 3:10 a.m. UTC | #6
> -----Original Message-----
> From: sjg@google.com [mailto:sjg@google.com] On Behalf Of Simon Glass
> Sent: Tuesday, June 30, 2015 8:28 PM
> To: Kushwaha Prabhakar-B32579
> Cc: Wood Scott-B07421; Sun York-R58495; trini@konsulko.com; u-
> boot@lists.denx.de; Dharmakan Rohit-B30502
> Subject: Re: [PATCH] powerpc/mpc85xx:Add GCC flag -fno-delete-null-
> pointer-checks
> 
> Hi,
> 
> On 29 June 2015 at 22:18, Kushwaha Prabhakar <prabhakar@freescale.com>
> wrote:
> > Hi Simon, Tom,
> >
> > -fdelete-null-pointer-checks flag controls global dataflow analyses and
> eliminate useless checks for null pointers; It assume that if a pointer is
> checked after it has already been dereferenced, it cannot be null.  This flag is
> enabled by default.
> >  gcc v4.9 has more optimizations added to this option. Hence it is very
> aggressive with GCC v4.9 series. It is also well documented in the GCC v4.9
> release notes:
> > https://gcc.gnu.org/gcc-4.9/porting_to.html
> >
> > There is possibility after moving to gcc-4.9 some platform may/may not
> work properly.
> > I tested this patch for freescale powerpc platforms.
> > But It may needs be taken care by all architecture like ARM, powerpc.
> > If this is the case; this flag should be in top level Makefile (not
> > sure)
> >
> 
> I suspect a top-level option would be best, perhaps near this one in Makefile:
> 
> KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
> 

I agree to put it here. 

But how to test it against different platform supported by u-boot.  

--prabhakar
diff mbox

Patch

diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk
index 72c964c..2aedd24 100644
--- a/arch/powerpc/cpu/mpc85xx/config.mk
+++ b/arch/powerpc/cpu/mpc85xx/config.mk
@@ -5,7 +5,8 @@ 
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string
+PLATFORM_CPPFLAGS += -Wa,-me500 -msoft-float -mno-string \
+					-fno-delete-null-pointer-checks
 
 # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
 # see "[PATCH,rs6000] make -mno-spe work as expected" on