1 : // Copyright 2012 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 : #ifndef SYZYGY_REORDER_DEAD_CODE_FINDER_H_
16 : #define SYZYGY_REORDER_DEAD_CODE_FINDER_H_
17 :
18 : #include <set>
19 :
20 : #include "syzygy/reorder/reorderer.h"
21 :
22 m : namespace reorder {
23 :
24 : // Identifies code symbols which are not referenced by a given call trace.
25 m : class DeadCodeFinder : public Reorderer::OrderGenerator {
26 m : public:
27 m : typedef BlockGraph::Block Block;
28 :
29 m : DeadCodeFinder();
30 m : virtual ~DeadCodeFinder();
31 :
32 : // Returns true if the block is of interest and unvisited.
33 m : bool IsDead(const Block* block) const;
34 :
35 : // OrderGenerator implementation.
36 : // @{
37 m : virtual bool OnCodeBlockEntry(const Block* block,
38 m : RelativeAddress address,
39 m : uint32 process_id,
40 m : uint32 thread_id,
41 m : const UniqueTime& time) override;
42 m : virtual bool CalculateReordering(const PEFile& pe_file,
43 m : const ImageLayout& image,
44 m : bool reorder_code,
45 m : bool reorder_data,
46 m : Order* order) override;
47 : // @}
48 :
49 m : protected:
50 : // The set of blocks observed while reading the call trace.
51 m : std::set<const Block*> visited_blocks_;
52 :
53 m : private:
54 m : DISALLOW_COPY_AND_ASSIGN(DeadCodeFinder);
55 m : };
56 :
57 m : } // namespace reorder
58 :
59 : #endif // SYZYGY_REORDER_DEAD_CODE_FINDER_H_
|