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" |
Benjamin Kramer | 613d13b | 2011-08-19 01:36:54 +0000 | [diff] [blame] | 11 | #include "llvm-c/Initialization.h" |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 12 | #include "llvm/Analysis/Verifier.h" |
Chandler Carruth | d04a8d4 | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 13 | #include "llvm/InitializePasses.h" |
Filip Pizlo | 40be1e8 | 2013-05-01 20:59:00 +0000 | [diff] [blame] | 14 | #include "llvm/IR/Module.h" |
| 15 | #include "llvm/PassRegistry.h" |
Anton Korobeynikov | ae9f3a3 | 2008-02-20 11:08:44 +0000 | [diff] [blame] | 16 | #include <cstring> |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace llvm; |
| 19 | |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 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); |
Jakub Staszak | f55c1c8 | 2011-07-25 19:25:40 +0000 | [diff] [blame] | 29 | initializeBlockFrequencyInfoPass(Registry); |
Andrew Trick | 9e76422 | 2011-06-04 01:16:30 +0000 | [diff] [blame] | 30 | initializeBranchProbabilityInfoPass(Registry); |
Nadav Rotem | 6bed58e | 2012-11-02 21:48:17 +0000 | [diff] [blame] | 31 | initializeCostModelAnalysisPass(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 32 | initializeCFGViewerPass(Registry); |
| 33 | initializeCFGPrinterPass(Registry); |
| 34 | initializeCFGOnlyViewerPass(Registry); |
| 35 | initializeCFGOnlyPrinterPass(Registry); |
Sebastian Pop | ad43499 | 2012-10-11 07:32:34 +0000 | [diff] [blame] | 36 | initializeDependenceAnalysisPass(Registry); |
Cameron Zwarich | 4676599 | 2011-01-18 06:06:27 +0000 | [diff] [blame] | 37 | initializeDominanceFrontierPass(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 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); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 52 | initializeLoopInfoPass(Registry); |
| 53 | initializeMemDepPrinterPass(Registry); |
| 54 | initializeMemoryDependenceAnalysisPass(Registry); |
| 55 | initializeModuleDebugInfoPrinterPass(Registry); |
| 56 | initializePostDominatorTreePass(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 57 | initializeRegionInfoPass(Registry); |
| 58 | initializeRegionViewerPass(Registry); |
| 59 | initializeRegionPrinterPass(Registry); |
| 60 | initializeRegionOnlyViewerPass(Registry); |
| 61 | initializeRegionOnlyPrinterPass(Registry); |
| 62 | initializeScalarEvolutionPass(Registry); |
| 63 | initializeScalarEvolutionAliasAnalysisPass(Registry); |
Chandler Carruth | 6554666 | 2013-01-07 03:33:08 +0000 | [diff] [blame] | 64 | initializeTargetTransformInfoAnalysisGroup(Registry); |
Owen Anderson | 861f4c3 | 2010-10-07 18:31:00 +0000 | [diff] [blame] | 65 | initializeTypeBasedAliasAnalysisPass(Registry); |
| 66 | } |
| 67 | |
| 68 | void LLVMInitializeAnalysis(LLVMPassRegistryRef R) { |
| 69 | initializeAnalysis(*unwrap(R)); |
| 70 | } |
| 71 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 72 | LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, |
| 73 | char **OutMessages) { |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 74 | std::string Messages; |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 75 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 76 | LLVMBool Result = verifyModule(*unwrap(M), |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 77 | static_cast<VerifierFailureAction>(Action), |
| 78 | OutMessages? &Messages : 0); |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 79 | |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 80 | if (OutMessages) |
| 81 | *OutMessages = strdup(Messages.c_str()); |
Andrew Trick | 04317cc | 2011-01-29 01:09:53 +0000 | [diff] [blame] | 82 | |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 83 | return Result; |
| 84 | } |
| 85 | |
Chris Lattner | d686c8e | 2010-01-09 22:27:07 +0000 | [diff] [blame] | 86 | LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) { |
Gordon Henriksen | c0491ac | 2007-10-06 21:00:36 +0000 | [diff] [blame] | 87 | return verifyFunction(*unwrap<Function>(Fn), |
| 88 | static_cast<VerifierFailureAction>(Action)); |
| 89 | } |
| 90 | |
Erick Tryzelaar | d6d0185 | 2008-03-31 16:22:09 +0000 | [diff] [blame] | 91 | void LLVMViewFunctionCFG(LLVMValueRef Fn) { |
| 92 | Function *F = unwrap<Function>(Fn); |
| 93 | F->viewCFG(); |
| 94 | } |
| 95 | |
| 96 | void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) { |
| 97 | Function *F = unwrap<Function>(Fn); |
| 98 | F->viewCFGOnly(); |
| 99 | } |