blob: 05463fc6a1ef798967307629b2b16a4eece40194 [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"
Chandler Carruth7b560d42015-09-09 17:55:00 +000016#include "llvm/Analysis/BasicAliasAnalysis.h"
Chandler Carruthb81dfa62015-01-28 04:57:56 +000017#include "llvm/Analysis/DominanceFrontier.h"
Chandler Carruth7b560d42015-09-09 17:55:00 +000018#include "llvm/Analysis/GlobalsModRef.h"
Chandler Carruthb81dfa62015-01-28 04:57:56 +000019#include "llvm/Analysis/IVUsers.h"
20#include "llvm/Analysis/LoopInfo.h"
Chandler Carruthb81dfa62015-01-28 04:57:56 +000021#include "llvm/Analysis/MemoryDependenceAnalysis.h"
22#include "llvm/Analysis/ScalarEvolution.h"
Chandler Carruth7b560d42015-09-09 17:55:00 +000023#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
Chandler Carruthb81dfa62015-01-28 04:57:56 +000024#include "llvm/CodeGen/MachineFunctionAnalysis.h"
David Greene9b063df2010-04-02 23:17:14 +000025#include "llvm/CodeGen/Passes.h"
Chandler Carruthb81dfa62015-01-28 04:57:56 +000026#include "llvm/CodeGen/StackProtector.h"
27#include "llvm/IR/Dominators.h"
28#include "llvm/IR/Function.h"
Dan Gohman5ea74d52009-07-31 18:16:33 +000029using namespace llvm;
30
David Greene9b063df2010-04-02 23:17:14 +000031Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O,
32 const std::string &Banner) const {
33 return createMachineFunctionPrinterPass(O, Banner);
34}
35
Dan Gohman5ea74d52009-07-31 18:16:33 +000036bool 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
46void 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 Gohman09984272009-10-08 17:00:02 +000052 // 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 Carruth7b560d42015-09-09 17:55:00 +000055 AU.addPreserved<BasicAAWrapperPass>();
Chandler Carruthb81dfa62015-01-28 04:57:56 +000056 AU.addPreserved<DominanceFrontier>();
57 AU.addPreserved<DominatorTreeWrapperPass>();
Chandler Carruth7b560d42015-09-09 17:55:00 +000058 AU.addPreserved<AAResultsWrapperPass>();
59 AU.addPreserved<GlobalsAAWrapperPass>();
Chandler Carruthb81dfa62015-01-28 04:57:56 +000060 AU.addPreserved<IVUsers>();
61 AU.addPreserved<LoopInfoWrapperPass>();
62 AU.addPreserved<MemoryDependenceAnalysis>();
Chandler Carruth2f1fd162015-08-17 02:08:17 +000063 AU.addPreserved<ScalarEvolutionWrapperPass>();
Chandler Carruth7b560d42015-09-09 17:55:00 +000064 AU.addPreserved<SCEVAAWrapperPass>();
Chandler Carruthb81dfa62015-01-28 04:57:56 +000065 AU.addPreserved<StackProtector>();
Dan Gohman5ea74d52009-07-31 18:16:33 +000066
67 FunctionPass::getAnalysisUsage(AU);
68}