Dan Gohman | ad2afc2 | 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 | |
| 14 | #include "llvm/Analysis/AliasAnalysis.h" |
| 15 | #include "llvm/Analysis/ScalarEvolution.h" |
| 16 | #include "llvm/Analysis/IVUsers.h" |
| 17 | #include "llvm/Analysis/LiveValues.h" |
| 18 | #include "llvm/Analysis/LoopDependenceAnalysis.h" |
| 19 | #include "llvm/Analysis/MemoryDependenceAnalysis.h" |
| 20 | #include "llvm/CodeGen/MachineFunctionAnalysis.h" |
| 21 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 22 | using namespace llvm; |
| 23 | |
| 24 | bool MachineFunctionPass::runOnFunction(Function &F) { |
| 25 | // Do not codegen any 'available_externally' functions at all, they have |
| 26 | // definitions outside the translation unit. |
| 27 | if (F.hasAvailableExternallyLinkage()) |
| 28 | return false; |
| 29 | |
| 30 | MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF(); |
| 31 | return runOnMachineFunction(MF); |
| 32 | } |
| 33 | |
| 34 | void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const { |
| 35 | AU.addRequired<MachineFunctionAnalysis>(); |
| 36 | AU.addPreserved<MachineFunctionAnalysis>(); |
| 37 | |
| 38 | // MachineFunctionPass preserves all LLVM IR passes, but there's no |
| 39 | // high-level way to express this. Instead, just list a bunch of |
| 40 | // passes explicitly. |
| 41 | AU.addPreserved<AliasAnalysis>(); |
| 42 | AU.addPreserved<ScalarEvolution>(); |
| 43 | AU.addPreserved<IVUsers>(); |
| 44 | AU.addPreserved<LoopDependenceAnalysis>(); |
| 45 | AU.addPreserved<MemoryDependenceAnalysis>(); |
| 46 | AU.addPreserved<LiveValues>(); |
| 47 | AU.addPreserved<DominatorTree>(); |
| 48 | AU.addPreserved<DominanceFrontier>(); |
| 49 | AU.addPreserved<LoopInfo>(); |
| 50 | |
| 51 | FunctionPass::getAnalysisUsage(AU); |
| 52 | } |