mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 00:11:00 +00:00
5b43c8551e
BDCE is a bit-tracking dead code elimination pass. It is based on ADCE (the "aggressive DCE" pass), with the added capability to track dead bits of integer valued instructions and remove those instructions when all of the bits are dead. Currently, it does not actually do this all-bits-dead removal, but rather replaces the instruction's uses with a constant zero, and lets instcombine (and the later run of ADCE) do the rest. Because we essentially get a run of ADCE "for free" while tracking the dead bits, we also do what ADCE does and removes actually-dead instructions as well (this includes instructions newly trivially dead because all bits were dead, but not all such instructions can be removed). The motivation for this is a case like: int __attribute__((const)) foo(int i); int bar(int x) { x |= (4 & foo(5)); x |= (8 & foo(3)); x |= (16 & foo(2)); x |= (32 & foo(1)); x |= (64 & foo(0)); x |= (128& foo(4)); return x >> 4; } As it turns out, if you order the bit-field insertions so that all of the dead ones come last, then instcombine will remove them. However, if you pick some other order (such as the one above), the fact that some of the calls to foo() are useless is not locally obvious, and we don't remove them (without this pass). I did a quick compile-time overhead check using sqlite from the test suite (Release+Asserts). BDCE took ~0.4% of the compilation time (making it about twice as expensive as ADCE). I've not looked at why yet, but we eliminate instructions due to having all-dead bits in: External/SPEC/CFP2006/447.dealII/447.dealII External/SPEC/CINT2006/400.perlbench/400.perlbench External/SPEC/CINT2006/403.gcc/403.gcc MultiSource/Applications/ClamAV/clamscan MultiSource/Benchmarks/7zip/7zip-benchmark git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229462 91177308-0d34-0410-b5e6-96231b3b80d8
186 lines
8.1 KiB
C++
186 lines
8.1 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/Analysis/AliasSetTracker.h"
|
|
#include "llvm/Analysis/CallPrinter.h"
|
|
#include "llvm/Analysis/DomPrinter.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/CodeGen/Passes.h"
|
|
#include "llvm/IR/Function.h"
|
|
#include "llvm/IR/IRPrintingPasses.h"
|
|
#include "llvm/Transforms/IPO.h"
|
|
#include "llvm/Transforms/Instrumentation.h"
|
|
#include "llvm/Transforms/ObjCARC.h"
|
|
#include "llvm/Transforms/Scalar.h"
|
|
#include "llvm/Transforms/Utils/SymbolRewriter.h"
|
|
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
|
|
#include "llvm/Transforms/Vectorize.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::createAliasAnalysisCounterPass();
|
|
(void) llvm::createAliasDebugger();
|
|
(void) llvm::createArgumentPromotionPass();
|
|
(void) llvm::createAlignmentFromAssumptionsPass();
|
|
(void) llvm::createBasicAliasAnalysisPass();
|
|
(void) llvm::createLibCallAliasAnalysisPass(nullptr);
|
|
(void) llvm::createScalarEvolutionAliasAnalysisPass();
|
|
(void) llvm::createTypeBasedAliasAnalysisPass();
|
|
(void) llvm::createScopedNoAliasAAPass();
|
|
(void) llvm::createBoundsCheckingPass();
|
|
(void) llvm::createBreakCriticalEdgesPass();
|
|
(void) llvm::createCallGraphPrinterPass();
|
|
(void) llvm::createCallGraphViewerPass();
|
|
(void) llvm::createCFGSimplificationPass();
|
|
(void) llvm::createCFLAliasAnalysisPass();
|
|
(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::createDependenceAnalysisPass();
|
|
(void) llvm::createDomOnlyPrinterPass();
|
|
(void) llvm::createDomPrinterPass();
|
|
(void) llvm::createDomOnlyViewerPass();
|
|
(void) llvm::createDomViewerPass();
|
|
(void) llvm::createGCOVProfilerPass();
|
|
(void) llvm::createInstrProfilingPass();
|
|
(void) llvm::createFunctionInliningPass();
|
|
(void) llvm::createAlwaysInlinerPass();
|
|
(void) llvm::createGlobalDCEPass();
|
|
(void) llvm::createGlobalOptimizerPass();
|
|
(void) llvm::createGlobalsModRefPass();
|
|
(void) llvm::createIPConstantPropagationPass();
|
|
(void) llvm::createIPSCCPPass();
|
|
(void) llvm::createInductiveRangeCheckEliminationPass();
|
|
(void) llvm::createIndVarSimplifyPass();
|
|
(void) llvm::createInstructionCombiningPass();
|
|
(void) llvm::createInternalizePass();
|
|
(void) llvm::createJumpInstrTableInfoPass();
|
|
(void) llvm::createJumpInstrTablesPass();
|
|
(void) llvm::createLCSSAPass();
|
|
(void) llvm::createLICMPass();
|
|
(void) llvm::createLazyValueInfoPass();
|
|
(void) llvm::createLoopExtractorPass();
|
|
(void) llvm::createLoopSimplifyPass();
|
|
(void) llvm::createLoopStrengthReducePass();
|
|
(void) llvm::createLoopRerollPass();
|
|
(void) llvm::createLoopUnrollPass();
|
|
(void) llvm::createLoopUnswitchPass();
|
|
(void) llvm::createLoopIdiomPass();
|
|
(void) llvm::createLoopRotatePass();
|
|
(void) llvm::createLowerExpectIntrinsicPass();
|
|
(void) llvm::createLowerInvokePass();
|
|
(void) llvm::createLowerSwitchPass();
|
|
(void) llvm::createNoAAPass();
|
|
(void) llvm::createObjCARCAliasAnalysisPass();
|
|
(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::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::createFunctionAttrsPass();
|
|
(void) llvm::createMergeFunctionsPass();
|
|
(void) llvm::createPrintModulePass(*(llvm::raw_ostream*)nullptr);
|
|
(void) llvm::createPrintFunctionPass(*(llvm::raw_ostream*)nullptr);
|
|
(void) llvm::createPrintBasicBlockPass(*(llvm::raw_ostream*)nullptr);
|
|
(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::createRewriteSymbolsPass();
|
|
(void) llvm::createStraightLineStrengthReducePass();
|
|
(void) llvm::createMemDerefPrinter();
|
|
|
|
(void)new llvm::IntervalPartition();
|
|
(void)new llvm::ScalarEvolution();
|
|
((llvm::Function*)nullptr)->viewCFGOnly();
|
|
llvm::RGPassManager RGM;
|
|
((llvm::RegionPass*)nullptr)->runOnRegion((llvm::Region*)nullptr, RGM);
|
|
llvm::AliasSetTracker X(*(llvm::AliasAnalysis*)nullptr);
|
|
X.add(nullptr, 0, llvm::AAMDNodes()); // for -print-alias-sets
|
|
}
|
|
} ForcePassLinking; // Force link by creating a global definition.
|
|
}
|
|
|
|
#endif
|