Bitcode: Serialize (and recover) use-list order
[oota-llvm.git] / include / llvm / IR / UseListOrder.h
1 //===- llvm/IR/UseListOrder.h - LLVM Use List Order functions ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file has functions to modify the use-list order and to verify that it
11 // doesn't change after serialization.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_IR_USELISTORDER_H
16 #define LLVM_IR_USELISTORDER_H
17
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include <vector>
21
22 namespace llvm {
23
24 class Module;
25 class Function;
26 class Value;
27
28 /// \brief Structure to hold a use-list order.
29 struct UseListOrder {
30   const Function *F;
31   const Value *V;
32   SmallVector<unsigned, 8> Shuffle;
33 };
34
35 typedef std::vector<UseListOrder> UseListOrderStack;
36
37 /// \brief Whether to preserve use-list ordering.
38 bool shouldPreserveBitcodeUseListOrder();
39 bool shouldPreserveAssemblyUseListOrder();
40
41 /// \brief Shuffle all use-lists in a module.
42 ///
43 /// Adds \c SeedOffset to the default seed for the random number generator.
44 void shuffleUseLists(Module &M, unsigned SeedOffset = 0);
45
46 } // end namespace llvm
47
48 #endif