|
10 | 10 | // |
11 | 11 | //===----------------------------------------------------------------------===// |
12 | 12 |
|
| 13 | +#include "llvm/CodeGen/FEntryInserter.h" |
13 | 14 | #include "llvm/CodeGen/MachineFunction.h" |
14 | 15 | #include "llvm/CodeGen/MachineFunctionPass.h" |
15 | 16 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 17 | +#include "llvm/CodeGen/MachinePassManager.h" |
16 | 18 | #include "llvm/CodeGen/TargetInstrInfo.h" |
17 | 19 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
18 | 20 | #include "llvm/IR/Function.h" |
|
21 | 23 | using namespace llvm; |
22 | 24 |
|
23 | 25 | namespace { |
24 | | -struct FEntryInserter : public MachineFunctionPass { |
| 26 | +struct FEntryInserter { |
| 27 | + bool run(MachineFunction &MF); |
| 28 | +}; |
| 29 | + |
| 30 | +struct FEntryInserterLegacy : public MachineFunctionPass { |
25 | 31 | static char ID; // Pass identification, replacement for typeid |
26 | | - FEntryInserter() : MachineFunctionPass(ID) { |
27 | | - initializeFEntryInserterPass(*PassRegistry::getPassRegistry()); |
| 32 | + FEntryInserterLegacy() : MachineFunctionPass(ID) { |
| 33 | + initializeFEntryInserterLegacyPass(*PassRegistry::getPassRegistry()); |
28 | 34 | } |
29 | 35 |
|
30 | | - bool runOnMachineFunction(MachineFunction &F) override; |
| 36 | + bool runOnMachineFunction(MachineFunction &F) override { |
| 37 | + return FEntryInserter().run(F); |
| 38 | + } |
31 | 39 | }; |
32 | 40 | } |
33 | 41 |
|
34 | | -bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) { |
| 42 | +PreservedAnalyses FEntryInserterPass::run(MachineFunction &MF, |
| 43 | + MachineFunctionAnalysisManager &AM) { |
| 44 | + if (!FEntryInserter().run(MF)) |
| 45 | + return PreservedAnalyses::all(); |
| 46 | + return getMachineFunctionPassPreservedAnalyses(); |
| 47 | +} |
| 48 | + |
| 49 | +bool FEntryInserter::run(MachineFunction &MF) { |
35 | 50 | const std::string FEntryName = std::string( |
36 | 51 | MF.getFunction().getFnAttribute("fentry-call").getValueAsString()); |
37 | 52 | if (FEntryName != "true") |
|
0 commit comments