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 : BlockGraph* block_graph,
47 : BasicBlockSubGraph* basic_block_subgraph) OVERRIDE;
48 :
49 : private:
50 : DISALLOW_COPY_AND_ASSIGN(LivenessFuzzingBasicBlockTransform);
51 : };
52 :
53 : // This transformation applied some basic block transform to validate analysis
54 : // done on subgraph. The behavior must be the same with each transformation.
55 : class FuzzingTransform
56 : : public block_graph::transforms::IterativeTransformImpl<FuzzingTransform> {
57 : public:
58 : FuzzingTransform();
59 :
60 : // @name IterativeTransformImpl implementation.
61 : // @{
62 : bool OnBlock(BlockGraph* block_graph, BlockGraph::Block* block);
63 : // @}
64 :
65 : // The transform name.
66 : static const char kTransformName[];
67 :
68 : private:
69 : DISALLOW_COPY_AND_ASSIGN(FuzzingTransform);
70 : };
71 :
72 : } // namespace transforms
73 : } // namespace block_graph
74 :
75 : #endif // SYZYGY_BLOCK_GRAPH_TRANSFORMS_FUZZING_TRANSFORM_H_
|