[llvm-exegesis] Fix missing std::move.
[llvm-complete.git] / lib / Analysis / Analysis.cpp
blob49b1bdb2e779610abfaa4b99ea4ea161a93fcb35
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 //===----------------------------------------------------------------------===//
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"
16 #include "llvm/Support/raw_ostream.h"
17 #include <cstring>
19 using namespace llvm;
21 /// initializeAnalysis - Initialize all passes linked into the Analysis library.
22 void llvm::initializeAnalysis(PassRegistry &Registry) {
23 initializeAAEvalLegacyPassPass(Registry);
24 initializeAliasSetPrinterPass(Registry);
25 initializeBasicAAWrapperPassPass(Registry);
26 initializeBlockFrequencyInfoWrapperPassPass(Registry);
27 initializeBranchProbabilityInfoWrapperPassPass(Registry);
28 initializeCallGraphWrapperPassPass(Registry);
29 initializeCallGraphDOTPrinterPass(Registry);
30 initializeCallGraphPrinterLegacyPassPass(Registry);
31 initializeCallGraphViewerPass(Registry);
32 initializeCostModelAnalysisPass(Registry);
33 initializeCFGViewerLegacyPassPass(Registry);
34 initializeCFGPrinterLegacyPassPass(Registry);
35 initializeCFGOnlyViewerLegacyPassPass(Registry);
36 initializeCFGOnlyPrinterLegacyPassPass(Registry);
37 initializeCFLAndersAAWrapperPassPass(Registry);
38 initializeCFLSteensAAWrapperPassPass(Registry);
39 initializeDependenceAnalysisWrapperPassPass(Registry);
40 initializeDelinearizationPass(Registry);
41 initializeDemandedBitsWrapperPassPass(Registry);
42 initializeDominanceFrontierWrapperPassPass(Registry);
43 initializeDomViewerPass(Registry);
44 initializeDomPrinterPass(Registry);
45 initializeDomOnlyViewerPass(Registry);
46 initializePostDomViewerPass(Registry);
47 initializeDomOnlyPrinterPass(Registry);
48 initializePostDomPrinterPass(Registry);
49 initializePostDomOnlyViewerPass(Registry);
50 initializePostDomOnlyPrinterPass(Registry);
51 initializeAAResultsWrapperPassPass(Registry);
52 initializeGlobalsAAWrapperPassPass(Registry);
53 initializeIVUsersWrapperPassPass(Registry);
54 initializeInstCountPass(Registry);
55 initializeIntervalPartitionPass(Registry);
56 initializeLazyBranchProbabilityInfoPassPass(Registry);
57 initializeLazyBlockFrequencyInfoPassPass(Registry);
58 initializeLazyValueInfoWrapperPassPass(Registry);
59 initializeLazyValueInfoPrinterPass(Registry);
60 initializeLegacyDivergenceAnalysisPass(Registry);
61 initializeLintPass(Registry);
62 initializeLoopInfoWrapperPassPass(Registry);
63 initializeMemDepPrinterPass(Registry);
64 initializeMemDerefPrinterPass(Registry);
65 initializeMemoryDependenceWrapperPassPass(Registry);
66 initializeModuleDebugInfoPrinterPass(Registry);
67 initializeModuleSummaryIndexWrapperPassPass(Registry);
68 initializeMustExecutePrinterPass(Registry);
69 initializeObjCARCAAWrapperPassPass(Registry);
70 initializeOptimizationRemarkEmitterWrapperPassPass(Registry);
71 initializePhiValuesWrapperPassPass(Registry);
72 initializePostDominatorTreeWrapperPassPass(Registry);
73 initializeRegionInfoPassPass(Registry);
74 initializeRegionViewerPass(Registry);
75 initializeRegionPrinterPass(Registry);
76 initializeRegionOnlyViewerPass(Registry);
77 initializeRegionOnlyPrinterPass(Registry);
78 initializeSCEVAAWrapperPassPass(Registry);
79 initializeScalarEvolutionWrapperPassPass(Registry);
80 initializeTargetTransformInfoWrapperPassPass(Registry);
81 initializeTypeBasedAAWrapperPassPass(Registry);
82 initializeScopedNoAliasAAWrapperPassPass(Registry);
83 initializeLCSSAVerificationPassPass(Registry);
84 initializeMemorySSAWrapperPassPass(Registry);
85 initializeMemorySSAPrinterLegacyPassPass(Registry);
88 void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
89 initializeAnalysis(*unwrap(R));
92 void LLVMInitializeIPA(LLVMPassRegistryRef R) {
93 initializeAnalysis(*unwrap(R));
96 LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
97 char **OutMessages) {
98 raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
99 std::string Messages;
100 raw_string_ostream MsgsOS(Messages);
102 LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
104 // Duplicate the output to stderr.
105 if (DebugOS && OutMessages)
106 *DebugOS << MsgsOS.str();
108 if (Action == LLVMAbortProcessAction && Result)
109 report_fatal_error("Broken module found, compilation aborted!");
111 if (OutMessages)
112 *OutMessages = strdup(MsgsOS.str().c_str());
114 return Result;
117 LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
118 LLVMBool Result = verifyFunction(
119 *unwrap<Function>(Fn), Action != LLVMReturnStatusAction ? &errs()
120 : nullptr);
122 if (Action == LLVMAbortProcessAction && Result)
123 report_fatal_error("Broken function found, compilation aborted!");
125 return Result;
128 void LLVMViewFunctionCFG(LLVMValueRef Fn) {
129 Function *F = unwrap<Function>(Fn);
130 F->viewCFG();
133 void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
134 Function *F = unwrap<Function>(Fn);
135 F->viewCFGOnly();