1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 12:02:58 +02:00
llvm-mirror/lib/Analysis
Chandler Carruth e597ed0112 [AA] Hoist the logic to reformulate various AA queries in terms of other
parts of the AA interface out of the base class of every single AA
result object.

Because this logic reformulates the query in terms of some other aspect
of the API, it would easily cause O(n^2) query patterns in alias
analysis. These could in turn be magnified further based on the number
of call arguments, and then further based on the number of AA queries
made for a particular call. This ended up causing problems for Rust that
were actually noticable enough to get a bug (PR26564) and probably other
places as well.

When originally re-working the AA infrastructure, the desire was to
regularize the pattern of refinement without losing any generality.
While I think it was successful, that is clearly proving to be too
costly. And the cost is needless: we gain no actual improvement for this
generality of making a direct query to tbaa actually be able to
re-use some other alias analysis's refinement logic for one of the other
APIs, or some such. In short, this is entirely wasted work.

To the extent possible, delegation to other API surfaces should be done
at the aggregation layer so that we can avoid re-walking the
aggregation. In fact, this significantly simplifies the logic as we no
longer need to smuggle the aggregation layer into each alias analysis
(or the TargetLibraryInfo into each alias analysis just so we can form
argument memory locations!).

However, we also have some delegation logic inside of BasicAA and some
of it even makes sense. When the delegation logic is baking in specific
knowledge of aliasing properties of the LLVM IR, as opposed to simply
reformulating the query to utilize a different alias analysis interface
entry point, it makes a lot of sense to restrict that logic to
a different layer such as BasicAA. So one aspect of the delegation that
was in every AA base class is that when we don't have operand bundles,
we re-use function AA results as a fallback for callsite alias results.
This relies on the IR properties of calls and functions w.r.t. aliasing,
and so seems a better fit to BasicAA. I've lifted the logic up to that
point where it seems to be a natural fit. This still does a bit of
redundant work (we query function attributes twice, once via the
callsite and once via the function AA query) but it is *exactly* twice
here, no more.

The end result is that all of the delegation logic is hoisted out of the
base class and into either the aggregation layer when it is a pure
retargeting to a different API surface, or into BasicAA when it relies
on the IR's aliasing properties. This should fix the quadratic query
pattern reported in PR26564, although I don't have a stand-alone test
case to reproduce it.

It also seems general goodness. Now the numerous AAs that don't need
target library info don't carry it around and depend on it. I think
I can even rip out the general access to the aggregation layer and only
expose that in BasicAA as it is the only place where we re-query in that
manner.

However, this is a non-trivial change to the AA infrastructure so I want
to get some additional eyes on this before it lands. Sadly, it can't
wait long because we should really cherry pick this into 3.8 if we're
going to go this route.

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

