aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOutliner.cpp
AgeCommit message (Collapse)AuthorFilesLines
2021-01-09[llvm] Drop unnecessary make_range (NFC)Kazu Hirata1-1/+1
2021-01-06[llvm] Use llvm::all_of (NFC)Kazu Hirata1-5/+4
2020-12-28[CodeGen] Use llvm::append_range (NFC)Kazu Hirata1-4/+2
2020-11-05 [MachineOutliner] Do not outline debug instructionsMomchil Velikov1-0/+2
The debug location is removed from any outlined instruction. This causes the MachineVerifier to crash on outlined DBG_VALUE instructions. Then, debug instructions are "invisible" to the outliner, that is, two ranges of instructions from different functions are considered identical if the only difference is debug instructions. Since a debug instruction from one function is unlikely to provide sensible debug information about all functions, sharing an outlined sequence, this patch just removes debug instructions from the outlined functions. Differential Revision: https://reviews.llvm.org/D89485
2020-09-08LiveRegUnits.h - reduce MachineRegisterInfo.h include. NFC.Simon Pilgrim1-2/+0
We only need to include MachineInstrBundle.h, but exposes an implicit dependency in MachineOutliner.h. Also, remove duplicate includes from LiveRegUnits.cpp + MachineOutliner.cpp.
2020-07-01[Outliner] Set nounwind for outlined functionsDavid Green1-3/+6
This prevents the outlined functions from pulling in a lot of unnecessary code in our downstream libraries/linker. Which stops outlining making codesize worse in c++ code with no-exceptions. Differential Revision: https://reviews.llvm.org/D57254
2020-06-08[SuffixTree][MachOpt] Factoring out Suffix Tree and adding Unit TestsAndrew Litteken1-508/+1
This moves the SuffixTree test used in the Machine Outliner and moves it into Support for use in other outliners elsewhere in the compilation pipeline. Differential Revision: https://reviews.llvm.org/D80586
2020-05-05[NFC] Outliner label name clean up.Puyan Lotfi1-6/+3
Just simplifying how the label name is generated while using std::to_string instead of Twine. Differential Revision: https://reviews.llvm.org/D79464
2020-04-29[NFCi] Iterative Outliner + clang-format refactoring.Puyan Lotfi1-39/+36
Prior to D69446 I had done some NFC cleanup to make landing an iterative outliner a cleaner more straight-forward patch. Since then, it seems that has landed but I noticed some ways it could be cleaned up. Specifically: 1) doOutline was meant to be the re-runable function, but instead runOnceOnModule was created that just calls doOutline. 2) In D69446 we discussed that the flag allowing the re-run of the outliner should be a flag to tell how many additional times to run the outliner again, not the total number of times. I don't think it makes sense to introduce a flag, but print an error if the flag is set to 0. This is an NFCi, the i being that I get rid of the way that the machine-outline-runs flag could be used to tell the outliner to not run at all, and because I renamed the flag to '-machine-outliner-reruns'. Differential Revision: https://reviews.llvm.org/D79070
2020-04-22[MachineOutliner] Teach outliner to set live-insEli Friedman1-4/+27
Preserving liveness can be useful even late in the pipeline, if we're doing substantial optimization work afterwards. (See, for example, D76065.) Teach MachineOutliner how to correctly set live-ins on the basic block in outlined functions. Differential Revision: https://reviews.llvm.org/D78605
2020-04-17fix to outline cfi instruction when can be grouped in a tail callAndrew Litteken1-1/+8
[MachineOutliner] fix test for excluding CFI and add test to include CFI in outlining New test to check that we only outline CFI instruction if all CFI Instructions in the function would be captured by the outlining adding x86 tests analagous to AARCH64 cfi tests Revision: https://reviews.llvm.org/D77852
2020-03-18Support repeated machine outliningJin Lin1-3/+44
Summary: The following change is to allow the machine outlining can be applied for Nth times, where N is specified by the compiler option. By default the value of N is 1. The motivation is that the repeated machine outlining can further reduce code size. Please refer to the presentation "Improving Swift Binary Size via Link Time Optimization" in LLVM Developers' Meeting in 2019. Reviewers: aschwaighofer, tellenbach, paquette Reviewed By: paquette Subscribers: tellenbach, hiraditya, llvm-commits, jinlin Tags: #llvm Differential Revision: https://reviews.llvm.org/D71027
2020-03-17Revert "Support repeated machine outlining"Jin Lin1-44/+3
This reverts commit ab2dcff309f99614983db7ef6ee4bf43d24dcc30.
2020-03-17Support repeated machine outliningJin Lin1-3/+44
Summary: The following change is to allow the machine outlining can be applied for Nth times, where N is specified by the compiler option. By default the value of N is 1. The motivation is that the repeated machine outlining can further reduce code size. Please refer to the presentation "Improving Swift Binary Size via Link Time Optimization" in LLVM Developers' Meeting in 2019. Reviewers: aschwaighofer, tellenbach, paquette Reviewed By: paquette Subscribers: tellenbach, hiraditya, llvm-commits, jinlin Tags: #llvm Differential Revision: https://reviews.llvm.org/D71027
2020-03-17Revert "Support repeated machine outlining"Jin Lin1-44/+3
This reverts commit 1f93b162fc6bed2e7763ac6c35cf51741014400e.
2020-03-17Support repeated machine outliningJin Lin1-3/+44
Summary: The following change is to allow the machine outlining can be applied for Nth times, where N is specified by the compiler option. By default the value of N is 1. The motivation is that the repeated machine outlining can further reduce code size. Please refer to the presentation "Improving Swift Binary Size via Link Time Optimization" in LLVM Developers' Meeting in 2019. Reviewers: aschwaighofer, tellenbach, paquette Reviewed By: paquette Subscribers: tellenbach, hiraditya, llvm-commits, jinlin Tags: #llvm Differential Revision: https://reviews.llvm.org/D71027
2020-03-06Fix incorrect logic in maintaining the side-effect of compiler generated ↵Jin Lin1-18/+41
outliner functions Summary: Fix incorrect logic in maintaining the side-effect of compiler generated outliner functions by adding the up-exposed uses. Reviewers: paquette, tellenbach Reviewed By: paquette Subscribers: aemerson, lebedev.ri, hiraditya, llvm-commits, jinlin Tags: #llvm Differential Revision: https://reviews.llvm.org/D71217
2020-02-27[CallSiteInfo] Handle bundles when updating call site infoDjordje Todorovic1-1/+1
This will address the issue: P8198 and P8199 (from D73534). The methods was not handle bundles properly. Differential Revision: https://reviews.llvm.org/D74904
2020-02-10[CSInfo] Use isCandidateForCallSiteEntry() when updating the CSInfoDjordje Todorovic1-1/+1
Use the isCandidateForCallSiteEntry(). This should mostly be an NFC, but there are some parts ensuring the moveCallSiteInfo() and copyCallSiteInfo() operate with call site entry candidates (both Src and Dest should be the call site entry candidates). Differential Revision: https://reviews.llvm.org/D74122
2020-01-28Make llvm::StringRef to std::string conversions explicit.Benjamin Kramer1-1/+1
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.
2020-01-10Fix Wdocumentation warning. NFCI.Simon Pilgrim1-2/+0
2020-01-07[MachineOutliner][AArch64] Save + restore LR in noreturn functionsJessica Paquette1-6/+0
Conservatively always save + restore LR in noreturn functions. These functions do not end in a RET, and so they aren't guaranteed to have an instruction which uses LR in any way. So, as a result, you can end up in unfortunate situations where you can't backtrace out of these functions in a debugger. Remove the old noreturn test, and add a new one which is more descriptive. Remove the restriction that we can't outline from noreturn functions as well since we now do the right thing.
2019-12-20[NFC][MachineOutliner] Rewrite setSuffixIndices to be iterativeJessica Paquette1-18/+25
Having this function be recursive could use up way too much stack space. Rewrite it as an iterative traversal in the tree instead to prevent this. Fixes PR44344.
2019-11-13Sink all InitializePasses.h includesReid Kleckner1-0/+1
This file lists every pass in LLVM, and is included by Pass.h, which is very popular. Every time we add, remove, or rename a pass in LLVM, it caused lots of recompilation. I found this fact by looking at this table, which is sorted by the number of times a file was changed over the last 100,000 git commits multiplied by the number of object files that depend on it in the current checkout: recompiles touches affected_files header 342380 95 3604 llvm/include/llvm/ADT/STLExtras.h 314730 234 1345 llvm/include/llvm/InitializePasses.h 307036 118 2602 llvm/include/llvm/ADT/APInt.h 213049 59 3611 llvm/include/llvm/Support/MathExtras.h 170422 47 3626 llvm/include/llvm/Support/Compiler.h 162225 45 3605 llvm/include/llvm/ADT/Optional.h 158319 63 2513 llvm/include/llvm/ADT/Triple.h 140322 39 3598 llvm/include/llvm/ADT/StringRef.h 137647 59 2333 llvm/include/llvm/Support/Error.h 131619 73 1803 llvm/include/llvm/Support/FileSystem.h Before this change, touching InitializePasses.h would cause 1345 files to recompile. After this change, touching it only causes 550 compiles in an incremental rebuild. Reviewers: bkramer, asbirlea, bollu, jdoerfert Differential Revision: https://reviews.llvm.org/D70211
2019-11-05Remove redundant assignment. NFCI.Simon Pilgrim1-1/+0
Fixes cppcheck warning.
2019-11-05Use iterator prefix increment. NFCI.Simon Pilgrim1-1/+1
2019-11-05[MachineOutliner] Reduce scope of variable and stop duplicate getMF() calls. ↵Simon Pilgrim1-3/+3
NFCI.
2019-11-05[MachineOutliner] Fix uninitialized variable warnings. NFCI.Simon Pilgrim1-1/+1
2019-10-30[NFC][MachineOutliner] Fix typo in commentDavid Tellenbach1-1/+1
2019-10-28[MachineOutliner][NFC] clang-formating the MachineOutliner.Puyan Lotfi1-34/+27
2019-10-28[MachineOuliner][NFC] Refactoring code to make outline rerunning a cleaner diff.Puyan Lotfi1-7/+19
I want to add the ability to rerun the outliner in certain cases, and I thought this could be an NFC change that could make a subsequent change that allows for rerunning the outliner a cleaner diff. Differential Revision: https://reviews.llvm.org/D69482
2019-10-08[DebugInfo][If-Converter] Update call site info during the optimizationNikola Prica1-1/+1
During the If-Converter optimization pay attention when copying or deleting call instructions in order to keep call site information in valid state. Reviewers: aprantl, vsk, efriedma Reviewed By: vsk, efriedma Differential Revision: https://reviews.llvm.org/D66955 llvm-svn: 374068
2019-10-04[MachineOutliner] Disable outlining from noreturn functionsJessica Paquette1-0/+6
Outlining from noreturn functions doesn't do the correct thing right now. The outliner should respect that the caller is marked noreturn. In the event that we have a noreturn function, and the outlined code is in tail position, the outliner will not see that the outlined function should be tail called. As a result, you end up with a regular call containing a return. Fixing this requires that we check that all candidates live inside noreturn functions. So, for the sake of correctness, don't outline from noreturn functions right now. Add machine-outliner-noreturn.mir to test this. llvm-svn: 373791
2019-09-30[NewPM] Port MachineModuleInfo to the new pass manager.Yuanfang Chen1-4/+4
Existing clients are converted to use MachineModuleInfoWrapperPass. The new interface is for defining a new pass manager API in CodeGen. Reviewers: fedor.sergeev, philip.pfaffe, chandlerc, arsenm Reviewed By: arsenm, fedor.sergeev Differential Revision: https://reviews.llvm.org/D64183 llvm-svn: 373240
2019-06-27[Backend] Keep call site info valid through the backendDjordje Todorovic1-4/+8
Handle call instruction replacements and deletions in order to preserve valid state of the call site info of the MachineFunction. NOTE: If the call site info is enabled for a new target, the assertion from the MachineFunction::DeleteMachineInstr() should help to locate places where the updateCallSiteInfo() should be called in order to preserve valid state of the call site info. ([10/13] Introduce the debug entry values.) Co-authored-by: Ananth Sowda <asowda@cisco.com> Co-authored-by: Nikola Prica <nikola.prica@rt-rk.com> Co-authored-by: Ivan Baev <ibaev@cisco.com> Differential Revision: https://reviews.llvm.org/D61062 llvm-svn: 364536
2019-04-23Use llvm::stable_sortFangrui Song1-5/+4
While touching the code, simplify if feasible. llvm-svn: 358996
2019-04-10[MachineOutliner] Replace ostringstream based string concatenation with TwineFangrui Song1-10/+4
This makes my libLLVMCodeGen.so.9svn 4936 bytes smaller. While here, delete unused #include <map> llvm-svn: 358089
2019-02-01[opaque pointer types] Add a FunctionCallee wrapper type, and use it.James Y Knight1-3/+3
Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc doesn't choke on it, hopefully. Original Message: The FunctionCallee type is effectively a {FunctionType*,Value*} pair, and is a useful convenience to enable code to continue passing the result of getOrInsertFunction() through to EmitCall, even once pointer types lose their pointee-type. Then: - update the CallInst/InvokeInst instruction creation functions to take a Callee, - modify getOrInsertFunction to return FunctionCallee, and - update all callers appropriately. One area of particular note is the change to the sanitizer code. Previously, they had been casting the result of `getOrInsertFunction` to a `Function*` via `checkSanitizerInterfaceFunction`, and storing that. That would report an error if someone had already inserted a function declaraction with a mismatching signature. However, in general, LLVM allows for such mismatches, as `getOrInsertFunction` will automatically insert a bitcast if needed. As part of this cleanup, cause the sanitizer code to do the same. (It will call its functions using the expected signature, however they may have been declared.) Finally, in a small number of locations, callers of `getOrInsertFunction` actually were expecting/requiring that a brand new function was being created. In such cases, I've switched them to Function::Create instead. Differential Revision: https://reviews.llvm.org/D57315 llvm-svn: 352827
2019-01-31Revert "[opaque pointer types] Add a FunctionCallee wrapper type, and use it."James Y Knight1-3/+3
This reverts commit f47d6b38c7a61d50db4566b02719de05492dcef1 (r352791). Seems to run into compilation failures with GCC (but not clang, where I tested it). Reverting while I investigate. llvm-svn: 352800
2019-01-31[opaque pointer types] Add a FunctionCallee wrapper type, and use it.James Y Knight1-3/+3
The FunctionCallee type is effectively a {FunctionType*,Value*} pair, and is a useful convenience to enable code to continue passing the result of getOrInsertFunction() through to EmitCall, even once pointer types lose their pointee-type. Then: - update the CallInst/InvokeInst instruction creation functions to take a Callee, - modify getOrInsertFunction to return FunctionCallee, and - update all callers appropriately. One area of particular note is the change to the sanitizer code. Previously, they had been casting the result of `getOrInsertFunction` to a `Function*` via `checkSanitizerInterfaceFunction`, and storing that. That would report an error if someone had already inserted a function declaraction with a mismatching signature. However, in general, LLVM allows for such mismatches, as `getOrInsertFunction` will automatically insert a bitcast if needed. As part of this cleanup, cause the sanitizer code to do the same. (It will call its functions using the expected signature, however they may have been declared.) Finally, in a small number of locations, callers of `getOrInsertFunction` actually were expecting/requiring that a brand new function was being created. In such cases, I've switched them to Function::Create instead. Differential Revision: https://reviews.llvm.org/D57315 llvm-svn: 352791
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-12-06Fix Wdocumentation warning. NFCI.Simon Pilgrim1-2/+0
llvm-svn: 348517
2018-12-06[MachineOutliner][NFC] Move yet another std::vector out of a loopJessica Paquette1-3/+4
Once again, following the wisdom of the LLVM Programmer's Manual. I think that's enough refactoring for today. :) llvm-svn: 348439
2018-12-06[MachineOutliner][NFC] Move std::vector out of loopJessica Paquette1-1/+2
See http://llvm.org/docs/ProgrammersManual.html#vector llvm-svn: 348433
2018-12-06[MachineOutliner][NFC] Remove IntegerInstructionMap from InstructionMapperJessica Paquette1-9/+2
Refactoring. This map was only used when we used a string of integers to output the outlined sequence. Since it's no longer used for anything, there's no reason to keep it around. llvm-svn: 348432
2018-12-05[MachineOutliner][NFC] Remove buildCandidateList and replace with findCandidatesJessica Paquette1-45/+9
More refactoring. Since the pruning logic has changed, and the candidate list is gone, everything can be sunk into findCandidates. We no longer need to keep track of the length of the longest substring, so we can drop all of that logic as well. After this, we just find all of the candidates and move to outlining. llvm-svn: 348428
2018-12-05[MachineOutliner][NFC] Candidates don't need to be shared_ptrs anymoreJessica Paquette1-11/+10
More refactoring. After the changes to the pruning logic, and removing CandidateList, there's no reason for Candiates to be shared_ptrs (or pointers at all). std::shared_ptr<Candidate> -> Candidate. llvm-svn: 348427
2018-12-05[MachineOutliner][NFC] Remove CandidateList, since it's now unused.Jessica Paquette1-29/+11
After removing the pruning logic, there's no reason to populate a list of Candidates. Remove CandidateList and update comments. llvm-svn: 348422
2018-12-05Fix buildbot capture warningJessica Paquette1-9/+6
A bot didn't like my lambda. This ought to fix it. Example: http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/30139/steps/build%20lld/logs/stdio error C3493: 'AlreadyRemoved' cannot be implicitly captured because no default capture mode has been specified llvm-svn: 348421
2018-12-05[MachineOutliner][NFC] Simplify and unify pruning/outlining logicJessica Paquette1-157/+15
Since we're now performing outlining per OutlinedFunction rather than per Candidate, we can simply outline each candidate as it shows up. Instead of having a pruning phase, instead, we'll outline entire functions. Then we'll update the UnsignedVec we mapped to reflect the deletion. If any candidate is in a space that's marked dirty, then we'll drop it. This lets us remove the pruning logic entirely, and greatly simplifies the code. llvm-svn: 348420