mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
d7c9485243
Summary: This is the first step in also serializing the index out to LLVM assembly. The per-module summary written to bitcode is moved out of the bitcode writer and to a new analysis pass (ModuleSummaryIndexWrapperPass). The pass itself uses a new builder class to compute index, and the builder class is used directly in places where we don't have a pass manager (e.g. llvm-as). Because we are computing summaries outside of the bitcode writer, we no longer can use value ids created by the bitcode writer's ValueEnumerator. This required changing the reference graph edge type to use a new ValueInfo class holding a union between a GUID (combined index) and Value* (permodule index). The Value* are converted to the appropriate value ID during bitcode writing. Also, this enables removal of the BitWriter library's dependence on the Analysis library that was previously required for the summary computation. Reviewers: joker.eph Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D18763 llvm-svn: 265941
127 lines
4.5 KiB
C++
127 lines
4.5 KiB
C++
//===-- 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"
|
|
#include "llvm-c/Initialization.h"
|
|
#include "llvm/IR/Module.h"
|
|
#include "llvm/IR/Verifier.h"
|
|
#include "llvm/InitializePasses.h"
|
|
#include "llvm/PassRegistry.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
#include <cstring>
|
|
|
|
using namespace llvm;
|
|
|
|
/// initializeAnalysis - Initialize all passes linked into the Analysis library.
|
|
void llvm::initializeAnalysis(PassRegistry &Registry) {
|
|
initializeAAEvalLegacyPassPass(Registry);
|
|
initializeAliasSetPrinterPass(Registry);
|
|
initializeBasicAAWrapperPassPass(Registry);
|
|
initializeBlockFrequencyInfoWrapperPassPass(Registry);
|
|
initializeBranchProbabilityInfoWrapperPassPass(Registry);
|
|
initializeCallGraphWrapperPassPass(Registry);
|
|
initializeCallGraphDOTPrinterPass(Registry);
|
|
initializeCallGraphPrinterLegacyPassPass(Registry);
|
|
initializeCallGraphViewerPass(Registry);
|
|
initializeCostModelAnalysisPass(Registry);
|
|
initializeCFGViewerPass(Registry);
|
|
initializeCFGPrinterPass(Registry);
|
|
initializeCFGOnlyViewerPass(Registry);
|
|
initializeCFGOnlyPrinterPass(Registry);
|
|
initializeCFLAAWrapperPassPass(Registry);
|
|
initializeDependenceAnalysisPass(Registry);
|
|
initializeDelinearizationPass(Registry);
|
|
initializeDemandedBitsPass(Registry);
|
|
initializeDivergenceAnalysisPass(Registry);
|
|
initializeDominanceFrontierWrapperPassPass(Registry);
|
|
initializeDomViewerPass(Registry);
|
|
initializeDomPrinterPass(Registry);
|
|
initializeDomOnlyViewerPass(Registry);
|
|
initializePostDomViewerPass(Registry);
|
|
initializeDomOnlyPrinterPass(Registry);
|
|
initializePostDomPrinterPass(Registry);
|
|
initializePostDomOnlyViewerPass(Registry);
|
|
initializePostDomOnlyPrinterPass(Registry);
|
|
initializeAAResultsWrapperPassPass(Registry);
|
|
initializeGlobalsAAWrapperPassPass(Registry);
|
|
initializeIVUsersPass(Registry);
|
|
initializeInstCountPass(Registry);
|
|
initializeIntervalPartitionPass(Registry);
|
|
initializeLazyValueInfoPass(Registry);
|
|
initializeLintPass(Registry);
|
|
initializeLoopInfoWrapperPassPass(Registry);
|
|
initializeMemDepPrinterPass(Registry);
|
|
initializeMemDerefPrinterPass(Registry);
|
|
initializeMemoryDependenceWrapperPassPass(Registry);
|
|
initializeModuleDebugInfoPrinterPass(Registry);
|
|
initializeModuleSummaryIndexWrapperPassPass(Registry);
|
|
initializeObjCARCAAWrapperPassPass(Registry);
|
|
initializePostDominatorTreeWrapperPassPass(Registry);
|
|
initializeRegionInfoPassPass(Registry);
|
|
initializeRegionViewerPass(Registry);
|
|
initializeRegionPrinterPass(Registry);
|
|
initializeRegionOnlyViewerPass(Registry);
|
|
initializeRegionOnlyPrinterPass(Registry);
|
|
initializeSCEVAAWrapperPassPass(Registry);
|
|
initializeScalarEvolutionWrapperPassPass(Registry);
|
|
initializeTargetTransformInfoWrapperPassPass(Registry);
|
|
initializeTypeBasedAAWrapperPassPass(Registry);
|
|
initializeScopedNoAliasAAWrapperPassPass(Registry);
|
|
}
|
|
|
|
void LLVMInitializeAnalysis(LLVMPassRegistryRef R) {
|
|
initializeAnalysis(*unwrap(R));
|
|
}
|
|
|
|
void LLVMInitializeIPA(LLVMPassRegistryRef R) {
|
|
initializeAnalysis(*unwrap(R));
|
|
}
|
|
|
|
LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
|
|
char **OutMessages) {
|
|
raw_ostream *DebugOS = Action != LLVMReturnStatusAction ? &errs() : nullptr;
|
|
std::string Messages;
|
|
raw_string_ostream MsgsOS(Messages);
|
|
|
|
LLVMBool Result = verifyModule(*unwrap(M), OutMessages ? &MsgsOS : DebugOS);
|
|
|
|
// Duplicate the output to stderr.
|
|
if (DebugOS && OutMessages)
|
|
*DebugOS << MsgsOS.str();
|
|
|
|
if (Action == LLVMAbortProcessAction && Result)
|
|
report_fatal_error("Broken module found, compilation aborted!");
|
|
|
|
if (OutMessages)
|
|
*OutMessages = strdup(MsgsOS.str().c_str());
|
|
|
|
return Result;
|
|
}
|
|
|
|
LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
|
|
LLVMBool Result = verifyFunction(
|
|
*unwrap<Function>(Fn), Action != LLVMReturnStatusAction ? &errs()
|
|
: nullptr);
|
|
|
|
if (Action == LLVMAbortProcessAction && Result)
|
|
report_fatal_error("Broken function found, compilation aborted!");
|
|
|
|
return Result;
|
|
}
|
|
|
|
void LLVMViewFunctionCFG(LLVMValueRef Fn) {
|
|
Function *F = unwrap<Function>(Fn);
|
|
F->viewCFG();
|
|
}
|
|
|
|
void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
|
|
Function *F = unwrap<Function>(Fn);
|
|
F->viewCFGOnly();
|
|
}
|