mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
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
159 lines
5.8 KiB
C++
159 lines
5.8 KiB
C++
/*===-- Scalar.h - Scalar Transformation Library C Interface ----*- C++ -*-===*\
|
|
|* *|
|
|
|* The LLVM Compiler Infrastructure *|
|
|
|* *|
|
|
|* This file is distributed under the University of Illinois Open Source *|
|
|
|* License. See LICENSE.TXT for details. *|
|
|
|* *|
|
|
|*===----------------------------------------------------------------------===*|
|
|
|* *|
|
|
|* This header declares the C interface to libLLVMScalarOpts.a, which *|
|
|
|* implements various scalar transformations of the LLVM IR. *|
|
|
|* *|
|
|
|* Many exotic languages can interoperate with C code but have a harder time *|
|
|
|* with C++ due to name mangling. So in addition to C, this interface enables *|
|
|
|* tools written in such languages. *|
|
|
|* *|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
#ifndef LLVM_C_TRANSFORMS_SCALAR_H
|
|
#define LLVM_C_TRANSFORMS_SCALAR_H
|
|
|
|
#include "llvm-c/Core.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @defgroup LLVMCTransformsScalar Scalar transformations
|
|
* @ingroup LLVMCTransforms
|
|
*
|
|
* @{
|
|
*/
|
|
|
|
/** See llvm::createAggressiveDCEPass function. */
|
|
void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createBitTrackingDCEPass function. */
|
|
void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createAlignmentFromAssumptionsPass function. */
|
|
void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createCFGSimplificationPass function. */
|
|
void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createDeadStoreEliminationPass function. */
|
|
void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createScalarizerPass function. */
|
|
void LLVMAddScalarizerPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createMergedLoadStoreMotionPass function. */
|
|
void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createGVNPass function. */
|
|
void LLVMAddGVNPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createIndVarSimplifyPass function. */
|
|
void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createInstructionCombiningPass function. */
|
|
void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createJumpThreadingPass function. */
|
|
void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLICMPass function. */
|
|
void LLVMAddLICMPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLoopDeletionPass function. */
|
|
void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLoopIdiomPass function */
|
|
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLoopRotatePass function. */
|
|
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLoopRerollPass function. */
|
|
void LLVMAddLoopRerollPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLoopUnrollPass function. */
|
|
void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLoopUnswitchPass function. */
|
|
void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createMemCpyOptPass function. */
|
|
void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createPartiallyInlineLibCallsPass function. */
|
|
void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLowerSwitchPass function. */
|
|
void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createPromoteMemoryToRegisterPass function. */
|
|
void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createReassociatePass function. */
|
|
void LLVMAddReassociatePass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createSCCPPass function. */
|
|
void LLVMAddSCCPPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createScalarReplAggregatesPass function. */
|
|
void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createScalarReplAggregatesPass function. */
|
|
void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createScalarReplAggregatesPass function. */
|
|
void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
|
|
int Threshold);
|
|
|
|
/** See llvm::createSimplifyLibCallsPass function. */
|
|
void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createTailCallEliminationPass function. */
|
|
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createConstantPropagationPass function. */
|
|
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::demotePromoteMemoryToRegisterPass function. */
|
|
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createVerifierPass function. */
|
|
void LLVMAddVerifierPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createCorrelatedValuePropagationPass function */
|
|
void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createEarlyCSEPass function */
|
|
void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createLowerExpectIntrinsicPass function */
|
|
void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createTypeBasedAliasAnalysisPass function */
|
|
void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createScopedNoAliasAAPass function */
|
|
void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM);
|
|
|
|
/** See llvm::createBasicAliasAnalysisPass function */
|
|
void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM);
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif /* defined(__cplusplus) */
|
|
|
|
#endif
|