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