|
67 | 67 | #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" |
68 | 68 | #include "llvm/CodeGen/Passes.h" |
69 | 69 | #include "llvm/CodeGen/TargetInstrInfo.h" |
| 70 | +#include "llvm/CodeGen/TargetPassConfig.h" |
70 | 71 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
71 | 72 | #include "llvm/IR/DIBuilder.h" |
72 | 73 | #include "llvm/IR/IRBuilder.h" |
|
77 | 78 | #include "llvm/Support/Debug.h" |
78 | 79 | #include "llvm/Support/SuffixTree.h" |
79 | 80 | #include "llvm/Support/raw_ostream.h" |
| 81 | +#include "llvm/Target/TargetMachine.h" |
80 | 82 | #include "llvm/Transforms/Utils/ModuleUtils.h" |
81 | 83 | #include <tuple> |
82 | 84 | #include <vector> |
@@ -427,6 +429,7 @@ struct MachineOutliner : public ModulePass { |
427 | 429 | static char ID; |
428 | 430 |
|
429 | 431 | MachineModuleInfo *MMI = nullptr; |
| 432 | + const TargetMachine *TM = nullptr; |
430 | 433 |
|
431 | 434 | /// Set to true if the outliner should consider functions with |
432 | 435 | /// linkonceodr linkage. |
@@ -462,6 +465,7 @@ struct MachineOutliner : public ModulePass { |
462 | 465 |
|
463 | 466 | void getAnalysisUsage(AnalysisUsage &AU) const override { |
464 | 467 | AU.addRequired<MachineModuleInfoWrapperPass>(); |
| 468 | + AU.addRequired<TargetPassConfig>(); |
465 | 469 | AU.addPreserved<MachineModuleInfoWrapperPass>(); |
466 | 470 | AU.addUsedIfAvailable<ImmutableModuleSummaryIndexWrapperPass>(); |
467 | 471 | AU.setPreservesAll(); |
@@ -1081,10 +1085,9 @@ bool MachineOutliner::outline( |
1081 | 1085 | // the outlined function. |
1082 | 1086 | SmallPtrSet<MachineInstr *, 2> MIs; |
1083 | 1087 | for (Candidate &C : OF->Candidates) { |
1084 | | - const TargetInstrInfo &TII = *C.getMF()->getSubtarget().getInstrInfo(); |
1085 | 1088 | for (MachineInstr &MI : C) |
1086 | 1089 | MIs.insert(&MI); |
1087 | | - NumRemovedLOHs += TII.clearLinkerOptimizationHints(MIs); |
| 1090 | + NumRemovedLOHs += TM->clearLinkerOptimizationHints(MIs); |
1088 | 1091 | MIs.clear(); |
1089 | 1092 | } |
1090 | 1093 |
|
@@ -1399,6 +1402,7 @@ bool MachineOutliner::runOnModule(Module &M) { |
1399 | 1402 | initializeOutlinerMode(M); |
1400 | 1403 |
|
1401 | 1404 | MMI = &getAnalysis<MachineModuleInfoWrapperPass>().getMMI(); |
| 1405 | + TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>(); |
1402 | 1406 |
|
1403 | 1407 | // Number to append to the current outlined function. |
1404 | 1408 | unsigned OutlinedFunctionNum = 0; |
|
0 commit comments