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 16 using namespace llvm; 17 18 /// initializeAnalysis - Initialize all passes linked into the Analysis library. initializeAnalysis(PassRegistry & Registry)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 initializeProfileMetadataLoaderPassPass(Registry); 65 initializeRegionInfoPass(Registry); 66 initializeRegionViewerPass(Registry); 67 initializeRegionPrinterPass(Registry); 68 initializeRegionOnlyViewerPass(Registry); 69 initializeRegionOnlyPrinterPass(Registry); 70 initializeScalarEvolutionPass(Registry); 71 initializeScalarEvolutionAliasAnalysisPass(Registry); 72 initializeTypeBasedAliasAnalysisPass(Registry); 73 } 74 LLVMInitializeAnalysis(LLVMPassRegistryRef R)75void LLVMInitializeAnalysis(LLVMPassRegistryRef R) { 76 initializeAnalysis(*unwrap(R)); 77 } 78 LLVMVerifyModule(LLVMModuleRef M,LLVMVerifierFailureAction Action,char ** OutMessages)79LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, 80 char **OutMessages) { 81 std::string Messages; 82 83 LLVMBool Result = verifyModule(*unwrap(M), 84 static_cast<VerifierFailureAction>(Action), 85 OutMessages? &Messages : 0); 86 87 if (OutMessages) 88 *OutMessages = strdup(Messages.c_str()); 89 90 return Result; 91 } 92 LLVMVerifyFunction(LLVMValueRef Fn,LLVMVerifierFailureAction Action)93LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) { 94 return verifyFunction(*unwrap<Function>(Fn), 95 static_cast<VerifierFailureAction>(Action)); 96 } 97 LLVMViewFunctionCFG(LLVMValueRef Fn)98void LLVMViewFunctionCFG(LLVMValueRef Fn) { 99 Function *F = unwrap<Function>(Fn); 100 F->viewCFG(); 101 } 102 LLVMViewFunctionCFGOnly(LLVMValueRef Fn)103void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) { 104 Function *F = unwrap<Function>(Fn); 105 F->viewCFGOnly(); 106 } 107