mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
479a57ca4a
Summary: Implement guard widening in LLVM. Description from GuardWidening.cpp: The semantics of the `@llvm.experimental.guard` intrinsic lets LLVM transform it so that it fails more often that it did before the transform. This optimization is called "widening" and can be used hoist and common runtime checks in situations like these: ``` %cmp0 = 7 u< Length call @llvm.experimental.guard(i1 %cmp0) [ "deopt"(...) ] call @unknown_side_effects() %cmp1 = 9 u< Length call @llvm.experimental.guard(i1 %cmp1) [ "deopt"(...) ] ... ``` to ``` %cmp0 = 9 u< Length call @llvm.experimental.guard(i1 %cmp0) [ "deopt"(...) ] call @unknown_side_effects() ... ``` If `%cmp0` is false, `@llvm.experimental.guard` will "deoptimize" back to a generic implementation of the same function, which will have the correct semantics from that point onward. It is always _legal_ to deoptimize (so replacing `%cmp0` with false is "correct"), though it may not always be profitable to do so. NB! This pass is a work in progress. It hasn't been tuned to be "production ready" yet. It is known to have quadriatic running time and will not scale to large numbers of guards Reviewers: reames, atrick, bogner, apilipenko, nlewycky Subscribers: mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D20143 llvm-svn: 269997
214 lines
9.3 KiB
C++
214 lines
9.3 KiB
C++
//===- llvm/LinkAllPasses.h ------------ Reference All Passes ---*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This header file pulls in all transformation and analysis passes for tools
|
|
// like opt and bugpoint that need this functionality.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LINKALLPASSES_H
|
|
#define LLVM_LINKALLPASSES_H
|
|
|
|
#include "llvm/ADT/Statistic.h"
|
|
#include "llvm/Analysis/AliasSetTracker.h"
|
|
#include "llvm/Analysis/AliasAnalysisEvaluator.h"
|
|
#include "llvm/Analysis/BasicAliasAnalysis.h"
|
|
#include "llvm/Analysis/CFLAliasAnalysis.h"
|
|
#include "llvm/Analysis/CallPrinter.h"
|
|
#include "llvm/Analysis/DomPrinter.h"
|
|
#include "llvm/Analysis/GlobalsModRef.h"
|
|
#include "llvm/Analysis/IntervalPartition.h"
|
|
#include "llvm/Analysis/Lint.h"
|
|
#include "llvm/Analysis/Passes.h"
|
|
#include "llvm/Analysis/PostDominators.h"
|
|
#include "llvm/Analysis/RegionPass.h"
|
|
#include "llvm/Analysis/RegionPrinter.h"
|
|
#include "llvm/Analysis/ScalarEvolution.h"
|
|
#include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h"
|
|
#include "llvm/Analysis/ScopedNoAliasAA.h"
|
|
#include "llvm/Analysis/TargetLibraryInfo.h"
|
|
#include "llvm/Analysis/TypeBasedAliasAnalysis.h"
|
|
#include "llvm/CodeGen/Passes.h"
|
|
#include "llvm/IR/Function.h"
|
|
#include "llvm/IR/IRPrintingPasses.h"
|
|
#include "llvm/Transforms/IPO.h"
|
|
#include "llvm/Transforms/IPO/FunctionAttrs.h"
|
|
#include "llvm/Transforms/Instrumentation.h"
|
|
#include "llvm/Transforms/ObjCARC.h"
|
|
#include "llvm/Transforms/Scalar.h"
|
|
#include "llvm/Transforms/Scalar/GVN.h"
|
|
#include "llvm/Transforms/Utils/SymbolRewriter.h"
|
|
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
|
|
#include "llvm/Transforms/Vectorize.h"
|
|
#include "llvm/Support/Valgrind.h"
|
|
#include <cstdlib>
|
|
|
|
namespace {
|
|
struct ForcePassLinking {
|
|
ForcePassLinking() {
|
|
// We must reference the passes in such a way that compilers will not
|
|
// delete it all as dead code, even with whole program optimization,
|
|
// yet is effectively a NO-OP. As the compiler isn't smart enough
|
|
// to know that getenv() never returns -1, this will do the job.
|
|
if (std::getenv("bar") != (char*) -1)
|
|
return;
|
|
|
|
(void) llvm::createAAEvalPass();
|
|
(void) llvm::createAggressiveDCEPass();
|
|
(void) llvm::createBitTrackingDCEPass();
|
|
(void) llvm::createArgumentPromotionPass();
|
|
(void) llvm::createAlignmentFromAssumptionsPass();
|
|
(void) llvm::createBasicAAWrapperPass();
|
|
(void) llvm::createSCEVAAWrapperPass();
|
|
(void) llvm::createTypeBasedAAWrapperPass();
|
|
(void) llvm::createScopedNoAliasAAWrapperPass();
|
|
(void) llvm::createBoundsCheckingPass();
|
|
(void) llvm::createBreakCriticalEdgesPass();
|
|
(void) llvm::createCallGraphDOTPrinterPass();
|
|
(void) llvm::createCallGraphViewerPass();
|
|
(void) llvm::createCFGSimplificationPass();
|
|
(void) llvm::createCFLAAWrapperPass();
|
|
(void) llvm::createStructurizeCFGPass();
|
|
(void) llvm::createConstantMergePass();
|
|
(void) llvm::createConstantPropagationPass();
|
|
(void) llvm::createCostModelAnalysisPass();
|
|
(void) llvm::createDeadArgEliminationPass();
|
|
(void) llvm::createDeadCodeEliminationPass();
|
|
(void) llvm::createDeadInstEliminationPass();
|
|
(void) llvm::createDeadStoreEliminationPass();
|
|
(void) llvm::createDependenceAnalysisWrapperPass();
|
|
(void) llvm::createDivergenceAnalysisPass();
|
|
(void) llvm::createDomOnlyPrinterPass();
|
|
(void) llvm::createDomPrinterPass();
|
|
(void) llvm::createDomOnlyViewerPass();
|
|
(void) llvm::createDomViewerPass();
|
|
(void) llvm::createGCOVProfilerPass();
|
|
(void) llvm::createPGOInstrumentationGenLegacyPass();
|
|
(void) llvm::createPGOInstrumentationUseLegacyPass();
|
|
(void) llvm::createPGOIndirectCallPromotionLegacyPass();
|
|
(void) llvm::createInstrProfilingLegacyPass();
|
|
(void) llvm::createFunctionImportPass();
|
|
(void) llvm::createFunctionInliningPass();
|
|
(void) llvm::createAlwaysInlinerPass();
|
|
(void) llvm::createGlobalDCEPass();
|
|
(void) llvm::createGlobalOptimizerPass();
|
|
(void) llvm::createGlobalsAAWrapperPass();
|
|
(void) llvm::createGuardWideningPass();
|
|
(void) llvm::createIPConstantPropagationPass();
|
|
(void) llvm::createIPSCCPPass();
|
|
(void) llvm::createInductiveRangeCheckEliminationPass();
|
|
(void) llvm::createIndVarSimplifyPass();
|
|
(void) llvm::createInstructionCombiningPass();
|
|
(void) llvm::createInternalizePass();
|
|
(void) llvm::createLCSSAPass();
|
|
(void) llvm::createLICMPass();
|
|
(void) llvm::createLazyValueInfoPass();
|
|
(void) llvm::createLoopExtractorPass();
|
|
(void) llvm::createLoopInterchangePass();
|
|
(void) llvm::createLoopSimplifyPass();
|
|
(void) llvm::createLoopSimplifyCFGPass();
|
|
(void) llvm::createLoopStrengthReducePass();
|
|
(void) llvm::createLoopRerollPass();
|
|
(void) llvm::createLoopUnrollPass();
|
|
(void) llvm::createLoopUnswitchPass();
|
|
(void) llvm::createLoopVersioningLICMPass();
|
|
(void) llvm::createLoopIdiomPass();
|
|
(void) llvm::createLoopRotatePass();
|
|
(void) llvm::createLowerExpectIntrinsicPass();
|
|
(void) llvm::createLowerInvokePass();
|
|
(void) llvm::createLowerSwitchPass();
|
|
(void) llvm::createNaryReassociatePass();
|
|
(void) llvm::createObjCARCAAWrapperPass();
|
|
(void) llvm::createObjCARCAPElimPass();
|
|
(void) llvm::createObjCARCExpandPass();
|
|
(void) llvm::createObjCARCContractPass();
|
|
(void) llvm::createObjCARCOptPass();
|
|
(void) llvm::createPAEvalPass();
|
|
(void) llvm::createPromoteMemoryToRegisterPass();
|
|
(void) llvm::createDemoteRegisterToMemoryPass();
|
|
(void) llvm::createPruneEHPass();
|
|
(void) llvm::createPostDomOnlyPrinterPass();
|
|
(void) llvm::createPostDomPrinterPass();
|
|
(void) llvm::createPostDomOnlyViewerPass();
|
|
(void) llvm::createPostDomViewerPass();
|
|
(void) llvm::createReassociatePass();
|
|
(void) llvm::createRegionInfoPass();
|
|
(void) llvm::createRegionOnlyPrinterPass();
|
|
(void) llvm::createRegionOnlyViewerPass();
|
|
(void) llvm::createRegionPrinterPass();
|
|
(void) llvm::createRegionViewerPass();
|
|
(void) llvm::createSCCPPass();
|
|
(void) llvm::createSafeStackPass();
|
|
(void) llvm::createScalarReplAggregatesPass();
|
|
(void) llvm::createSingleLoopExtractorPass();
|
|
(void) llvm::createStripSymbolsPass();
|
|
(void) llvm::createStripNonDebugSymbolsPass();
|
|
(void) llvm::createStripDeadDebugInfoPass();
|
|
(void) llvm::createStripDeadPrototypesPass();
|
|
(void) llvm::createTailCallEliminationPass();
|
|
(void) llvm::createJumpThreadingPass();
|
|
(void) llvm::createUnifyFunctionExitNodesPass();
|
|
(void) llvm::createInstCountPass();
|
|
(void) llvm::createConstantHoistingPass();
|
|
(void) llvm::createCodeGenPreparePass();
|
|
(void) llvm::createEarlyCSEPass();
|
|
(void) llvm::createMergedLoadStoreMotionPass();
|
|
(void) llvm::createGVNPass();
|
|
(void) llvm::createMemCpyOptPass();
|
|
(void) llvm::createLoopDeletionPass();
|
|
(void) llvm::createPostDomTree();
|
|
(void) llvm::createInstructionNamerPass();
|
|
(void) llvm::createMetaRenamerPass();
|
|
(void) llvm::createPostOrderFunctionAttrsLegacyPass();
|
|
(void) llvm::createReversePostOrderFunctionAttrsPass();
|
|
(void) llvm::createMergeFunctionsPass();
|
|
std::string buf;
|
|
llvm::raw_string_ostream os(buf);
|
|
(void) llvm::createPrintModulePass(os);
|
|
(void) llvm::createPrintFunctionPass(os);
|
|
(void) llvm::createPrintBasicBlockPass(os);
|
|
(void) llvm::createModuleDebugInfoPrinterPass();
|
|
(void) llvm::createPartialInliningPass();
|
|
(void) llvm::createLintPass();
|
|
(void) llvm::createSinkingPass();
|
|
(void) llvm::createLowerAtomicPass();
|
|
(void) llvm::createCorrelatedValuePropagationPass();
|
|
(void) llvm::createMemDepPrinter();
|
|
(void) llvm::createInstructionSimplifierPass();
|
|
(void) llvm::createLoopVectorizePass();
|
|
(void) llvm::createSLPVectorizerPass();
|
|
(void) llvm::createBBVectorizePass();
|
|
(void) llvm::createPartiallyInlineLibCallsPass();
|
|
(void) llvm::createScalarizerPass();
|
|
(void) llvm::createSeparateConstOffsetFromGEPPass();
|
|
(void) llvm::createSpeculativeExecutionPass();
|
|
(void) llvm::createSpeculativeExecutionIfHasBranchDivergencePass();
|
|
(void) llvm::createRewriteSymbolsPass();
|
|
(void) llvm::createStraightLineStrengthReducePass();
|
|
(void) llvm::createMemDerefPrinter();
|
|
(void) llvm::createFloat2IntPass();
|
|
(void) llvm::createEliminateAvailableExternallyPass();
|
|
|
|
(void)new llvm::IntervalPartition();
|
|
(void)new llvm::ScalarEvolutionWrapperPass();
|
|
llvm::Function::Create(nullptr, llvm::GlobalValue::ExternalLinkage)->viewCFGOnly();
|
|
llvm::RGPassManager RGM;
|
|
llvm::TargetLibraryInfoImpl TLII;
|
|
llvm::TargetLibraryInfo TLI(TLII);
|
|
llvm::AliasAnalysis AA(TLI);
|
|
llvm::AliasSetTracker X(AA);
|
|
X.add(nullptr, 0, llvm::AAMDNodes()); // for -print-alias-sets
|
|
(void) llvm::AreStatisticsEnabled();
|
|
(void) llvm::sys::RunningOnValgrind();
|
|
}
|
|
} ForcePassLinking; // Force link by creating a global definition.
|
|
}
|
|
|
|
#endif
|