aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ModuleSummaryIndex.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-03-01[IR] Use range-based for loops (NFC)Kazu Hirata1-4/+3
2021-02-12[LTO] Perform DSOLocal propagation in combined indexWei Wang1-11/+35
Perform DSOLocal propagation within summary list of every GV. This avoids the repeated query of this information during function importing. Differential Revision: https://reviews.llvm.org/D96398
2021-01-27[ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlagsFangrui Song1-0/+14
Imported functions and variable get the visibility from the module supplying the definition. However, non-imported definitions do not get the visibility from (ELF) the most constraining visibility among all modules (Mach-O) the visibility of the prevailing definition. This patch * adds visibility bits to GlobalValueSummary::GVFlags * computes the result visibility and propagates it to all definitions Protected/hidden can imply dso_local which can enable some optimizations (this is stronger than GVFlags::DSOLocal because the implied dso_local can be leveraged for ELF -shared while default visibility dso_local has to be cleared for ELF -shared). Note: we don't have summaries for declarations, so for ELF if a declaration has the most constraining visibility, the result visibility may not be that one. Differential Revision: https://reviews.llvm.org/D92900
2020-12-18[Analysis, CodeGen, IR] Use contains (NFC)Kazu Hirata1-1/+1
2020-07-31[ThinLTO] Compile time improvement to propagateAttributesTeresa Johnson1-4/+24
I found that propagateAttributes was ~23% of a thin link's run time (almost 4x higher than the second hottest function). The main reason is that it re-examines a global var each time it is referenced. This becomes unnecessary once it is marked both non read only and non write only. I added a set to avoid doing redundant work, which dropped the runtime of that thin link by almost 15%. I made a smaller efficiency improvement (no measurable impact) to skip all summaries for a VI if the first copy is dead. I added an assert to ensure that all copies are dead if any is. The code in computeDeadSymbols marks all summaries for a VI as live. There is one corner case where it was skipping marking an alias as live, that I fixed. However, since the code earlier marked all copies of a preserved GUID's VI as live, and each 'visit' marks all copies live, the only case where this could make a difference is summaries that were marked live when they were built initially, and that is only a few special compiler generated symbols and inline assembly symbols, so it likely is never provoked in practice. Differential Revision: https://reviews.llvm.org/D84985
2020-07-01Revert "[StackSafety,NFC] Remove unneded constexpr"Alexey Bataev1-0/+2
This reverts commit 38470baa542bde038340b7d10a0ed2c25fac1bfa because it breaks builds with lld and gold linkers.
2020-07-01[StackSafety,NFC] Remove unneded constexprVitaly Buka1-2/+0
Differential Revision: https://reviews.llvm.org/D80908
2020-06-10[StackSafety] Add info into function summaryVitaly Buka1-0/+2
Summary: This patch adds optional field into function summary, implements asm and bitcode serialization. YAML serialization is omitted and can be added later if needed. This patch includes this information into summary only if module contains at least one sanitize_memtag function. In a near future MTE is the user of the analysis. Later if needed we can provede more direct control on when information is included into summary. Reviewers: eugenis Subscribers: hiraditya, steven_wu, dexonsmith, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D80908
2020-03-01[ADT][NFC] SCCIterator: Change hasLoop() to hasCycle()Stefanos Baziotis1-1/+1
2020-02-18[Assembler] Emit summary index flagsevgeny1-0/+46
Differential revision: https://reviews.llvm.org/D74420
2020-02-14Reenable "Always import constants" after compile time fixesTeresa Johnson1-3/+1
Summary: Reenables importing of constants by default, which was disabled in D73724 due to excessive thin link times. These inefficiencies were fixed in D73851. I re-measured thin link times for a number of binaries that had compile time explosions with importing of constants previously and confirmed they no longer have any notable increases with it enabled. Reviewers: wmi, evgeny777 Subscribers: hiraditya, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74512
2020-01-30[ThinLTO] Disable "Always import constants" due to compile time issuesTeresa Johnson1-2/+8
Summary: Disable the always importing of constants introduced in D70404 by default under a new internal option, since it is causing order of magnitude compile time regressions during the thin link. Will continue investigating why the regressions occur. Reviewers: evgeny777, wmi Subscribers: mehdi_amini, inglorion, hiraditya, steven_wu, dexonsmith, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73724
2020-01-15[ThinLTO] Always import constantsevgeny1-1/+10
This patch imports constant variables even when they can't be internalized (which results in promotion). This offers some extra constant folding opportunities. Differential revision: https://reviews.llvm.org/D70404
2019-12-18[ThinLTO] Show preserved symbols in DOT filesevgeny1-1/+5
Differential revision: https://reviews.llvm.org/D71608
2019-12-17[IR] Use a reference in a range-based forMark de Wever1-1/+1
This avoids unneeded copies when using a range-based for loops. This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D70870
2019-12-05[ThinLTO] Add option to disable readonly/writeonly attribute propagationTeresa Johnson1-0/+8
Summary: Add an option to allow the attribute propagation on the index to be disabled, to allow a workaround for issues (such as that fixed by D70977). Also move the setting of the WithAttributePropagation flag on the index into propagateAttributes(), and remove some old stale code that predated this flag and cleared the maybe read/write only bits when we need to disable the propagation (previously only when importing disabled, now also when the new option disables it). Reviewers: evgeny777, steven_wu Subscribers: mehdi_amini, inglorion, hiraditya, dexonsmith, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70984
2019-11-18Fix error message missed in commit dde589389fcb8b5098f7a47f1b781b27d29a0cac.Andrew Browne1-0/+2
Patch by Andrew Browne <browneee@google.com> Reviewers: tejohnson, evgeny777 Reviewed By: tejohnson Subscribers: arphaman, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70195
2019-11-08ThinLTO : Import always_inline functions irrespective of the thresholdTeresa Johnson1-1/+1
Summary: A user can force a function to be inlined by specifying the always_inline attribute. Currently, thinlto implementation is not aware of always_inline functions and does not guarantee import of such functions, which in turn can prevent inlining of such functions. Patch by Bharathi Seshadri <bseshadr@cisco.com> Reviewers: tejohnson Reviewed By: tejohnson Subscribers: mehdi_amini, inglorion, hiraditya, steven_wu, dexonsmith, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70014
2019-11-08[ThinLTO] Fix bug when importing writeonly variablesevgeny1-1/+15
Patch enables import of write-only variables with non-trivial initializers to fix linker errors. Initializers of imported variables are converted to 'zeroinitializer' to avoid promotion of referenced objects. Differential revision: https://reviews.llvm.org/D70006
2019-11-07[ThinLTO] Import readonly vars with refsevgeny1-2/+20
Patch allows importing declarations of functions and variables, referenced by the initializer of some other readonly variable. Differential revision: https://reviews.llvm.org/D69561
2019-07-05[ThinLTO] Attempt to recommit r365188 after alignment fixEugene Leviant1-55/+86
llvm-svn: 365215
2019-07-05Reverted r365188 due to alignment problems on i686-androidEugene Leviant1-86/+55
llvm-svn: 365206
2019-07-05[ThinLTO] Attempt to recommit r365040 after caching fixEugene Leviant1-55/+86
It's possible that some function can load and store the same variable using the same constant expression: store %Derived* @foo, %Derived** bitcast (%Base** @bar to %Derived**) %42 = load %Derived*, %Derived** bitcast (%Base** @bar to %Derived**) The bitcast expression was mistakenly cached while processing loads, and never examined later when processing store. This caused @bar to be mistakenly treated as read-only variable. See load-store-caching.ll. llvm-svn: 365188
2019-07-04Revert [ThinLTO] Optimize writeonly globals outReid Kleckner1-86/+55
This reverts r365040 (git commit 5cacb914758c7f436b47c8362100f10cef14bbc4) Speculatively reverting, since this appears to have broken check-lld on Linux. Partial analysis in https://crbug.com/981168. llvm-svn: 365097
2019-07-03[ThinLTO] Optimize writeonly globals outEugene Leviant1-55/+86
Differential revision: https://reviews.llvm.org/D63444 llvm-svn: 365040
2019-05-10[ThinLTO] Auto-hide prevailing linkonce_odr only when all copies eligibleTeresa Johnson1-0/+14
Summary: We hit undefined references building with ThinLTO when one source file contained explicit instantiations of a template method (weak_odr) but there were also implicit instantiations in another file (linkonce_odr), and the latter was the prevailing copy. In this case the symbol was marked hidden when the prevailing linkonce_odr copy was promoted to weak_odr. It led to unsats when the resulting shared library was linked with other code that contained a reference (expecting to be resolved due to the explicit instantiation). Add a CanAutoHide flag to the GV summary to allow the thin link to identify when all copies are eligible for auto-hiding (because they were all originally linkonce_odr global unnamed addr), and only do the auto-hide in that case. Most of the changes here are due to plumbing the new flag through the bitcode and llvm assembly, and resulting test changes. I augmented the existing auto-hide test to check for this situation. Reviewers: pcc Subscribers: mehdi_amini, inglorion, eraman, dexonsmith, arphaman, dang, llvm-commits, steven_wu, wmi Tags: #llvm Differential Revision: https://reviews.llvm.org/D59709 llvm-svn: 360466
2019-03-15[ThinLTO] Restructure AliasSummary to contain ValueInfo of AliaseeTeresa Johnson1-11/+1
Summary: The AliasSummary previously contained the AliaseeGUID, which was only populated when reading the summary from bitcode. This patch changes it to instead hold the ValueInfo of the aliasee, and always populates it. This enables more efficient access to the ValueInfo (specifically in the recent patch r352438 which needed to perform an index hash table lookup using the aliasee GUID). As noted in the comments in AliasSummary, we no longer technically need to keep a pointer to the corresponding aliasee summary, since it could be obtained by walking the list of summaries on the ValueInfo looking for the summary in the same module. However, I am concerned that this would be inefficient when walking through the index during the thin link for various analyses. That can be reevaluated in the future. By always populating this new field, we can remove the guard and special handling for a 0 aliasee GUID when dumping the dot graph of the summary. An additional improvement in this patch is when reading the summaries from LLVM assembly we now set the AliaseeSummary field to the aliasee summary in that same module, which makes it consistent with the behavior when reading the summary from bitcode. Reviewers: pcc, mehdi_amini Subscribers: inglorion, eraman, steven_wu, dexonsmith, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D57470 llvm-svn: 356268
2019-02-26[ThinLTO] Use defined node and edge order when dumping DOT fileEugene Leviant1-15/+5
Differential revision: https://reviews.llvm.org/D58631 llvm-svn: 354850
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-11-19[ThinLTO] Fix comment. NFCEugene Leviant1-1/+1
llvm-svn: 347207
2018-11-17Fix bot failure from r347145Teresa Johnson1-8/+7
The #if check around the statistics computation gave an error about the statistic being an unused variable. Instead, guard with AreStatisticsEnabled(). llvm-svn: 347146
2018-11-17[ThinLTO] Add some stats for read only variable internalizationTeresa Johnson1-0/+14
Summary: Follow up to D49362 ([ThinLTO] Internalize read only globals). Add a statistic on the number of read only variables (only counting live variables since dead variables will be dropped anyway). Reviewers: evgeny777 Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D54642 llvm-svn: 347145
2018-11-16[ThinLTO] Internalize readonly globalsEugene Leviant1-6/+101
An attempt to recommit r346584 after failure on OSX build bot. Fixed cache key computation in ThinLTOCodeGenerator and added test case llvm-svn: 347033
2018-11-13Revert "[ThinLTO] Internalize readonly globals"Steven Wu1-101/+6
This reverts commit 10c84a8f35cae4a9fc421648d9608fccda3925f2. llvm-svn: 346768
2018-11-10[ThinLTO] Internalize readonly globalsEugene Leviant1-6/+101
This patch allows internalising globals if all accesses to them (from live functions) are from non-volatile load instructions Differential revision: https://reviews.llvm.org/D49362 llvm-svn: 346584
2018-11-06[ThinLTO] Split NotEligibleToImport into legality and inlinability flagsTeresa Johnson1-2/+3
Summary: The NotEligibleToImport flag on the GlobalValueSummary was set if it isn't legal to import (e.g. because it references unpromotable locals) and when it can't be inlined (in which case importing is pointless). I split out the inlinable piece into a separate flag on the FunctionSummary (doesn't make sense for aliases or global variables), because in the future we may want to import for reasons other than inlining. Reviewers: davidxl Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D53345 llvm-svn: 346261
2018-11-02[LTO] Fix a crash caused by accessing an empty ValueInfoTeresa Johnson1-12/+28
ModuleSummaryIndex::exportToDot crashes when linking the Linux kernel under ThinLTO using LLVMgold.so. This is due to the exportToDot function trying to get the GUID of an empty ValueInfo. The root cause related to the fact that we attempt to get the GUID of an aliasee via its OriginalGUID recorded in the aliasee summary, and that is not always possible. Specifically, we cannot do this mapping when the value is internal linkage and there were other internal linkage symbols with the same name. There are 2 fixes for the problem included here. 1) In all cases where we can currently print the dot file from the command line (which is only via save-temps), we have a valid AliaseeGUID in the AliasSummary. Use that when it is available, so that we can get the correct aliasee GUID whenever possible. 2) However, if we were to invoke exportToDot from the debugger right after it is built during the initial analysis step (i.e. the per-module summary), we won't have the AliaseeGUID field populated. In that case, we have a fallback fix that will simply print "@"+GUID when we aren't able to get the GUID from the OriginalGUID. It simply checks if the VI is valid or not before attempting to get the name. Additionally, since getAliaseeGUID will assert that the AliaseeGUID is non-zero, guard the earlier fix #1 by a new function hasAliaseeGUID(). Reviewers: pcc, tmroeder Subscribers: evgeny777, mehdi_amini, inglorion, dexonsmith, arphaman, llvm-commits Differential Revision: https://reviews.llvm.org/D53986 llvm-svn: 346055
2018-10-24[ThinLTO] Change parameter type. NFCEugene Leviant1-1/+1
Change destination module type for consistency with r345118 llvm-svn: 345124
2018-10-24[ThinLTO] Fix dot dumper for regular LTO modulesEugene Leviant1-1/+1
Regular LTO module identifier is (unsigned)-1. This patch emits correct module identifier while printing edges with source summary in regular LTO module. Differential revision: https://reviews.llvm.org/D53583 llvm-svn: 345118
2018-02-19[ThinLTO] Add GraphTraits for FunctionSummariesCharles Saternos1-0/+24
Add GraphTraits definitions to the FunctionSummary and ModuleSummaryIndex classes. These GraphTraits will be used to construct find SCC's in ThinLTO analysis passes. Third attempt - moved function from lambda to static function due to build failures. llvm-svn: 325506
2018-02-18Revert: [llvm] r325448 - [ThinLTO] Add GraphTraits for FunctionSummaries Simon Pilgrim1-24/+0
Add GraphTraits definitions to the FunctionSummary and ModuleSummaryIndex classes. These GraphTraits will be used to construct find SCC's in ThinLTO analysis passes. Second attempt, since last patch caused stage2 build to fail (now using function_ref rather than std::function). Reverted due to buildbot failures llvm-svn: 325454
2018-02-17[ThinLTO] Add GraphTraits for FunctionSummariesCharles Saternos1-0/+24
Add GraphTraits definitions to the FunctionSummary and ModuleSummaryIndex classes. These GraphTraits will be used to construct find SCC's in ThinLTO analysis passes. Second attempt, since last patch caused stage2 build to fail (now using function_ref rather than std::function). llvm-svn: 325448
2018-02-12Revert "[ThinLTO] Add GraphTraits for FunctionSummaries"Volodymyr Sapsai1-24/+0
It caused assertion failure Assertion failed: (!DD.IsLambda && !MergeDD.IsLambda && "faked up lambda definition?"), function MergeDefinitionData, file /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp, line 1675. on the second stage build bots. llvm-svn: 324932
2018-02-11[ThinLTO] Add GraphTraits for FunctionSummariesCharles Saternos1-0/+24
Add GraphTraits definitions to the FunctionSummary and ModuleSummaryIndex classes. These GraphTraits will be used to construct find SCC's in ThinLTO analysis passes. llvm-svn: 324854
2018-02-05LTO: Include dso-local bit in ThinLTO cache key.Peter Collingbourne1-0/+9
Differential Revision: https://reviews.llvm.org/D42713 llvm-svn: 324253
2018-01-22[ThinLTO] Re-commit of dot dumper after test fixEugene Leviant1-0/+245
llvm-svn: 323116
2018-01-21Temporarily revert r323062 to investigate buildbot failuresEugene Leviant1-244/+0
llvm-svn: 323065
2018-01-21[ThinLTO] Implement summary visualizerEugene Leviant1-0/+244
Differential revision: https://reviews.llvm.org/D41297 llvm-svn: 323062
2017-06-16[cfi] CFI-ICall for ThinLTO.Evgeniy Stepanov1-2/+5
Implement ControlFlowIntegrity for indirect function calls in ThinLTO. Design follows the RFC in llvm-dev, see https://groups.google.com/d/msg/llvm-dev/MgUlaphu4Qc/kywu0AqjAQAJ llvm-svn: 305533
2017-06-15Apply summary-based dead stripping to regular LTO modules with summaries.Peter Collingbourne1-0/+10
If a regular LTO module has a summary index, then instead of linking it into the combined regular LTO module right away, add it to the combined summary index and associate it with a special module that represents the combined regular LTO module. Any such modules are linked during LTO::run(), at which time we use the results of summary-based dead stripping to control whether to link prevailing symbols. Differential Revision: https://reviews.llvm.org/D33922 llvm-svn: 305482