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