1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/lib/Analysis
Peter Collingbourne dc614179c3 Analysis: Don't look through aliases when simplifying GEPs.
It is not safe in general to replace an alias in a GEP with its aliasee
if the alias can be replaced with another definition (i.e. via strong/weak
resolution (linkonce_odr) or via symbol interposition (default visibility
in ELF)) while the aliasee cannot. An example of how this can go wrong is
in the included test case.

I was concerned that this might be a load-bearing misoptimization (it's
possible for us to use aliases to share vtables between base and derived
classes, and on Windows, vtable symbols will always be aliases in RTTI
mode, so this change could theoretically inhibit trivial devirtualization
in some cases), so I built Chromium for Linux and Windows with and without
this change. The file sizes of the resulting binaries were identical, so it
doesn't look like this is going to be a problem.

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

llvm-svn: 366754
2019-07-22 22:13:46 +00:00
..
AliasAnalysis.cpp
AliasAnalysisEvaluator.cpp
AliasAnalysisSummary.cpp
AliasAnalysisSummary.h
AliasSetTracker.cpp
Analysis.cpp
AssumptionCache.cpp
BasicAliasAnalysis.cpp
BlockFrequencyInfo.cpp
BlockFrequencyInfoImpl.cpp
BranchProbabilityInfo.cpp
CallGraph.cpp
CallGraphSCCPass.cpp
CallPrinter.cpp
CaptureTracking.cpp [CaptureTracking] Don't let comparisons against null escape inbounds pointers 2019-06-09 10:20:33 +00:00
CFG.cpp
CFGPrinter.cpp
CFLAndersAliasAnalysis.cpp
CFLGraph.h [CFLGraph] Add support for unary fneg instruction. 2019-06-06 19:21:23 +00:00
CFLSteensAliasAnalysis.cpp
CGSCCPassManager.cpp
CMakeLists.txt [IDF] Generalize IDFCalculator to be used with Clang's CFG 2019-07-02 11:30:12 +00:00
CmpInstAnalysis.cpp
CodeMetrics.cpp
ConstantFolding.cpp Analysis: Don't look through aliases when simplifying GEPs. 2019-07-22 22:13:46 +00:00
CostModel.cpp
Delinearization.cpp
DemandedBits.cpp
DependenceAnalysis.cpp [DA] Add an option to control delinearization validity checks 2019-06-06 15:12:49 +00:00
DivergenceAnalysis.cpp
DominanceFrontier.cpp
DomPrinter.cpp
DomTreeUpdater.cpp
EHPersonalities.cpp
GlobalsModRef.cpp
GuardUtils.cpp
IndirectCallPromotionAnalysis.cpp
InlineCost.cpp [AMDGPU] Tune inlining parameters for AMDGPU target 2019-07-17 16:51:29 +00:00
InstCount.cpp
InstructionPrecedenceTracking.cpp
InstructionSimplify.cpp [InstructionSimplify] Apply sext/trunc after pointer stripping 2019-07-16 01:03:06 +00:00
Interval.cpp
IntervalPartition.cpp
IVDescriptors.cpp
IVUsers.cpp
LazyBlockFrequencyInfo.cpp
LazyBranchProbabilityInfo.cpp
LazyCallGraph.cpp
LazyValueInfo.cpp Introduce Value::stripPointerCastsSameRepresentation 2019-06-04 20:21:46 +00:00
LegacyDivergenceAnalysis.cpp
Lint.cpp
LLVMBuild.txt
Loads.cpp OpaquePtr: add Type parameter to Loads analysis API. 2019-07-09 11:35:35 +00:00
LoopAccessAnalysis.cpp [LAA] Re-check bit-width of pointers after stripping. 2019-07-18 17:30:27 +00:00
LoopAnalysisManager.cpp Only passes that preserve MemorySSA must mark it as preserved. 2019-06-11 18:27:49 +00:00
LoopInfo.cpp Make DT a transitive dependency of LI. 2019-07-17 23:31:59 +00:00
LoopPass.cpp ftime-trace: Trace loop passes 2019-05-31 10:14:04 +00:00
LoopUnrollAnalyzer.cpp
MemDepPrinter.cpp
MemDerefPrinter.cpp OpaquePtr: add Type parameter to Loads analysis API. 2019-07-09 11:35:35 +00:00
MemoryBuiltins.cpp OpaquePtr: switch to GlobalValue::getValueType in a few places. NFC. 2019-07-11 13:13:02 +00:00
MemoryDependenceAnalysis.cpp
MemoryLocation.cpp
MemorySSA.cpp
MemorySSAUpdater.cpp [MemorySSA] Use SetVector to avoid nondeterminism. 2019-07-12 22:30:30 +00:00
ModuleDebugInfoPrinter.cpp
ModuleSummaryAnalysis.cpp [ThinLTO] Attempt to recommit r365188 after alignment fix 2019-07-05 15:25:05 +00:00
MustExecute.cpp
ObjCARCAliasAnalysis.cpp
ObjCARCAnalysisUtils.cpp
ObjCARCInstKind.cpp [ObjC][ARC] Delete ObjC runtime calls on global variables annotated 2019-06-14 22:06:32 +00:00
OptimizationRemarkEmitter.cpp
OrderedBasicBlock.cpp
OrderedInstructions.cpp
PHITransAddr.cpp
PhiValues.cpp
PostDominators.cpp
ProfileSummaryInfo.cpp Cleanup: llvm::bsearch -> llvm::partition_point after r364719 2019-06-30 11:19:56 +00:00
PtrUseVisitor.cpp SROA: Allow eliminating addrspacecasted allocas 2019-06-14 21:38:31 +00:00
README.txt
RegionInfo.cpp
RegionPass.cpp
RegionPrinter.cpp
ScalarEvolution.cpp [SCEV] add no wrap flag for SCEVAddExpr. 2019-07-18 09:23:19 +00:00
ScalarEvolutionAliasAnalysis.cpp
ScalarEvolutionExpander.cpp [SCEV] Fix for PR42397. SCEVExpander wrongly adds nsw to shl instruction. 2019-07-08 18:03:43 +00:00
ScalarEvolutionNormalization.cpp
ScopedNoAliasAA.cpp
StackSafetyAnalysis.cpp
StratifiedSets.h
SyncDependenceAnalysis.cpp
SyntheticCountsUtils.cpp
TargetLibraryInfo.cpp Initial support for IBM MASS vector library 2019-06-05 01:31:43 +00:00
TargetTransformInfo.cpp [AMDGPU] Tune inlining parameters for AMDGPU target 2019-07-17 16:51:29 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp
TypeMetadataUtils.cpp
ValueLattice.cpp
ValueLatticeUtils.cpp
ValueTracking.cpp Basic codegen for MTE stack tagging. 2019-07-17 19:24:02 +00:00
VectorUtils.cpp [Scalarizer] Add scalarizer support for smul.fix.sat 2019-06-24 12:07:11 +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))

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