[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / llvm / lib / Analysis / Analysis.cpp
blob5461ce07af0b9f4abd4c3aeb714ac6f1cf6d4dd0
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/IR/Module.h"
11 #include "llvm/IR/Verifier.h"
12 #include "llvm/InitializePasses.h"
13 #include "llvm/PassRegistry.h"
14 #include "llvm/Support/raw_ostream.h"
15 #include <cstring>
17 using namespace llvm;
19 /// initializeAnalysis - Initialize all passes linked into the Analysis library.
20 void llvm::initializeAnalysis(PassRegistry &Registry) {
21 initializeAAEvalLegacyPassPass(Registry);
22 initializeBasicAAWrapperPassPass(Registry);
23 initializeBlockFrequencyInfoWrapperPassPass(Registry);
24 initializeBranchProbabilityInfoWrapperPassPass(Registry);
25 initializeCallGraphWrapperPassPass(Registry);
26 initializeCallGraphDOTPrinterPass(Registry);
27 initializeCallGraphPrinterLegacyPassPass(Registry);
28 initializeCallGraphViewerPass(Registry);
29 initializeCostModelAnalysisPass(Registry);
30 initializeCFGViewerLegacyPassPass(Registry);
31 initializeCFGPrinterLegacyPassPass(Registry);
32 initializeCFGOnlyViewerLegacyPassPass(Registry);
33 initializeCFGOnlyPrinterLegacyPassPass(Registry);
34 initializeCycleInfoWrapperPassPass(Registry);
35 initializeDependenceAnalysisWrapperPassPass(Registry);
36 initializeDelinearizationPass(Registry);
37 initializeDominanceFrontierWrapperPassPass(Registry);
38 initializeDomViewerWrapperPassPass(Registry);
39 initializeDomPrinterWrapperPassPass(Registry);
40 initializeDomOnlyViewerWrapperPassPass(Registry);
41 initializePostDomViewerWrapperPassPass(Registry);
42 initializeDomOnlyPrinterWrapperPassPass(Registry);
43 initializePostDomPrinterWrapperPassPass(Registry);
44 initializePostDomOnlyViewerWrapperPassPass(Registry);
45 initializePostDomOnlyPrinterWrapperPassPass(Registry);
46 initializeAAResultsWrapperPassPass(Registry);
47 initializeGlobalsAAWrapperPassPass(Registry);
48 initializeIVUsersWrapperPassPass(Registry);
49 initializeInstCountLegacyPassPass(Registry);
50 initializeIntervalPartitionPass(Registry);
51 initializeIRSimilarityIdentifierWrapperPassPass(Registry);
52 initializeLazyBranchProbabilityInfoPassPass(Registry);
53 initializeLazyBlockFrequencyInfoPassPass(Registry);
54 initializeLazyValueInfoWrapperPassPass(Registry);
55 initializeLazyValueInfoPrinterPass(Registry);
56 initializeLoopInfoWrapperPassPass(Registry);
57 initializeMemoryDependenceWrapperPassPass(Registry);
58 initializeModuleSummaryIndexWrapperPassPass(Registry);
59 initializeOptimizationRemarkEmitterWrapperPassPass(Registry);
60 initializePhiValuesWrapperPassPass(Registry);
61 initializePostDominatorTreeWrapperPassPass(Registry);
62 initializeRegionInfoPassPass(Registry);
63 initializeRegionViewerPass(Registry);
64 initializeRegionPrinterPass(Registry);
65 initializeRegionOnlyViewerPass(Registry);
66 initializeRegionOnlyPrinterPass(Registry);
67 initializeSCEVAAWrapperPassPass(Registry);
68 initializeScalarEvolutionWrapperPassPass(Registry);
69 initializeStackSafetyGlobalInfoWrapperPassPass(Registry);
70 initializeStackSafetyInfoWrapperPassPass(Registry);
71 initializeTargetTransformInfoWrapperPassPass(Registry);
72 initializeTypeBasedAAWrapperPassPass(Registry);
73 initializeScopedNoAliasAAWrapperPassPass(Registry);
74 initializeLCSSAVerificationPassPass(Registry);
75 initializeMemorySSAWrapperPassPass(Registry);
78 LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
79 char **OutMessages) {
80 raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
81 std::string Messages;
82 raw_string_ostream MsgsOS(Messages);
84 LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
86 // Duplicate the output to stderr.
87 if (DebugOS && OutMessages)
88 *DebugOS << MsgsOS.str();
90 if (Action == LLVMAbortProcessAction && Result)
91 report_fatal_error("Broken module found, compilation aborted!");
93 if (OutMessages)
94 *OutMessages = strdup(MsgsOS.str().c_str());
96 return Result;
99 LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
100 LLVMBool Result = verifyFunction(
101 *unwrap<Function>(Fn), Action != LLVMReturnStatusAction ? &errs()
102 : nullptr);
104 if (Action == LLVMAbortProcessAction && Result)
105 report_fatal_error("Broken function found, compilation aborted!");
107 return Result;
110 void LLVMViewFunctionCFG(LLVMValueRef Fn) {
111 Function *F = unwrap<Function>(Fn);
112 F->viewCFG();
115 void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
116 Function *F = unwrap<Function>(Fn);
117 F->viewCFGOnly();