From ef21df917fb9b85b86e4e627893a84426a35a967 Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Fri, 31 May 2024 14:26:30 +1000 Subject: [PATCH] glsl: remove do_function_inlining() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This no longer has any users. nir based inlining should be used for any new code. Reviewed-by: Marek Olšák Part-of: --- src/compiler/glsl/ir_function_can_inline.cpp | 75 ------------------- src/compiler/glsl/ir_function_inlining.h | 35 --------- src/compiler/glsl/ir_optimization.h | 1 - src/compiler/glsl/meson.build | 2 - src/compiler/glsl/opt_function_inlining.cpp | 78 -------------------- src/compiler/glsl/test_optpass.cpp | 2 - src/compiler/glsl/tests/warnings_test.py | 2 +- 7 files changed, 1 insertion(+), 194 deletions(-) delete mode 100644 src/compiler/glsl/ir_function_can_inline.cpp delete mode 100644 src/compiler/glsl/ir_function_inlining.h diff --git a/src/compiler/glsl/ir_function_can_inline.cpp b/src/compiler/glsl/ir_function_can_inline.cpp deleted file mode 100644 index 3b1d15f80fc..00000000000 --- a/src/compiler/glsl/ir_function_can_inline.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_function_can_inline.cpp - * - * Determines if we can inline a function call using ir_function_inlining.cpp. - * - * The primary restriction is that we can't return from the function other - * than as the last instruction. In lower_jumps.cpp, we can lower return - * statements not at the end of the function to other control flow in order to - * deal with this restriction. - */ - -#include "ir.h" - -class ir_function_can_inline_visitor : public ir_hierarchical_visitor { -public: - ir_function_can_inline_visitor() - { - this->num_returns = 0; - } - - virtual ir_visitor_status visit_enter(ir_return *); - - int num_returns; -}; - -ir_visitor_status -ir_function_can_inline_visitor::visit_enter(ir_return *ir) -{ - (void) ir; - this->num_returns++; - return visit_continue; -} - -bool -can_inline(ir_call *call) -{ - ir_function_can_inline_visitor v; - const ir_function_signature *callee = call->callee; - if (!callee->is_defined) - return false; - - v.run((exec_list *) &callee->body); - - /* If the function is empty (no last instruction) or does not end with a - * return statement, we need to count the implicit return. - */ - ir_instruction *last = (ir_instruction *)callee->body.get_tail(); - if (last == NULL || !last->as_return()) - v.num_returns++; - - return v.num_returns == 1; -} diff --git a/src/compiler/glsl/ir_function_inlining.h b/src/compiler/glsl/ir_function_inlining.h deleted file mode 100644 index 2af33fac668..00000000000 --- a/src/compiler/glsl/ir_function_inlining.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_function_inlining.h - * - * Replaces calls to functions with the body of the function. - */ - -#ifndef GLSL_IR_FUNCTION_INLINING_H -#define GLSL_IR_FUNCTION_INLINING_H - -bool can_inline(ir_call *call); - -#endif /* GLSL_IR_FUNCTION_INLINING_H */ diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h index ddf1783353d..e4beeef95ac 100644 --- a/src/compiler/glsl/ir_optimization.h +++ b/src/compiler/glsl/ir_optimization.h @@ -45,7 +45,6 @@ bool do_dead_code(exec_list *instructions); bool do_dead_code_local(exec_list *instructions); bool do_dead_code_unlinked(exec_list *instructions); bool opt_flip_matrices(exec_list *instructions); -bool do_function_inlining(exec_list *instructions); bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lower_sub_return = true, bool lower_main_return = false, bool lower_continue = false); bool do_if_simplification(exec_list *instructions); bool opt_flatten_nested_if_blocks(exec_list *instructions); diff --git a/src/compiler/glsl/meson.build b/src/compiler/glsl/meson.build index 71481ba8781..7d7d8bfb56b 100644 --- a/src/compiler/glsl/meson.build +++ b/src/compiler/glsl/meson.build @@ -168,9 +168,7 @@ files_libglsl = files( 'ir_equals.cpp', 'ir_expression_flattening.cpp', 'ir_expression_flattening.h', - 'ir_function_can_inline.cpp', 'ir_function_detect_recursion.cpp', - 'ir_function_inlining.h', 'ir_function.cpp', 'ir_hierarchical_visitor.cpp', 'ir_hierarchical_visitor.h', diff --git a/src/compiler/glsl/opt_function_inlining.cpp b/src/compiler/glsl/opt_function_inlining.cpp index 411d76efe4a..1e14aa41729 100644 --- a/src/compiler/glsl/opt_function_inlining.cpp +++ b/src/compiler/glsl/opt_function_inlining.cpp @@ -30,7 +30,6 @@ #include "ir.h" #include "ir_visitor.h" #include "ir_rvalue_visitor.h" -#include "ir_function_inlining.h" #include "ir_expression_flattening.h" #include "compiler/glsl_types.h" #include "util/hash_table.h" @@ -42,27 +41,6 @@ do_variable_replacement(exec_list *instructions, namespace { -class ir_function_inlining_visitor : public ir_hierarchical_visitor { -public: - ir_function_inlining_visitor() - { - progress = false; - } - - virtual ~ir_function_inlining_visitor() - { - /* empty */ - } - - virtual ir_visitor_status visit_enter(ir_expression *); - virtual ir_visitor_status visit_enter(ir_call *); - virtual ir_visitor_status visit_enter(ir_return *); - virtual ir_visitor_status visit_enter(ir_texture *); - virtual ir_visitor_status visit_enter(ir_swizzle *); - - bool progress; -}; - class ir_save_lvalue_visitor : public ir_hierarchical_visitor { public: virtual ir_visitor_status visit_enter(ir_dereference_array *); @@ -70,16 +48,6 @@ public: } /* unnamed namespace */ -bool -do_function_inlining(exec_list *instructions) -{ - ir_function_inlining_visitor v; - - v.run(instructions); - - return v.progress; -} - static void replace_return_with_assignment(ir_instruction *ir, void *data) { @@ -310,52 +278,6 @@ ir_call::generate_inline(ir_instruction *next_ir) _mesa_hash_table_destroy(ht, NULL); } - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_expression *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_return *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_texture *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_swizzle *ir) -{ - (void) ir; - return visit_continue_with_parent; -} - - -ir_visitor_status -ir_function_inlining_visitor::visit_enter(ir_call *ir) -{ - if (can_inline(ir)) { - ir->generate_inline(ir); - ir->remove(); - this->progress = true; - } - - return visit_continue; -} - - /** * Replaces references to the "orig" variable with a clone of "repl." * diff --git a/src/compiler/glsl/test_optpass.cpp b/src/compiler/glsl/test_optpass.cpp index 238de22f7ad..a6287f33a68 100644 --- a/src/compiler/glsl/test_optpass.cpp +++ b/src/compiler/glsl/test_optpass.cpp @@ -72,8 +72,6 @@ do_optimization(struct exec_list *ir, const char *optimization, return do_dead_code_local(ir); } else if (strcmp(optimization, "do_dead_code_unlinked") == 0) { return do_dead_code_unlinked(ir); - } else if (strcmp(optimization, "do_function_inlining") == 0) { - return do_function_inlining(ir); } else if (sscanf(optimization, "do_lower_jumps ( %d , %d , %d , %d ) ", &int_0, &int_1, &int_2, &int_3) == 4) { diff --git a/src/compiler/glsl/tests/warnings_test.py b/src/compiler/glsl/tests/warnings_test.py index fed5a75f236..ef6d1671089 100644 --- a/src/compiler/glsl/tests/warnings_test.py +++ b/src/compiler/glsl/tests/warnings_test.py @@ -74,7 +74,7 @@ def main(): expected = f.read().splitlines() proc= subprocess.run( - runner + ['--just-log', '--version', '150', file], + runner + ['--just-log', '--version', '150', '--link', file], stdout=subprocess.PIPE ) if proc.returncode == 255: