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/InitializePasses.h"
13#include "llvm/Analysis/Verifier.h"
14#include <cstring>
15
16using namespace llvm;
17
18/// initializeAnalysis - Initialize all passes linked into the Analysis library.
19void llvm::initializeAnalysis(PassRegistry &Registry) {
20  initializeAliasAnalysisAnalysisGroup(Registry);
21  initializeAliasAnalysisCounterPass(Registry);
22  initializeAAEvalPass(Registry);
23  initializeAliasDebuggerPass(Registry);
24  initializeAliasSetPrinterPass(Registry);
25  initializeNoAAPass(Registry);
26  initializeBasicAliasAnalysisPass(Registry);
27  initializeBlockFrequencyInfoPass(Registry);
28  initializeBranchProbabilityInfoPass(Registry);
29  initializeCFGViewerPass(Registry);
30  initializeCFGPrinterPass(Registry);
31  initializeCFGOnlyViewerPass(Registry);
32  initializeCFGOnlyPrinterPass(Registry);
33  initializePrintDbgInfoPass(Registry);
34  initializeDominanceFrontierPass(Registry);
35  initializeDomViewerPass(Registry);
36  initializeDomPrinterPass(Registry);
37  initializeDomOnlyViewerPass(Registry);
38  initializePostDomViewerPass(Registry);
39  initializeDomOnlyPrinterPass(Registry);
40  initializePostDomPrinterPass(Registry);
41  initializePostDomOnlyViewerPass(Registry);
42  initializePostDomOnlyPrinterPass(Registry);
43  initializeIVUsersPass(Registry);
44  initializeInstCountPass(Registry);
45  initializeIntervalPartitionPass(Registry);
46  initializeLazyValueInfoPass(Registry);
47  initializeLibCallAliasAnalysisPass(Registry);
48  initializeLintPass(Registry);
49  initializeLoopDependenceAnalysisPass(Registry);
50  initializeLoopInfoPass(Registry);
51  initializeMemDepPrinterPass(Registry);
52  initializeMemoryDependenceAnalysisPass(Registry);
53  initializeModuleDebugInfoPrinterPass(Registry);
54  initializePostDominatorTreePass(Registry);
55  initializeProfileEstimatorPassPass(Registry);
56  initializeNoProfileInfoPass(Registry);
57  initializeNoPathProfileInfoPass(Registry);
58  initializeProfileInfoAnalysisGroup(Registry);
59  initializePathProfileInfoAnalysisGroup(Registry);
60  initializeLoaderPassPass(Registry);
61  initializePathProfileLoaderPassPass(Registry);
62  initializeProfileVerifierPassPass(Registry);
63  initializePathProfileVerifierPass(Registry);
64  initializeRegionInfoPass(Registry);
65  initializeRegionViewerPass(Registry);
66  initializeRegionPrinterPass(Registry);
67  initializeRegionOnlyViewerPass(Registry);
68  initializeRegionOnlyPrinterPass(Registry);
69  initializeScalarEvolutionPass(Registry);
70  initializeScalarEvolutionAliasAnalysisPass(Registry);
71  initializeTypeBasedAliasAnalysisPass(Registry);
72}
73
74void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
75  initializeAnalysis(*unwrap(R));
76}
77
78LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
79                          char **OutMessages) {
80  std::string Messages;
81
82  LLVMBool Result = verifyModule(*unwrap(M),
83                            static_cast<VerifierFailureAction>(Action),
84                            OutMessages? &Messages : 0);
85
86  if (OutMessages)
87    *OutMessages = strdup(Messages.c_str());
88
89  return Result;
90}
91
92LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
93  return verifyFunction(*unwrap<Function>(Fn),
94                        static_cast<VerifierFailureAction>(Action));
95}
96
97void LLVMViewFunctionCFG(LLVMValueRef Fn) {
98  Function *F = unwrap<Function>(Fn);
99  F->viewCFG();
100}
101
102void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
103  Function *F = unwrap<Function>(Fn);
104  F->viewCFGOnly();
105}
106