2008-03-16 17:32:40 +01:00
|
|
|
/*===-- 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
|
|
|
|
|
2015-12-18 02:46:52 +01:00
|
|
|
#include "llvm-c/Types.h"
|
2008-03-16 17:32:40 +01:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-03-21 04:54:29 +01:00
|
|
|
/**
|
|
|
|
* @defgroup LLVMCTransformsScalar Scalar transformations
|
|
|
|
* @ingroup LLVMCTransforms
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** See llvm::createAggressiveDCEPass function. */
|
|
|
|
void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM);
|
|
|
|
|
[BDCE] Add a bit-tracking DCE pass
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
llvm-svn: 229462
2015-02-17 02:36:59 +01:00
|
|
|
/** See llvm::createBitTrackingDCEPass function. */
|
|
|
|
void LLVMAddBitTrackingDCEPass(LLVMPassManagerRef PM);
|
|
|
|
|
2014-09-07 22:05:11 +02:00
|
|
|
/** See llvm::createAlignmentFromAssumptionsPass function. */
|
|
|
|
void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM);
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** See llvm::createCFGSimplificationPass function. */
|
|
|
|
void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
/** See llvm::createDeadStoreEliminationPass function. */
|
|
|
|
void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM);
|
|
|
|
|
2013-11-22 17:58:05 +01:00
|
|
|
/** See llvm::createScalarizerPass function. */
|
|
|
|
void LLVMAddScalarizerPass(LLVMPassManagerRef PM);
|
|
|
|
|
2014-07-18 21:13:09 +02:00
|
|
|
/** See llvm::createMergedLoadStoreMotionPass function. */
|
|
|
|
void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM);
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** See llvm::createGVNPass function. */
|
|
|
|
void LLVMAddGVNPass(LLVMPassManagerRef PM);
|
|
|
|
|
[GVN] Initial check-in of a new global value numbering algorithm.
The code have been developed by Daniel Berlin over the years, and
the new implementation goal is that of addressing shortcomings of
the current GVN infrastructure, i.e. long compile time for large
testcases, lack of phi predication, no load/store value numbering
etc...
The current code just implements the "core" GVN algorithm, although
other pieces (load coercion, phi handling, predicate system) are
already implemented in a branch out of tree. Once the core is stable,
we'll start adding pieces on top of the base framework.
The test currently living in test/Transform/NewGVN are a copy
of the ones in GVN, with proper `XFAIL` (missing features in NewGVN).
A flag will be added in a future commit to enable NewGVN, so that
interested parties can exercise this code easily.
Differential Revision: https://reviews.llvm.org/D26224
llvm-svn: 290346
2016-12-22 17:03:48 +01:00
|
|
|
/** See llvm::createGVNPass function. */
|
|
|
|
void LLVMAddNewGVNPass(LLVMPassManagerRef PM);
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** See llvm::createIndVarSimplifyPass function. */
|
|
|
|
void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM);
|
2008-03-16 17:32:40 +01:00
|
|
|
|
|
|
|
/** See llvm::createInstructionCombiningPass function. */
|
|
|
|
void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM);
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** See llvm::createJumpThreadingPass function. */
|
|
|
|
void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
/** See llvm::createLICMPass function. */
|
|
|
|
void LLVMAddLICMPass(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
/** See llvm::createLoopDeletionPass function. */
|
|
|
|
void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM);
|
|
|
|
|
2011-04-07 20:20:46 +02:00
|
|
|
/** See llvm::createLoopIdiomPass function */
|
|
|
|
void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM);
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** See llvm::createLoopRotatePass function. */
|
|
|
|
void LLVMAddLoopRotatePass(LLVMPassManagerRef PM);
|
|
|
|
|
2013-11-17 00:59:05 +01:00
|
|
|
/** See llvm::createLoopRerollPass function. */
|
|
|
|
void LLVMAddLoopRerollPass(LLVMPassManagerRef PM);
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** See llvm::createLoopUnrollPass function. */
|
|
|
|
void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
/** See llvm::createLoopUnswitchPass function. */
|
|
|
|
void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
/** See llvm::createMemCpyOptPass function. */
|
|
|
|
void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM);
|
|
|
|
|
2013-08-23 12:27:02 +02:00
|
|
|
/** See llvm::createPartiallyInlineLibCallsPass function. */
|
|
|
|
void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM);
|
|
|
|
|
2014-09-11 23:32:32 +02:00
|
|
|
/** See llvm::createLowerSwitchPass function. */
|
|
|
|
void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM);
|
|
|
|
|
2008-03-20 18:16:03 +01:00
|
|
|
/** See llvm::createPromoteMemoryToRegisterPass function. */
|
|
|
|
void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM);
|
|
|
|
|
2008-03-16 17:32:40 +01:00
|
|
|
/** See llvm::createReassociatePass function. */
|
|
|
|
void LLVMAddReassociatePass(LLVMPassManagerRef PM);
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** See llvm::createSCCPPass function. */
|
|
|
|
void LLVMAddSCCPPass(LLVMPassManagerRef PM);
|
2008-03-16 17:32:40 +01:00
|
|
|
|
2016-06-15 02:19:09 +02:00
|
|
|
/** See llvm::createSROAPass function. */
|
2009-03-06 17:52:18 +01:00
|
|
|
void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM);
|
|
|
|
|
2016-06-15 02:19:09 +02:00
|
|
|
/** See llvm::createSROAPass function. */
|
2011-04-07 20:20:46 +02:00
|
|
|
void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM);
|
|
|
|
|
2016-06-15 02:19:09 +02:00
|
|
|
/** See llvm::createSROAPass function. */
|
2010-03-12 00:06:07 +01:00
|
|
|
void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,
|
|
|
|
int Threshold);
|
|
|
|
|
2009-03-06 17:52:18 +01:00
|
|
|
/** 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);
|
2008-03-16 17:32:40 +01:00
|
|
|
|
2010-03-12 00:06:07 +01:00
|
|
|
/** See llvm::createVerifierPass function. */
|
|
|
|
void LLVMAddVerifierPass(LLVMPassManagerRef PM);
|
|
|
|
|
2011-04-07 20:20:46 +02:00
|
|
|
/** See llvm::createCorrelatedValuePropagationPass function */
|
|
|
|
void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
/** See llvm::createEarlyCSEPass function */
|
2016-09-01 17:07:46 +02:00
|
|
|
void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM);
|
|
|
|
|
|
|
|
/** See llvm::createEarlyCSEPass function */
|
|
|
|
void LLVMAddEarlyCSEMemSSAPass(LLVMPassManagerRef PM);
|
2011-04-07 20:20:46 +02:00
|
|
|
|
2011-07-25 22:57:59 +02:00
|
|
|
/** See llvm::createLowerExpectIntrinsicPass function */
|
|
|
|
void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM);
|
|
|
|
|
2011-04-13 17:44:58 +02:00
|
|
|
/** See llvm::createTypeBasedAliasAnalysisPass function */
|
|
|
|
void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM);
|
|
|
|
|
Add scoped-noalias metadata
This commit adds scoped noalias metadata. The primary motivations for this
feature are:
1. To preserve noalias function attribute information when inlining
2. To provide the ability to model block-scope C99 restrict pointers
Neither of these two abilities are added here, only the necessary
infrastructure. In fact, there should be no change to existing functionality,
only the addition of new features. The logic that converts noalias function
parameters into this metadata during inlining will come in a follow-up commit.
What is added here is the ability to generally specify noalias memory-access
sets. Regarding the metadata, alias-analysis scopes are defined similar to TBAA
nodes:
!scope0 = metadata !{ metadata !"scope of foo()" }
!scope1 = metadata !{ metadata !"scope 1", metadata !scope0 }
!scope2 = metadata !{ metadata !"scope 2", metadata !scope0 }
!scope3 = metadata !{ metadata !"scope 2.1", metadata !scope2 }
!scope4 = metadata !{ metadata !"scope 2.2", metadata !scope2 }
Loads and stores can be tagged with an alias-analysis scope, and also, with a
noalias tag for a specific scope:
... = load %ptr1, !alias.scope !{ !scope1 }
... = load %ptr2, !alias.scope !{ !scope1, !scope2 }, !noalias !{ !scope1 }
When evaluating an aliasing query, if one of the instructions is associated
with an alias.scope id that is identical to the noalias scope associated with
the other instruction, or is a descendant (in the scope hierarchy) of the
noalias scope associated with the other instruction, then the two memory
accesses are assumed not to alias.
Note that is the first element of the scope metadata is a string, then it can
be combined accross functions and translation units. The string can be replaced
by a self-reference to create globally unqiue scope identifiers.
[Note: This overview is slightly stylized, since the metadata nodes really need
to just be numbers (!0 instead of !scope0), and the scope lists are also global
unnamed metadata.]
Existing noalias metadata in a callee is "cloned" for use by the inlined code.
This is necessary because the aliasing scopes are unique to each call site
(because of possible control dependencies on the aliasing properties). For
example, consider a function: foo(noalias a, noalias b) { *a = *b; } that gets
inlined into bar() { ... if (...) foo(a1, b1); ... if (...) foo(a2, b2); } --
now just because we know that a1 does not alias with b1 at the first call site,
and a2 does not alias with b2 at the second call site, we cannot let inlining
these functons have the metadata imply that a1 does not alias with b2.
llvm-svn: 213864
2014-07-24 16:25:39 +02:00
|
|
|
/** See llvm::createScopedNoAliasAAPass function */
|
|
|
|
void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM);
|
|
|
|
|
2011-04-13 17:44:58 +02:00
|
|
|
/** See llvm::createBasicAliasAnalysisPass function */
|
|
|
|
void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM);
|
|
|
|
|
2012-03-21 04:54:29 +01:00
|
|
|
/**
|
|
|
|
* @}
|
|
|
|
*/
|
2011-04-13 17:44:58 +02:00
|
|
|
|
2008-03-16 17:32:40 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* defined(__cplusplus) */
|
|
|
|
|
|
|
|
#endif
|