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