OLD | NEW |
1 //===-- JumpInstrTables.h: Jump-Instruction Tables --------------*- C++ -*-===// | 1 //===-- JumpInstrTables.h: Jump-Instruction Tables --------------*- C++ -*-===// |
2 // | 2 // |
3 // This file is distributed under the University of Illinois Open Source | 3 // This file is distributed under the University of Illinois Open Source |
4 // License. See LICENSE.TXT for details. | 4 // License. See LICENSE.TXT for details. |
5 // | 5 // |
6 //===----------------------------------------------------------------------===// | 6 //===----------------------------------------------------------------------===// |
7 /// | 7 /// |
8 /// \file | 8 /// \file |
9 /// \brief An implementation of tables consisting of jump instructions | 9 /// \brief An implementation of tables consisting of jump instructions |
10 /// | 10 /// |
11 //===----------------------------------------------------------------------===// | 11 //===----------------------------------------------------------------------===// |
12 | 12 |
13 #ifndef LLVM_CODEGEN_JUMPINSTRTABLES_H | 13 #ifndef LLVM_CODEGEN_JUMPINSTRTABLES_H |
14 #define LLVM_CODEGEN_JUMPINSTRTABLES_H | 14 #define LLVM_CODEGEN_JUMPINSTRTABLES_H |
15 | 15 |
16 #include "llvm/ADT/DenseMap.h" | 16 #include "llvm/ADT/DenseMap.h" |
| 17 #include "llvm/IR/LegacyPassManagers.h" |
17 #include "llvm/Pass.h" | 18 #include "llvm/Pass.h" |
18 #include "llvm/Target/TargetOptions.h" | 19 #include "llvm/Target/TargetOptions.h" |
19 | 20 |
20 namespace llvm { | 21 namespace llvm { |
21 class Constant; | 22 class Constant; |
22 class Function; | 23 class Function; |
23 class FunctionType; | 24 class FunctionType; |
24 class JumpInstrTableInfo; | 25 class JumpInstrTableInfo; |
25 class Module; | 26 class Module; |
26 | 27 |
(...skipping 24 matching lines...) Expand all Loading... |
51 public: | 52 public: |
52 static char ID; | 53 static char ID; |
53 | 54 |
54 JumpInstrTables(); | 55 JumpInstrTables(); |
55 JumpInstrTables(JumpTable::JumpTableType JTT); | 56 JumpInstrTables(JumpTable::JumpTableType JTT); |
56 virtual ~JumpInstrTables(); | 57 virtual ~JumpInstrTables(); |
57 bool runOnModule(Module &M) override; | 58 bool runOnModule(Module &M) override; |
58 const char *getPassName() const override { return "Jump-Instruction Tables"; } | 59 const char *getPassName() const override { return "Jump-Instruction Tables"; } |
59 void getAnalysisUsage(AnalysisUsage &AU) const override; | 60 void getAnalysisUsage(AnalysisUsage &AU) const override; |
60 | 61 |
| 62 // @LOCALMOD-BEGIN |
| 63 // If there is not a ModulePassManager in the pass manager stack, do not |
| 64 // schedule this pass. pnacl-llc uses only a FunctionPassManager but for |
| 65 // some reason it will happily schedule any module passes that are handed to |
| 66 // it and call them with bogus arguments. We could move this mod up into |
| 67 // ModulePass::assignPassManager except that the JIT also uses a FPM and |
| 68 // schedules a DebugInfoVerifier (which we do not use). That is still |
| 69 // probably wrong but DebugInfoVerifier seems to accidentally work anyway for |
| 70 // that case. |
| 71 // All of this should be fixed upstream, except that the pass manager is being |
| 72 // completely rewritten. So for now this is a noninvasive solution. |
| 73 void assignPassManager(PMStack &PMS, PassManagerType PreferredType) override { |
| 74 |
| 75 if (std::none_of(PMS.begin(), PMS.end(), [](PMDataManager *PM) { |
| 76 return PM->getPassManagerType() == PMT_ModulePassManager;})) { |
| 77 return; |
| 78 } |
| 79 ModulePass::assignPassManager(PMS, PreferredType); |
| 80 } |
| 81 // @LOCALMOD-END |
| 82 |
61 /// Creates a jump-instruction table function for the Target and adds it to | 83 /// Creates a jump-instruction table function for the Target and adds it to |
62 /// the tables. | 84 /// the tables. |
63 Function *insertEntry(Module &M, Function *Target); | 85 Function *insertEntry(Module &M, Function *Target); |
64 | 86 |
65 /// Checks to see if there is already a table for the given FunctionType. | 87 /// Checks to see if there is already a table for the given FunctionType. |
66 bool hasTable(FunctionType *FunTy); | 88 bool hasTable(FunctionType *FunTy); |
67 | 89 |
68 /// Maps the function into a subset of function types, depending on the | 90 /// Maps the function into a subset of function types, depending on the |
69 /// jump-instruction table style selected from JumpTableTypes in | 91 /// jump-instruction table style selected from JumpTableTypes in |
70 /// JumpInstrTables.cpp. The choice of mapping determines the number of | 92 /// JumpInstrTables.cpp. The choice of mapping determines the number of |
(...skipping 25 matching lines...) Expand all Loading... |
96 | 118 |
97 /// The type of tables to build. | 119 /// The type of tables to build. |
98 JumpTable::JumpTableType JTType; | 120 JumpTable::JumpTableType JTType; |
99 }; | 121 }; |
100 | 122 |
101 /// Creates a JumpInstrTables pass for the given type of jump table. | 123 /// Creates a JumpInstrTables pass for the given type of jump table. |
102 ModulePass *createJumpInstrTablesPass(JumpTable::JumpTableType JTT); | 124 ModulePass *createJumpInstrTablesPass(JumpTable::JumpTableType JTT); |
103 } | 125 } |
104 | 126 |
105 #endif /* LLVM_CODEGEN_JUMPINSTRTABLES_H */ | 127 #endif /* LLVM_CODEGEN_JUMPINSTRTABLES_H */ |
OLD | NEW |