Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 1 | //===-- Analysis.cpp ------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm-c/Analysis.h" |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 11 | #include "llvm/InitializePasses.h" |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 12 | #include "llvm/Analysis/Verifier.h" |
Anton Korobeynikov | ae9f3a3 | 2008-02-20 11:08:44 +0000 | [diff] [blame] | 13 | #include <cstring> |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 14 | |
| 15 | using namespace llvm; |
| 16 | |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 17 | /// initializeAnalysis - Initialize all passes linked into the Analysis library. |
| 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 | initializeCFGViewerPass(Registry); |
| 27 | initializeCFGPrinterPass(Registry); |
| 28 | initializeCFGOnlyViewerPass(Registry); |
| 29 | initializeCFGOnlyPrinterPass(Registry); |
| 30 | initializePrintDbgInfoPass(Registry); |
Cameron Zwarich | 4676599 | 2011-01-18 06:06:27 +0000 | [diff] [blame] | 31 | initializeDominanceFrontierPass(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 32 | initializeDomViewerPass(Registry); |
| 33 | initializeDomPrinterPass(Registry); |
| 34 | initializeDomOnlyViewerPass(Registry); |
| 35 | initializePostDomViewerPass(Registry); |
| 36 | initializeDomOnlyPrinterPass(Registry); |
| 37 | initializePostDomPrinterPass(Registry); |
| 38 | initializePostDomOnlyViewerPass(Registry); |
| 39 | initializePostDomOnlyPrinterPass(Registry); |
| 40 | initializeIVUsersPass(Registry); |
| 41 | initializeInstCountPass(Registry); |
| 42 | initializeIntervalPartitionPass(Registry); |
| 43 | initializeLazyValueInfoPass(Registry); |
| 44 | initializeLibCallAliasAnalysisPass(Registry); |
| 45 | initializeLintPass(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 46 | initializeLoopDependenceAnalysisPass(Registry); |
| 47 | initializeLoopInfoPass(Registry); |
| 48 | initializeMemDepPrinterPass(Registry); |
| 49 | initializeMemoryDependenceAnalysisPass(Registry); |
| 50 | initializeModuleDebugInfoPrinterPass(Registry); |
| 51 | initializePostDominatorTreePass(Registry); |
| 52 | initializePostDominanceFrontierPass(Registry); |
| 53 | initializeProfileEstimatorPassPass(Registry); |
| 54 | initializeNoProfileInfoPass(Registry); |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 55 | initializeNoPathProfileInfoPass(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 56 | initializeProfileInfoAnalysisGroup(Registry); |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 57 | initializePathProfileInfoAnalysisGroup(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 58 | initializeLoaderPassPass(Registry); |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 59 | initializePathProfileLoaderPassPass(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 60 | initializeProfileVerifierPassPass(Registry); |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 61 | initializePathProfileVerifierPass(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 62 | initializeRegionInfoPass(Registry); |
| 63 | initializeRegionViewerPass(Registry); |
| 64 | initializeRegionPrinterPass(Registry); |
| 65 | initializeRegionOnlyViewerPass(Registry); |
| 66 | initializeRegionOnlyPrinterPass(Registry); |
| 67 | initializeScalarEvolutionPass(Registry); |
| 68 | initializeScalarEvolutionAliasAnalysisPass(Registry); |
| 69 | initializeTypeBasedAliasAnalysisPass(Registry); |
| 70 | } |
| 71 | |
| 72 | void LLVMInitializeAnalysis(LLVMPassRegistryRef R) { |
| 73 | initializeAnalysis(*unwrap(R)); |
| 74 | } |
| 75 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 76 | LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, |
| 77 | char **OutMessages) { |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 78 | std::string Messages; |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 79 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 80 | LLVMBool Result = verifyModule(*unwrap(M), |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 81 | static_cast<VerifierFailureAction>(Action), |
| 82 | OutMessages? &Messages : 0); |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 83 | |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 84 | if (OutMessages) |
| 85 | *OutMessages = strdup(Messages.c_str()); |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 86 | |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 87 | return Result; |
| 88 | } |
| 89 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 90 | LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) { |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 91 | return verifyFunction(*unwrap<Function>(Fn), |
| 92 | static_cast<VerifierFailureAction>(Action)); |
| 93 | } |
| 94 | |
Erick Tryzelaar | d6d0185 | 2008-03-31 16:22:09 +0000 | [diff] [blame] | 95 | void LLVMViewFunctionCFG(LLVMValueRef Fn) { |
| 96 | Function *F = unwrap<Function>(Fn); |
| 97 | F->viewCFG(); |
| 98 | } |
| 99 | |
| 100 | void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) { |
| 101 | Function *F = unwrap<Function>(Fn); |
| 102 | F->viewCFGOnly(); |
| 103 | } |