2009-06-02 17:52:33 +00:00
|
|
|
//===-- Analysis.cpp ------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm-c/Analysis.h"
|
2011-10-20 21:10:27 +00:00
|
|
|
#include "llvm-c/Initialization.h"
|
2013-06-10 20:36:52 +00:00
|
|
|
#include "llvm/IR/Module.h"
|
2014-11-24 09:08:18 +00:00
|
|
|
#include "llvm/IR/Verifier.h"
|
|
|
|
#include "llvm/InitializePasses.h"
|
2013-06-10 20:36:52 +00:00
|
|
|
#include "llvm/PassRegistry.h"
|
2014-11-24 09:08:18 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
2009-06-02 17:52:33 +00:00
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2011-02-20 12:57:14 +00:00
|
|
|
/// initializeAnalysis - Initialize all passes linked into the Analysis library.
|
|
|
|
void llvm::initializeAnalysis(PassRegistry &Registry) {
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeAAEvalLegacyPassPass(Registry);
|
2011-02-20 12:57:14 +00:00
|
|
|
initializeAliasSetPrinterPass(Registry);
|
2015-12-30 11:46:15 +00:00
|
|
|
initializeBasicAAWrapperPassPass(Registry);
|
|
|
|
initializeBlockFrequencyInfoWrapperPassPass(Registry);
|
|
|
|
initializeBranchProbabilityInfoWrapperPassPass(Registry);
|
|
|
|
initializeCallGraphWrapperPassPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeCallGraphDOTPrinterPass(Registry);
|
|
|
|
initializeCallGraphPrinterLegacyPassPass(Registry);
|
2015-12-30 11:46:15 +00:00
|
|
|
initializeCallGraphViewerPass(Registry);
|
2012-12-02 13:10:19 +00:00
|
|
|
initializeCostModelAnalysisPass(Registry);
|
2017-01-02 19:17:04 +00:00
|
|
|
initializeCFGViewerLegacyPassPass(Registry);
|
|
|
|
initializeCFGPrinterLegacyPassPass(Registry);
|
|
|
|
initializeCFGOnlyViewerLegacyPassPass(Registry);
|
|
|
|
initializeCFGOnlyPrinterLegacyPassPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeCFLAndersAAWrapperPassPass(Registry);
|
|
|
|
initializeCFLSteensAAWrapperPassPass(Registry);
|
|
|
|
initializeDependenceAnalysisWrapperPassPass(Registry);
|
2013-12-22 00:04:03 +00:00
|
|
|
initializeDelinearizationPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeDemandedBitsWrapperPassPass(Registry);
|
2015-05-27 18:44:32 +00:00
|
|
|
initializeDivergenceAnalysisPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeDominanceFrontierWrapperPassPass(Registry);
|
2011-02-20 12:57:14 +00:00
|
|
|
initializeDomViewerPass(Registry);
|
|
|
|
initializeDomPrinterPass(Registry);
|
|
|
|
initializeDomOnlyViewerPass(Registry);
|
|
|
|
initializePostDomViewerPass(Registry);
|
|
|
|
initializeDomOnlyPrinterPass(Registry);
|
|
|
|
initializePostDomPrinterPass(Registry);
|
|
|
|
initializePostDomOnlyViewerPass(Registry);
|
|
|
|
initializePostDomOnlyPrinterPass(Registry);
|
2015-12-30 11:46:15 +00:00
|
|
|
initializeAAResultsWrapperPassPass(Registry);
|
|
|
|
initializeGlobalsAAWrapperPassPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeIVUsersWrapperPassPass(Registry);
|
2011-02-20 12:57:14 +00:00
|
|
|
initializeInstCountPass(Registry);
|
|
|
|
initializeIntervalPartitionPass(Registry);
|
2017-01-02 19:17:04 +00:00
|
|
|
initializeLazyBranchProbabilityInfoPassPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeLazyBlockFrequencyInfoPassPass(Registry);
|
|
|
|
initializeLazyValueInfoWrapperPassPass(Registry);
|
2017-04-16 16:01:22 +00:00
|
|
|
initializeLazyValueInfoPrinterPass(Registry);
|
2011-02-20 12:57:14 +00:00
|
|
|
initializeLintPass(Registry);
|
2015-05-27 18:44:32 +00:00
|
|
|
initializeLoopInfoWrapperPassPass(Registry);
|
2011-02-20 12:57:14 +00:00
|
|
|
initializeMemDepPrinterPass(Registry);
|
2015-05-27 18:44:32 +00:00
|
|
|
initializeMemDerefPrinterPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeMemoryDependenceWrapperPassPass(Registry);
|
2011-02-20 12:57:14 +00:00
|
|
|
initializeModuleDebugInfoPrinterPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeModuleSummaryIndexWrapperPassPass(Registry);
|
2015-12-30 11:46:15 +00:00
|
|
|
initializeObjCARCAAWrapperPassPass(Registry);
|
2016-07-23 20:41:05 +00:00
|
|
|
initializeOptimizationRemarkEmitterWrapperPassPass(Registry);
|
|
|
|
initializePostDominatorTreeWrapperPassPass(Registry);
|
2014-11-24 09:08:18 +00:00
|
|
|
initializeRegionInfoPassPass(Registry);
|
2011-02-20 12:57:14 +00:00
|
|
|
initializeRegionViewerPass(Registry);
|
|
|
|
initializeRegionPrinterPass(Registry);
|
|
|
|
initializeRegionOnlyViewerPass(Registry);
|
|
|
|
initializeRegionOnlyPrinterPass(Registry);
|
2015-12-30 11:46:15 +00:00
|
|
|
initializeSCEVAAWrapperPassPass(Registry);
|
|
|
|
initializeScalarEvolutionWrapperPassPass(Registry);
|
2015-05-27 18:44:32 +00:00
|
|
|
initializeTargetTransformInfoWrapperPassPass(Registry);
|
2015-12-30 11:46:15 +00:00
|
|
|
initializeTypeBasedAAWrapperPassPass(Registry);
|
|
|
|
initializeScopedNoAliasAAWrapperPassPass(Registry);
|
2017-01-02 19:17:04 +00:00
|
|
|
initializeLCSSAVerificationPassPass(Registry);
|
2017-04-16 16:01:22 +00:00
|
|
|
initializeMemorySSAWrapperPassPass(Registry);
|
|
|
|
initializeMemorySSAPrinterLegacyPassPass(Registry);
|
2011-02-20 12:57:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
|
|
|
|
initializeAnalysis(*unwrap(R));
|
|
|
|
}
|
|
|
|
|
2015-12-30 11:46:15 +00:00
|
|
|
void LLVMInitializeIPA(LLVMPassRegistryRef R) {
|
|
|
|
initializeAnalysis(*unwrap(R));
|
|
|
|
}
|
|
|
|
|
2010-01-15 15:37:28 +00:00
|
|
|
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
|
|
|
|
char **OutMessages) {
|
2014-11-24 09:08:18 +00:00
|
|
|
raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
|
2009-06-02 17:52:33 +00:00
|
|
|
std::string Messages;
|
2014-11-24 09:08:18 +00:00
|
|
|
raw_string_ostream MsgsOS(Messages);
|
|
|
|
|
|
|
|
LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
|
|
|
|
|
|
|
|
// Duplicate the output to stderr.
|
|
|
|
if (DebugOS && OutMessages)
|
|
|
|
*DebugOS << MsgsOS.str();
|
2011-02-20 12:57:14 +00:00
|
|
|
|
2014-11-24 09:08:18 +00:00
|
|
|
if (Action == LLVMAbortProcessAction && Result)
|
|
|
|
report_fatal_error("Broken module found, compilation aborted!");
|
2011-02-20 12:57:14 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
if (OutMessages)
|
2014-11-24 09:08:18 +00:00
|
|
|
*OutMessages = strdup(MsgsOS.str().c_str());
|
2011-02-20 12:57:14 +00:00
|
|
|
|
2009-06-02 17:52:33 +00:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2010-01-15 15:37:28 +00:00
|
|
|
LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
|
2014-11-24 09:08:18 +00:00
|
|
|
LLVMBool Result = verifyFunction(
|
|
|
|
*unwrap<Function>(Fn), Action != LLVMReturnStatusAction ? &errs()
|
|
|
|
: nullptr);
|
|
|
|
|
|
|
|
if (Action == LLVMAbortProcessAction && Result)
|
|
|
|
report_fatal_error("Broken function found, compilation aborted!");
|
|
|
|
|
|
|
|
return Result;
|
2009-06-02 17:52:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMViewFunctionCFG(LLVMValueRef Fn) {
|
|
|
|
Function *F = unwrap<Function>(Fn);
|
|
|
|
F->viewCFG();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
|
|
|
|
Function *F = unwrap<Function>(Fn);
|
|
|
|
F->viewCFGOnly();
|
|
|
|
}
|