Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-13 Thread Ilia Mirkin
On Fri, Jun 10, 2016 at 11:34 AM, Stephan Bergmann  wrote:
> On 06/10/2016 05:20 PM, Ilia Mirkin wrote:
>>
>> It's pretty easy for me to fix up before I apply it too, but if I "git
>> am" your email, it'll be attributed to the one you sent it from,
>> unless that From line is there as line 1 of the email body. Just let
>> me know if you want me to fix it up. Despite the fact that the patch
>> is a 1-liner, I need to spend a few minutes carefully going through
>> things to ensure that it really is OK to make that destructor virtual
>> - I should get the time tonight or tomorrow.
>
>
> I'm fine with the From as is, no need for any fixup.  Thanks for taking care
> of the patch.

Stephan,

I've pushed this out now. Thanks for contributing!

  -ilia
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-10 Thread Ilia Mirkin
On Fri, Jun 10, 2016 at 11:32 AM, Jan Vesely  wrote:
> On Fri, 2016-06-10 at 11:20 -0400, Ilia Mirkin wrote:
>> On Fri, Jun 10, 2016 at 6:28 AM, Stephan Bergmann > m> wrote:
>> > On 06/10/2016 12:09 PM, Eric Engestrom wrote:
>> > >
>> > > On Thu, Jun 09, 2016 at 05:13:20PM +0200, Stephan Bergmann wrote:
>> > >
>> > > Since you didn't send this patch from your primary email account,
>> > > you might want to add this line here, otherwise the author will
>> > > be
>> > > "stephan.bergmann.second...@googlemail.com":
>> > >
>> > > From: Stephan Bergmann 
>> >
>> >
>> > Add that line where exactly?
>> >
>> > (Seriously, this starts to get boring to me.  I had a rather
>> > trivial
>> > drive-by patch.  I got asked to provide it as exactly "git send-
>> > email" (a
>> > "git format-patch"'ed attachment apparently didn't suit reviewers,
>> > for
>> > whatever reasons), so I dutifully set up "git send-email" (which I
>> > never use
>> > otherwise).  It didn't work with my primary SMTP server (which I
>> > didn't
>> > bother to investigate into further), so I used another one that
>> > happened to
>> > work.  I don't really care with what attribution that change would
>> > be
>> > merged.)
>>
>> It's pretty easy for me to fix up before I apply it too, but if I
>> "git
>> am" your email, it'll be attributed to the one you sent it from,
>> unless that From line is there as line 1 of the email body. Just let
>> me know if you want me to fix it up. Despite the fact that the patch
>> is a 1-liner, I need to spend a few minutes carefully going through
>> things to ensure that it really is OK to make that destructor virtual
>> - I should get the time tonight or tomorrow.
>
> adding virtual destructor is always OK. If you're worried about
> possible performance implications, the compiler devirtualization pass
> should handle those cases.

Not when the original code explicitly relies on it being non-virtual.
Just have to make sure that wasn't the case. The original author of a
lot of this code tended to do tricky things, I wouldn't put this past
him.

  -ilia
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-10 Thread Stephan Bergmann

On 06/10/2016 05:20 PM, Ilia Mirkin wrote:

It's pretty easy for me to fix up before I apply it too, but if I "git
am" your email, it'll be attributed to the one you sent it from,
unless that From line is there as line 1 of the email body. Just let
me know if you want me to fix it up. Despite the fact that the patch
is a 1-liner, I need to spend a few minutes carefully going through
things to ensure that it really is OK to make that destructor virtual
- I should get the time tonight or tomorrow.


I'm fine with the From as is, no need for any fixup.  Thanks for taking 
care of the patch.

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-10 Thread Jan Vesely
On Fri, 2016-06-10 at 11:20 -0400, Ilia Mirkin wrote:
> On Fri, Jun 10, 2016 at 6:28 AM, Stephan Bergmann  m> wrote:
> > On 06/10/2016 12:09 PM, Eric Engestrom wrote:
> > > 
> > > On Thu, Jun 09, 2016 at 05:13:20PM +0200, Stephan Bergmann wrote:
> > > 
> > > Since you didn't send this patch from your primary email account,
> > > you might want to add this line here, otherwise the author will
> > > be
> > > "stephan.bergmann.second...@googlemail.com":
> > > 
> > > From: Stephan Bergmann 
> > 
> > 
> > Add that line where exactly?
> > 
> > (Seriously, this starts to get boring to me.  I had a rather
> > trivial
> > drive-by patch.  I got asked to provide it as exactly "git send-
> > email" (a
> > "git format-patch"'ed attachment apparently didn't suit reviewers,
> > for
> > whatever reasons), so I dutifully set up "git send-email" (which I
> > never use
> > otherwise).  It didn't work with my primary SMTP server (which I
> > didn't
> > bother to investigate into further), so I used another one that
> > happened to
> > work.  I don't really care with what attribution that change would
> > be
> > merged.)
> 
> It's pretty easy for me to fix up before I apply it too, but if I
> "git
> am" your email, it'll be attributed to the one you sent it from,
> unless that From line is there as line 1 of the email body. Just let
> me know if you want me to fix it up. Despite the fact that the patch
> is a 1-liner, I need to spend a few minutes carefully going through
> things to ensure that it really is OK to make that destructor virtual
> - I should get the time tonight or tomorrow.

