1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/lib/Analysis
Chandler Carruth 099fbc1e8e [PM/LCG] Teach the LazyCallGraph to maintain reference edges from every
function to every defined function known to LLVM as a library function.

LLVM can introduce calls to these functions either by replacing other
library calls or by recognizing patterns (such as memset_pattern or
vector math patterns) and replacing those with calls. When these library
functions are actually defined in the module, we need to have reference
edges to them initially so that we visit them during the CGSCC walk in
the right order and can effectively rebuild the call graph afterward.

This was discovered when building code with Fortify enabled as that is
a common case of both inline definitions of library calls and
simplifications of code into calling them.

This can in extreme cases of LTO-ing with libc introduce *many* more
reference edges. I discussed a bunch of different options with folks but
all of them are unsatisfying. They either make the graph operations
substantially more complex even when there are *no* defined libfuncs, or
they introduce some other complexity into the callgraph. So this patch
goes with the simplest possible solution of actual synthetic reference
edges. If this proves to be a memory problem, I'm happy to implement one
of the clever techniques to save memory here.

llvm-svn: 308088
2017-07-15 08:08:19 +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 [AST] Fix a bug in aliasesUnknownInst. Make sure we are comparing the unknown instructions in the alias set and the instruction interested in. 2017-06-25 12:55:11 +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 [IR][AssumptionCache] Add m_Shift and m_BitwiseLogic matchers to replace a couple m_CombineOr 2017-06-24 06:27:14 +00:00
BasicAliasAnalysis.cpp Whitespace. 2017-07-11 02:31:54 +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 [Constants] If we already have a ConstantInt*, prefer to use isZero/isOne/isMinusOne instead of isNullValue/isOneValue/isAllOnesValue inherited from Constant. NFCI 2017-07-06 18:39:47 +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 fix trivial typos; NFC 2017-07-09 05:54:44 +00:00
CFG.cpp
CFGPrinter.cpp
CFLAndersAliasAnalysis.cpp [CFLAA] Move a common function to the header to reduce duplication. 2017-06-27 02:25:06 +00:00
CFLGraph.h [CFLAA] Remove unused include. NFCI. 2017-06-06 23:16:19 +00:00
CFLSteensAliasAnalysis.cpp [CFLAA] Remove unneded function declaration. NFCI. 2017-06-29 22:57:37 +00:00
CGSCCPassManager.cpp [PM/LCG] Teach the LazyCallGraph to maintain reference edges from every 2017-07-15 08:08:19 +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 [DemandedBits] fix formatting; NFC 2017-07-07 14:39:26 +00:00
DependenceAnalysis.cpp fix typos in comments and error messages; NFC 2017-07-10 12:44:25 +00:00
DivergenceAnalysis.cpp DivergencyAnalysis patch for review 2017-06-15 19:33:10 +00:00
DominanceFrontier.cpp [Dominators] Make IsPostDominator a template parameter 2017-07-14 18:26:09 +00:00
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 Fix a typo. 2017-06-28 21:10:31 +00:00
InstCount.cpp Sort the remaining #include lines in include/... and lib/.... 2017-06-06 11:49:48 +00:00
InstructionSimplify.cpp [IR] Add Type::isIntOrIntVectorTy(unsigned) similar to the existing isIntegerTy(unsigned), but also works for vectors. 2017-07-09 07:04:03 +00:00
Interval.cpp
IntervalPartition.cpp
IteratedDominanceFrontier.cpp [Dominators] Make IsPostDominator a template parameter 2017-07-14 18:26:09 +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] Don't assume that strcmp returning >0 is more likely than <0 2017-06-08 09:44:40 +00:00
LazyCallGraph.cpp [PM/LCG] Teach the LazyCallGraph to maintain reference edges from every 2017-07-15 08:08:19 +00:00
LazyValueInfo.cpp [JumpThreading] Teach jump threading how to analyze (and (cmp A, C1), (cmp A, C2)) after InstCombine has turned it into (cmp (add A, C3), C4) 2017-06-23 05:41:35 +00:00
Lint.cpp [Constants] If we already have a ConstantInt*, prefer to use isZero/isOne/isMinusOne instead of isNullValue/isOneValue/isAllOnesValue inherited from Constant. NFCI 2017-07-06 18:39:47 +00:00
LLVMBuild.txt Update libdeps to add BinaryFormat, introduced in r304864. 2017-06-07 04:48:49 +00:00
Loads.cpp Make visible isDereferenceableAndAlignedPointer(..., const APInt &Size, ...) 2017-06-24 01:35:13 +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 [Dominators] Make IsPostDominator a template parameter 2017-07-14 18:26:09 +00:00
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] Allow truncation in visitAllocaInst() 2017-07-12 06:19:10 +00:00
MemoryDependenceAnalysis.cpp [MemDep] Cleanup return after else & use auto. NFC. 2017-06-25 22:12:59 +00:00
MemoryLocation.cpp [Analysis] Add LibFunc_ prefix to enums in TargetLibraryInfo. (NFC) 2017-01-23 23:16:46 +00:00
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 Increase the import-threshold for crtical functions. 2017-07-07 21:01:00 +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 [ORE] Add diagnostics hotness threshold 2017-06-30 23:14:53 +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 [Dominators] Make IsPostDominator a template parameter 2017-07-14 18:26:09 +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 [Analysis] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC). 2017-06-27 21:52:05 +00:00
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 [Constants] Replace calls to ConstantInt::equalsInt(0)/equalsInt(1) with isZero and isOne. NFCI 2017-07-06 18:39:49 +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 [TTI] Refine the cost of EXT in getUserCost() 2017-07-15 02:12:16 +00:00
Trace.cpp
TypeBasedAliasAnalysis.cpp [TBAA] Remove metadata keyword from IR examples in comments (NFC). 2017-06-29 13:55:23 +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 Revert r307581, "Avoid doing conservative phi checks in aliasSameBasePointerGEPs() if no phis have been visited yet." 2017-07-11 02:31:51 +00:00
VectorUtils.cpp [Constants] If we already have a ConstantInt*, prefer to use isZero/isOne/isMinusOne instead of isNullValue/isOneValue/isAllOnesValue inherited from Constant. NFCI 2017-07-06 18:39:47 +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))

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