llvm-svn: 262490
2016-03-02 15:56:53 +00:00
..
AliasAnalysis.cpp [AA] Hoist the logic to reformulate various AA queries in terms of other 2016-03-02 15:56:53 +00:00
AliasAnalysisEvaluator.cpp [PM/AA] Port alias analysis evaluator to the new pass manager, and use 2016-02-20 03:46:03 +00:00
AliasSetTracker.cpp [AliasSetTracker] Teach AliasSetTracker about MemSetInst 2016-02-17 02:01:50 +00:00
Analysis.cpp Introduce DominanceFrontierAnalysis to the new PassManager to compute DominanceFrontier. NFC 2016-02-25 17:54:15 +00:00
AssumptionCache.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
BasicAliasAnalysis.cpp [AA] Hoist the logic to reformulate various AA queries in terms of other 2016-03-02 15:56:53 +00:00
BlockFrequencyInfo.cpp Recommit r250345, it was reverted in r250366 to investigate a bot failure. 2015-10-15 14:59:40 +00:00
BlockFrequencyInfoImpl.cpp Fix Clang-tidy readability-redundant-control-flow warnings; other minor fixes. 2016-02-02 18:20:45 +00:00
BranchProbabilityInfo.cpp [BPI] Fix two potential divide-by-zero operations that are introduced in r256263. 2015-12-22 23:45:55 +00:00
CallGraph.cpp [PM] Introduce CRTP mixin base classes to help define passes and 2016-02-26 11:44:45 +00:00
CallGraphSCCPass.cpp Recommit r256952 "Filtering IR printing for print-after-all/print-before-all" 2016-01-06 22:55:03 +00:00
CallPrinter.cpp [PM/AA] Remove the last relics of the separate IPA library from LLVM, 2015-08-18 17:51:53 +00:00
CaptureTracking.cpp [CaptureTracking] Support atomicrmw and cmpxchg 2016-02-18 19:23:27 +00:00
CFG.cpp Avoid overly large SmallPtrSet/SmallSet 2016-01-30 01:24:31 +00:00
CFGPrinter.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
CFLAliasAnalysis.cpp [AA] Hoist the logic to reformulate various AA queries in terms of other 2016-03-02 15:56:53 +00:00
CGSCCPassManager.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
CMakeLists.txt PM: Implement a basic loop pass manager 2016-02-25 07:23:08 +00:00
CodeMetrics.cpp Add convergent property to CodeMetrics. 2016-02-12 21:01:31 +00:00
ConstantFolding.cpp [ConstantFolding] Reduce APInt and APFloat copying. 2016-02-13 16:54:14 +00:00
CostModel.cpp Implemented cost model for masked gather and scatter operations 2015-12-28 20:10:59 +00:00
Delinearization.cpp SCEV: Allow simple AddRec * Parameter products in delinearization 2015-10-12 08:02:00 +00:00
DemandedBits.cpp [DemandedBits] Revert r249687 due to PR26071 2016-02-03 15:05:06 +00:00
DependenceAnalysis.cpp [SCEV] Add and use SCEVConstant::getAPInt; NFCI 2015-12-17 20:28:46 +00:00
DivergenceAnalysis.cpp Introduce analysis pass to compute PostDominators in the new pass manager. NFC 2016-02-25 17:54:07 +00:00
DominanceFrontier.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
DomPrinter.cpp Introduce analysis pass to compute PostDominators in the new pass manager. NFC 2016-02-25 17:54:07 +00:00
EHPersonalities.cpp [WinEH] Rename CatchReturnInst::getParentPad, NFC 2016-01-15 21:16:19 +00:00
GlobalsModRef.cpp [AA] Hoist the logic to reformulate various AA queries in terms of other 2016-03-02 15:56:53 +00:00
InlineCost.cpp CallAnalyzer::analyzeCall: change the condition back to "Cost < Threshold" 2016-02-05 20:32:42 +00:00
InstCount.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
InstructionSimplify.cpp [InstSimplify] Restore fsub 0.0, (fsub 0.0, X) ==> X optzn 2016-02-29 12:18:25 +00:00
Interval.cpp
IntervalPartition.cpp
IteratedDominanceFrontier.cpp Move IDF Calculation to a separate file, expose an interface to it. 2015-04-21 19:13:02 +00:00
IVUsers.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
LazyCallGraph.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
LazyValueInfo.cpp Suppress an uncovered switch warning [NFC] 2016-02-27 05:18:30 +00:00
Lint.cpp [opaque pointer types] [NFC] FindAvailableLoadedValue: take LoadInst instead of just the pointer. 2016-01-22 01:51:51 +00:00
LLVMBuild.txt [PM/AA] Remove the last relics of the separate IPA library from LLVM, 2015-08-18 17:51:53 +00:00
Loads.cpp NFC. Move isDereferenceable to Loads.h/cpp 2016-02-24 12:49:04 +00:00
LoopAccessAnalysis.cpp [LAA] Add missing debug output 2016-03-01 00:50:08 +00:00
LoopInfo.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
LoopPass.cpp LoopInfo: Simplify ownership of Loop objects 2016-01-08 19:08:53 +00:00
LoopPassManager.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
LoopUnrollAnalyzer.cpp [LoopUnrollAnalyzer] Check that we're using SCEV for the same loop we're simulating. 2016-02-26 02:57:05 +00:00
MemDepPrinter.cpp [PM/AA] Rebuild LLVM's alias analysis infrastructure in a way compatible 2015-09-09 17:55:00 +00:00
MemDerefPrinter.cpp NFC. Move isDereferenceable to Loads.h/cpp 2016-02-24 12:49:04 +00:00
MemoryBuiltins.cpp [MemoryBuiltins] Fix an issue with hasNoAliasAttr 2016-02-09 21:54:18 +00:00
MemoryDependenceAnalysis.cpp More detailed dependence test between volatile and non-volatile accesses 2016-02-22 23:07:43 +00:00
MemoryLocation.cpp [PM/AA] Split the location computation out of getArgLocation so the 2015-06-17 07:12:40 +00:00
ModuleDebugInfoPrinter.cpp Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
ObjCARCAliasAnalysis.cpp [AA] Hoist the logic to reformulate various AA queries in terms of other 2016-03-02 15:56:53 +00:00
ObjCARCAnalysisUtils.cpp [ARC] Pull the ObjC ARC components that really serve the role of 2015-08-20 08:06:03 +00:00
ObjCARCInstKind.cpp Add support for objc_unsafeClaimAutoreleasedReturnValue to the 2016-01-27 19:05:08 +00:00
OrderedBasicBlock.cpp [CaptureTracker] Provide an ordered basic block to PointerMayBeCapturedBefore 2015-07-31 14:31:35 +00:00
PHITransAddr.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
PostDominators.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
PtrUseVisitor.cpp Update SetVector to rely on the underlying set's insert to return a pair<iterator, bool> 2014-11-19 07:49:26 +00:00
README.txt
RegionInfo.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
RegionPass.cpp Change range-based for-loops to be -Wrange-loop-analysis clean. 2015-04-15 01:21:15 +00:00
RegionPrinter.cpp [RegionInfo] Add debug-time region viewer functions 2015-08-10 13:21:59 +00:00
ScalarEvolution.cpp [SCEV] Minor naming, braces cleanup; NFC 2016-03-02 04:52:22 +00:00
ScalarEvolutionAliasAnalysis.cpp [AA] Hoist the logic to reformulate various AA queries in terms of other 2016-03-02 15:56:53 +00:00
ScalarEvolutionExpander.cpp ADT: Remove == and != comparisons between ilist iterators and pointers 2016-02-21 20:39:50 +00:00
ScalarEvolutionNormalization.cpp Analysis: Remove implicit ilist iterator conversions 2015-10-10 00:53:03 +00:00
ScopedNoAliasAA.cpp [AA] Hoist the logic to reformulate various AA queries in terms of other 2016-03-02 15:56:53 +00:00
SparsePropagation.cpp Analysis: Remove implicit ilist iterator conversions 2015-10-10 00:53:03 +00:00
StratifiedSets.h Revert r240137 (Fixed/added namespace ending comments using clang-tidy. NFC) 2015-06-23 09:49:53 +00:00
TargetLibraryInfo.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
TargetTransformInfo.cpp [PM] Appease mingw32's auto-import DLL build with minimal tweaks, with fix for clang. 2016-02-28 17:17:00 +00:00
Trace.cpp Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith r259192 post commit comment. 2016-01-29 20:50:44 +00:00
TypeBasedAliasAnalysis.cpp [AA] Hoist the logic to reformulate various AA queries in terms of other 2016-03-02 15:56:53 +00:00
ValueTracking.cpp NFC. Move isDereferenceable to Loads.h/cpp 2016-02-24 12:49:04 +00:00
VectorUtils.cpp [opaque pointer types] [NFC] GEP: replace get(Pointer)ElementType uses with get{Source,Result}ElementType. 2016-01-19 17:28:00 +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))

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