-msave-args : uninitialized variable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

-msave-args : uninitialized variable

Sebastien Marie-3
Hi,

Recently, devel/llvm (the port) has copied the -msave-args diff from
base, and it resulted lang/rust to segfault.

Since, the change has been backouted, but I continued searching the root
cause as the diff is on base too.

and I think the culprit is SaveArgs variable member in class X86Subtarget.

If -msave-args is used, it is set to `true'.
If -mno-save-args is used, it is set to `false'.
But else, it lefts uninitialized.

As the value is a boolean, I changed type from unsigned to bool, and set
the default value.

I didn't test it on base, but with such patch on devel/llvm, rust is
able to compile correctly.

--
Sebastien Marie

Index: lib/Target/X86/X86Subtarget.h
===================================================================
RCS file: /cvs/src/gnu/llvm/lib/Target/X86/X86Subtarget.h,v
retrieving revision 1.4
diff -u -p -r1.4 X86Subtarget.h
--- lib/Target/X86/X86Subtarget.h 30 Jan 2019 03:08:12 -0000 1.4
+++ lib/Target/X86/X86Subtarget.h 4 Feb 2019 15:44:11 -0000
@@ -401,7 +401,7 @@ protected:
   unsigned stackAlignment = 4;
 
   /// Whether function prologues should save register arguments on the stack.
-  unsigned SaveArgs;
+  bool SaveArgs = false;
 
   /// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
   ///
@@ -481,7 +481,7 @@ public:
     return &getInstrInfo()->getRegisterInfo();
   }
 
-  unsigned getSaveArgs() const { return SaveArgs; }
+  bool getSaveArgs() const { return SaveArgs; }
 
   /// Returns the minimum alignment known to hold of the
   /// stack frame on entry to the function and which must be maintained by every

Reply | Threaded
Open this post in threaded view
|

Re: -msave-args : uninitialized variable

Mark Kettenis
> Date: Mon, 4 Feb 2019 16:53:36 +0100
> From: Sebastien Marie <[hidden email]>
>
> Hi,
>
> Recently, devel/llvm (the port) has copied the -msave-args diff from
> base, and it resulted lang/rust to segfault.
>
> Since, the change has been backouted, but I continued searching the root
> cause as the diff is on base too.
>
> and I think the culprit is SaveArgs variable member in class X86Subtarget.
>
> If -msave-args is used, it is set to `true'.
> If -mno-save-args is used, it is set to `false'.
> But else, it lefts uninitialized.
>
> As the value is a boolean, I changed type from unsigned to bool, and set
> the default value.
>
> I didn't test it on base, but with such patch on devel/llvm, rust is
> able to compile correctly.

ok kettenis@

> Index: lib/Target/X86/X86Subtarget.h
> ===================================================================
> RCS file: /cvs/src/gnu/llvm/lib/Target/X86/X86Subtarget.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 X86Subtarget.h
> --- lib/Target/X86/X86Subtarget.h 30 Jan 2019 03:08:12 -0000 1.4
> +++ lib/Target/X86/X86Subtarget.h 4 Feb 2019 15:44:11 -0000
> @@ -401,7 +401,7 @@ protected:
>    unsigned stackAlignment = 4;
>  
>    /// Whether function prologues should save register arguments on the stack.
> -  unsigned SaveArgs;
> +  bool SaveArgs = false;
>  
>    /// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
>    ///
> @@ -481,7 +481,7 @@ public:
>      return &getInstrInfo()->getRegisterInfo();
>    }
>  
> -  unsigned getSaveArgs() const { return SaveArgs; }
> +  bool getSaveArgs() const { return SaveArgs; }
>  
>    /// Returns the minimum alignment known to hold of the
>    /// stack frame on entry to the function and which must be maintained by every
>
>

Reply | Threaded
Open this post in threaded view
|

Re: -msave-args : uninitialized variable

Todd Mortimer
In reply to this post by Sebastien Marie-3
On Mon, Feb 04, 2019 at 04:53:36PM +0100, Sebastien Marie wrote:

> Hi,
>
> Recently, devel/llvm (the port) has copied the -msave-args diff from
> base, and it resulted lang/rust to segfault.
>
> Since, the change has been backouted, but I continued searching the root
> cause as the diff is on base too.
>
> and I think the culprit is SaveArgs variable member in class X86Subtarget.
>
> If -msave-args is used, it is set to `true'.
> If -mno-save-args is used, it is set to `false'.
> But else, it lefts uninitialized.
>
> As the value is a boolean, I changed type from unsigned to bool, and set
> the default value.
>
> I didn't test it on base, but with such patch on devel/llvm, rust is
> able to compile correctly.

ok mortimer@.

The unitialized memory argument makes sense. I would expect that it
would affect more than just the rust port though.

>
> --
> Sebastien Marie
>
> Index: lib/Target/X86/X86Subtarget.h
> ===================================================================
> RCS file: /cvs/src/gnu/llvm/lib/Target/X86/X86Subtarget.h,v
> retrieving revision 1.4
> diff -u -p -r1.4 X86Subtarget.h
> --- lib/Target/X86/X86Subtarget.h 30 Jan 2019 03:08:12 -0000 1.4
> +++ lib/Target/X86/X86Subtarget.h 4 Feb 2019 15:44:11 -0000
> @@ -401,7 +401,7 @@ protected:
>    unsigned stackAlignment = 4;
>
>    /// Whether function prologues should save register arguments on the stack.
> -  unsigned SaveArgs;
> +  bool SaveArgs = false;
>
>    /// Max. memset / memcpy size that is turned into rep/movs, rep/stos ops.
>    ///
> @@ -481,7 +481,7 @@ public:
>      return &getInstrInfo()->getRegisterInfo();
>    }
>
> -  unsigned getSaveArgs() const { return SaveArgs; }
> +  bool getSaveArgs() const { return SaveArgs; }
>
>    /// Returns the minimum alignment known to hold of the
>    /// stack frame on entry to the function and which must be maintained by every
>