LLVM  6.0.0svn
MachineFunctionPass.cpp
Go to the documentation of this file.
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 
19 #include "llvm/Analysis/IVUsers.h"
20 #include "llvm/Analysis/LoopInfo.h"
26 #include "llvm/CodeGen/Passes.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  const std::string &Banner) const {
35  return createMachineFunctionPrinterPass(O, Banner);
36 }
37 
38 bool MachineFunctionPass::runOnFunction(Function &F) {
39  // Do not codegen any 'available_externally' functions at all, they have
40  // definitions outside the translation unit.
42  return false;
43 
44  MachineModuleInfo &MMI = getAnalysis<MachineModuleInfo>();
46 
47  MachineFunctionProperties &MFProps = MF.getProperties();
48 
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  bool RV = runOnMachineFunction(MF);
63 
64  MFProps.set(SetProperties);
65  MFProps.reset(ClearedProperties);
66  return RV;
67 }
68 
72 
73  // MachineFunctionPass preserves all LLVM IR passes, but there's no
74  // high-level way to express this. Instead, just list a bunch of
75  // passes explicitly. This does not include setPreservesCFG,
76  // because CodeGen overloads that to mean preserving the MachineBasicBlock
77  // CFG in addition to the LLVM IR CFG.
89 
91 }
Legacy wrapper pass to provide the GlobalsAAResult object.
Pass interface - Implemented by all &#39;passes&#39;.
Definition: Pass.h:81
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
MachineFunctionProperties & reset(Property P)
This is the interface for a simple mod/ref and alias analysis over globals.
bool hasAvailableExternallyLinkage() const
Definition: GlobalValue.h:403
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Definition: Pass.cpp:67
AnalysisUsage & addRequired()
void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
This is the interface for a SCEV-based alias analysis.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: Pass.cpp:84
#define F(x, y, z)
Definition: MD5.cpp:55
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool verifyRequiredProperties(const MachineFunctionProperties &V) const
Represent the analysis usage information of a pass.
MachineFunction & getOrCreateMachineFunction(const Function &F)
Returns the MachineFunction constructed for the IR function F.
A wrapper analysis pass for the legacy pass manager that exposes a MemoryDepnedenceResults instance...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Legacy wrapper pass to provide the SCEVAAResult object.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
MachineFunctionPass * createMachineFunctionPrinterPass(raw_ostream &OS, const std::string &Banner="")
MachineFunctionPrinter pass - This pass prints out the machine function to the given stream as a debu...
MachineFunctionProperties & set(Property P)
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:218
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
The legacy pass manager&#39;s analysis pass to compute loop information.
Definition: LoopInfo.h:845
This is the interface for LLVM&#39;s primary stateless and local alias analysis.
Legacy analysis pass which computes a DominatorTree.
Definition: Dominators.h:261
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object...
Properties which a MachineFunction may have at a given point in time.
This class contains meta information specific to a module.
Legacy wrapper pass to provide the BasicAAResult object.