2007-10-07 05:00:36 +08:00
|
|
|
//===-- Analysis.cpp ------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-10-07 05:00:36 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm-c/Analysis.h"
|
2011-08-19 09:36:54 +08:00
|
|
|
#include "llvm-c/Initialization.h"
|
2007-10-07 05:00:36 +08:00
|
|
|
#include "llvm/Analysis/Verifier.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/InitializePasses.h"
|
2013-05-02 04:59:00 +08:00
|
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "llvm/PassRegistry.h"
|
2008-02-20 19:08:44 +08:00
|
|
|
#include <cstring>
|
2007-10-07 05:00:36 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2010-10-08 02:31:00 +08:00
|
|
|
/// initializeAnalysis - Initialize all passes linked into the Analysis library.
|
|
|
|
void llvm::initializeAnalysis(PassRegistry &Registry) {
|
|
|
|
initializeAliasAnalysisAnalysisGroup(Registry);
|
|
|
|
initializeAliasAnalysisCounterPass(Registry);
|
|
|
|
initializeAAEvalPass(Registry);
|
|
|
|
initializeAliasDebuggerPass(Registry);
|
|
|
|
initializeAliasSetPrinterPass(Registry);
|
|
|
|
initializeNoAAPass(Registry);
|
|
|
|
initializeBasicAliasAnalysisPass(Registry);
|
2011-07-26 03:25:40 +08:00
|
|
|
initializeBlockFrequencyInfoPass(Registry);
|
2011-06-04 09:16:30 +08:00
|
|
|
initializeBranchProbabilityInfoPass(Registry);
|
2012-11-03 05:48:17 +08:00
|
|
|
initializeCostModelAnalysisPass(Registry);
|
2010-10-08 02:31:00 +08:00
|
|
|
initializeCFGViewerPass(Registry);
|
|
|
|
initializeCFGPrinterPass(Registry);
|
|
|
|
initializeCFGOnlyViewerPass(Registry);
|
|
|
|
initializeCFGOnlyPrinterPass(Registry);
|
dependence analysis
Patch from Preston Briggs <preston.briggs@gmail.com>.
This is an updated version of the dependence-analysis patch, including an MIV
test based on Banerjee's inequalities.
It's a fairly complete implementation of the paper
Practical Dependence Testing
Gina Goff, Ken Kennedy, and Chau-Wen Tseng
PLDI 1991
It cannot yet propagate constraints between coupled RDIV subscripts (discussed
in Section 5.3.2 of the paper).
It's organized as a FunctionPass with a single entry point that supports testing
for dependence between two instructions in a function. If there's no dependence,
it returns null. If there's a dependence, it returns a pointer to a Dependence
which can be queried about details (what kind of dependence, is it loop
independent, direction and distance vector entries, etc). I haven't included
every imaginable feature, but there's a good selection that should be adequate
for supporting many loop transformations. Of course, it can be extended as
necessary.
Included in the patch file are many test cases, commented with C code showing
the loops and array references.
llvm-svn: 165708
2012-10-11 15:32:34 +08:00
|
|
|
initializeDependenceAnalysisPass(Registry);
|
2011-01-18 14:06:27 +08:00
|
|
|
initializeDominanceFrontierPass(Registry);
|
2010-10-08 02:31:00 +08:00
|
|
|
initializeDomViewerPass(Registry);
|
|
|
|
initializeDomPrinterPass(Registry);
|
|
|
|
initializeDomOnlyViewerPass(Registry);
|
|
|
|
initializePostDomViewerPass(Registry);
|
|
|
|
initializeDomOnlyPrinterPass(Registry);
|
|
|
|
initializePostDomPrinterPass(Registry);
|
|
|
|
initializePostDomOnlyViewerPass(Registry);
|
|
|
|
initializePostDomOnlyPrinterPass(Registry);
|
|
|
|
initializeIVUsersPass(Registry);
|
|
|
|
initializeInstCountPass(Registry);
|
|
|
|
initializeIntervalPartitionPass(Registry);
|
|
|
|
initializeLazyValueInfoPass(Registry);
|
|
|
|
initializeLibCallAliasAnalysisPass(Registry);
|
|
|
|
initializeLintPass(Registry);
|
|
|
|
initializeLoopInfoPass(Registry);
|
|
|
|
initializeMemDepPrinterPass(Registry);
|
|
|
|
initializeMemoryDependenceAnalysisPass(Registry);
|
|
|
|
initializeModuleDebugInfoPrinterPass(Registry);
|
|
|
|
initializePostDominatorTreePass(Registry);
|
|
|
|
initializeRegionInfoPass(Registry);
|
|
|
|
initializeRegionViewerPass(Registry);
|
|
|
|
initializeRegionPrinterPass(Registry);
|
|
|
|
initializeRegionOnlyViewerPass(Registry);
|
|
|
|
initializeRegionOnlyPrinterPass(Registry);
|
|
|
|
initializeScalarEvolutionPass(Registry);
|
|
|
|
initializeScalarEvolutionAliasAnalysisPass(Registry);
|
2013-01-07 11:33:08 +08:00
|
|
|
initializeTargetTransformInfoAnalysisGroup(Registry);
|
2010-10-08 02:31:00 +08:00
|
|
|
initializeTypeBasedAliasAnalysisPass(Registry);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
|
|
|
|
initializeAnalysis(*unwrap(R));
|
|
|
|
}
|
|
|
|
|
2010-01-10 06:27:07 +08:00
|
|
|
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
|
|
|
|
char **OutMessages) {
|
2007-10-07 05:00:36 +08:00
|
|
|
std::string Messages;
|
2011-01-29 09:09:53 +08:00
|
|
|
|
2010-01-10 06:27:07 +08:00
|
|
|
LLVMBool Result = verifyModule(*unwrap(M),
|
2007-10-07 05:00:36 +08:00
|
|
|
static_cast<VerifierFailureAction>(Action),
|
|
|
|
OutMessages? &Messages : 0);
|
2011-01-29 09:09:53 +08:00
|
|
|
|
2007-10-07 05:00:36 +08:00
|
|
|
if (OutMessages)
|
|
|
|
*OutMessages = strdup(Messages.c_str());
|
2011-01-29 09:09:53 +08:00
|
|
|
|
2007-10-07 05:00:36 +08:00
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2010-01-10 06:27:07 +08:00
|
|
|
LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
|
2007-10-07 05:00:36 +08:00
|
|
|
return verifyFunction(*unwrap<Function>(Fn),
|
|
|
|
static_cast<VerifierFailureAction>(Action));
|
|
|
|
}
|
|
|
|
|
2008-04-01 00:22:09 +08:00
|
|
|
void LLVMViewFunctionCFG(LLVMValueRef Fn) {
|
|
|
|
Function *F = unwrap<Function>(Fn);
|
|
|
|
F->viewCFG();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
|
|
|
|
Function *F = unwrap<Function>(Fn);
|
|
|
|
F->viewCFGOnly();
|
|
|
|
}
|