Dan Gohman | 5ea74d5 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 1 | //===-- MachineFunctionPass.cpp -------------------------------------------===// |
| 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 contains the definitions of the MachineFunctionPass members. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Dan Gohman | 5ea74d5 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 14 | #include "llvm/CodeGen/MachineFunctionPass.h" |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 15 | #include "llvm/Analysis/AliasAnalysis.h" |
Chandler Carruth | 7b560d4 | 2015-09-09 17:55:00 +0000 | [diff] [blame] | 16 | #include "llvm/Analysis/BasicAliasAnalysis.h" |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 17 | #include "llvm/Analysis/DominanceFrontier.h" |
Chandler Carruth | 7b560d4 | 2015-09-09 17:55:00 +0000 | [diff] [blame] | 18 | #include "llvm/Analysis/GlobalsModRef.h" |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 19 | #include "llvm/Analysis/IVUsers.h" |
| 20 | #include "llvm/Analysis/LoopInfo.h" |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 21 | #include "llvm/Analysis/MemoryDependenceAnalysis.h" |
| 22 | #include "llvm/Analysis/ScalarEvolution.h" |
Chandler Carruth | 7b560d4 | 2015-09-09 17:55:00 +0000 | [diff] [blame] | 23 | #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 24 | #include "llvm/CodeGen/MachineFunctionAnalysis.h" |
David Greene | 9b063df | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 25 | #include "llvm/CodeGen/Passes.h" |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 26 | #include "llvm/CodeGen/StackProtector.h" |
| 27 | #include "llvm/IR/Dominators.h" |
| 28 | #include "llvm/IR/Function.h" |
Dan Gohman | 5ea74d5 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 29 | using namespace llvm; |
| 30 | |
David Greene | 9b063df | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 31 | Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, |
| 32 | const std::string &Banner) const { |
| 33 | return createMachineFunctionPrinterPass(O, Banner); |
| 34 | } |
| 35 | |
Dan Gohman | 5ea74d5 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 36 | bool MachineFunctionPass::runOnFunction(Function &F) { |
| 37 | // Do not codegen any 'available_externally' functions at all, they have |
| 38 | // definitions outside the translation unit. |
| 39 | if (F.hasAvailableExternallyLinkage()) |
| 40 | return false; |
| 41 | |
| 42 | MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF(); |
| 43 | return runOnMachineFunction(MF); |
| 44 | } |
| 45 | |
| 46 | void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const { |
| 47 | AU.addRequired<MachineFunctionAnalysis>(); |
| 48 | AU.addPreserved<MachineFunctionAnalysis>(); |
| 49 | |
| 50 | // MachineFunctionPass preserves all LLVM IR passes, but there's no |
| 51 | // high-level way to express this. Instead, just list a bunch of |
Dan Gohman | 0998427 | 2009-10-08 17:00:02 +0000 | [diff] [blame] | 52 | // passes explicitly. This does not include setPreservesCFG, |
| 53 | // because CodeGen overloads that to mean preserving the MachineBasicBlock |
| 54 | // CFG in addition to the LLVM IR CFG. |
Chandler Carruth | 7b560d4 | 2015-09-09 17:55:00 +0000 | [diff] [blame] | 55 | AU.addPreserved<BasicAAWrapperPass>(); |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 56 | AU.addPreserved<DominanceFrontier>(); |
| 57 | AU.addPreserved<DominatorTreeWrapperPass>(); |
Chandler Carruth | 7b560d4 | 2015-09-09 17:55:00 +0000 | [diff] [blame] | 58 | AU.addPreserved<AAResultsWrapperPass>(); |
| 59 | AU.addPreserved<GlobalsAAWrapperPass>(); |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 60 | AU.addPreserved<IVUsers>(); |
| 61 | AU.addPreserved<LoopInfoWrapperPass>(); |
| 62 | AU.addPreserved<MemoryDependenceAnalysis>(); |
Chandler Carruth | 2f1fd16 | 2015-08-17 02:08:17 +0000 | [diff] [blame] | 63 | AU.addPreserved<ScalarEvolutionWrapperPass>(); |
Chandler Carruth | 7b560d4 | 2015-09-09 17:55:00 +0000 | [diff] [blame] | 64 | AU.addPreserved<SCEVAAWrapperPass>(); |
Chandler Carruth | b81dfa6 | 2015-01-28 04:57:56 +0000 | [diff] [blame] | 65 | AU.addPreserved<StackProtector>(); |
Dan Gohman | 5ea74d5 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 66 | |
| 67 | FunctionPass::getAnalysisUsage(AU); |
| 68 | } |