LLVM API Documentation
00001 //===-- MachineFunctionPass.cpp -------------------------------------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file contains the definitions of the MachineFunctionPass members. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "llvm/IR/Function.h" 00015 #include "llvm/Analysis/AliasAnalysis.h" 00016 #include "llvm/CodeGen/MachineFunctionAnalysis.h" 00017 #include "llvm/CodeGen/MachineFunctionPass.h" 00018 #include "llvm/CodeGen/Passes.h" 00019 using namespace llvm; 00020 00021 Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, 00022 const std::string &Banner) const { 00023 return createMachineFunctionPrinterPass(O, Banner); 00024 } 00025 00026 bool MachineFunctionPass::runOnFunction(Function &F) { 00027 // Do not codegen any 'available_externally' functions at all, they have 00028 // definitions outside the translation unit. 00029 if (F.hasAvailableExternallyLinkage()) 00030 return false; 00031 00032 MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF(); 00033 return runOnMachineFunction(MF); 00034 } 00035 00036 void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const { 00037 AU.addRequired<MachineFunctionAnalysis>(); 00038 AU.addPreserved<MachineFunctionAnalysis>(); 00039 00040 // MachineFunctionPass preserves all LLVM IR passes, but there's no 00041 // high-level way to express this. Instead, just list a bunch of 00042 // passes explicitly. This does not include setPreservesCFG, 00043 // because CodeGen overloads that to mean preserving the MachineBasicBlock 00044 // CFG in addition to the LLVM IR CFG. 00045 AU.addPreserved<AliasAnalysis>(); 00046 AU.addPreserved("scalar-evolution"); 00047 AU.addPreserved("iv-users"); 00048 AU.addPreserved("memdep"); 00049 AU.addPreserved("live-values"); 00050 AU.addPreserved("domtree"); 00051 AU.addPreserved("domfrontier"); 00052 AU.addPreserved("loops"); 00053 AU.addPreserved("lda"); 00054 AU.addPreserved("stack-protector"); 00055 00056 FunctionPass::getAnalysisUsage(AU); 00057 }