llvm/lib/Analysis
David Majnemer 2dacece9e2 [IR] Add token types
This introduces the basic functionality to support "token types".
The motivation stems from the need to perform operations on a Value
whose provenance cannot be obscured.

There are several applications for such a type but my immediate
motivation stems from WinEH.  Our personality routine enforces a
single-entry - single-exit regime for cleanups.  After several rounds of
optimizations, we may be left with a terminator whose "cleanup-entry
block" is not entirely clear because control flow has merged two
cleanups together.  We have experimented with using labels as operands
inside of instructions which are not terminators to indicate where we
came from but found that LLVM does not expect such exotic uses of
BasicBlocks.

Instead, we can use this new type to clearly associate the "entry point"
and "exit point" of our cleanup.  This is done by having the cleanuppad
yield a Token and consuming it at the cleanupret.
The token type makes it impossible to obscure or otherwise hide the
Value, making it trivial to track the relationship between the two
points.

What is the burden to the optimizer?  Well, it turns out we have already
paid down this cost by accepting that there are certain calls that we
are not permitted to duplicate, optimizations have to watch out for
such instructions anyway.  There are additional places in the optimizer
that we will probably have to update but early examination has given me
the impression that this will not be heroic.

Differential Revision: http://reviews.llvm.org/D11861

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245029 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-14 05:09:07 +00:00
..
IPA [PM/AA] Extract the interface for GlobalsModRef into a header along with 2015-08-14 03:48:20 +00:00
AliasAnalysis.cpp [PM/AA] Simplify the AliasAnalysis interface by removing a wrapper 2015-08-06 02:05:46 +00:00
AliasAnalysisCounter.cpp [PM/AA] Sink all the actual code from AliasAnalysisCounter back into the 2015-08-14 02:12:12 +00:00
AliasAnalysisEvaluator.cpp [PM/AA] Simplify the AliasAnalysis interface by removing a wrapper 2015-08-06 02:05:46 +00:00
AliasSetTracker.cpp [PM/AA] Simplify the AliasAnalysis interface by removing a wrapper 2015-08-06 02:05:46 +00:00
Analysis.cpp [PM/AA] Remove the AliasDebugger pass. 2015-08-12 22:54:47 +00:00
AssumptionCache.cpp
BasicAliasAnalysis.cpp [PM/AA] Clean up and homogenize comments throughout basic-aa. 2015-08-06 08:17:06 +00:00
BlockFrequencyInfo.cpp Add new constructors for LoopInfo/DominatorTree/BFI/BPI 2015-07-16 23:23:35 +00:00
BlockFrequencyInfoImpl.cpp
BranchProbabilityInfo.cpp Create a wrapper pass for BranchProbabilityInfo. 2015-07-15 22:48:29 +00:00
CaptureTracking.cpp [CaptureTracker] Provide an ordered basic block to PointerMayBeCapturedBefore 2015-07-31 14:31:35 +00:00
CFG.cpp
CFGPrinter.cpp
CFLAliasAnalysis.cpp [PM/AA] Hoist the value handle definition for CFLAA into the header to 2015-08-14 02:50:34 +00:00
CGSCCPassManager.cpp
CMakeLists.txt [PM/AA] Remove the AliasDebugger pass. 2015-08-12 22:54:47 +00:00
CodeMetrics.cpp [IR] Add token types 2015-08-14 05:09:07 +00:00
ConstantFolding.cpp Fix assert when inlining a constantexpr addrspacecast 2015-07-27 18:31:03 +00:00
CostModel.cpp Roll forward r243250 2015-07-26 19:10:03 +00:00
Delinearization.cpp Move delinearization from SCEVAddRecExpr to ScalarEvolution 2015-06-29 14:42:48 +00:00
DependenceAnalysis.cpp [PM/AA] Simplify the AliasAnalysis interface by removing a wrapper 2015-08-06 02:05:46 +00:00
DivergenceAnalysis.cpp Rename inst_range() to instructions() for consistency. NFC 2015-08-06 19:10:45 +00:00
DominanceFrontier.cpp
DomPrinter.cpp
InstCount.cpp
InstructionSimplify.cpp [InstSimplify] Teach InstSimplify how to simplify extractelement 2015-07-13 01:15:53 +00:00
Interval.cpp
IntervalPartition.cpp
IteratedDominanceFrontier.cpp
IVUsers.cpp [LSR] don't attempt to promote ephemeral values to indvars 2015-07-13 03:28:53 +00:00
LazyCallGraph.cpp
LazyValueInfo.cpp -Wdeprecated-clean: Fix cases of violating the rule of 5 in ways that are deprecated in C++11 2015-08-03 22:30:24 +00:00
LibCallAliasAnalysis.cpp [PM/AA] Remove the function names and class names from doxygen comments 2015-08-14 01:43:46 +00:00
LibCallSemantics.cpp
Lint.cpp [PM/AA] Simplify the AliasAnalysis interface by removing a wrapper 2015-08-06 02:05:46 +00:00
LLVMBuild.txt
Loads.cpp [PM/AA] Extract the ModRef enums from the AliasAnalysis class in 2015-07-22 23:15:57 +00:00
LoopAccessAnalysis.cpp [LAA] Change name from addRuntimeCheck to addRuntimeChecks, NFC 2015-08-11 00:09:37 +00:00
LoopInfo.cpp [IR] Add token types 2015-08-14 05:09:07 +00:00
LoopPass.cpp
Makefile
MemDepPrinter.cpp Rename inst_range() to instructions() for consistency. NFC 2015-08-06 19:10:45 +00:00
MemDerefPrinter.cpp Rename inst_range() to instructions() for consistency. NFC 2015-08-06 19:10:45 +00:00
MemoryBuiltins.cpp
MemoryDependenceAnalysis.cpp [PM/AA] Add missing static dependency edges from DSE and memdep to TLI. 2015-08-12 18:10:45 +00:00
MemoryLocation.cpp
ModuleDebugInfoPrinter.cpp
NoAliasAnalysis.cpp [PM/AA] Extract the ModRef enums from the AliasAnalysis class in 2015-07-22 23:15:57 +00:00
OrderedBasicBlock.cpp [CaptureTracker] Provide an ordered basic block to PointerMayBeCapturedBefore 2015-07-31 14:31:35 +00:00
PHITransAddr.cpp [PHITransAddr] Don't assume that instruction operands are translatable 2015-08-09 15:43:02 +00:00
PostDominators.cpp
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp [RegionInfo] Add debug-time region viewer functions 2015-08-10 13:21:59 +00:00
RegionPass.cpp
RegionPrinter.cpp [RegionInfo] Add debug-time region viewer functions 2015-08-10 13:21:59 +00:00
ScalarEvolution.cpp [IndVars] Fix PR24356. 2015-08-06 20:43:41 +00:00
ScalarEvolutionAliasAnalysis.cpp [PM/AA] Clean up the SCEV-AA comment formatting and typos. 2015-08-14 03:14:50 +00:00
ScalarEvolutionExpander.cpp [IndVarSimplify] Make cost estimation in RewriteLoopExitValues smarter 2015-08-10 18:23:58 +00:00
ScalarEvolutionNormalization.cpp
ScopedNoAliasAA.cpp [PM/AA] Hoist ScopedNoAliasAA's interface into a header and move the 2015-08-14 02:55:50 +00:00
SparsePropagation.cpp
StratifiedSets.h
TargetLibraryInfo.cpp
TargetTransformInfo.cpp [TTI] Add a hook for specifying per-target defaults for Interleaved Accesses 2015-08-10 14:50:54 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp [PM/AA] Hoist the interface to TBAA into a dedicated header along with 2015-08-14 03:33:48 +00:00
ValueTracking.cpp [ValueTracking] Tweak a comment slightly 2015-08-12 15:11:43 +00:00
VectorUtils.cpp De-constify pointers to Type since they can't be modified. NFC 2015-08-01 22:20:21 +00:00

Analysis Opportunities:

//===---------------------------------------------------------------------===//

In test/Transforms/LoopStrengthReduce/quadradic-exit-value.ll, the
ScalarEvolution expression for %r is this:

  {1,+,3,+,2}<loop>

Outside the loop, this could be evaluated simply as (%n * %n), however
ScalarEvolution currently evaluates it as

  (-2 + (2 * (trunc i65 (((zext i64 (-2 + %n) to i65) * (zext i64 (-1 + %n) to i65)) /u 2) to i64)) + (3 * %n))

In addition to being much more complicated, it involves i65 arithmetic,
which is very inefficient when expanded into code.

//===---------------------------------------------------------------------===//

In formatValue in test/CodeGen/X86/lsr-delayed-fold.ll,

ScalarEvolution is forming this expression:

((trunc i64 (-1 * %arg5) to i32) + (trunc i64 %arg5 to i32) + (-1 * (trunc i64 undef to i32)))

This could be folded to

(-1 * (trunc i64 undef to i32))

//===---------------------------------------------------------------------===//