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 | |
Dan Gohman | 8a261e4 | 2009-10-08 17:00:02 +0000 | [diff] [blame] | 14 | #include "llvm/Function.h" |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 15 | #include "llvm/Analysis/AliasAnalysis.h" |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 16 | #include "llvm/CodeGen/MachineFunctionAnalysis.h" |
| 17 | #include "llvm/CodeGen/MachineFunctionPass.h" |
David Greene | 5c8aa95 | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/Passes.h" |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 19 | using namespace llvm; |
| 20 | |
David Greene | 5c8aa95 | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 21 | Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, |
| 22 | const std::string &Banner) const { |
| 23 | return createMachineFunctionPrinterPass(O, Banner); |
| 24 | } |
| 25 | |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 26 | bool MachineFunctionPass::runOnFunction(Function &F) { |
| 27 | // Do not codegen any 'available_externally' functions at all, they have |
| 28 | // definitions outside the translation unit. |
| 29 | if (F.hasAvailableExternallyLinkage()) |
| 30 | return false; |
| 31 | |
| 32 | MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF(); |
| 33 | return runOnMachineFunction(MF); |
| 34 | } |
| 35 | |
| 36 | void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const { |
| 37 | AU.addRequired<MachineFunctionAnalysis>(); |
| 38 | AU.addPreserved<MachineFunctionAnalysis>(); |
| 39 | |
| 40 | // MachineFunctionPass preserves all LLVM IR passes, but there's no |
| 41 | // high-level way to express this. Instead, just list a bunch of |
Dan Gohman | 8a261e4 | 2009-10-08 17:00:02 +0000 | [diff] [blame] | 42 | // passes explicitly. This does not include setPreservesCFG, |
| 43 | // because CodeGen overloads that to mean preserving the MachineBasicBlock |
| 44 | // CFG in addition to the LLVM IR CFG. |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 45 | AU.addPreserved<AliasAnalysis>(); |
Dan Gohman | 8a261e4 | 2009-10-08 17:00:02 +0000 | [diff] [blame] | 46 | AU.addPreserved("scalar-evolution"); |
| 47 | AU.addPreserved("iv-users"); |
| 48 | AU.addPreserved("memdep"); |
| 49 | AU.addPreserved("live-values"); |
| 50 | AU.addPreserved("domtree"); |
| 51 | AU.addPreserved("domfrontier"); |
| 52 | AU.addPreserved("loops"); |
| 53 | AU.addPreserved("lda"); |
Dan Gohman | ad2afc2 | 2009-07-31 18:16:33 +0000 | [diff] [blame] | 54 | |
| 55 | FunctionPass::getAnalysisUsage(AU); |
| 56 | } |