/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/CodeGen/MachineFunctionPass.cpp
Line | Count | Source |
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/CodeGen/MachineFunctionPass.h" |
15 | | #include "llvm/Analysis/AliasAnalysis.h" |
16 | | #include "llvm/Analysis/BasicAliasAnalysis.h" |
17 | | #include "llvm/Analysis/DominanceFrontier.h" |
18 | | #include "llvm/Analysis/GlobalsModRef.h" |
19 | | #include "llvm/Analysis/IVUsers.h" |
20 | | #include "llvm/Analysis/LoopInfo.h" |
21 | | #include "llvm/Analysis/MemoryDependenceAnalysis.h" |
22 | | #include "llvm/Analysis/ScalarEvolution.h" |
23 | | #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" |
24 | | #include "llvm/CodeGen/MachineFunction.h" |
25 | | #include "llvm/CodeGen/MachineModuleInfo.h" |
26 | | #include "llvm/CodeGen/Passes.h" |
27 | | #include "llvm/CodeGen/StackProtector.h" |
28 | | #include "llvm/IR/Dominators.h" |
29 | | #include "llvm/IR/Function.h" |
30 | | |
31 | | using namespace llvm; |
32 | | |
33 | | Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, |
34 | 224 | const std::string &Banner) const { |
35 | 224 | return createMachineFunctionPrinterPass(O, Banner); |
36 | 224 | } |
37 | | |
38 | 56.7M | bool MachineFunctionPass::runOnFunction(Function &F) { |
39 | 56.7M | // Do not codegen any 'available_externally' functions at all, they have |
40 | 56.7M | // definitions outside the translation unit. |
41 | 56.7M | if (F.hasAvailableExternallyLinkage()) |
42 | 2.70k | return false; |
43 | 56.7M | |
44 | 56.7M | MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo>(); |
45 | 56.7M | MachineFunction &MF = MMI.getOrCreateMachineFunction(F); |
46 | 56.7M | |
47 | 56.7M | MachineFunctionProperties &MFProps = MF.getProperties(); |
48 | 56.7M | |
49 | | #ifndef NDEBUG |
50 | | if (!MFProps.verifyRequiredProperties(RequiredProperties)) { |
51 | | errs() << "MachineFunctionProperties required by " << getPassName() |
52 | | << " pass are not met by function " << F.getName() << ".\n" |
53 | | << "Required properties: "; |
54 | | RequiredProperties.print(errs()); |
55 | | errs() << "\nCurrent properties: "; |
56 | | MFProps.print(errs()); |
57 | | errs() << "\n"; |
58 | | llvm_unreachable("MachineFunctionProperties check failed"); |
59 | | } |
60 | | #endif |
61 | | |
62 | 56.7M | bool RV = runOnMachineFunction(MF); |
63 | 56.7M | |
64 | 56.7M | MFProps.set(SetProperties); |
65 | 56.7M | MFProps.reset(ClearedProperties); |
66 | 56.7M | return RV; |
67 | 56.7M | } |
68 | | |
69 | 3.13M | void MachineFunctionPass::getAnalysisUsage(AnalysisUsage &AU) const { |
70 | 3.13M | AU.addRequired<MachineModuleInfo>(); |
71 | 3.13M | AU.addPreserved<MachineModuleInfo>(); |
72 | 3.13M | |
73 | 3.13M | // MachineFunctionPass preserves all LLVM IR passes, but there's no |
74 | 3.13M | // high-level way to express this. Instead, just list a bunch of |
75 | 3.13M | // passes explicitly. This does not include setPreservesCFG, |
76 | 3.13M | // because CodeGen overloads that to mean preserving the MachineBasicBlock |
77 | 3.13M | // CFG in addition to the LLVM IR CFG. |
78 | 3.13M | AU.addPreserved<BasicAAWrapperPass>(); |
79 | 3.13M | AU.addPreserved<DominanceFrontierWrapperPass>(); |
80 | 3.13M | AU.addPreserved<DominatorTreeWrapperPass>(); |
81 | 3.13M | AU.addPreserved<AAResultsWrapperPass>(); |
82 | 3.13M | AU.addPreserved<GlobalsAAWrapperPass>(); |
83 | 3.13M | AU.addPreserved<IVUsersWrapperPass>(); |
84 | 3.13M | AU.addPreserved<LoopInfoWrapperPass>(); |
85 | 3.13M | AU.addPreserved<MemoryDependenceWrapperPass>(); |
86 | 3.13M | AU.addPreserved<ScalarEvolutionWrapperPass>(); |
87 | 3.13M | AU.addPreserved<SCEVAAWrapperPass>(); |
88 | 3.13M | AU.addPreserved<StackProtector>(); |
89 | 3.13M | |
90 | 3.13M | FunctionPass::getAnalysisUsage(AU); |
91 | 3.13M | } |