1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 12:33:33 +02:00
llvm-mirror/lib/Analysis
Michael Kruse af578b1205 [BasicAA] Use MayAlias instead of PartialAlias for fallback.
Using various methods, BasicAA tries to determine whether two
GetElementPtr memory locations alias when its base pointers are known
to be equal. When none of its heuristics are applicable, it falls back
to PartialAlias to, according to a comment, protect TBAA making a wrong
decision in case of unions and malloc. PartialAlias is not correct,
because a PartialAlias result implies that some, but not all, bytes
overlap which is not necessarily the case here.

AAResults returns the first analysis result that is not MayAlias.
BasicAA is always the first alias analysis. When it returns
PartialAlias, no other analysis is queried to give a more exact result
(which was the intention of returning PartialAlias instead of MayAlias).
For instance, ScopedAA could return a more accurate result.

The PartialAlias hack was introduced in r131781 (and re-applied in
r132632 after some reverts) to fix llvm.org/PR9971 where TBAA returns a
wrong NoAlias result due to a union. A test case for the malloc case
mentioned in the comment was not provided and I don't think it is
affected since it returns an omnipotent char anyway.

Since r303851 (https://reviews.llvm.org/D33328) clang does emit specific
TBAA for unions anymore (but "omnipotent char" instead). Hence, the
PartialAlias workaround is not required anymore.

This patch passes the test-suite and check-llvm/check-clang of a
self-hoisted build on x64.

Reviewed By: hfinkel

Differential Revision: https://reviews.llvm.org/D34318

llvm-svn: 305938
2017-06-21 18:25:37 +00:00
..
AliasAnalysis.cpp [IR] Make paramHasAttr to use arg indices instead of attr indices 2017-04-14 20:19:02 +00:00
AliasAnalysisEvaluator.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
AliasAnalysisSummary.cpp
AliasAnalysisSummary.h
AliasSetTracker.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
Analysis.cpp MemorySSA: Move to Analysis, from Transforms/Utils. It's used as 2017-04-11 20:06:36 +00:00
AssumptionCache.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
BasicAliasAnalysis.cpp [BasicAA] Use MayAlias instead of PartialAlias for fallback. 2017-06-21 18:25:37 +00:00
BlockFrequencyInfo.cpp
BlockFrequencyInfoImpl.cpp
BranchProbabilityInfo.cpp [BPI] Don't assume that strcmp returning >0 is more likely than <0 2017-06-08 09:44:40 +00:00
CallGraph.cpp CallGraph: Remove almost-unused field 'Root'. 2017-05-11 23:59:05 +00:00
CallGraphSCCPass.cpp Address http://bugs.llvm.org/pr32207 by making BannerPrinted local to runOnSCC and skipping banner for function declarations. 2017-06-12 02:18:50 +00:00
CallPrinter.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
CaptureTracking.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
CFG.cpp
CFGPrinter.cpp
CFLAndersAliasAnalysis.cpp
CFLGraph.h [CFLAA] Remove unused include. NFCI. 2017-06-06 23:16:19 +00:00
CFLSteensAliasAnalysis.cpp
CGSCCPassManager.cpp [PM/LCG] Teach the LazyCallGraph how to replace a function without 2017-02-09 23:24:13 +00:00
CMakeLists.txt MemorySSA: Move to Analysis, from Transforms/Utils. It's used as 2017-04-11 20:06:36 +00:00
CodeMetrics.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
ConstantFolding.cpp [InstSimplify] Don't constant fold or DCE calls that are marked nobuiltin 2017-06-09 23:18:11 +00:00
CostModel.cpp [SystemZ] TargetTransformInfo cost functions implemented. 2017-04-12 11:49:08 +00:00
Delinearization.cpp
DemandedBits.cpp [BDCE] Add comments. NFC 2017-06-19 20:10:41 +00:00
DependenceAnalysis.cpp BitVector: add iterators for set bits 2017-05-17 01:07:53 +00:00
DivergenceAnalysis.cpp DivergencyAnalysis patch for review 2017-06-15 19:33:10 +00:00
DominanceFrontier.cpp
DomPrinter.cpp [DomPrinter] Add a way to programmatically dump a dot representation. 2017-04-24 17:48:44 +00:00
EHPersonalities.cpp [EH] Recognize __(gxx|gcc)_personality_seh0 as the GNU EH personalities 2017-05-31 22:35:52 +00:00
GlobalsModRef.cpp GlobalsModRef: Ensure optnone+readonly/readnone attributes are respected 2017-06-07 21:37:39 +00:00
IndirectCallPromotionAnalysis.cpp [PGO] Adjust indirect call promotion threshold 2017-06-01 21:10:10 +00:00
InlineCost.cpp [InstSimplify] Don't constant fold or DCE calls that are marked nobuiltin 2017-06-09 23:18:11 +00:00
InstCount.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
InstructionSimplify.cpp [InstSimplify] Don't constant fold or DCE calls that are marked nobuiltin 2017-06-09 23:18:11 +00:00
Interval.cpp
IntervalPartition.cpp
IteratedDominanceFrontier.cpp
IVUsers.cpp [IVUsers] Don't bail out of normalizing non-affine add recs 2017-04-25 06:53:25 +00:00
LazyBlockFrequencyInfo.cpp [LazyBFI] Fix typos 2017-02-14 17:21:12 +00:00
LazyBranchProbabilityInfo.cpp [BPI] Don't assume that strcmp returning >0 is more likely than <0 2017-06-08 09:44:40 +00:00
LazyCallGraph.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
LazyValueInfo.cpp [LVI] Fix spelling error in comment. NFC 2017-06-09 21:21:17 +00:00
Lint.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
LLVMBuild.txt Update libdeps to add BinaryFormat, introduced in r304864. 2017-06-07 04:48:49 +00:00
Loads.cpp Extract FindAvailablePtrLoadStore out of FindAvailableLoadedValue. NFCI 2017-03-19 15:27:52 +00:00
LoopAccessAnalysis.cpp [LAA] Correctly return a half-open range in expandBounds 2017-04-05 09:24:26 +00:00
LoopAnalysisManager.cpp
LoopInfo.cpp
LoopPass.cpp [LegacyPM] Make the 'addLoop' method accept a loop to add rather than 2017-05-25 03:01:31 +00:00
LoopUnrollAnalyzer.cpp
MemDepPrinter.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
MemDerefPrinter.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
MemoryBuiltins.cpp [MemoryBuiltins] Add isMallocOrCallocLikeFn so BasicAA can check for both at the same time 2017-04-18 21:43:46 +00:00
MemoryDependenceAnalysis.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
MemoryLocation.cpp
MemorySSA.cpp Strip UTF8 BOM that got added for some reason in rL305163 2017-06-13 09:58:27 +00:00
MemorySSAUpdater.cpp [mssa] Fix case when there is no definition in a block prior to an inserted use. 2017-06-07 16:46:53 +00:00
ModuleDebugInfoPrinter.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
ModuleSummaryAnalysis.cpp Write summaries for merged modules when splitting modules for ThinLTO. 2017-06-08 23:01:49 +00:00
ObjCARCAliasAnalysis.cpp
ObjCARCAnalysisUtils.cpp
ObjCARCInstKind.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
OptimizationDiagnosticInfo.cpp IR: Give function GlobalValue::getRealLinkageName() a less misleading name: dropLLVMManglingEscape(). 2017-05-16 00:39:01 +00:00
OrderedBasicBlock.cpp [OrderedBasicBlock] Return false for comesBefore(A, A) 2017-06-02 13:10:31 +00:00
PHITransAddr.cpp PHITransAddr: Use new SimplifyQuery based API. 2017-04-26 20:56:13 +00:00
PostDominators.cpp
ProfileSummaryInfo.cpp Add hasProfileSummary and has{Sample|Instrumentation}Profile methods 2017-05-16 20:14:39 +00:00
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp
RegionPass.cpp Add opt-bisect support for region passes. 2017-06-01 21:22:26 +00:00
RegionPrinter.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
ScalarEvolution.cpp [SCEV] Make MulOpsInlineThreshold lower to avoid excessive compilation time 2017-06-21 07:28:13 +00:00
ScalarEvolutionAliasAnalysis.cpp
ScalarEvolutionExpander.cpp [SCEV] Teach SCEVExpander to expand BinPow 2017-06-19 06:24:53 +00:00
ScalarEvolutionNormalization.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
ScopedNoAliasAA.cpp
SparsePropagation.cpp [IR] Redesign the case iterator in SwitchInst to actually be an iterator 2017-04-12 07:27:28 +00:00
StratifiedSets.h
TargetLibraryInfo.cpp Revert "Add pthread_self function prototype and make it speculatable." 2017-05-21 00:37:55 +00:00
TargetTransformInfo.cpp DivergencyAnalysis patch for review 2017-06-15 19:33:10 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp
TypeMetadataUtils.cpp
ValueTracking.cpp [ValueTracking] Correct early out in computeKnownBitsFromOperator to work with non power of 2 bit widths 2017-06-14 17:04:59 +00:00
VectorUtils.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +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))

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