1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 20:12:56 +02:00
llvm-mirror/lib/Analysis
Reid Kleckner 73e1a13fdc [IR] De-virtualize ~Value to save a vptr
Summary:
Implements PR889

Removing the virtual table pointer from Value saves 1% of RSS when doing
LTO of llc on Linux. The impact on time was positive, but too noisy to
conclusively say that performance improved. Here is a link to the
spreadsheet with the original data:

https://docs.google.com/spreadsheets/d/1F4FHir0qYnV0MEp2sYYp_BuvnJgWlWPhWOwZ6LbW7W4/edit?usp=sharing

This change makes it invalid to directly delete a Value, User, or
Instruction pointer. Instead, such code can be rewritten to a null check
and a call Value::deleteValue(). Value objects tend to have their
lifetimes managed through iplist, so for the most part, this isn't a big
deal.  However, there are some places where LLVM deletes values, and
those places had to be migrated to deleteValue.  I have also created
llvm::unique_value, which has a custom deleter, so it can be used in
place of std::unique_ptr<Value>.

I had to add the "DerivedUser" Deleter escape hatch for MemorySSA, which
derives from User outside of lib/IR. Code in IR cannot include MemorySSA
headers or call the MemoryAccess object destructors without introducing
a circular dependency, so we need some level of indirection.
Unfortunately, no class derived from User may have any virtual methods,
because adding a virtual method would break User::getHungOffOperands(),
which assumes that it can find the use list immediately prior to the
User object. I've added a static_assert to the appropriate OperandTraits
templates to help people avoid this trap.

Reviewers: chandlerc, mehdi_amini, pete, dberlin, george.burgess.iv

Reviewed By: chandlerc

Subscribers: krytarowski, eraman, george.burgess.iv, mzolotukhin, Prazek, nlewycky, hans, inglorion, pcc, tejohnson, dberlin, llvm-commits

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

