1 : // Copyright 2013 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 :
16 : #ifndef SYZYGY_BLOCK_GRAPH_TRANSFORMS_FUZZING_TRANSFORM_H_
17 : #define SYZYGY_BLOCK_GRAPH_TRANSFORMS_FUZZING_TRANSFORM_H_
18 :
19 : #include "syzygy/block_graph/iterate.h"
20 : #include "syzygy/block_graph/transforms/iterative_transform.h"
21 : #include "syzygy/block_graph/transforms/named_transform.h"
22 :
23 : namespace block_graph {
24 : namespace transforms {
25 :
26 : typedef block_graph::BlockGraph BlockGraph;
27 : typedef block_graph::BasicBlockSubGraph BasicBlockSubGraph;
28 :
29 : // This class applies the liveness fuzzing transformation to each basic block.
30 : //
31 : // At each program point where a register has been proven dead (i.e., it has
32 : // no downstream read dependency), an instruction is inserted which modifies
33 : // the contents of the register to contain a dummy value.
34 : class LivenessFuzzingBasicBlockTransform
35 : : public block_graph::transforms::NamedBasicBlockSubGraphTransformImpl<
36 : LivenessFuzzingBasicBlockTransform> {
37 : public:
38 E : LivenessFuzzingBasicBlockTransform() {}
39 :
40 : // The transform name.
41 : static const char kTransformName[];
42 :
43 : protected:
44 : // @name BasicBlockSubGraphTransformInterface method.
45 : virtual bool TransformBasicBlockSubGraph(
46 : const TransformPolicyInterface* policy,
47 : BlockGraph* block_graph,
48 : BasicBlockSubGraph* basic_block_subgraph) override;
49 :
50 : private:
51 : DISALLOW_COPY_AND_ASSIGN(LivenessFuzzingBasicBlockTransform);
52 : };
53 :
54 : // This transformation applied some basic block transform to validate analysis
55 : // done on subgraph. The behavior must be the same with each transformation.
56 : class FuzzingTransform
57 : : public block_graph::transforms::IterativeTransformImpl<FuzzingTransform> {
58 : public:
59 : FuzzingTransform();
60 :
61 : // @name IterativeTransformImpl implementation.
62 : // @{
63 : bool OnBlock(const TransformPolicyInterface* policy,
64 : BlockGraph* block_graph,
65 : BlockGraph::Block* block);
66 : // @}
67 :
68 : // The transform name.
69 : static const char kTransformName[];
70 :
71 : private:
72 : DISALLOW_COPY_AND_ASSIGN(FuzzingTransform);
73 : };
74 :
75 : } // namespace transforms
76 : } // namespace block_graph
77 :
78 : #endif // SYZYGY_BLOCK_GRAPH_TRANSFORMS_FUZZING_TRANSFORM_H_
|