adding virtual destructor is always OK. If you're worried about
possible performance implications, the compiler devirtualization pass
should handle those cases.

Jan

> 
> Cheers,
> 
>   -ilia
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-- 
Jan Vesely 

signature.asc
Description: This is a digitally signed message part
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-10 Thread Ilia Mirkin
On Fri, Jun 10, 2016 at 6:28 AM, Stephan Bergmann  wrote:
> On 06/10/2016 12:09 PM, Eric Engestrom wrote:
>>
>> On Thu, Jun 09, 2016 at 05:13:20PM +0200, Stephan Bergmann wrote:
>>
>> Since you didn't send this patch from your primary email account,
>> you might want to add this line here, otherwise the author will be
>> "stephan.bergmann.second...@googlemail.com":
>>
>> From: Stephan Bergmann 
>
>
> Add that line where exactly?
>
> (Seriously, this starts to get boring to me.  I had a rather trivial
> drive-by patch.  I got asked to provide it as exactly "git send-email" (a
> "git format-patch"'ed attachment apparently didn't suit reviewers, for
> whatever reasons), so I dutifully set up "git send-email" (which I never use
> otherwise).  It didn't work with my primary SMTP server (which I didn't
> bother to investigate into further), so I used another one that happened to
> work.  I don't really care with what attribution that change would be
> merged.)

It's pretty easy for me to fix up before I apply it too, but if I "git
am" your email, it'll be attributed to the one you sent it from,
unless that From line is there as line 1 of the email body. Just let
me know if you want me to fix it up. Despite the fact that the patch
is a 1-liner, I need to spend a few minutes carefully going through
things to ensure that it really is OK to make that destructor virtual
- I should get the time tonight or tomorrow.

Cheers,

  -ilia
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-10 Thread Eric Engestrom
On Fri, Jun 10, 2016 at 12:28:38PM +0200, Stephan Bergmann wrote:
> On 06/10/2016 12:09 PM, Eric Engestrom wrote:
> > On Thu, Jun 09, 2016 at 05:13:20PM +0200, Stephan Bergmann wrote:
> > 
> > Since you didn't send this patch from your primary email account,
> > you might want to add this line here, otherwise the author will be
> > "stephan.bergmann.second...@googlemail.com":
> > 
> > From: Stephan Bergmann 
> 
> Add that line where exactly?

At the top, above the commit message. Using `git send-email` on the
patch you originally sent does it automatically (I just double-checked).

> 
> (Seriously, this starts to get boring to me.  I had a rather trivial
> drive-by patch.  I got asked to provide it as exactly "git send-email" (a
> "git format-patch"'ed attachment apparently didn't suit reviewers, for
> whatever reasons),

Inline patches allow for inline comments, which most reviewers prefer.
It also makes the use of git-am much easier, when someone wants to test
your patch, or when a maintainer wants to apply and push your patch.

> so I dutifully set up "git send-email" (which I never use
> otherwise).  It didn't work with my primary SMTP server (which I didn't
> bother to investigate into further), so I used another one that happened to
> work.  I don't really care with what attribution that change would be
> merged.)

I didn't mean to bother. If you don't care what email address gets
attached to your name, feel free to ignore this :)

Cheers,
  Eric
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-10 Thread Stephan Bergmann

On 06/10/2016 12:09 PM, Eric Engestrom wrote:

On Thu, Jun 09, 2016 at 05:13:20PM +0200, Stephan Bergmann wrote:

Since you didn't send this patch from your primary email account,
you might want to add this line here, otherwise the author will be
"stephan.bergmann.second...@googlemail.com":

From: Stephan Bergmann 


Add that line where exactly?

