Line data Source code
1 : // Copyright 2015 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_COMPILER_DEAD_CODE_ELIMINATION_H_
6 : #define V8_COMPILER_DEAD_CODE_ELIMINATION_H_
7 :
8 : #include "src/base/compiler-specific.h"
9 : #include "src/compiler/graph-reducer.h"
10 : #include "src/globals.h"
11 :
12 : namespace v8 {
13 : namespace internal {
14 : namespace compiler {
15 :
16 : // Forward declarations.
17 : class CommonOperatorBuilder;
18 :
19 : // Propagates {Dead} control through the graph and thereby removes dead code.
20 : // Note that this does not include trimming dead uses from the graph, and it
21 : // also does not include detecting dead code by any other means than seeing a
22 : // {Dead} control input; that is left to other reducers.
23 : class V8_EXPORT_PRIVATE DeadCodeElimination final
24 : : public NON_EXPORTED_BASE(AdvancedReducer) {
25 : public:
26 : DeadCodeElimination(Editor* editor, Graph* graph,
27 : CommonOperatorBuilder* common);
28 2671810 : ~DeadCodeElimination() final {}
29 :
30 0 : const char* reducer_name() const override { return "DeadCodeElimination"; }
31 :
32 : Reduction Reduce(Node* node) final;
33 :
34 : private:
35 : Reduction ReduceEnd(Node* node);
36 : Reduction ReduceLoopOrMerge(Node* node);
37 : Reduction ReduceLoopExit(Node* node);
38 : Reduction ReduceNode(Node* node);
39 :
40 : Reduction RemoveLoopExit(Node* node);
41 :
42 : void TrimMergeOrPhi(Node* node, int size);
43 :
44 : Graph* graph() const { return graph_; }
45 : CommonOperatorBuilder* common() const { return common_; }
46 : Node* dead() const { return dead_; }
47 :
48 : Graph* const graph_;
49 : CommonOperatorBuilder* const common_;
50 : Node* const dead_;
51 :
52 : DISALLOW_COPY_AND_ASSIGN(DeadCodeElimination);
53 : };
54 :
55 : } // namespace compiler
56 : } // namespace internal
57 : } // namespace v8
58 :
59 : #endif // V8_COMPILER_DEAD_CODE_ELIMINATION_H_
|