[Mesa-dev] [RFC PATCH 5/5] glsl: Remove the virtual destructor of ir_instruction.

Francisco Jerez currojerez at riseup.net
Thu Oct 10 05:32:34 CEST 2013


ir_instruction and its derived classes are only being allocated and
destroyed using ralloc_new/delete, which already keep track of the
allocation type of an object and will always call the correct
destructor.  Having a virtual empty destructor in the definition of
ir_instruction is unnecessary (because we don't call operator delete
to free it anymore, so the previous compiler warning is no longer an
issue), and inefficient (because it prevents ralloc_new() from
inferring that ir_instruction subclasses are trivially destructible
and causes two additional indirect calls every time an ir_instruction
is released).  Remove it.
---
 src/glsl/ir.h | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index 9af267c..d81751c 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -93,16 +93,6 @@ class ir_instruction : public exec_node {
 public:
    enum ir_node_type ir_type;
 
-   /**
-    * GCC 4.7+ and clang warn when deleting an ir_instruction unless
-    * there's a virtual destructor present.  Because we almost
-    * universally use ralloc for our memory management of
-    * ir_instructions, the destructor doesn't need to do any work.
-    */
-   virtual ~ir_instruction()
-   {
-   }
-
    /** ir_print_visitor helper for debugging. */
    void print(void) const;
 
-- 
1.8.3.4



More information about the mesa-dev mailing list