1 //===-- Analysis.cpp ------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm-c/Analysis.h"
11 #include "llvm-c/Initialization.h"
12 #include "llvm/IR/Module.h"
13 #include "llvm/IR/Verifier.h"
14 #include "llvm/InitializePasses.h"
15 #include "llvm/PassRegistry.h"
16 #include "llvm/Support/raw_ostream.h"
21 /// initializeAnalysis - Initialize all passes linked into the Analysis library.
22 void llvm::initializeAnalysis(PassRegistry &Registry) {
23 initializeAliasAnalysisAnalysisGroup(Registry);
24 initializeAliasAnalysisCounterPass(Registry);
25 initializeAAEvalPass(Registry);
26 initializeAliasDebuggerPass(Registry);
27 initializeAliasSetPrinterPass(Registry);
28 initializeNoAAPass(Registry);
29 initializeBasicAliasAnalysisPass(Registry);
30 initializeBlockFrequencyInfoPass(Registry);
31 initializeBranchProbabilityInfoPass(Registry);
32 initializeCostModelAnalysisPass(Registry);
33 initializeCFGViewerPass(Registry);
34 initializeCFGPrinterPass(Registry);
35 initializeCFGOnlyViewerPass(Registry);
36 initializeCFGOnlyPrinterPass(Registry);
37 initializeDependenceAnalysisPass(Registry);
38 initializeDelinearizationPass(Registry);
39 initializeDominanceFrontierPass(Registry);
40 initializeDomViewerPass(Registry);
41 initializeDomPrinterPass(Registry);
42 initializeDomOnlyViewerPass(Registry);
43 initializePostDomViewerPass(Registry);
44 initializeDomOnlyPrinterPass(Registry);
45 initializePostDomPrinterPass(Registry);
46 initializePostDomOnlyViewerPass(Registry);
47 initializePostDomOnlyPrinterPass(Registry);
48 initializeIVUsersPass(Registry);
49 initializeInstCountPass(Registry);
50 initializeIntervalPartitionPass(Registry);
51 initializeJumpInstrTableInfoPass(Registry);
52 initializeLazyValueInfoPass(Registry);
53 initializeLibCallAliasAnalysisPass(Registry);
54 initializeLintPass(Registry);
55 initializeLoopInfoPass(Registry);
56 initializeMemDepPrinterPass(Registry);
57 initializeMemoryDependenceAnalysisPass(Registry);
58 initializeModuleDebugInfoPrinterPass(Registry);
59 initializePostDominatorTreePass(Registry);
60 initializeRegionInfoPass(Registry);
61 initializeRegionViewerPass(Registry);
62 initializeRegionPrinterPass(Registry);
63 initializeRegionOnlyViewerPass(Registry);
64 initializeRegionOnlyPrinterPass(Registry);
65 initializeScalarEvolutionPass(Registry);
66 initializeScalarEvolutionAliasAnalysisPass(Registry);
67 initializeTargetTransformInfoAnalysisGroup(Registry);
68 initializeTypeBasedAliasAnalysisPass(Registry);
71 void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
72 initializeAnalysis(*unwrap(R));
75 LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
77 raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
79 raw_string_ostream MsgsOS(Messages);
81 LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
83 // Duplicate the output to stderr.
84 if (DebugOS && OutMessages)
85 *DebugOS << MsgsOS.str();
87 if (Action == LLVMAbortProcessAction && Result)
88 report_fatal_error("Broken module found, compilation aborted!");
91 *OutMessages = strdup(MsgsOS.str().c_str());
96 LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
97 LLVMBool Result = verifyFunction(
98 *unwrap<Function>(Fn), Action != LLVMReturnStatusAction ? &errs()
101 if (Action == LLVMAbortProcessAction && Result)
102 report_fatal_error("Broken function found, compilation aborted!");
107 void LLVMViewFunctionCFG(LLVMValueRef Fn) {
108 Function *F = unwrap<Function>(Fn);
112 void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
113 Function *F = unwrap<Function>(Fn);