(Seriously, this starts to get boring to me.  I had a rather trivial 
drive-by patch.  I got asked to provide it as exactly "git send-email" 
(a "git format-patch"'ed attachment apparently didn't suit reviewers, 
for whatever reasons), so I dutifully set up "git send-email" (which I 
never use otherwise).  It didn't work with my primary SMTP server (which 
I didn't bother to investigate into further), so I used another one that 
happened to work.  I don't really care with what attribution that change 
would be merged.)

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-10 Thread Eric Engestrom
On Thu, Jun 09, 2016 at 05:13:20PM +0200, Stephan Bergmann wrote:

Since you didn't send this patch from your primary email account,
you might want to add this line here, otherwise the author will be
"stephan.bergmann.second...@googlemail.com":

From: Stephan Bergmann 

> ...when Function::domTree is created as DominatorTree in 
> Function::convertToSSA
> (src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp) but destroyed only as 
> base
> Graph in ~Function (src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp).
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h
> index b0981ff..115f20e 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h
> @@ -147,7 +147,7 @@ public:
>  
>  public:
> Graph();
> -   ~Graph(); // does *not* free the nodes (make it an option ?)
> +   virtual ~Graph(); // does *not* free the nodes (make it an option ?)
>  
> inline Node *getRoot() const { return root; }
>  
> -- 
> 2.7.4
> 
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-09 Thread Stephan Bergmann
...when Function::domTree is created as DominatorTree in Function::convertToSSA
(src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp) but destroyed only as base
Graph in ~Function (src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp).
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h
index b0981ff..115f20e 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_graph.h
@@ -147,7 +147,7 @@ public:
 
 public:
Graph();
-   ~Graph(); // does *not* free the nodes (make it an option ?)
+   virtual ~Graph(); // does *not* free the nodes (make it an option ?)
 
inline Node *getRoot() const { return root; }
 
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-09 Thread Stephan Bergmann

On 06/09/2016 05:01 PM, Ilia Mirkin wrote:

Is this all because Graph doesn't have a virtual destructor? We don't
construct/destruct those too often, I'd much rather just make it
virtual rather than moving DominatorTree.


Yes, that of course also works.  Corresponding patch coming.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-09 Thread Ilia Mirkin
Is this all because Graph doesn't have a virtual destructor? We don't
construct/destruct those too often, I'd much rather just make it
virtual rather than moving DominatorTree.

On Thu, Jun 9, 2016 at 10:52 AM, Stephan Bergmann
 wrote:
