aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/LegacyPassManager.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-07-09[NFC] Derive from PassInfoMixin for no-op/printing passesArthur Eubanks1-96/+106
PassInfoMixin should be used for all NPM passes, rater than a custom `name()`. This caused ambiguous references in LegacyPassManager.cpp, so had to remove "using namespace llvm::legacy" and move some things around. The passes had to be moved to the llvm namespace, or else they would get printed as "(anonymous namespace)::FooPass". Reviewed By: ychen, asbirlea Differential Revision: https://reviews.llvm.org/D83498
2020-07-08Revert "Double check that passes correctly set their Modified status"serge-sans-paille1-87/+0
This reverts commit 37afd99c768b29c7df7c5f2eb645362fb61f9915.
2020-07-08Double check that passes correctly set their Modified statusserge-sans-paille1-0/+87
The approach is simple: if a pass reports that it's not modifying a Function/Module, compute a loose hash of that Function/Module and compare it with the original one. If we report no change but there's a hash change, then we have an error. This approach misses a lot of change but it's not super intrusive and can detect most of the simple mistakes. Differential Revision: https://reviews.llvm.org/D80916
2020-06-26Improve LegacyPassManager API to correctly report modified statusserge-sans-paille1-8/+11
When calling on-the-fly passes from the legacy pass manager, the modification status is not reported, which is a problem in case we depend on an acutal transformation pass, and not only analyse. Update the Legacy PM API to optionally report the changed status, assert if a change is detected but this change is lost. Related to https://reviews.llvm.org/D80916 Differential Revision: https://reviews.llvm.org/D81236
2020-06-26Fix some clang-tidy namespace closing comments warnings. NFC.Simon Pilgrim1-4/+4
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-2/+3
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
2019-11-28[LegacyPassManager] Simplify FunctionPass::assignPassManagerFangrui Song1-13/+9
And make it clear the parameter PreferredType is unused for FunctionPass.
2019-11-28[LegacyPassManager] Simplify PMStack popFangrui Song1-18/+6
2019-11-02[LegacyPassManager] Fixed "null check after derefencing" warningDávid Bolvanský1-2/+1
The 'RequiredPass' pointer was utilized before it was verified against nullptr. Check lines: 1626, 1629.
2019-11-01[LegacyPM] Fix pass structure dumpingevgeny1-0/+5
If module pass uses on-demand function analyses then structure is being displayed incorrectly because FunctionPassManagerImpl can't dump contained FPPassManager instances. Differential revision: https://reviews.llvm.org/D69315
2019-10-30[LegacyPassManager] Delete BasicBlockPass/Manager.Alina Sbirlea1-228/+0
Summary: Delete the BasicBlockPass and BasicBlockManager, all its dependencies and update documentation. The BasicBlockManager was improperly tested and found to be potentially broken, and was deprecated as of rL373254. In light of the switch to the new pass manager coming before the next release, this patch is a first cleanup of the LegacyPassManager. Reviewers: chandlerc, echristo Subscribers: mehdi_amini, sanjoy.google, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69121
2019-09-30[LegacyPassManager] Attempt to fix BasicBlockManagerAlina Sbirlea1-0/+19
Temporarily fix BaiscBlockManager based on the code in the other managers. Replacement of all uses of the BasicBlockPass to follow. Resolves PR42264. llvm-svn: 373235
2019-09-28[TimeProfiler] Fix "OptModule" section and add new "Backend" sectionsAnton Afanasyev1-1/+0
Remove unnecessary "OptModule" section. Add "PerFunctionPasses", "PerModulePasses" and "CodeGenPasses" sections under "Backend" section. llvm-svn: 373142
2019-07-16Fix parameter name comments using clang-tidy. NFC.Rui Ueyama1-1/+1
This patch applies clang-tidy's bugprone-argument-comment tool to LLVM, clang and lld source trees. Here is how I created this patch: $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project $ mkdir build $ cd build $ cmake -GNinja -DCMAKE_BUILD_TYPE=Debug \ -DLLVM_ENABLE_PROJECTS='clang;lld;clang-tools-extra' \ -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DLLVM_ENABLE_LLD=On \ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ../llvm $ ninja $ parallel clang-tidy -checks='-*,bugprone-argument-comment' \ -config='{CheckOptions: [{key: StrictMode, value: 1}]}' -fix \ ::: ../llvm/lib/**/*.{cpp,h} ../clang/lib/**/*.{cpp,h} ../lld/**/*.{cpp,h} llvm-svn: 366177
2019-07-12[LegacyPassManager] Small ModuleCount cleanupFangrui Song1-5/+3
llvm-svn: 365907
2019-04-20ftime-trace: Trace the name of the currently active pass as well.Nico Weber1-6/+3
Differential Revision: https://reviews.llvm.org/D60782 llvm-svn: 358834
2019-03-30Adds `-ftime-trace` option to clang that produces Chrome `chrome://tracing` ↵Anton Afanasyev1-0/+12
compatible JSON profiling output dumps. This change adds hierarchical "time trace" profiling blocks that can be visualized in Chrome, in a "flame chart" style. Each profiling block can have a "detail" string that for example indicates the file being processed, template name being instantiated, function being optimized etc. This is taken from GitHub PR: https://github.com/aras-p/llvm-project-20170507/pull/2 Patch by Aras Pranckevičius. Differential Revision: https://reviews.llvm.org/D58675 llvm-svn: 357340
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-09-24[New PM][PassInstrumentation] IR printing support for New Pass ManagerFedor Sergeev1-12/+16
Implementing -print-before-all/-print-after-all/-filter-print-func support through PassInstrumentation callbacks. - PrintIR routines implement printing callbacks. - StandardInstrumentations class provides a central place to manage all the "standard" in-tree pass instrumentations. Currently it registers PrintIR callbacks. Reviewers: chandlerc, paquette, philip.pfaffe Differential Revision: https://reviews.llvm.org/D50923 llvm-svn: 342896
2018-09-06Output per-function size-info remarksJessica Paquette1-12/+111
This patch adds per-function size information remarks. Previously, passing -Rpass-analysis=size-info would only give you per-module changes. By adding the ability to do this per-function, it's easier to see which functions contributed the most to size changes. https://reviews.llvm.org/D51467 llvm-svn: 341588
2018-09-04[NFC] Improve clarity in emitInstrCountChangedRemarkJessica Paquette1-1/+4
Add a "CouldOnlyImpactOneFunction" bool that's true when we pass in a function. Just cleaning up a little bit, since I'm going to add in the per-function remarks soon from D51467. llvm-svn: 341407
2018-08-31Fix typo in size remarks for module passesJessica Paquette1-1/+1
ModuleCount = InstrCount was incorrect. It should have been InstrCount = ModuleCount. This was making it emit an extra, incorrect remark for Print Module IR. The test didn't catch this, because it didn't ensure that the only remark output was from the desired pass. So, it was possible to have an extra remark come through and not fail. Updated the test so that we ensure that the last remark that's output comes from the desired pass. This is done by ensuring that whatever is being read after the last remark is YAML output rather than some incorrect garbage. llvm-svn: 341267
2018-08-31[NFC] Optionally pass a function to emitInstrCountChangedRemarkJessica Paquette1-14/+18
In basic block, loop, and function passes, we already have a function that we can use to emit optimization remarks. We can use that instead of searching the module for the first suitable function (that is, one that contains at least one basic block.) llvm-svn: 341253
2018-08-31[NFC] Check if P is a pass manager on entry to emitInstrCountChangedRemarkJessica Paquette1-7/+7
There's no point in finding a function to use for remark output when we're not going to emit anything. llvm-svn: 341252
2018-08-31[NFC] Pass the instruction delta to emitInstrCountChangedRemarkJessica Paquette1-19/+7
Instead of counting the size of the entire module every time we run a pass, pass along a delta instead and use that to emit the remark. This means we only have to use (on average) smaller IR units to calculate instruction counts. E.g, in a BB pass, we only need to look at the delta of the BB instead of the delta of the entire module. 6/6 (This improved compile time for size remarks on sqlite3 + O2 significantly) llvm-svn: 341250
2018-08-31[NFC] Pre-calculate module IR counts in size remarks.Jessica Paquette1-5/+18
Same as the previous NFC commits in the same vein. This one introduces a TODO. I'm going to change emitInstrCountChangedRemark so that it takes in a delta. Since the delta isn't necessary yet, it's not there. For now, this means that we're calculating the size of the module twice. Just done separately to keep the patches small. 4/6 llvm-svn: 341248
2018-08-31[NFC] Pre-calculate basic block IR counts in size remarks.Jessica Paquette1-6/+21
Size remarks are slow due to lots of recalculation of the module. This is similar to the previous commit. Cache the size of the module and update counts in basic block passes based off a less-expensive delta. 2/6 llvm-svn: 341246
2018-08-31[NFC] Pre-calculate function IR counts in size remarks.Jessica Paquette1-5/+20
Size remarks are slow due to lots of recalculation of the module. Pre-calculate the module size and initial function size for a remark. Use deltas calculated using the less-expensive function IR count to update the module counts for Function passes. 1/6 llvm-svn: 341245
2018-08-28[NFC][PassTiming] factor out generic PassTimingInfoFedor Sergeev1-96/+1
Moving PassTimingInfo from legacy pass manager code into a separate header. Making it suitable for both legacy and new pass manager. Adding a test on -time-passes main functionality. llvm-svn: 340872
2018-08-20[LegacyPassManager] Remove analysis P from AnUsageMap before deleting it in ↵Craig Topper1-0/+2
schedulePass. If we deem the analysis pass useless and delete it, we need to make sure we remove it from AnUsageMap. Otherwise we might allocate another pass in the freed memory. This will cause us to reuse the AnalysisUsage from the original pass instead of the new one. Fixes PR38511 Differential Revision: https://reviews.llvm.org/D50573 llvm-svn: 340210
2018-07-22[ORE] Move loop invariant ORE checks outside the PM loop.Xin Tong1-13/+19
Summary: This takes 22ms out of ~20s compiling sqlite3.c because we call it for every unit of compilation and every pass. Reviewers: paquette, anemet Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D49586 llvm-svn: 337654
2018-07-03[IR] Strip trailing whitespace. NFCBjorn Pettersson1-1/+1
llvm-svn: 336194
2018-06-13Reland: [Timers] Use the pass argument name for JSON keys in time-passesFrancis Visoiu Mistrih1-1/+5
When using clang --save-stats -mllvm -time-passes, both timers and stats end up in the same json file. We could end up with things like: { "asm-printer.EmittedInsts": 1, "time.pass.Virtual Register Map.wall": 2.9015541076660156e-04, "time.pass.Virtual Register Map.user": 2.0500000000000379e-04, "time.pass.Virtual Register Map.sys": 8.5000000000001741e-05, } This patch makes use of the pass argument name (if available) in the JSON key to end up with things like: { "asm-printer.EmittedInsts": 1, "time.pass.virtregmap.wall": 2.9015541076660156e-04, "time.pass.virtregmap.user": 2.0500000000000379e-04, "time.pass.virtregmap.sys": 8.5000000000001741e-05, } This also helps avoiding to write another JSON printer to handle all the cases that we could have in our pass names. Fixed test instead of adding a new one originally from r334649. Differential Revision: https://reviews.llvm.org/D48109 llvm-svn: 334657
2018-06-13Revert r334649 "[Timers] Use the pass argument name for JSON keys in ↵Francis Visoiu Mistrih1-5/+1
time-passes" This reverts commit r334649. This breaks a test. llvm-svn: 334651
2018-06-13[Timers] Use the pass argument name for JSON keys in time-passesFrancis Visoiu Mistrih1-1/+5
When using clang --save-stats -mllvm -time-passes, both timers and stats end up in the same json file. We could end up with things like: { "asm-printer.EmittedInsts": 1, "time.pass.Virtual Register Map.wall": 2.9015541076660156e-04, "time.pass.Virtual Register Map.user": 2.0500000000000379e-04, "time.pass.Virtual Register Map.sys": 8.5000000000001741e-05, } This patch makes use of the pass argument name (if available) in the JSON key to end up with things like: { "asm-printer.EmittedInsts": 1, "time.pass.virtregmap.wall": 2.9015541076660156e-04, "time.pass.virtregmap.user": 2.0500000000000379e-04, "time.pass.virtregmap.sys": 8.5000000000001741e-05, } This also helps avoiding to write another JSON printer to handle all the cases that we could have in our pass names. Differential Revision: https://reviews.llvm.org/D48109 llvm-svn: 334649
2018-05-24[LegacyPM] Use MapVector for OnTheFlyPassManagers.Florian Hahn1-4/+4
Currently the iteration order of OnTheFlyManagers is not deterministic between executions, which means some of test/Other/opt-*-pipeline.ll tests fail non-deterministically if an additional on-the-fly manager is added, as in D45330. By using MapVector, we always iterate in the insertion order. As we are not removing elements, there shouldn't be a performance hit, except that we store an additional vector with the keys. Reviewers: efriedma, chandlerc, pcc, jhenderson Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D47317 llvm-svn: 333231
2018-05-18[NFC] Change cast from r332739 to a static castJessica Paquette1-1/+2
The casts in the delta computation for size remarks should have been static casts. This fixes that. Thanks to Dávid Bolvanský for pointing that out. llvm-svn: 332758
2018-05-18Add remarks describing when a pass changes the IR instruction count of a moduleJessica Paquette1-3/+66
This patch adds a remark which tells the user when a pass changes the number of IR instructions in a module. It can be enabled by using -Rpass-analysis=size-info. The point of this is to make it easier to collect statistics on how passes modify programs in terms of code size. This is similar in concept to timing reports, but using a remark-based interface makes it easy to diff changes over multiple compilations of the same program. By adding functionality like this, we can see * Which passes impact code size the most * How passes impact code size at different optimization levels * Which pass might have contributed the most to an overall code size regression The patch lives in the legacy pass manager, but since it's simply emitting remarks, it shouldn't be too difficult to adapt the functionality to the new pass manager as well. This can also be adapted to handle MachineInstr counts in code gen passes. https://reviews.llvm.org/D38768 llvm-svn: 332739
2018-04-01[LegacyPassManager] Make 'print-module-scope' cl::Hidden like the rest of ↵Craig Topper1-1/+1
the printing options. llvm-svn: 328947
2017-12-01IR printing improvement for function passes - introducing -print-module-scopeFedor Sergeev1-0/+8
Summary: When debugging function passes it happens to be rather useful to dump the whole module before the transformation and then use this dump to analyze this single transformation by running it separately on that particular module state. Introducing -print-module-scope debugging option that forces all the function-level IR dumps to become whole-module dumps. This option builds on top of normal dumping controls like -print-before/after -filter-print-funcs The plan is to eventually extend this option to cover other local passes (at least loop passes) but that should go as a separate change. Reviewers: sanjoy, weimingz, silvas, fedor.sergeev Reviewed By: weimingz Subscribers: apilipenko, skatkov, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D40245 llvm-svn: 319561
2017-12-01Mark all library options as hidden.Zachary Turner1-12/+10
These command line options are not intended for public use, and often don't even make sense in the context of a particular tool anyway. About 90% of them are already hidden, but when people add new options they forget to hide them, so if you were to make a brand new tool today, link against one of LLVM's libraries, and run tool -help you would get a bunch of junk that doesn't make sense for the tool you're writing. This patch hides these options. The real solution is to not have libraries defining command line options, but that's a much larger effort and not something I'm prepared to take on. Differential Revision: https://reviews.llvm.org/D40674 llvm-svn: 319505
2017-07-13[PM] Use range-based for loops in LegacyPassManager.cpp (NFC).Florian Hahn1-28/+23
Summary: This patch replaces a bunch of iterator-based for loops with range-based for loops. There are 2 iterator-based loops left in this file in removeNotPreservedAnalysis, but I think those cannot be replaced by range-based for loops as they modify the container they are iterating over. Unless I missed something, this schould be a NFC and I would appreciate if someone could have a quick look to confirm that. Reviewers: chandlerc, pcc, jhenderson Reviewed By: jhenderson Subscribers: llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D35310 llvm-svn: 307902
2017-06-06[llvm] Remove double semicolonsMandeep Singh Grang1-1/+1
Reviewers: craig.topper, arsenm, mehdi_amini Reviewed By: mehdi_amini Subscribers: mehdi_amini, wdng, nhaehnle, javed.absar, llvm-commits Differential Revision: https://reviews.llvm.org/D33924 llvm-svn: 304767
2017-05-16[LTO] Print time-passes information at conclusion of LTO codegenJames Henderson1-0/+13
The information collected when requested by -time-passes is only printed when llvm_shutdown is called at the moment. This means that when linking against the LTO library dynamically and using the C interface, it is not possible to see the timing information, because llvm_shutdown cannot be called. This change modifies the LTO code generation functions for both regular LTO and thin LTO to explicitly print and reset the timing information. I have tested that this works with our proprietary linker. However, as this relies on a specific method of building and linking against the LTO library, I'm not sure how or if this can be tested in the LLVM testsuite. Reviewed by: mehdi_amini Differential Revision: https://reviews.llvm.org/D32803 llvm-svn: 303152
2017-01-15Reverted: Track validity of pass resultsSerge Pavlov1-15/+3
Commits r291882 and related r291887. llvm-svn: 292062
2017-01-13Track validity of pass resultsSerge Pavlov1-3/+15
Running tests with expensive checks enabled exhibits some problems with verification of pass results. First, the pass verification may require results of analysis that are not available. For instance, verification of loop info requires results of dominator tree analysis. A pass may be marked as conserving loop info but does not need to be dependent on DominatorTreePass. When a pass manager tries to verify that loop info is valid, it needs dominator tree, but corresponding analysis may be already destroyed as no user of it remained. Another case is a pass that is skipped. For instance, entities with linkage available_externally do not need code generation and such passes are skipped for them. In this case result verification must also be skipped. To solve these problems this change introduces a special flag to the Pass structure to mark passes that have valid results. If this flag is reset, verifications dependent on the pass result are skipped. Differential Revision: https://reviews.llvm.org/D27190 llvm-svn: 291882
2016-11-18Timer: Track name and description.Matthias Braun1-3/+5
The previously used "names" are rather descriptions (they use multiple words and contain spaces), use short programming language identifier like strings for the "names" which should be used when exporting to machine parseable formats. Also removed a unused TimerGroup from Hexxagon. Differential Revision: https://reviews.llvm.org/D25583 llvm-svn: 287369
2016-11-09Bitcode: Change the materializer interface to return llvm::Error.Peter Collingbourne1-2/+4
Differential Revision: https://reviews.llvm.org/D26439 llvm-svn: 286382
2016-10-25Replace TimeValue by TimePoint in LegacyPassManager. NFC.Pavel Labath1-5/+4
llvm-svn: 285081
2016-10-08Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini1-2/+1
template The core of the change is supposed to be NFC, however it also fixes what I believe was an undefined behavior when calling: va_start(ValueArgs, Desc); with Desc being a StringRef. Differential Revision: https://reviews.llvm.org/D25342 llvm-svn: 283671