From 3f3cb1e2fab128edda35473189c7e0666960f252 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 10 Jun 2024 15:19:45 -0700 Subject: [PATCH] intel/elk: delete copy constructor and copy-assignment-operator To keep the rule-of-three. This points out that the implicit copy operations would be dangerous when there is an explicit constructor and destructor, since the class is holding un-managed memory. Acked-by: Caio Oliveira Part-of: --- src/intel/compiler/elk/elk_cfg.h | 5 +++++ src/intel/compiler/elk/elk_fs.h | 5 +++++ src/intel/compiler/elk/elk_fs_combine_constants.cpp | 4 ++++ src/intel/compiler/elk/elk_fs_live_variables.h | 2 ++ src/intel/compiler/elk/elk_fs_reg_allocate.cpp | 3 +++ src/intel/compiler/elk/elk_ir_allocator.h | 4 ++++ src/intel/compiler/elk/elk_ir_analysis.h | 3 +++ src/intel/compiler/elk/elk_vec4_live_variables.h | 2 ++ 8 files changed, 28 insertions(+) diff --git a/src/intel/compiler/elk/elk_cfg.h b/src/intel/compiler/elk/elk_cfg.h index 86eb9d56402..d35bc08864a 100644 --- a/src/intel/compiler/elk/elk_cfg.h +++ b/src/intel/compiler/elk/elk_cfg.h @@ -326,8 +326,11 @@ struct elk_cfg_t { DECLARE_RALLOC_CXX_OPERATORS(elk_cfg_t) elk_cfg_t(const elk_backend_shader *s, exec_list *instructions); + elk_cfg_t(const elk_cfg_t &) = delete; ~elk_cfg_t(); + elk_cfg_t & operator=(const elk_cfg_t &) = delete; + void remove_block(elk_bblock_t *block); elk_bblock_t *first_block(); @@ -487,7 +490,9 @@ namespace elk { */ struct idom_tree { idom_tree(const elk_backend_shader *s); + idom_tree(const idom_tree &) = delete; ~idom_tree(); + idom_tree & operator=(const idom_tree &) = delete; bool validate(const elk_backend_shader *) const diff --git a/src/intel/compiler/elk/elk_fs.h b/src/intel/compiler/elk/elk_fs.h index 95abb621b33..ce26f735ecb 100644 --- a/src/intel/compiler/elk/elk_fs.h +++ b/src/intel/compiler/elk/elk_fs.h @@ -48,7 +48,9 @@ namespace elk { */ struct register_pressure { register_pressure(const elk_fs_visitor *v); + register_pressure(const register_pressure &) = delete; ~register_pressure(); + register_pressure & operator=(const register_pressure &) = delete; analysis_dependency_class dependency_class() const @@ -186,9 +188,12 @@ public: const nir_shader *shader, bool needs_register_pressure, bool debug_enabled); + elk_fs_visitor(const elk_fs_visitor &) = delete; void init(); ~elk_fs_visitor(); + elk_fs_visitor & operator=(const elk_fs_visitor &) = delete; + elk_fs_reg vgrf(const glsl_type *const type); void import_uniforms(elk_fs_visitor *v); diff --git a/src/intel/compiler/elk/elk_fs_combine_constants.cpp b/src/intel/compiler/elk/elk_fs_combine_constants.cpp index d86767772dc..82018b85b00 100644 --- a/src/intel/compiler/elk/elk_fs_combine_constants.cpp +++ b/src/intel/compiler/elk/elk_fs_combine_constants.cpp @@ -193,12 +193,16 @@ public: success = (user_map != NULL && values_to_emit != NULL); } + combine_constants_result(const combine_constants_result &) = delete; + ~combine_constants_result() { free(values_to_emit); free(user_map); } + combine_constants_result & operator=(const combine_constants_result &) = delete; + void append_value(const nir_const_value &value, unsigned bit_size) { values_to_emit[num_values_to_emit].value = value; diff --git a/src/intel/compiler/elk/elk_fs_live_variables.h b/src/intel/compiler/elk/elk_fs_live_variables.h index 0856e9e2dc0..cf28e104a9d 100644 --- a/src/intel/compiler/elk/elk_fs_live_variables.h +++ b/src/intel/compiler/elk/elk_fs_live_variables.h @@ -78,7 +78,9 @@ public: }; fs_live_variables(const elk_backend_shader *s); + fs_live_variables(const fs_live_variables &) = delete; ~fs_live_variables(); + fs_live_variables & operator=(const fs_live_variables &) = delete; bool validate(const elk_backend_shader *s) const; diff --git a/src/intel/compiler/elk/elk_fs_reg_allocate.cpp b/src/intel/compiler/elk/elk_fs_reg_allocate.cpp index 68cc31d775b..61416b19d68 100644 --- a/src/intel/compiler/elk/elk_fs_reg_allocate.cpp +++ b/src/intel/compiler/elk/elk_fs_reg_allocate.cpp @@ -342,6 +342,9 @@ public: spill_node_count = 0; } + elk_fs_reg_alloc(const elk_fs_reg_alloc &) = delete; + elk_fs_reg_alloc & operator=(const elk_fs_reg_alloc &) = delete; + ~elk_fs_reg_alloc() { ralloc_free(mem_ctx); diff --git a/src/intel/compiler/elk/elk_ir_allocator.h b/src/intel/compiler/elk/elk_ir_allocator.h index e26a3f5c4dc..7c8bb5e707d 100644 --- a/src/intel/compiler/elk/elk_ir_allocator.h +++ b/src/intel/compiler/elk/elk_ir_allocator.h @@ -42,12 +42,16 @@ namespace elk { { } + simple_allocator(const simple_allocator &) = delete; + ~simple_allocator() { free(offsets); free(sizes); } + simple_allocator & operator=(const simple_allocator &) = delete; + unsigned allocate(unsigned size) { diff --git a/src/intel/compiler/elk/elk_ir_analysis.h b/src/intel/compiler/elk/elk_ir_analysis.h index a320bdc90dc..5295dd2e372 100644 --- a/src/intel/compiler/elk/elk_ir_analysis.h +++ b/src/intel/compiler/elk/elk_ir_analysis.h @@ -139,6 +139,7 @@ public: * object of type \p T. */ elk_analysis(const C *c) : c(c), p(NULL) {} + elk_analysis(const elk_analysis &) = delete; /** * Destroy a program analysis. @@ -148,6 +149,8 @@ public: delete p; } + elk_analysis & operator=(const elk_analysis &) = delete; + /** * Obtain the result of a program analysis. This gives a * guaranteed up-to-date result, the analysis pass will be diff --git a/src/intel/compiler/elk/elk_vec4_live_variables.h b/src/intel/compiler/elk/elk_vec4_live_variables.h index b764eb51814..e0832dda956 100644 --- a/src/intel/compiler/elk/elk_vec4_live_variables.h +++ b/src/intel/compiler/elk/elk_vec4_live_variables.h @@ -65,7 +65,9 @@ public: }; vec4_live_variables(const elk_backend_shader *s); + vec4_live_variables(const vec4_live_variables &) = delete; ~vec4_live_variables(); + vec4_live_variables & operator=(const vec4_live_variables &) = delete; bool validate(const elk_backend_shader *s) const;