[ASan] Make insertion of version mismatch guard configurable
[llvm-core.git] / lib / Analysis / Analysis.cpp
blobaf718526684b8d429d92af465a289d6494609c90
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 //===----------------------------------------------------------------------===//
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"
15 #include "llvm/Support/raw_ostream.h"
16 #include <cstring>
18 using namespace llvm;
20 /// initializeAnalysis - Initialize all passes linked into the Analysis library.
21 void llvm::initializeAnalysis(PassRegistry &Registry) {
22 initializeAAEvalLegacyPassPass(Registry);
23 initializeAliasSetPrinterPass(Registry);
24 initializeBasicAAWrapperPassPass(Registry);
25 initializeBlockFrequencyInfoWrapperPassPass(Registry);
26 initializeBranchProbabilityInfoWrapperPassPass(Registry);
27 initializeCallGraphWrapperPassPass(Registry);
28 initializeCallGraphDOTPrinterPass(Registry);
29 initializeCallGraphPrinterLegacyPassPass(Registry);
30 initializeCallGraphViewerPass(Registry);
31 initializeCostModelAnalysisPass(Registry);
32 initializeCFGViewerLegacyPassPass(Registry);
33 initializeCFGPrinterLegacyPassPass(Registry);
34 initializeCFGOnlyViewerLegacyPassPass(Registry);
35 initializeCFGOnlyPrinterLegacyPassPass(Registry);
36 initializeCFLAndersAAWrapperPassPass(Registry);
37 initializeCFLSteensAAWrapperPassPass(Registry);
38 initializeDependenceAnalysisWrapperPassPass(Registry);
39 initializeDelinearizationPass(Registry);
40 initializeDemandedBitsWrapperPassPass(Registry);
41 initializeDominanceFrontierWrapperPassPass(Registry);
42 initializeDomViewerPass(Registry);
43 initializeDomPrinterPass(Registry);
44 initializeDomOnlyViewerPass(Registry);
45 initializePostDomViewerPass(Registry);
46 initializeDomOnlyPrinterPass(Registry);
47 initializePostDomPrinterPass(Registry);
48 initializePostDomOnlyViewerPass(Registry);
49 initializePostDomOnlyPrinterPass(Registry);
50 initializeAAResultsWrapperPassPass(Registry);
51 initializeGlobalsAAWrapperPassPass(Registry);
52 initializeIVUsersWrapperPassPass(Registry);
53 initializeInstCountPass(Registry);
54 initializeIntervalPartitionPass(Registry);
55 initializeLazyBranchProbabilityInfoPassPass(Registry);
56 initializeLazyBlockFrequencyInfoPassPass(Registry);
57 initializeLazyValueInfoWrapperPassPass(Registry);
58 initializeLazyValueInfoPrinterPass(Registry);
59 initializeLegacyDivergenceAnalysisPass(Registry);
60 initializeLintPass(Registry);
61 initializeLoopInfoWrapperPassPass(Registry);
62 initializeMemDepPrinterPass(Registry);
63 initializeMemDerefPrinterPass(Registry);
64 initializeMemoryDependenceWrapperPassPass(Registry);
65 initializeModuleDebugInfoPrinterPass(Registry);
66 initializeModuleSummaryIndexWrapperPassPass(Registry);
67 initializeMustExecutePrinterPass(Registry);
68 initializeMustBeExecutedContextPrinterPass(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 initializeStackSafetyGlobalInfoWrapperPassPass(Registry);
81 initializeStackSafetyInfoWrapperPassPass(Registry);
82 initializeTargetTransformInfoWrapperPassPass(Registry);
83 initializeTypeBasedAAWrapperPassPass(Registry);
84 initializeScopedNoAliasAAWrapperPassPass(Registry);
85 initializeLCSSAVerificationPassPass(Registry);
86 initializeMemorySSAWrapperPassPass(Registry);
87 initializeMemorySSAPrinterLegacyPassPass(Registry);
90 void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
91 initializeAnalysis(*unwrap(R));
94 void LLVMInitializeIPA(LLVMPassRegistryRef R) {
95 initializeAnalysis(*unwrap(R));
98 LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
99 char **OutMessages) {
100 raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
101 std::string Messages;
102 raw_string_ostream MsgsOS(Messages);
104 LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
106 // Duplicate the output to stderr.
107 if (DebugOS && OutMessages)
108 *DebugOS << MsgsOS.str();
110 if (Action == LLVMAbortProcessAction && Result)
111 report_fatal_error("Broken module found, compilation aborted!");
113 if (OutMessages)
114 *OutMessages = strdup(MsgsOS.str().c_str());
116 return Result;
119 LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
120 LLVMBool Result = verifyFunction(
121 *unwrap<Function>(Fn), Action != LLVMReturnStatusAction ? &errs()
122 : nullptr);
124 if (Action == LLVMAbortProcessAction && Result)
125 report_fatal_error("Broken function found, compilation aborted!");
127 return Result;
130 void LLVMViewFunctionCFG(LLVMValueRef Fn) {
131 Function *F = unwrap<Function>(Fn);
132 F->viewCFG();
135 void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
136 Function *F = unwrap<Function>(Fn);
137 F->viewCFGOnly();