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/Analysis/Verifier.h" 13 #include "llvm/InitializePasses.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 initializeCostModelAnalysisPass(Registry); 30 initializeCFGViewerPass(Registry); 31 initializeCFGPrinterPass(Registry); 32 initializeCFGOnlyViewerPass(Registry); 33 initializeCFGOnlyPrinterPass(Registry); 34 initializeDependenceAnalysisPass(Registry); 35 initializeDominanceFrontierPass(Registry); 36 initializeDomViewerPass(Registry); 37 initializeDomPrinterPass(Registry); 38 initializeDomOnlyViewerPass(Registry); 39 initializePostDomViewerPass(Registry); 40 initializeDomOnlyPrinterPass(Registry); 41 initializePostDomPrinterPass(Registry); 42 initializePostDomOnlyViewerPass(Registry); 43 initializePostDomOnlyPrinterPass(Registry); 44 initializeIVUsersPass(Registry); 45 initializeInstCountPass(Registry); 46 initializeIntervalPartitionPass(Registry); 47 initializeLazyValueInfoPass(Registry); 48 initializeLibCallAliasAnalysisPass(Registry); 49 initializeLintPass(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 initializeTargetTransformInfoAnalysisGroup(Registry); 73 initializeTypeBasedAliasAnalysisPass(Registry); 74 } 75 LLVMInitializeAnalysis(LLVMPassRegistryRef R)76void LLVMInitializeAnalysis(LLVMPassRegistryRef R) { 77 initializeAnalysis(*unwrap(R)); 78 } 79 LLVMVerifyModule(LLVMModuleRef M,LLVMVerifierFailureAction Action,char ** OutMessages)80LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, 81 char **OutMessages) { 82 std::string Messages; 83 84 LLVMBool Result = verifyModule(*unwrap(M), 85 static_cast<VerifierFailureAction>(Action), 86 OutMessages? &Messages : 0); 87 88 if (OutMessages) 89 *OutMessages = strdup(Messages.c_str()); 90 91 return Result; 92 } 93 LLVMVerifyFunction(LLVMValueRef Fn,LLVMVerifierFailureAction Action)94LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) { 95 return verifyFunction(*unwrap<Function>(Fn), 96 static_cast<VerifierFailureAction>(Action)); 97 } 98 LLVMViewFunctionCFG(LLVMValueRef Fn)99void LLVMViewFunctionCFG(LLVMValueRef Fn) { 100 Function *F = unwrap<Function>(Fn); 101 F->viewCFG(); 102 } 103 LLVMViewFunctionCFGOnly(LLVMValueRef Fn)104void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) { 105 Function *F = unwrap<Function>(Fn); 106 F->viewCFGOnly(); 107 } 108