> ...when Function::domTree is created as DominatorTree in 
> Function::convertToSSA
> (src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp) but destroyed only as 
> base
> Graph in ~Function (src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp).
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir.h  | 37 
> +-
>  .../drivers/nouveau/codegen/nv50_ir_ssa.cpp| 37 
> +-
>  2 files changed, 37 insertions(+), 37 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
> index 94e54bb..c864d56 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
> @@ -1132,6 +1132,41 @@ private:
> void splitCommon(Instruction *, BasicBlock *, bool attach);
>  };
>
> +// DominatorTree implements an algorithm for finding immediate dominators,
> +// as described by T. Lengauer & R. Tarjan.
> +class DominatorTree : public Graph
> +{
> +public:
> +   DominatorTree(Graph *cfg);
> +   ~DominatorTree() { }
> +
> +   bool dominates(BasicBlock *, BasicBlock *);
> +
> +   void findDominanceFrontiers();
> +
> +private:
> +   void build();
> +   void buildDFS(Node *);
> +
> +   void squash(int);
> +   inline void link(int, int);
> +   inline int eval(int);
> +
> +   void debugPrint();
> +
> +   Graph *cfg;
> +
> +   Node **vert;
> +   int *data;
> +   const int count;
> +
> +   #define SEMI(i) (data[(i) + 0 * count])
> +   #define ANCESTOR(i) (data[(i) + 1 * count])
> +   #define PARENT(i)   (data[(i) + 2 * count])
> +   #define LABEL(i)(data[(i) + 3 * count])
> +   #define DOM(i)  (data[(i) + 4 * count])
> +};
> +
>  class Function
>  {
>  public:
> @@ -1171,7 +1206,7 @@ public:
>
> Graph cfg;
> Graph::Node *cfgExit;
> -   Graph *domTree;
> +   DominatorTree *domTree;
> Graph::Node call; // node in the call graph
>
> BasicBlock **bbArray; // BBs in emission order
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp 
> b/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
> index 3d25ad9..9652b72 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
> @@ -27,41 +27,6 @@ namespace nv50_ir {
>
>  // Converts nv50 IR generated from TGSI to SSA form.
>
> -// DominatorTree implements an algorithm for finding immediate dominators,
> -// as described by T. Lengauer & R. Tarjan.
> -class DominatorTree : public Graph
> -{
> -public:
> -   DominatorTree(Graph *cfg);
> -   ~DominatorTree() { }
> -
> -   bool dominates(BasicBlock *, BasicBlock *);
> -
> -   void findDominanceFrontiers();
> -
> -private:
> -   void build();
> -   void buildDFS(Node *);
> -
> -   void squash(int);
> -   inline void link(int, int);
> -   inline int eval(int);
> -
> -   void debugPrint();
> -
> -   Graph *cfg;
> -
> -   Node **vert;
> -   int *data;
> -   const int count;
> -
> -   #define SEMI(i) (data[(i) + 0 * count])
> -   #define ANCESTOR(i) (data[(i) + 1 * count])
> -   #define PARENT(i)   (data[(i) + 2 * count])
> -   #define LABEL(i)(data[(i) + 3 * count])
> -   #define DOM(i)  (data[(i) + 4 * count])
> -};
> -
>  void DominatorTree::debugPrint()
>  {
> for (int i = 0; i < count; ++i) {
> @@ -326,7 +291,7 @@ Function::convertToSSA()
>
> // 1. create the dominator tree
> domTree = new DominatorTree();
> -   reinterpret_cast(domTree)->findDominanceFrontiers();
> +   domTree->findDominanceFrontiers();
>
> // 2. insert PHI functions
> DLList workList;
> --
> 2.7.4
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch

2016-06-09 Thread Stephan Bergmann
...when Function::domTree is created as DominatorTree in Function::convertToSSA
(src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp) but destroyed only as base
Graph in ~Function (src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp).
---
 src/gallium/drivers/nouveau/codegen/nv50_ir.h  | 37 +-
 .../drivers/nouveau/codegen/nv50_ir_ssa.cpp| 37 +-
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h 
b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
index 94e54bb..c864d56 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
@@ -1132,6 +1132,41 @@ private:
void splitCommon(Instruction *, BasicBlock *, bool attach);
 };
 
+// DominatorTree implements an algorithm for finding immediate dominators,
+// as described by T. Lengauer & R. Tarjan.
+class DominatorTree : public Graph
+{
+public:
+   DominatorTree(Graph *cfg);
+   ~DominatorTree() { }
+
+   bool dominates(BasicBlock *, BasicBlock *);
+
+   void findDominanceFrontiers();
+
+private:
+   void build();
+   void buildDFS(Node *);
+
+   void squash(int);
+   inline void link(int, int);
+   inline int eval(int);
+
+   void debugPrint();
+
+   Graph *cfg;
+
+   Node **vert;
+   int *data;
+   const int count;
+
+   #define SEMI(i) (data[(i) + 0 * count])
+   #define ANCESTOR(i) (data[(i) + 1 * count])
+   #define PARENT(i)   (data[(i) + 2 * count])
+   #define LABEL(i)(data[(i) + 3 * count])
+   #define DOM(i)  (data[(i) + 4 * count])
+};
+
 class Function
 {
 public:
@@ -1171,7 +1206,7 @@ public:
 
Graph cfg;
Graph::Node *cfgExit;
-   Graph *domTree;
+   DominatorTree *domTree;
Graph::Node call; // node in the call graph
 
BasicBlock **bbArray; // BBs in emission order
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp 
b/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
index 3d25ad9..9652b72 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
@@ -27,41 +27,6 @@ namespace nv50_ir {
 
 // Converts nv50 IR generated from TGSI to SSA form.
 
-// DominatorTree implements an algorithm for finding immediate dominators,
-// as described by T. Lengauer & R. Tarjan.
-class DominatorTree : public Graph
-{
-public:
-   DominatorTree(Graph *cfg);
-   ~DominatorTree() { }
-
-   bool dominates(BasicBlock *, BasicBlock *);
-
-   void findDominanceFrontiers();
-
-private:
-   void build();
-   void buildDFS(Node *);
-
-   void squash(int);
-   inline void link(int, int);
-   inline int eval(int);
-
-   void debugPrint();
-
-   Graph *cfg;
-
-   Node **vert;
-   int *data;
-   const int count;
-
-   #define SEMI(i) (data[(i) + 0 * count])
-   #define ANCESTOR(i) (data[(i) + 1 * count])
-   #define PARENT(i)   (data[(i) + 2 * count])
-   #define LABEL(i)(data[(i) + 3 * count])
-   #define DOM(i)  (data[(i) + 4 * count])
-};
-
 void DominatorTree::debugPrint()
 {
for (int i = 0; i < count; ++i) {
@@ -326,7 +291,7 @@ Function::convertToSSA()
 
// 1. create the dominator tree
domTree = new DominatorTree();
-   reinterpret_cast(domTree)->findDominanceFrontiers();
+   domTree->findDominanceFrontiers();
 
// 2. insert PHI functions
DLList workList;
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch (in src/gallium/drivers/nouveau/codegen/)

2016-06-09 Thread Ilia Mirkin
Please send the patch inline, and in such a way that I'll be able to apply
it with git am. Git send-email does the right thing, FYI.
On Jun 9, 2016 9:26 AM, "Stephan Bergmann"  wrote:

> see attached 0001-Avoid-ASan-new-delete-type-mismatch.patch
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
>
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Avoid ASan new-delete-type-mismatch (in src/gallium/drivers/nouveau/codegen/)

2016-06-09 Thread Stephan Bergmann

see attached 0001-Avoid-ASan-new-delete-type-mismatch.patch
>From 653d9da624c56fab05ed568133f30640b9e75b4f Mon Sep 17 00:00:00 2001
From: Stephan Bergmann 
Date: Thu, 9 Jun 2016 15:21:46 +0200
Subject: [PATCH] Avoid ASan new-delete-type-mismatch

...when Function::domTree is created as DominatorTree in Function::convertToSSA
(src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp) but destroyed only as base
Graph in ~Function (src/gallium/drivers/nouveau/codegen/nv50_ir_bb.cpp).
---
 src/gallium/drivers/nouveau/codegen/nv50_ir.h  | 37 +-
 .../drivers/nouveau/codegen/nv50_ir_ssa.cpp| 37 +-
 2 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.h b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
index 94e54bb..c864d56 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir.h
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.h
@@ -1132,6 +1132,41 @@ private:
void splitCommon(Instruction *, BasicBlock *, bool attach);
 };
 
+// DominatorTree implements an algorithm for finding immediate dominators,
+// as described by T. Lengauer & R. Tarjan.
+class DominatorTree : public Graph
+{
+public:
+   DominatorTree(Graph *cfg);
+   ~DominatorTree() { }
+
+   bool dominates(BasicBlock *, BasicBlock *);
+
+   void findDominanceFrontiers();
+
+private:
+   void build();
+   void buildDFS(Node *);
+
+   void squash(int);
+   inline void link(int, int);
+   inline int eval(int);
+
+   void debugPrint();
+
+   Graph *cfg;
+
+   Node **vert;
+   int *data;
+   const int count;
+
+   #define SEMI(i) (data[(i) + 0 * count])
+   #define ANCESTOR(i) (data[(i) + 1 * count])
+   #define PARENT(i)   (data[(i) + 2 * count])
+   #define LABEL(i)(data[(i) + 3 * count])
+   #define DOM(i)  (data[(i) + 4 * count])
+};
+
 class Function
 {
 public:
@@ -1171,7 +1206,7 @@ public:
 
Graph cfg;
Graph::Node *cfgExit;
-   Graph *domTree;
+   DominatorTree *domTree;
Graph::Node call; // node in the call graph
 
BasicBlock **bbArray; // BBs in emission order
diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
index 3d25ad9..9652b72 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_ssa.cpp
@@ -27,41 +27,6 @@ namespace nv50_ir {
 
 // Converts nv50 IR generated from TGSI to SSA form.
 
-// DominatorTree implements an algorithm for finding immediate dominators,
-// as described by T. Lengauer & R. Tarjan.
-class DominatorTree : public Graph
-{
-public:
-   DominatorTree(Graph *cfg);
-   ~DominatorTree() { }
-
-   bool dominates(BasicBlock *, BasicBlock *);
-
-   void findDominanceFrontiers();
-
-private:
-   void build();
-   void buildDFS(Node *);
-
-   void squash(int);
-   inline void link(int, int);
-   inline int eval(int);
-
-   void debugPrint();
-
-   Graph *cfg;
-
-   Node **vert;
-   int *data;
-   const int count;
-
-   #define SEMI(i) (data[(i) + 0 * count])
-   #define ANCESTOR(i) (data[(i) + 1 * count])
-   #define PARENT(i)   (data[(i) + 2 * count])
-   #define LABEL(i)(data[(i) + 3 * count])
-   #define DOM(i)  (data[(i) + 4 * count])
-};
-
 void DominatorTree::debugPrint()
 {
for (int i = 0; i < count; ++i) {
@@ -326,7 +291,7 @@ Function::convertToSSA()
 
// 1. create the dominator tree
domTree = new DominatorTree();
-   reinterpret_cast(domTree)->findDominanceFrontiers();
+   domTree->findDominanceFrontiers();
 
// 2. insert PHI functions
DLList workList;
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev