Roland Levillain | 72bceff | 2014-09-15 18:29:00 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_OPTIMIZING_DEAD_CODE_ELIMINATION_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_DEAD_CODE_ELIMINATION_H_ |
| 19 | |
| 20 | #include "nodes.h" |
Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 21 | #include "optimization.h" |
Calin Juravle | 8f20bdb | 2015-04-21 14:07:50 +0100 | [diff] [blame] | 22 | #include "optimizing_compiler_stats.h" |
Roland Levillain | 72bceff | 2014-09-15 18:29:00 +0100 | [diff] [blame] | 23 | |
Vladimir Marko | 0a51605 | 2019-10-14 13:00:44 +0000 | [diff] [blame] | 24 | namespace art { |
Roland Levillain | 72bceff | 2014-09-15 18:29:00 +0100 | [diff] [blame] | 25 | |
| 26 | /** |
| 27 | * Optimization pass performing dead code elimination (removal of |
| 28 | * unused variables/instructions) on the SSA form. |
| 29 | */ |
Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 30 | class HDeadCodeElimination : public HOptimization { |
Roland Levillain | 72bceff | 2014-09-15 18:29:00 +0100 | [diff] [blame] | 31 | public: |
Andreas Gampe | ca620d7 | 2016-11-08 08:09:33 -0800 | [diff] [blame] | 32 | HDeadCodeElimination(HGraph* graph, OptimizingCompilerStats* stats, const char* name) |
David Brazdil | 69ba7b7 | 2015-06-23 18:27:30 +0100 | [diff] [blame] | 33 | : HOptimization(graph, name, stats) {} |
Roland Levillain | 72bceff | 2014-09-15 18:29:00 +0100 | [diff] [blame] | 34 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 35 | bool Run() override; |
Aart Bik | 2477320 | 2018-04-26 10:28:51 -0700 | [diff] [blame] | 36 | |
Wojciech Staszkiewicz | 5319d3c | 2016-08-01 17:48:59 -0700 | [diff] [blame] | 37 | static constexpr const char* kDeadCodeEliminationPassName = "dead_code_elimination"; |
Roland Levillain | 72bceff | 2014-09-15 18:29:00 +0100 | [diff] [blame] | 38 | |
| 39 | private: |
David Brazdil | 2d7352b | 2015-04-20 14:52:42 +0100 | [diff] [blame] | 40 | void MaybeRecordDeadBlock(HBasicBlock* block); |
Nicolas Geoffray | dac9b19 | 2016-07-15 10:46:17 +0100 | [diff] [blame] | 41 | void MaybeRecordSimplifyIf(); |
| 42 | bool RemoveDeadBlocks(); |
David Brazdil | 2d7352b | 2015-04-20 14:52:42 +0100 | [diff] [blame] | 43 | void RemoveDeadInstructions(); |
Aart Bik | a8b8e9b | 2018-01-09 11:01:02 -0800 | [diff] [blame] | 44 | bool SimplifyAlwaysThrows(); |
Nicolas Geoffray | dac9b19 | 2016-07-15 10:46:17 +0100 | [diff] [blame] | 45 | bool SimplifyIfs(); |
| 46 | void ConnectSuccessiveBlocks(); |
David Brazdil | 2d7352b | 2015-04-20 14:52:42 +0100 | [diff] [blame] | 47 | |
Roland Levillain | 75be283 | 2014-10-17 17:02:00 +0100 | [diff] [blame] | 48 | DISALLOW_COPY_AND_ASSIGN(HDeadCodeElimination); |
Roland Levillain | 72bceff | 2014-09-15 18:29:00 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | } // namespace art |
| 52 | |
| 53 | #endif // ART_COMPILER_OPTIMIZING_DEAD_CODE_ELIMINATION_H_ |