llvm-svn: 303362
2017-05-18 17:24:10 +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 Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
AliasAnalysisSummary.cpp Update a comment. 2016-08-25 01:29:55 +00:00
AliasAnalysisSummary.h Make some LLVM_CONSTEXPR variables const. NFC. 2016-08-25 01:05:08 +00:00
AliasSetTracker.cpp Use a WeakVH for UnknownInstructions in AliasSetTracker 2017-03-11 01:15: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 [ValueTracking] Replace all uses of ComputeSignBit with computeKnownBits. 2017-05-15 06:39:41 +00:00
BlockFrequencyInfo.cpp [PGO] internal option cleanups 2017-02-02 21:29:17 +00:00
BlockFrequencyInfoImpl.cpp Cleanup dump() functions. 2017-01-28 02:02:38 +00:00
BranchProbabilityInfo.cpp [BPI] Reduce the probability of unreachable edge to minimal value greater than 0 2017-05-18 06:11:56 +00:00
CallGraph.cpp CallGraph: Remove almost-unused field 'Root'. 2017-05-11 23:59:05 +00:00
CallGraphSCCPass.cpp [Statistics] Add a method to atomically update a statistic that contains a maximum 2017-05-18 00:51:39 +00:00
CallPrinter.cpp
CaptureTracking.cpp
CFG.cpp
CFGPrinter.cpp [PM] Port CFGViewer and CFGPrinter to the new Pass Manager 2016-09-15 18:35:27 +00:00
CFLAndersAliasAnalysis.cpp Apply clang-tidy's performance-unnecessary-value-param to LLVM. 2017-01-13 14:39:03 +00:00
CFLGraph.h [IR] Abstract away ArgNo+1 attribute indexing as much as possible 2017-05-03 18:17:31 +00:00
CFLSteensAliasAnalysis.cpp [PM] Change the static object whose address is used to uniquely identify 2016-11-23 17:53:26 +00:00
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 Revert @llvm.assume with operator bundles (r289755-r289757) 2016-12-19 08:22:17 +00:00
ConstantFolding.cpp [ConstantFolding] Add folding for various math '__<func>_finite' routines generated from -ffast-math 2017-05-12 22:11:20 +00:00
CostModel.cpp [SystemZ] TargetTransformInfo cost functions implemented. 2017-04-12 11:49:08 +00:00
Delinearization.cpp
DemandedBits.cpp [ValueTracking] Remove const_casts on several calls to computeKnownBits and ComputeSignBit. NFC 2017-05-13 17:22:16 +00:00
DependenceAnalysis.cpp BitVector: add iterators for set bits 2017-05-17 01:07:53 +00:00
DivergenceAnalysis.cpp
DominanceFrontier.cpp [PM] Introduce an analysis set used to preserve all analyses over 2017-01-15 06:32:49 +00:00
DomPrinter.cpp [DomPrinter] Add a way to programmatically dump a dot representation. 2017-04-24 17:48:44 +00:00
EHPersonalities.cpp [tsan] Add support for C++ exceptions into TSan (call __tsan_func_exit during unwinding), LLVM part 2016-11-14 21:41:13 +00:00
GlobalsModRef.cpp [PM] Change the static object whose address is used to uniquely identify 2016-11-23 17:53:26 +00:00
IndirectCallPromotionAnalysis.cpp Remove another unused variable from r275216 2016-07-12 23:49:17 +00:00
InlineCost.cpp [Inliner] Do not mix callsite and callee hotness based updates. 2017-05-16 21:18:09 +00:00
InstCount.cpp
InstructionSimplify.cpp [InstSimplify] handle all icmp i1 X, C in one place; NFCI 2017-05-17 20:27:55 +00:00
Interval.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
IntervalPartition.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
IteratedDominanceFrontier.cpp Drop graph_ prefix 2017-02-09 20:37:46 +00:00
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] Add new LazyBPI analysis 2016-07-28 23:31:12 +00:00
LazyCallGraph.cpp [LCG] Fix EXPENSIVE_CHECKS typo. NFC 2017-02-28 18:34:55 +00:00
LazyValueInfo.cpp [LazyValueInfo] Avoid unnecessary copies of ConstantRanges 2017-05-06 03:35:15 +00:00
Lint.cpp [KnownBits] Add wrapper methods for setting and clear all bits in the underlying APInts in KnownBits. 2017-05-05 17:36:09 +00:00
LLVMBuild.txt Restore "[ThinLTO] Prevent exporting of locals used/defined in module level asm" 2016-11-14 17:12:32 +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 Revert r293017 and fix the actual underlying issue. 2017-02-07 01:50:48 +00:00
LoopInfo.cpp Make VerifyDomInfo and VerifyLoopInfo global variables 2017-01-24 05:52:07 +00:00
LoopPass.cpp Implement getPassName() for IR printing passes. 2017-03-10 07:09:20 +00:00
LoopUnrollAnalyzer.cpp [LoopUnrollAnalyzer] Handle out of bounds accesses in visitLoad 2016-07-23 02:56:49 +00:00
MemDepPrinter.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
MemDerefPrinter.cpp
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 [Devirtualization] MemDep returns non-local !invariant.group dependencies 2017-01-12 11:33:58 +00:00
MemoryLocation.cpp [Analysis] Add LibFunc_ prefix to enums in TargetLibraryInfo. (NFC) 2017-01-23 23:16:46 +00:00
MemorySSA.cpp [IR] De-virtualize ~Value to save a vptr 2017-05-18 17:24:10 +00:00
MemorySSAUpdater.cpp [MSSA] Clean up the updater a bit. NFC 2017-04-21 04:54:52 +00:00
ModuleDebugInfoPrinter.cpp [IR] Remove the DIExpression field from DIGlobalVariable. 2016-12-20 02:09:43 +00:00
ModuleSummaryAnalysis.cpp Ensure non-null ProfileSummaryInfo passed to ModuleSummaryIndex builder 2017-05-10 18:52:16 +00:00
ObjCARCAliasAnalysis.cpp Consistently use FunctionAnalysisManager 2016-08-09 00:28:15 +00:00
ObjCARCAnalysisUtils.cpp
ObjCARCInstKind.cpp Create llvm.addressofreturnaddress intrinsic 2016-10-12 22:13:19 +00:00
OptimizationDiagnosticInfo.cpp IR: Give function GlobalValue::getRealLinkageName() a less misleading name: dropLLVMManglingEscape(). 2017-05-16 00:39:01 +00:00
OrderedBasicBlock.cpp
PHITransAddr.cpp PHITransAddr: Use new SimplifyQuery based API. 2017-04-26 20:56:13 +00:00
PostDominators.cpp [PM] Introduce an analysis set used to preserve all analyses over 2017-01-15 06:32:49 +00:00
ProfileSummaryInfo.cpp Add hasProfileSummary and has{Sample|Instrumentation}Profile methods 2017-05-16 20:14:39 +00:00
PtrUseVisitor.cpp
README.txt
RegionInfo.cpp [PM] Introduce an analysis set used to preserve all analyses over 2017-01-15 06:32:49 +00:00
RegionPass.cpp Implement getPassName() for IR printing passes. 2017-03-10 07:09:20 +00:00
RegionPrinter.cpp Apply clang-tidy's modernize-loop-convert to lib/Analysis. 2016-06-26 17:27:42 +00:00
ScalarEvolution.cpp [SCEV][NFC] Remove duplication of isLoopInvariant code 2017-05-18 08:26:41 +00:00
ScalarEvolutionAliasAnalysis.cpp [PM] Change the static object whose address is used to uniquely identify 2016-11-23 17:53:26 +00:00
ScalarEvolutionExpander.cpp Rename WeakVH to WeakTrackingVH; NFC 2017-05-01 17:07:49 +00:00
ScalarEvolutionNormalization.cpp Teach SCEV normalization to de/normalize non-affine add recs 2017-04-25 00:09:19 +00:00
ScopedNoAliasAA.cpp [PM] Change the static object whose address is used to uniquely identify 2016-11-23 17:53:26 +00:00
SparsePropagation.cpp [IR] Redesign the case iterator in SwitchInst to actually be an iterator 2017-04-12 07:27:28 +00:00
StratifiedSets.h Do a sweep over move ctors and remove those that are identical to the default. 2016-10-20 12:20:28 +00:00
TargetLibraryInfo.cpp IR: Give function GlobalValue::getRealLinkageName() a less misleading name: dropLLVMManglingEscape(). 2017-05-16 00:39:01 +00:00
TargetTransformInfo.cpp [SLP] Enable 64-bit wide vectorization on AArch64 2017-05-15 21:15:01 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp [TBAA] Don't generate invalid TBAA when merging nodes 2016-12-11 20:07:25 +00:00
TypeMetadataUtils.cpp Analysis: Add appropriate const qualification to functions in TypeMetadataUtils.cpp. NFC. 2017-01-27 22:55:30 +00:00
ValueTracking.cpp [ValueTracking] Replace all uses of ComputeSignBit with computeKnownBits. 2017-05-15 06:39:41 +00:00
VectorUtils.cpp Introduce experimental generic intrinsics for horizontal vector reductions. 2017-05-09 10:43:25 +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))

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