blob: cc965947bbd980a6ba4cd4aa81c87592cd02edec [file] [log] [blame]
Dan Gohman5ea74d52009-07-31 18:16:33 +00001//===-- 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 Gohman5ea74d52009-07-31 18:16:33 +000014#include "llvm/CodeGen/MachineFunctionPass.h"
Chandler Carruthb81dfa62015-01-28 04:57:56 +000015#include "llvm/Analysis/AliasAnalysis.h"
16#include "llvm/Analysis/DominanceFrontier.h"
17#include "llvm/Analysis/IVUsers.h"
18#include "llvm/Analysis/LoopInfo.h"
Chandler Carruthb81dfa62015-01-28 04:57:56 +000019#include "llvm/Analysis/MemoryDependenceAnalysis.h"
20#include "llvm/Analysis/ScalarEvolution.h"
21#include "llvm/CodeGen/MachineFunctionAnalysis.h"
David Greene9b063df2010-04-02 23:17:14 +000022#include "llvm/CodeGen/Passes.h"
Chandler Carruthb81dfa62015-01-28 04:57:56 +000023#include "llvm/CodeGen/StackProtector.h"
24#include "llvm/IR/Dominators.h"
25#include "llvm/IR/Function.h"
Dan Gohman5ea74d52009-07-31 18:16:33 +000026using namespace llvm;
27
David Greene9b063df2010-04-02 23:17:14 +000028Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O,
29 const std::string &Banner) const {
30 return createMachineFunctionPrinterPass(O, Banner);
31}
32
Dan Gohman5ea74d52009-07-31 18:16:33 +000033bool MachineFunctionPass::runOnFunction(Function &F) {
34 // Do not codegen any 'available_externally' functions at all, they have
35 // definitions outside the translation unit.
36 if (F.hasAvailableExternallyLinkage())
37 return false;
38
39 MachineFunction &MF = getAnalysis<MachineFunctionAnalysis>().getMF();
40 return runOnMachineFunction(MF);
41}
42
43void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const {
44 AU.addRequired<MachineFunctionAnalysis>();
45 AU.addPreserved<MachineFunctionAnalysis>();
46
47 // MachineFunctionPass preserves all LLVM IR passes, but there's no
48 // high-level way to express this. Instead, just list a bunch of
Dan Gohman09984272009-10-08 17:00:02 +000049 // passes explicitly. This does not include setPreservesCFG,
50 // because CodeGen overloads that to mean preserving the MachineBasicBlock
51 // CFG in addition to the LLVM IR CFG.
Dan Gohman5ea74d52009-07-31 18:16:33 +000052 AU.addPreserved<AliasAnalysis>();
Chandler Carruthb81dfa62015-01-28 04:57:56 +000053 AU.addPreserved<DominanceFrontier>();
54 AU.addPreserved<DominatorTreeWrapperPass>();
55 AU.addPreserved<IVUsers>();
56 AU.addPreserved<LoopInfoWrapperPass>();
57 AU.addPreserved<MemoryDependenceAnalysis>();
Chandler Carruth2f1fd162015-08-17 02:08:17 +000058 AU.addPreserved<ScalarEvolutionWrapperPass>();
Chandler Carruthb81dfa62015-01-28 04:57:56 +000059 AU.addPreserved<StackProtector>();
Dan Gohman5ea74d52009-07-31 18:16:33 +000060
61 FunctionPass::getAnalysisUsage(AU);
62}