LLVM  14.0.0git
Analysis.cpp
Go to the documentation of this file.
1 //===-- Analysis.cpp ------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm-c/Analysis.h"
10 #include "llvm-c/Initialization.h"
11 #include "llvm/IR/Module.h"
12 #include "llvm/IR/Verifier.h"
13 #include "llvm/InitializePasses.h"
14 #include "llvm/PassRegistry.h"
16 #include <cstring>
17 
18 using namespace llvm;
19 
20 /// initializeAnalysis - Initialize all passes linked into the Analysis library.
89 }
90 
93 }
94 
97 }
98 
100  char **OutMessages) {
101  raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
102  std::string Messages;
103  raw_string_ostream MsgsOS(Messages);
104 
105  LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
106 
107  // Duplicate the output to stderr.
108  if (DebugOS && OutMessages)
109  *DebugOS << MsgsOS.str();
110 
111  if (Action == LLVMAbortProcessAction && Result)
112  report_fatal_error("Broken module found, compilation aborted!");
113 
114  if (OutMessages)
115  *OutMessages = strdup(MsgsOS.str().c_str());
116 
117  return Result;
118 }
119 
121  LLVMBool Result = verifyFunction(
122  *unwrap<Function>(Fn), Action != LLVMReturnStatusAction ? &errs()
123  : nullptr);
124 
125  if (Action == LLVMAbortProcessAction && Result)
126  report_fatal_error("Broken function found, compilation aborted!");
127 
128  return Result;
129 }
130 
132  Function *F = unwrap<Function>(Fn);
133  F->viewCFG();
134 }
135 
137  Function *F = unwrap<Function>(Fn);
138  F->viewCFGOnly();
139 }
llvm::initializeCFLSteensAAWrapperPassPass
void initializeCFLSteensAAWrapperPassPass(PassRegistry &)
llvm::initializeLoopInfoWrapperPassPass
void initializeLoopInfoWrapperPassPass(PassRegistry &)
llvm::initializeRegionOnlyPrinterPass
void initializeRegionOnlyPrinterPass(PassRegistry &)
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::initializeScopedNoAliasAAWrapperPassPass
void initializeScopedNoAliasAAWrapperPassPass(PassRegistry &)
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::initializeDomPrinterPass
void initializeDomPrinterPass(PassRegistry &)
llvm::initializeAnalysis
void initializeAnalysis(PassRegistry &)
Initialize all passes linked into the Analysis library.
Definition: Analysis.cpp:21
llvm::initializeMustExecutePrinterPass
void initializeMustExecutePrinterPass(PassRegistry &)
LLVMPassRegistryRef
struct LLVMOpaquePassRegistry * LLVMPassRegistryRef
Definition: Types.h:130
llvm::Function
Definition: Function.h:61
llvm::initializeDomOnlyPrinterPass
void initializeDomOnlyPrinterPass(PassRegistry &)
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:625
llvm::initializeDominanceFrontierWrapperPassPass
void initializeDominanceFrontierWrapperPassPass(PassRegistry &)
llvm::initializeLazyBranchProbabilityInfoPassPass
void initializeLazyBranchProbabilityInfoPassPass(PassRegistry &)
llvm::initializeBasicAAWrapperPassPass
void initializeBasicAAWrapperPassPass(PassRegistry &)
llvm::initializeTargetTransformInfoWrapperPassPass
void initializeTargetTransformInfoWrapperPassPass(PassRegistry &)
LLVMVerifyFunction
LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action)
Definition: Analysis.cpp:120
llvm::initializeStackSafetyGlobalInfoWrapperPassPass
void initializeStackSafetyGlobalInfoWrapperPassPass(PassRegistry &)
llvm::verifyFunction
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
Definition: Verifier.cpp:5815
Analysis.h
Module.h
llvm::initializePostDomOnlyPrinterPass
void initializePostDomOnlyPrinterPass(PassRegistry &)
llvm::initializeLegacyDivergenceAnalysisPass
void initializeLegacyDivergenceAnalysisPass(PassRegistry &)
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:892
llvm::initializePhiValuesWrapperPassPass
void initializePhiValuesWrapperPassPass(PassRegistry &)
LLVMAbortProcessAction
@ LLVMAbortProcessAction
Definition: Analysis.h:35
llvm::initializeLintLegacyPassPass
void initializeLintLegacyPassPass(PassRegistry &)
llvm::initializeDomOnlyViewerPass
void initializeDomOnlyViewerPass(PassRegistry &)
PassRegistry.h
llvm::initializeCFLAndersAAWrapperPassPass
void initializeCFLAndersAAWrapperPassPass(PassRegistry &)
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::initializeIVUsersWrapperPassPass
void initializeIVUsersWrapperPassPass(PassRegistry &)
llvm::initializeRegionOnlyViewerPass
void initializeRegionOnlyViewerPass(PassRegistry &)
llvm::initializeDelinearizationPass
void initializeDelinearizationPass(PassRegistry &)
llvm::initializeCallGraphViewerPass
void initializeCallGraphViewerPass(PassRegistry &)
llvm::initializeStackSafetyInfoWrapperPassPass
void initializeStackSafetyInfoWrapperPassPass(PassRegistry &)
llvm::initializeCFGViewerLegacyPassPass
void initializeCFGViewerLegacyPassPass(PassRegistry &)
llvm::initializeOptimizationRemarkEmitterWrapperPassPass
void initializeOptimizationRemarkEmitterWrapperPassPass(PassRegistry &)
llvm::initializeMemDerefPrinterPass
void initializeMemDerefPrinterPass(PassRegistry &)
llvm::initializeDomViewerPass
void initializeDomViewerPass(PassRegistry &)
llvm::initializeGlobalsAAWrapperPassPass
void initializeGlobalsAAWrapperPassPass(PassRegistry &)
LLVMInitializeAnalysis
void LLVMInitializeAnalysis(LLVMPassRegistryRef R)
Definition: Analysis.cpp:91
llvm::initializeCFGOnlyPrinterLegacyPassPass
void initializeCFGOnlyPrinterLegacyPassPass(PassRegistry &)
llvm::PassRegistry
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:38
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:256
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
LLVMReturnStatusAction
@ LLVMReturnStatusAction
Definition: Analysis.h:37
llvm::initializeRegionViewerPass
void initializeRegionViewerPass(PassRegistry &)
llvm::initializeMemorySSAPrinterLegacyPassPass
void initializeMemorySSAPrinterLegacyPassPass(PassRegistry &)
llvm::initializeRegionInfoPassPass
void initializeRegionInfoPassPass(PassRegistry &)
llvm::initializeAAEvalLegacyPassPass
void initializeAAEvalLegacyPassPass(PassRegistry &)
llvm::initializeIntervalPartitionPass
void initializeIntervalPartitionPass(PassRegistry &)
llvm::initializeModuleDebugInfoLegacyPrinterPass
void initializeModuleDebugInfoLegacyPrinterPass(PassRegistry &)
llvm::initializeDependenceAnalysisWrapperPassPass
void initializeDependenceAnalysisWrapperPassPass(PassRegistry &)
llvm::initializeMemoryDependenceWrapperPassPass
void initializeMemoryDependenceWrapperPassPass(PassRegistry &)
llvm::initializeObjCARCAAWrapperPassPass
void initializeObjCARCAAWrapperPassPass(PassRegistry &)
llvm::initializePostDomOnlyViewerPass
void initializePostDomOnlyViewerPass(PassRegistry &)
LLVMVerifyModule
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, char **OutMessages)
Definition: Analysis.cpp:99
llvm::initializeCallGraphPrinterLegacyPassPass
void initializeCallGraphPrinterLegacyPassPass(PassRegistry &)
llvm::initializeMustBeExecutedContextPrinterPass
void initializeMustBeExecutedContextPrinterPass(PassRegistry &)
LLVMViewFunctionCFG
void LLVMViewFunctionCFG(LLVMValueRef Fn)
Definition: Analysis.cpp:131
llvm::initializeModuleSummaryIndexWrapperPassPass
void initializeModuleSummaryIndexWrapperPassPass(PassRegistry &)
llvm::initializeCallGraphWrapperPassPass
void initializeCallGraphWrapperPassPass(PassRegistry &)
llvm::initializeIRSimilarityIdentifierWrapperPassPass
void initializeIRSimilarityIdentifierWrapperPassPass(PassRegistry &)
llvm::initializePostDomPrinterPass
void initializePostDomPrinterPass(PassRegistry &)
llvm::initializeLCSSAVerificationPassPass
void initializeLCSSAVerificationPassPass(PassRegistry &)
llvm::initializeTypeBasedAAWrapperPassPass
void initializeTypeBasedAAWrapperPassPass(PassRegistry &)
llvm::initializeAAResultsWrapperPassPass
void initializeAAResultsWrapperPassPass(PassRegistry &)
llvm::initializeRegionPrinterPass
void initializeRegionPrinterPass(PassRegistry &)
llvm::initializeSCEVAAWrapperPassPass
void initializeSCEVAAWrapperPassPass(PassRegistry &)
llvm::initializeCFGOnlyViewerLegacyPassPass
void initializeCFGOnlyViewerLegacyPassPass(PassRegistry &)
llvm::initializeMemDepPrinterPass
void initializeMemDepPrinterPass(PassRegistry &)
llvm::initializeAliasSetPrinterPass
void initializeAliasSetPrinterPass(PassRegistry &)
llvm::initializeInstCountLegacyPassPass
void initializeInstCountLegacyPassPass(PassRegistry &)
Verifier.h
llvm::initializeLazyValueInfoWrapperPassPass
void initializeLazyValueInfoWrapperPassPass(PassRegistry &)
LLVMBool
int LLVMBool
Definition: Types.h:28
llvm::initializePostDomViewerPass
void initializePostDomViewerPass(PassRegistry &)
llvm::initializePostDominatorTreeWrapperPassPass
void initializePostDominatorTreeWrapperPassPass(PassRegistry &)
llvm::initializeLazyBlockFrequencyInfoPassPass
void initializeLazyBlockFrequencyInfoPassPass(PassRegistry &)
llvm::initializeLazyValueInfoPrinterPass
void initializeLazyValueInfoPrinterPass(PassRegistry &)
LLVMVerifierFailureAction
LLVMVerifierFailureAction
Definition: Analysis.h:34
llvm::Registry
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:44
llvm::initializeCallGraphDOTPrinterPass
void initializeCallGraphDOTPrinterPass(PassRegistry &)
llvm::initializeBranchProbabilityInfoWrapperPassPass
void initializeBranchProbabilityInfoWrapperPassPass(PassRegistry &)
llvm::initializeMemorySSAWrapperPassPass
void initializeMemorySSAWrapperPassPass(PassRegistry &)
llvm::initializeDemandedBitsWrapperPassPass
void initializeDemandedBitsWrapperPassPass(PassRegistry &)
LLVMViewFunctionCFGOnly
void LLVMViewFunctionCFGOnly(LLVMValueRef Fn)
Definition: Analysis.cpp:136
llvm::initializeCFGPrinterLegacyPassPass
void initializeCFGPrinterLegacyPassPass(PassRegistry &)
LLVMValueRef
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Types.h:75
llvm::initializeBlockFrequencyInfoWrapperPassPass
void initializeBlockFrequencyInfoWrapperPassPass(PassRegistry &)
raw_ostream.h
LLVMInitializeIPA
void LLVMInitializeIPA(LLVMPassRegistryRef R)
Definition: Analysis.cpp:95
llvm::raw_string_ostream::str
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
Definition: raw_ostream.h:643
llvm::initializeCostModelAnalysisPass
void initializeCostModelAnalysisPass(PassRegistry &)
InitializePasses.h
llvm::initializeScalarEvolutionWrapperPassPass
void initializeScalarEvolutionWrapperPassPass(PassRegistry &)
llvm::verifyModule
bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
Definition: Verifier.cpp:5826
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61
Initialization.h