aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-05-07[Analysis, CodeGen, DebugInfo] Use StringRef::operator== instead of ↵Kazu Hirata1-3/+2
StringRef::equals (NFC) (#91304) I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 53 under llvm/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-02-27[SHT_LLVM_BB_ADDR_MAP] Adds pretty printing of BFI and BPI for PGO Analysis ↵Micah Weston1-1/+1
Map in tools. (#82292) Primary change is to add a flag `--pretty-pgo-analysis-map` to llvm-readobj and llvm-objdump that prints block frequencies and branch probabilities in the same manner as BFI and BPI respectively. This can be helpful if you are manually inspecting the outputs from the tools. In order to print, I moved the `printBlockFreqImpl` function from Analysis to Support and renamed it to `printRelativeBlockFreq`.
2023-10-05BlockFrequencyInfo: Add PrintBlockFreq helper (#67512)Matthias Braun1-13/+12
- Refactor the (Machine)BlockFrequencyInfo::printBlockFreq functions into a `PrintBlockFreq()` function returning a `Printable` object. This simplifies usage as it can be directly piped to a `raw_ostream` like `dbgs() << PrintBlockFreq(MBFI, Freq) << '\n';`. - Previously there was an interesting behavior where `BlockFrequencyInfoImpl` stores frequencies both as a `Scaled64` number and as an `uint64_t`. Most algorithms use the `BlockFrequency` abstraction with the integers, the print function for basic blocks printed the `Scaled64` number potentially showing higher accuracy than was used by the algorithm. This changes things to only print `BlockFrequency` values. - Replace some instances of `dbgs() << Freq.getFrequency()` with the new function.
2023-10-05Use BlockFrequency type in more places (NFC) (#68266)Matthias Braun1-5/+5
The `BlockFrequency` class abstracts `uint64_t` frequency values. Use it more consistently in various APIs and disable implicit conversion to make usage more consistent and explicit. - Use `BlockFrequency Freq` parameter for `setBlockFreq`, `getProfileCountFromFreq` and `setBlockFreqAndScale` functions. - Return `BlockFrequency` in `getEntryFreq()` functions. - While on it change some `const BlockFrequency& Freq` parameters to plain `BlockFreqency Freq`. - Mark `BlockFrequency(uint64_t)` constructor as explicit. - Add missing `BlockFrequency::operator!=`. - Remove `uint64_t BlockFreqency::getMaxFrequency()`. - Add `BlockFrequency BlockFrequency::max()` function.
2022-12-10Don't include None.h (NFC)Kazu Hirata1-1/+0
I've converted all known uses of None to std::nullopt, so we no longer need to include None.h. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-06[YAML] Convert Optional to std::optionalKrzysztof Parzyszek1-2/+3
2022-12-02[CodeGen] Use std::nullopt instead of None (NFC)Kazu Hirata1-2/+2
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2021-05-11CodeGen: Fix null dereference before null checkMatt Arsenault1-2/+8
2021-05-07Internalize some cl::opt global variables or move them under namespace llvmFangrui Song1-0/+2
2020-07-28[llvm][NFC] refactor setBlockFrequency for clarity.Mircea Trofin1-3/+8
The refactoring encapsulates frequency calculation in MachineBlockFrequencyInfo, and renames the API to clarify its motivation. It should clarify frequencies may not be reset 'freely' by users of the analysis, as the API serves as a partial update to avoid a full analysis recomputation. Differential Revision: https://reviews.llvm.org/D84427
2020-07-22[llvm][NFC] const-ed MachineBlockFrequencyInfo::isIrrLoopHeaderMircea Trofin1-2/+2
2020-02-21[BFI] Fix missed BFI updates in MachineSink.Hiroshi Yamauchi1-0/+6
Summary: This prevents BFI queries on new blocks (from MachineSinking::GetAllSortedSuccessors) and fixes a bunch of assert failures under -check-bfi-unknown-block-queries=true. Reviewers: davidxl Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D74511
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-10-28[PGO][PGSO] SizeOpts changes.Hiroshi Yamauchi1-0/+7
Summary: (Split of off D67120) SizeOpts/MachineSizeOpts changes for profile guided size optimization. (A second try after previously committed as r375254 and reverted as r375375.) Subscribers: mgorny, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69409
2019-10-20Reverted r375254 as it has broken some build bots for a long time.Vladimir Vereschaka1-7/+0
llvm-svn: 375375
2019-10-18[PGO][PGSO] SizeOpts changes.Hiroshi Yamauchi1-0/+7
Summary: (Split of off D67120) SizeOpts/MachineSizeOpts changes for profile guided size optimization. Reviewers: davidxl Subscribers: mgorny, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69070 llvm-svn: 375254
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
2017-12-15MachineFunction: Return reference from getFunction(); NFCMatthias Braun1-4/+4
The Function can never be nullptr so we can return a reference. llvm-svn: 320884
2017-11-02Irreducible loop metadata for more accurate block frequency under PGO.Hiroshi Yamauchi1-0/+6
Summary: Currently the block frequency analysis is an approximation for irreducible loops. The new irreducible loop metadata is used to annotate the irreducible loop headers with their header weights based on the PGO profile (currently this is approximated to be evenly weighted) and to help improve the accuracy of the block frequency analysis for irreducible loops. This patch is a basic support for this. Reviewers: davidxl Reviewed By: davidxl Subscribers: mehdi_amini, llvm-commits, eraman Differential Revision: https://reviews.llvm.org/D39028 llvm-svn: 317278
2017-08-26Add options to dump block frequency/branch probability info in text.Hiroshi Yamauchi1-0/+13
Summary: Add options -print-bfi/-print-bpi that dump block frequency and branch probability info like -view-block-freq-propagation-dags and -view-machine-block-freq-propagation-dags do but in text. This is useful when the graph is very large and complex (the dot command crashes, lines/edges too close to tell apart, hard to navigate without textual search) or simply when text is preferred. Reviewers: davidxl Reviewed By: davidxl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37165 llvm-svn: 311822
2017-08-24[CodeGen] Fix some Clang-tidy modernize-use-using and Include What You Use ↵Eugene Zelenko1-18/+20
warnings; other minor fixes (NFC). llvm-svn: 311703
2017-05-25CodeGen: Rename DEBUG_TYPE to match passnamesMatthias Braun1-3/+3
Rename the DEBUG_TYPE to match the names of corresponding passes where it makes sense. Also establish the pattern of simply referencing DEBUG_TYPE instead of repeating the passname where possible. llvm-svn: 303921
2017-02-15include function name in dot filenameXinliang David Li1-5/+4
Differential Revision: http://reviews.llvm.org/D29975 llvm-svn: 295220
2017-02-14Add new pass LazyMachineBlockFrequencyInfoAdam Nemet1-4/+10
And use it in MachineOptimizationRemarkEmitter. A test will follow on top of Justin's changes to enable MachineORE in AsmPrinter. The approach is similar to the IR-level pass. It's a bit simpler because BPI is immutable at the Machine level so we don't need to make that lazy. Because of this, a new function mapping is introduced (BPIPassTrait::getBPI). This function extracts BPI from the pass. In case of the lazy pass, this is when the calculation of the BFI occurs. For Machine-level, this is the identity function. Differential Revision: https://reviews.llvm.org/D29836 llvm-svn: 295072
2017-02-02[PGO] internal option cleanupsXinliang David Li1-0/+4
1. Added comments for options 2. Added missing option cl::desc field 3. Uniified function filter option for graph viewing. Now PGO count/raw-counts share the same filter option: -view-bfi-func-name=. llvm-svn: 293938
2017-02-02[PGO] make graph view internal options available for all buildsXinliang David Li1-9/+0
Differential Revision: https://reviews.llvm.org/D29259 llvm-svn: 293921
2017-01-29Add support to dump dot graph block layout after MBPXinliang David Li1-5/+48
Differential Revision: https://reviews.llvm.org/D29141 llvm-svn: 293408
2016-10-08Turn cl::values() (for enum) from a vararg function to using C++ variadic ↵Mehdi Amini1-3/+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
2016-08-31s/static inline/static/ for headers I have changed in r279475. NFC.Tim Shen1-1/+1
llvm-svn: 280257
2016-08-22[GraphTraits] Replace all NodeType usage with NodeRefTim Shen1-7/+3
This should finish the GraphTraits migration. Differential Revision: http://reviews.llvm.org/D23730 llvm-svn: 279475
2016-08-19[GraphTraits] Make nodes_iterator dereference to NodeType*/NodeRefTim Shen1-3/+3
Currently nodes_iterator may dereference to a NodeType* or a NodeType&. Make them all dereference to NodeType*, which is NodeRef later. Differential Revision: https://reviews.llvm.org/D23704 Differential Revision: https://reviews.llvm.org/D23705 llvm-svn: 279326
2016-08-17[GraphWriter] Change GraphWriter to use NodeRef in GraphTraitsTim Shen1-0/+1
Summary: This is part of the "NodeType* -> NodeRef" migration. Notice that since GraphWriter prints object address as identity, I added a static_assert on NodeRef to be a pointer type. Reviewers: dblaikie Subscribers: llvm-commits, MatzeB Differential Revision: https://reviews.llvm.org/D23580 llvm-svn: 278966
2016-08-02CodeExtractor : Add ability to preserve profile data.Sean Silva1-0/+6
Added ability to estimate the entry count of the extracted function and the branch probabilities of the exit branches. Patch by River Riddle! Differential Revision: https://reviews.llvm.org/D22744 llvm-svn: 277411
2016-08-01Revert r277313 and r277314.Sean Silva1-6/+0
They seem to trigger an LSan failure: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/15140/steps/check-llvm%20asan/logs/stdio Revert "Add the tests for r277313" This reverts commit r277314. Revert "CodeExtractor : Add ability to preserve profile data." This reverts commit r277313. llvm-svn: 277317
2016-08-01CodeExtractor : Add ability to preserve profile data.Sean Silva1-0/+6
Added ability to estimate the entry count of the extracted function and the branch probabilities of the exit branches. Patch by River Riddle! Differential Revision: https://reviews.llvm.org/D22744 llvm-svn: 277313
2016-06-28Fixed MSVC unresolved symbol error due to an incorrectly declared externSimon Pilgrim1-1/+1
llvm-svn: 274007
2016-06-28[BFI/MBFI]: cfg graph view with color scheme Xinliang David Li1-1/+9
This patch enhances dot graph viewer to show hot regions with hot bbs/edges displayed in red. The ratio of the bb freq to the max freq of the function needs to be no less than the value specified by view-hot-freq-percent option. The default value is 10 (i.e. 10%). llvm-svn: 273996
2016-06-28[BFI]: enhance BFI graph dumpXinliang David Li1-4/+3
MBFI supports profile count dumping and function name based filtering. Add these two feature to BFI as well. The filtering option is shared between BFI and MBFI: -view-bfi-func-name=.. llvm-svn: 273992
2016-06-28[BFI]: graph viewer code refactoring Xinliang David Li1-47/+11
BFI and MBFI's dot traits class share most of the code and all future enhancement. This patch extracts common implementation into base class BFIDOTGraphTraitsBase. This patch also enables BFI graph to show branch probability on edges as MBFI does before. llvm-svn: 273990
2016-06-28[BFI]: code cleanup Xinliang David Li1-4/+9
Expose getBPI interface from BFI impl and use it in graph viewer. This eliminates the dependency on old PM interface. llvm-svn: 273967
2016-06-22[MBFI]: Add a new suboption for graph viewerXinliang David Li1-3/+19
-view-machine-block-freq-propagation-dags currently support integer and fraction as the suboptions. This patch adds the 'count' suboption to display actual profile count if available. llvm-svn: 273460
2016-06-22[MBFI]: show branch probability in DOT graphXinliang David Li1-0/+18
Differential Revision: http://reviews.llvm.org/D21596 llvm-svn: 273430
2016-06-22Add an option to enable MBFI dot viewer for a given functionXinliang David Li1-1/+6
llvm-svn: 273366
2016-06-21Clang format change /NFCXinliang David Li1-35/+27
llvm-svn: 273335
2015-10-09CodeGen: Avoid ilist iterator implicit conversions in a few more places, NFCDuncan P. N. Exon Smith1-1/+1
llvm-svn: 249880
2015-07-15Rename doFunction() in BFI to calculate() and change its parameters from ↵Cong Hou1-1/+1
pointers to references. http://reviews.llvm.org/D11196 llvm-svn: 242322
2014-06-26Revert "Introduce a string_ostream string builder facilty"Alp Toker1-3/+4
Temporarily back out commits r211749, r211752 and r211754. llvm-svn: 211814
2014-06-26Introduce a string_ostream string builder faciltyAlp Toker1-4/+3
string_ostream is a safe and efficient string builder that combines opaque stack storage with a built-in ostream interface. small_string_ostream<bytes> additionally permits an explicit stack storage size other than the default 128 bytes to be provided. Beyond that, storage is transferred to the heap. This convenient class can be used in most places an std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair would previously have been used, in order to guarantee consistent access without byte truncation. The patch also converts much of LLVM to use the new facility. These changes include several probable bug fixes for truncated output, a programming error that's no longer possible with the new interface. llvm-svn: 211749
2014-04-22[Modules] Remove potential ODR violations by sinking the DEBUG_TYPEChandler Carruth1-1/+2
define below all header includes in the lib/CodeGen/... tree. While the current modules implementation doesn't check for this kind of ODR violation yet, it is likely to grow support for it in the future. It also removes one layer of macro pollution across all the included headers. Other sub-trees will follow. llvm-svn: 206837
2014-04-21Reapply "blockfreq: Rewrite BlockFrequencyInfoImpl"Duncan P. N. Exon Smith1-3/+9
This reverts commit r206707, reapplying r206704. The preceding commit to CalcSpillWeights should have sorted out the failing buildbots. <rdar://problem/14292693> llvm-svn: 206766