LLVM  6.0.0svn
Analysis.cpp
Go to the documentation of this file.
1 //===-- Analysis.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 #include "llvm-c/Analysis.h"
11 #include "llvm-c/Initialization.h"
12 #include "llvm/IR/Module.h"
13 #include "llvm/IR/Verifier.h"
14 #include "llvm/InitializePasses.h"
15 #include "llvm/PassRegistry.h"
17 #include <cstring>
18 
19 using namespace llvm;
20 
21 /// initializeAnalysis - Initialize all passes linked into the Analysis library.
44  initializeDomViewerPass(Registry);
45  initializeDomPrinterPass(Registry);
55  initializeInstCountPass(Registry);
61  initializeLintPass(Registry);
84 }
85 
88 }
89 
92 }
93 
95  char **OutMessages) {
96  raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
97  std::string Messages;
98  raw_string_ostream MsgsOS(Messages);
99 
100  LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
101 
102  // Duplicate the output to stderr.
103  if (DebugOS && OutMessages)
104  *DebugOS << MsgsOS.str();
105 
106  if (Action == LLVMAbortProcessAction && Result)
107  report_fatal_error("Broken module found, compilation aborted!");
108 
109  if (OutMessages)
110  *OutMessages = strdup(MsgsOS.str().c_str());
111 
112  return Result;
113 }
114 
116  LLVMBool Result = verifyFunction(
117  *unwrap<Function>(Fn), Action != LLVMReturnStatusAction ? &errs()
118  : nullptr);
119 
120  if (Action == LLVMAbortProcessAction && Result)
121  report_fatal_error("Broken function found, compilation aborted!");
122 
123  return Result;
124 }
125 
127  Function *F = unwrap<Function>(Fn);
128  F->viewCFG();
129 }
130 
132  Function *F = unwrap<Function>(Fn);
133  F->viewCFGOnly();
134 }
void initializeMemorySSAWrapperPassPass(PassRegistry &)
void initializeDemandedBitsWrapperPassPass(PassRegistry &)
void initializeDomViewerPass(PassRegistry &)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
void initializeMemDepPrinterPass(PassRegistry &)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:115
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:62
void initializeLazyValueInfoWrapperPassPass(PassRegistry &)
void initializeRegionViewerPass(PassRegistry &)
void initializeCostModelAnalysisPass(PassRegistry &)
void initializeRegionPrinterPass(PassRegistry &)
void initializeOptimizationRemarkEmitterWrapperPassPass(PassRegistry &)
void initializeAAEvalLegacyPassPass(PassRegistry &)
void initializeCFLAndersAAWrapperPassPass(PassRegistry &)
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:45
void initializeIVUsersWrapperPassPass(PassRegistry &)
void initializePostDomViewerPass(PassRegistry &)
void initializePostDomOnlyViewerPass(PassRegistry &)
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Types.h:117
F(f)
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry &)
void initializeRegionInfoPassPass(PassRegistry &)
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, char **OutMessages)
Definition: Analysis.cpp:94
void initializeTypeBasedAAWrapperPassPass(PassRegistry &)
void initializeDomOnlyPrinterPass(PassRegistry &)
void initializeBlockFrequencyInfoWrapperPassPass(PassRegistry &)
void initializeCFGOnlyPrinterLegacyPassPass(PassRegistry &)
void LLVMViewFunctionCFG(LLVMValueRef Fn)
Definition: Analysis.cpp:126
void initializeLoopInfoWrapperPassPass(PassRegistry &)
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:195
void initializeInstCountPass(PassRegistry &)
void initializePostDomPrinterPass(PassRegistry &)
void initializeAliasSetPrinterPass(PassRegistry &)
void initializeDependenceAnalysisWrapperPassPass(PassRegistry &)
void LLVMInitializeAnalysis(LLVMPassRegistryRef R)
Definition: Analysis.cpp:86
void initializeAnalysis(PassRegistry &)
Initialize all passes linked into the Analysis library.
Definition: Analysis.cpp:22
LLVMVerifierFailureAction
Definition: Analysis.h:35
void initializeAAResultsWrapperPassPass(PassRegistry &)
void viewCFG() const
viewCFG - This function is meant for use from the debugger.
Definition: CFGPrinter.cpp:164
void initializeScopedNoAliasAAWrapperPassPass(PassRegistry &)
void initializeTargetTransformInfoWrapperPassPass(PassRegistry &)
void initializeDivergenceAnalysisPass(PassRegistry &)
void initializeDelinearizationPass(PassRegistry &)
void initializeModuleDebugInfoPrinterPass(PassRegistry &)
void initializeCallGraphViewerPass(PassRegistry &)
void initializeBranchProbabilityInfoWrapperPassPass(PassRegistry &)
void initializeCallGraphPrinterLegacyPassPass(PassRegistry &)
void viewCFGOnly() const
viewCFGOnly - This function is meant for use from the debugger.
Definition: CFGPrinter.cpp:173
void initializeLazyBranchProbabilityInfoPassPass(PassRegistry &)
void initializeCallGraphWrapperPassPass(PassRegistry &)
void initializePostDominatorTreeWrapperPassPass(PassRegistry &)
void initializeDomOnlyViewerPass(PassRegistry &)
void initializeLazyBlockFrequencyInfoPassPass(PassRegistry &)
void initializeMemDerefPrinterPass(PassRegistry &)
void initializeSCEVAAWrapperPassPass(PassRegistry &)
void initializeCallGraphDOTPrinterPass(PassRegistry &)
int LLVMBool
Definition: Types.h:29
std::string & str()
Flushes the stream contents to the target string and returns the string&#39;s reference.
Definition: raw_ostream.h:478
void initializeGlobalsAAWrapperPassPass(PassRegistry &)
void initializePostDomOnlyPrinterPass(PassRegistry &)
LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action)
Definition: Analysis.cpp:115
void initializeScalarEvolutionWrapperPassPass(PassRegistry &)
void LLVMViewFunctionCFGOnly(LLVMValueRef Fn)
Definition: Analysis.cpp:131
Module.h This file contains the declarations for the Module class.
void initializeDominanceFrontierWrapperPassPass(PassRegistry &)
void initializeLintPass(PassRegistry &)
void initializeIntervalPartitionPass(PassRegistry &)
void initializeObjCARCAAWrapperPassPass(PassRegistry &)
void initializeRegionOnlyViewerPass(PassRegistry &)
void initializeDomPrinterPass(PassRegistry &)
bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
Definition: Verifier.cpp:4638
void initializeCFGViewerLegacyPassPass(PassRegistry &)
void initializeMemorySSAPrinterLegacyPassPass(PassRegistry &)
void initializeCFGPrinterLegacyPassPass(PassRegistry &)
void initializeMemoryDependenceWrapperPassPass(PassRegistry &)
void initializeRegionOnlyPrinterPass(PassRegistry &)
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
Definition: Verifier.cpp:4627
void initializeCFLSteensAAWrapperPassPass(PassRegistry &)
void LLVMInitializeIPA(LLVMPassRegistryRef R)
Definition: Analysis.cpp:90
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:462
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:39
void initializeLCSSAVerificationPassPass(PassRegistry &)
void initializeLazyValueInfoPrinterPass(PassRegistry &)
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Types.h:76
void initializeBasicAAWrapperPassPass(PassRegistry &)
void initializeCFGOnlyViewerLegacyPassPass(PassRegistry &)