[all-commits] [llvm/llvm-project] 628d06: Preserve layout of basic blocks with 0 profile cou...

maksfb via All-commits all-commits at lists.llvm.org
Tue Jan 11 12:38:52 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 628d06b1e5a3b652824e963d2c6b202579a7a135
      https://github.com/llvm/llvm-project/commit/628d06b1e5a3b652824e963d2c6b202579a7a135
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-01-21 (Thu, 21 Jan 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Preserve layout of basic blocks with 0 profile counts.

Summary:
Preserve original layout for basic blocks that have 0 execution
count. Since we don't optimize for size, it's better to rely on
the original input order.

(cherry picked from FBD2875335)


  Commit: d1526083fc825706fc79dd75c58bd7e5f9509f95
      https://github.com/llvm/llvm-project/commit/d1526083fc825706fc79dd75c58bd7e5f9509f95
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-02-05 (Fri, 05 Feb 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/CMakeLists.txt
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/Exceptions.cpp
    M bolt/Exceptions.h
    M bolt/LLVMBuild.txt
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h
    A bolt/llvm-bolt.cpp
    R bolt/llvm-flo.cpp

  Log Message:
  -----------
  Rename binary optimizer to BOLT.

Summary:
BOLT - Binary Optimization and Layout Tool replaces FLO.
I'm keeping .fdata extension for "feedback data".

(cherry picked from FBD2908028)


  Commit: e1a61e1eed72164db65537b1ddb42163b3e93ad7
      https://github.com/llvm/llvm-project/commit/e1a61e1eed72164db65537b1ddb42163b3e93ad7
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Keep intermediate .o file only under -keep-tmp option.

Summary:
We use intermediate .o file for debugging purposes, but there's no
reason to generate it by default. Only do it if "-keep-tmp" is
specified.

(cherry picked from FBD2912098)


  Commit: 50c895ad0c87be12eaebed0cd5e6c24ed71463cf
      https://github.com/llvm/llvm-project/commit/50c895ad0c87be12eaebed0cd5e6c24ed71463cf
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-02-08 (Mon, 08 Feb 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Drop requirement for __flo_storage in the input binary.

Summary:
We used to require pre-allocated space in the input binary so that
we can write extra sections in there (.eh_frame, .eh_frame_hdr,
.gcc_except_table, etc.). With this diff there's no further
need for pre-allocated storage as we create a new segment and
can use as much space as needed.

There are certain limitations on where the new segment could
be allocated, and as a result the size of the file may increase.

There's currently a limitation if the binary size is close to 4GB
we cannot allocate new segment prior to that and as a result
we require debug info to be stripped to reduce the file size.
The fix is in progress.

(cherry picked from FBD2916029)


  Commit: 7f7d4af7e030ece87bb1da3894d9af398ae93ca2
      https://github.com/llvm/llvm-project/commit/7f7d4af7e030ece87bb1da3894d9af398ae93ca2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-02-12 (Fri, 12 Feb 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Add an option to use PT_GNU_STACK for new segment.

Summary:
Added an option to reuse existing program header entry.
This option allows for bfd tools like strip and objcopy
to operate on the optimized binary without destroying it.

Also, all new sections are now properly marked in ELF.

(cherry picked from FBD2943339)


  Commit: 73e9afe99c4d09584490090157bf1f4701878c7e
      https://github.com/llvm/llvm-project/commit/73e9afe99c4d09584490090157bf1f4701878c7e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-02-22 (Mon, 22 Feb 2016)

  Changed paths:
    M bolt/Exceptions.cpp
    M bolt/Exceptions.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Don't abort on unknown CFI instructions.

Summary:
If we see an unknown CFI instruction, skip processing the function
containing it instead of aborting execution.

(cherry picked from FBD2964557)


  Commit: 62da18d32a3291f4788734cc8b3b2874da4b687a
      https://github.com/llvm/llvm-project/commit/62da18d32a3291f4788734cc8b3b2874da4b687a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-02-22 (Mon, 22 Feb 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Always split functions under '-split-functions=1' option.

Summary:
Force the splitting of the function into hot/cold even when
the function fits into original slot.

This reduces BOLT optimization time by 50% without affecting
hhvm performance.

(cherry picked from FBD2973773)


  Commit: 77a6b72842cd0ebfc3c7101ed446be2cdc60169f
      https://github.com/llvm/llvm-project/commit/77a6b72842cd0ebfc3c7101ed446be2cdc60169f
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-02-25 (Thu, 25 Feb 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/CMakeLists.txt
    A bolt/DebugLineTableRowRef.cpp
    A bolt/DebugLineTableRowRef.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  BOLT: Read and tie .debug_line info to IR.

Summary:
Reads information in the DWARF .debug_line section using LLVM and
tie every MCInst to one line of a line table from the input binary. Subsequent
diffs will update this information to match the final binary layout and
output updated line tables.

(cherry picked from FBD2989813)


  Commit: d68b1c7b16c624a45089cc97ccddc19764e4f7ff
      https://github.com/llvm/llvm-project/commit/d68b1c7b16c624a45089cc97ccddc19764e4f7ff
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-03 (Thu, 03 Mar 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Extending support for non-allocatable sections.

Summary:
The is a set of changes that allow modification of non-allocatable
sections in ELF binary. Primarily for the purpose of updating debug
info.

Extend LLVM interface to allow processing relocations in non-allocatable
sections. This allows to produce .debug* sections with resolved
relocations against generated code.

Extend BOLT rewriting framework to allow appending contents to
non-allocatable sections in the binary.

Re-worked ELF binary rewriting to support the above and to allow future
extensions (e.g. new section names).

(cherry picked from FBD3023403)


  Commit: 73c9f0abe384f06653fdb6d7735bd506f4533a92
      https://github.com/llvm/llvm-project/commit/73c9f0abe384f06653fdb6d7735bd506f4533a92
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-03-02 (Wed, 02 Mar 2016)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Write updated .debug_line information to temp file

Summary:
Writes .debug_line section by setting the state
in MCContext that LLVM needs to produce and output the
line tables. This basically consists of setting the
current location and compile unit offset. This makes LLVM
output .debug_line in the temporary file, but not yet in
the generated ELF file.

Also computes the line table offsets for each compile unit
and saves them into BinaryContext. Added an option to
print these offsets.

(cherry picked from FBD3004554)


  Commit: 9212a9ad691ec0f47837ba8589f83cafed0332bc
      https://github.com/llvm/llvm-project/commit/9212a9ad691ec0f47837ba8589f83cafed0332bc
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-10 (Thu, 10 Mar 2016)

  Changed paths:
    M bolt/Exceptions.cpp

  Log Message:
  -----------
  Proper skipping of unsupported CFI instructions.

Summary:
Skip DW_CFA_expression and DW_CFA_val_expression instructions
properly, according to DWARF spec.

If CFI range does not match function range skip that function.

(cherry picked from FBD3040502)


  Commit: f2df1a8d97325f6f8992373063671e5ee92b7efe
      https://github.com/llvm/llvm-project/commit/f2df1a8d97325f6f8992373063671e5ee92b7efe
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-09 (Wed, 09 Mar 2016)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Update stmt_list value to point to new .debug_line offset.

Summary:
After we add new line number information we have to update stmt_list
offsets in .debug_info. For this I had to add a primitive relocations
support for non-allocatable sections we are copying from input file.

Also enabled functionality to process relocations in non-allocatable
sections that LLVM is generating, such as .debug_line. I thought
we already had it, but apparently it didn't work, at least not
for ELF binaries.

(cherry picked from FBD3037903)


  Commit: e7e9e15b90b4f8301f3167b9446d491484cdd217
      https://github.com/llvm/llvm-project/commit/e7e9e15b90b4f8301f3167b9446d491484cdd217
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-11 (Fri, 11 Mar 2016)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/Exceptions.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Check function data in symbol table against data in .eh_frame.

Summary:
At the moment we rely solely on the symbol table information to discover
function boundaries. However, similar information is contained in
.eh_frame. Verify that the information from these two sources is
consistent, and if it's not, then skip processing the functions with
conflicting information.

(cherry picked from FBD3043800)


  Commit: 80ea31b24e8f1c1be031b4899342ebd83881be48
      https://github.com/llvm/llvm-project/commit/80ea31b24e8f1c1be031b4899342ebd83881be48
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-03-11 (Fri, 11 Mar 2016)

  Changed paths:
    M bolt/CMakeLists.txt
    A bolt/DebugArangesWriter.cpp
    A bolt/DebugArangesWriter.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Write updated .debug_aranges section after optimizations.

Summary:
Write the .debug_aranges section after optimizations to the output binary.
Each function generates at least one range and at most two (one extra for its cold part).
The writing is done manually because LLVM's implementation is tied to the output of
.debug_info (see EmitGenDwarfInfo and EmitGenDwarfARanges in lib/MC/MCDwarf.cpp),
which we don't want to trigger right now.

(cherry picked from FBD3043108)


  Commit: dc7cc1fb185d2c4999175ecb8891aace752bfd33
      https://github.com/llvm/llvm-project/commit/dc7cc1fb185d2c4999175ecb8891aace752bfd33
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-03-14 (Mon, 14 Mar 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/DebugLineTableRowRef.cpp
    M bolt/DebugLineTableRowRef.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix default line number information for instructions.

Summary:
The line number information generated from a null pointer
was actually valid, which caused new instructions without the line number
information set to have a valid and wrong line number reference. This diff
fixes this by making the null pointer be assigned to an invalid line number
row.

(cherry picked from FBD3048453)


  Commit: d01172ffa8ef88c20aab47b9a3571a88e409ebe9
      https://github.com/llvm/llvm-project/commit/d01172ffa8ef88c20aab47b9a3571a88e409ebe9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-14 (Mon, 14 Mar 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Refactor existing debugging code.

Summary: Almost NFC. Isolate code for updating debug info.

(cherry picked from FBD3051536)


  Commit: a60914427cfbf4e6ff334128db3a01a76556c3fb
      https://github.com/llvm/llvm-project/commit/a60914427cfbf4e6ff334128db3a01a76556c3fb
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-14 (Mon, 14 Mar 2016)

  Changed paths:
    M bolt/DebugArangesWriter.cpp
    M bolt/DebugArangesWriter.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Update DW_AT_ranges for CU when it exists.

Summary:
If CU has DW_AT_ranges update the value.
Note that it does not create DW_AT_ranges attribute.

(cherry picked from FBD3051904)


  Commit: 9cdb7bdb55c0316e32a8b6ebbd0dc866b3b3ae9a
      https://github.com/llvm/llvm-project/commit/9cdb7bdb55c0316e32a8b6ebbd0dc866b3b3ae9a
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-03-15 (Tue, 15 Mar 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Write only minimal .debug_line information.

Summary:
We used to output .debug_line information for every instruction, but because of the way
gdb (and probably lldb as of llvm::DWARFDebugLine::LineTable::findAddress) queries the
line table it's not necessary to output information for two instructions if they follow
each other and map to the same source line. By not repeating this information we generate
a bit less .debug_line data.

(cherry picked from FBD3056402)


  Commit: 466cbae866cf3ea0b76ec1f11891ae2a50d02a4b
      https://github.com/llvm/llvm-project/commit/466cbae866cf3ea0b76ec1f11891ae2a50d02a4b
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-03-16 (Wed, 16 Mar 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.h
    A bolt/BinaryPatcher.cpp
    A bolt/BinaryPatcher.h
    M bolt/CMakeLists.txt
    M bolt/DebugArangesWriter.cpp
    M bolt/DebugArangesWriter.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Update subroutine address ranges in binary.

Summary:
[WIP] Update DWARF info for function address ranges.

This diff currently does not work for unknown reasons,
but I'm describing here what's the current state.
According to both llvm-dwarf and readelf our output seems correct,
but GDB does not interpret it as expected. All details go below in
hope I missed something.

I couldn't actually track the whole change that introduced support for
what we need in gdb yet, but I think I can get to it
(2007-12-04: Support
lexical bocks and function bodies that occupy non-contiguous address ranges). I have reasons to believe gdb at least at some
nges).

The set of introduced changes was basically this:

- After disassembly, iterate over the DIEs in .debug_info and find the
ones that correspond to each BinaryFunction.
- Refactor DebugArangesWriter to also write addresses of functions to
.debug_ranges and track the offsets of function address ranges there
- Add some infrastructure to facilitate patching the binary in
simple ways (BinaryPatcher.h)
- In RewriteInstance, after writing .debug_ranges already with
function address ranges, for each function do:
-- Find the abbreviation corresponding to the function
-- Patch .debug_abbrev to replace DW_AT_low_pc with DW_AT_ranges and
DW_AT_high_pc with DW_AT_producer (I'll explain this hack below).
Also patch the corresponding forms to DW_FORM_sec_offset and
DW_FORM_string (null-terminated in-place string).
-- Patch debug_info with the .debug_ranges offset in place of
the first 4 bytes of DW_AT_low_pc (DW_AT_ranges only occupies 4
bytes whereas low_pc occupies 8), and write an arbitrary string
in-place in the other 12 bytes that were the 4 MSB of low_pc
and the 8 bytes of high_pc before the patch. This depends on
low_pc and high_pc being put consecutively by the compiler, but
it serves to validate the idea. I tried another way of doing it
that does not rely on this but it didn't work either and I believe
the reason for either not working is the same (and still unknown,
but unrelated to them. I might be wrong though, and if I find yet
another way of doing it I may try it). The other way was to
use a form of DW_FORM_data8 for the section offset. This is
disallowed by the specification, but I doubt gdb validates this,
as it's just easier to store it as 64-bit anyway as this is even
necessary to support 64-bit DWARF (which is not what gcc generates
by default apparently).

I still need to make changes to the diff to make it production-ready,
but first I want to figure out why it doesn't work as expected.

By looking at the output of llvm-dwarfdump or readelf, all of
.debug_ranges, .debug_abbrev and .debug_info seem to have been
correctly updated. However, gdb seems to have serious problems with
what we write.

(In fact, readelf --debug-dump=Ranges shows some funny warning messages
of the form ("Warning: There is a hole [0x100 - 0x120] in .debug_ranges"),
but I played around with this and it seems it's just because no
compile unit was using these ranges. Changing .debug_info apparently
changes these warnings, so they seem to be unrelated to the section
itself. Also looking at the hex dump of the section doesn't help,
as everything seems fine. llvm-dwarfdump doesn't say anything.
So I think .debug_ranges is fine.)

The result is that gdb not only doesn't show the function name as we
wanted, but it also stops showing line number information.
Apparently it's not reading/interpreting the address ranges at all,
and so the functions now have no associated address ranges, only the
symbol value which allows one to put a breakpoint in the function,
but not to show source code.

As this left me without more ideas of what to try to feed gdb with,
I believe the most promising next trial is to try to debug gdb itself,
unless someone spots anything I missed.
I found where the interesting part of the code lies for this
case (gdb/dwarf2read.c and some other related files, but mainly that one).
It seems in some parts gdb uses DW_AT_ranges for only getting
its lowest and highest addresses and setting that as low_pc and
high_pc (see dwarf2_get_pc_bounds in gdb's code and where it's called).
I really hope this is not actually the case for
function address ranges. I'll investigate this further. Otherwise
I don't think any changes we make will make it work as initially
intended, as we'll simply need gdb to support it and in that case it
doesn't.

(cherry picked from FBD3073641)


  Commit: 595d0885d9ab93bd69c7f9b5c0ba866e7510c07c
      https://github.com/llvm/llvm-project/commit/595d0885d9ab93bd69c7f9b5c0ba866e7510c07c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-28 (Mon, 28 Mar 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/DataReader.cpp
    M bolt/DataReader.h

  Log Message:
  -----------
  Populate function execution count while parsing fdata.

Summary:
Populate function execution count while parsing fdata. Before
we used a quadratic algorithm to populate the execution count
(had to iterate over *all* branches for every single function).

Ignore non-symbol to non-symbol branches while parsing fdata.

These changes combined drop HHVM processing time from
4 minutes 53 seconds down to 2 minutes 9 seconds on my devserver.

Test case had to be modified since it contained irrelevant
branches from PLT to libc.

(cherry picked from FBD3106263)


  Commit: e8ef8a56194371f7a9c84d58b7e5ccf5adf363d0
      https://github.com/llvm/llvm-project/commit/e8ef8a56194371f7a9c84d58b7e5ccf5adf363d0
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-28 (Mon, 28 Mar 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Speedup section remapping.

Summary:
Before this diff LLVM used to iterate over all sections to find the
one with an address we want to remap. Since we have extremely
large number of section this process is highly inefficient.
Instead we add a new interface to remap a section with a given ID
(which effectively is an index into an array of sections), and
pass the ID instead of the address.

This cuts down the processing time of hhvm binary by 10 seconds,
and brings the total processing time to a little under 2 minutes.

(cherry picked from FBD3110015)


  Commit: ffa9641e16b3f53a686a6cff2c3f16239da8fc5c
      https://github.com/llvm/llvm-project/commit/ffa9641e16b3f53a686a6cff2c3f16239da8fc5c
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-03-28 (Mon, 28 Mar 2016)

  Changed paths:
    A bolt/BasicBlockOffsetRanges.cpp
    A bolt/BasicBlockOffsetRanges.h
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/CMakeLists.txt
    R bolt/DebugArangesWriter.cpp
    R bolt/DebugArangesWriter.h
    A bolt/DebugRangesSectionsWriter.cpp
    A bolt/DebugRangesSectionsWriter.h
    A bolt/LexicalBlock.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Update DWARF lexical blocks address ranges.

Summary:
Updates DWARF lexical blocks address ranges in the output binary after optimizations.
This is similar to updating function address ranges except that the ranges representation needs
to be more general, since address ranges can begin or end in the middle of a basic block.

The following changes were made:

- Added a data structure for iterating over the basic blocks that intersect an address range: BasicBlockTable.h
- Added some more bookkeeping in BinaryBasicBlock. Basically, I needed to keep track of the block's size in the input binary as well as its address in the output binary. This information is mostly set by BinaryFunction after disassembly.
- Added a representation for address ranges relative to basic blocks (BasicBlockOffsetRanges.h). Will also serve for location lists.
- Added a representation for Lexical Blocks (LexicalBlock.h)
- Small refactorings in DebugArangesWriter:
-- Renamed to DebugRangesSectionsWriter since it also writes .debug_ranges
-- Refactored it not to depend on BinaryFunction but instead on anything that can be assined an aoffset in .debug_ranges (added an interface for that)
- Iterate over the DIE tree during initialization to find lexical blocks in .debug_info (BinaryContext.cpp)
- Added patches to .debug_abbrev and .debug_info in RewriteInstance to update lexical blocks attributes (in fact, this part is very similar to what was done to function address ranges and I just refactored/reused that code)
- Added small test case (lexical_blocks_address_ranges_debug.test)

(cherry picked from FBD3113181)


  Commit: 0a07d9bf884d6ef8d65f51b6dc3179db5bcac5fb
      https://github.com/llvm/llvm-project/commit/0a07d9bf884d6ef8d65f51b6dc3179db5bcac5fb
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-01 (Fri, 01 Apr 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Don't skip non-simple functions on function address ranges update.

Summary:
This fixes a problem in which bolt was generating a malformed .debug_info
section on the bzip2 binary. The bug was the following:

- A simple and a non-simple function shared an abbreviation
- The abbreviation was patched to contain DW_AT_ranges because of the simple function
- The non-simple function's data was not updated, but then it didn't match the
  layout expected by the abbreviation anymore

And because we were already creating an address ranges list in .debug_ranges even
for non-simple functions, it doesn't make sense not to use it anyway.

(cherry picked from FBD3129219)


  Commit: 4349b631441fd40a94776c3605f3c5c6450e64b4
      https://github.com/llvm/llvm-project/commit/4349b631441fd40a94776c3605f3c5c6450e64b4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-03-31 (Thu, 31 Mar 2016)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Re-enable conditional function spitting under an option.

Summary:
Add a parameter value to "-split-functions=" option to allow splitting
only when the function is too large to fit:
  0 - never split
  1 - split if too large to fit
  2 - always split
We may use this option when the profile data is not very precise.
In that case excessive splitting may increase iTLB misses.

(cherry picked from FBD3137700)


  Commit: 4b4db401748f74bed71cc5b32eb67ed30afa5812
      https://github.com/llvm/llvm-project/commit/4b4db401748f74bed71cc5b32eb67ed30afa5812
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-01 (Fri, 01 Apr 2016)

  Changed paths:
    M bolt/BasicBlockOffsetRanges.cpp
    M bolt/BasicBlockOffsetRanges.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/CMakeLists.txt
    A bolt/DebugLocWriter.cpp
    A bolt/DebugLocWriter.h
    M bolt/LexicalBlock.h
    A bolt/LocationList.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Update DWARF location lists after optimization.

Summary:

    Summary: Update DWARF location lists in .debug_loc and pointers to
    them in .debug_info so that gdb can print variables which change
    location during their lifetime.

    The following changes were made:

    - Refactored BasicBlockOffsetRanges to allow ranges to be tied to binary information (so that we can reuse it for location lists)
    - Implemented range compression optimization in BasicBlockOffsetRanges (needed otherwise too much data was being generated).
    - Added representation for location lists (LocationList.h, BinaryContext.h)
    - Implemented .debug_loc serializer that keeps the updated offsets (DebugLocWriter.{h,cpp})
    - After disassembly, traverse entries in .debug_loc and save them in context (BinaryContext.cpp)
    - After optimizations, serialize .debug_loc and update pointers in .debug_info (RewriteInstance.cpp)

(cherry picked from FBD3130682)


  Commit: e513bfd86ddd0bf345038185c606b67a419869b5
      https://github.com/llvm/llvm-project/commit/e513bfd86ddd0bf345038185c606b67a419869b5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-06 (Wed, 06 Apr 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Only set output ranges when updating dbg info.

Summary: Save processing time by setting output ranges when needed.

(cherry picked from FBD3148791)


  Commit: 784f6a8773436d7c1333533ea1ae5fee45d9b933
      https://github.com/llvm/llvm-project/commit/784f6a8773436d7c1333533ea1ae5fee45d9b933
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-05 (Tue, 05 Apr 2016)

  Changed paths:
    M bolt/DebugRangesSectionsWriter.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Emit debug line information for non-simple functions.

Summary:
Non-simple functions aren't emitted, and thus didn't have line number information
emitted. This diff emits it for those functions by extending LLVM's generation of the line number program to allow for absolute addresses (it is wholly symbolic), then iterating over the relevant line tables from the input and appending entries with absolute addresses to the line tables to be emited.

This still leaves the simple but not overwritten functions unhandled (there were 48 in HHVM in
my last run). However, I think that to fix them we'd need another pass, since by the time we
realize a simple function wont't fit, debug line info was already written to the output.

(cherry picked from FBD3148468)


  Commit: 665b03a46417519a67fa70c1461a4b052ddc7a37
      https://github.com/llvm/llvm-project/commit/665b03a46417519a67fa70c1461a4b052ddc7a37
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-08 (Fri, 08 Apr 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix behavior with multiple functions with same address.

Summary:
We were updating only one DIE per function, but because the Linker Script may map
multiple functions to the same address this would cause us to generate invalid debug info
(as some DIEs weren't updated but their abbreviations were changed).

(cherry picked from FBD3157263)


  Commit: 2694e58fa2a35ea42e3308e1b34da0cda8fb219a
      https://github.com/llvm/llvm-project/commit/2694e58fa2a35ea42e3308e1b34da0cda8fb219a
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-08 (Fri, 08 Apr 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/DebugRangesSectionsWriter.cpp
    M bolt/DebugRangesSectionsWriter.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Update unmatched and nested subprogram DIEs.

Summary:
readelf was showing some errors because we weren't updating DIEs that were not shallow
in the DIE tree, or DIEs of functions with addresses we don't recognize (mostly functions with
address 0, which could have been removed by the Linker Script but still have debugging information
there). These DIEs need to be updated because their abbreviations are patched.

(cherry picked from FBD3159335)


  Commit: e16b5d8b78ceb9d7b1bfaf6c5ed4ec8aefc33cae
      https://github.com/llvm/llvm-project/commit/e16b5d8b78ceb9d7b1bfaf6c5ed4ec8aefc33cae
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-08 (Fri, 08 Apr 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Option to pass a file with list of functions to skip.

Summary:
Take "-skip_funcs_file=<file>" option and don't process any function
listed in the <file>.

(cherry picked from FBD3160226)


  Commit: 0e77c53b896473d33e3ff10a130991c8d6307b3a
      https://github.com/llvm/llvm-project/commit/0e77c53b896473d33e3ff10a130991c8d6307b3a
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-12 (Tue, 12 Apr 2016)

  Changed paths:
    A bolt/AddressRangesDWARFObject.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    R bolt/LexicalBlock.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Update address ranges of inlined functions and try/catch blocks.

Summary:
Update address ranges of inlined functions and try/catch blocks.
This was missing and lead gdb to show weird information in a core dump we inspected
because of the several nestings of inline in the call stack.

This is very similar to Lexical Blocks, so the change is to basically generalize that
code to do the same for DW_AT_try_block, DW_AT_catch_block and DW_AT_inlined_subroutine.

(cherry picked from FBD3169417)


  Commit: f6c8929799496e420394d6860ebbaddfb81f38f7
      https://github.com/llvm/llvm-project/commit/f6c8929799496e420394d6860ebbaddfb81f38f7
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-11 (Mon, 11 Apr 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Fix debugging info for simple functions that we fail to rewrite.

Summary:
Simple functions which we fail to rewrite after optimizations were
having wrong debugging information because the latter would reflect the optimized
version of the function.

There are only 48 functions (at this time) in this situation in the HHVM binary.

The simple fix is to add another full pass. Another more complicated path, which will
be more efficient, is to reset only the BinaryContext and emit again, but then we need
to recreate all symbols in the new MCContext and update the pointers. I started
taking this path but it started getting too complicated for only those 48 functions
(needed to create a new map of global symbols, recreate landing pads - which needed
to have the internal intermediate labels in the functions kept to be updated too, etc).

Because the overhead is quite large (another full emission pass - around 4m30s here)
and the impact is small I put this behind a new
command-line flag which is off by default: -fix-debuginfo-large-functions.

(cherry picked from FBD3166576)


  Commit: ad344c4387cddae99419f49c7d4f28a7343e5715
      https://github.com/llvm/llvm-project/commit/ad344c4387cddae99419f49c7d4f28a7343e5715
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-07 (Thu, 07 Apr 2016)

  Changed paths:
    R bolt/AddressRangesDWARFObject.h
    R bolt/BasicBlockOffsetRanges.cpp
    R bolt/BasicBlockOffsetRanges.h
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    R bolt/BinaryPatcher.cpp
    R bolt/BinaryPatcher.h
    M bolt/CMakeLists.txt
    A bolt/DebugData.cpp
    A bolt/DebugData.h
    R bolt/DebugLineTableRowRef.cpp
    R bolt/DebugLineTableRowRef.h
    R bolt/DebugLocWriter.cpp
    R bolt/DebugLocWriter.h
    R bolt/DebugRangesSectionsWriter.cpp
    R bolt/DebugRangesSectionsWriter.h
    R bolt/LocationList.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Group debugging info representation and serialization code.

Summary:
Moved the classes related to representing and serializing DWARF entities into a single
header, DebugData.h.

(cherry picked from FBD3153279)


  Commit: 4f44d609472880c6193d5c179ec4e754399683cd
      https://github.com/llvm/llvm-project/commit/4f44d609472880c6193d5c179ec4e754399683cd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-19 (Tue, 19 Apr 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Special handling for GNU_args_size call frame instruction.

Summary:
GNU_args_size is a special kind of CFI that tells runtime to adjust
%rsp when control is passed to a landing pad. It is used for annotating
call instructions that pass (extra) parameters on the stack and there's
a corresponding landing pad.

It is also special in a way that its value is not handled by
DW_CFA_remember_state/DW_CFA_restore_state instruction sequence
that we utilize to restore the state after block re-ordering.

This diff adds association of call instructions with GNU_args_size value
when it's used. If the function does not use GNU_args_size, there is
no overhead. Otherwise, we regenerate GNU_args_size instruction during
code emission, i.e. after all optimizations and block-reordering.

(cherry picked from FBD3201322)


  Commit: 43bc4a09add349e6708de99b3aa55b591795a79c
      https://github.com/llvm/llvm-project/commit/43bc4a09add349e6708de99b3aa55b591795a79c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-20 (Wed, 20 Apr 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Changed splitting options and fixed sorting.

Summary:
Splitting option now has different meanings/values. Since landing pads
are mostly always cold/frozen, we should split them before anything
else (we still check the execution count is 0). That's value '1'.
Everything else goes on top of that and has increased value (2 - large
functions, 3 - everything).

Sorting was non-deterministic and somewhat broken for functions
with EH ranges. Fixed that and added '-split-all-cold' option to
outline all 0-count blocks.

Fixed compilation of test cases. After my last commit the binaries
were linked to wrong source files (i.e. debug info). Had to rebuild
the binaries from updated sources.

(cherry picked from FBD3209369)


  Commit: ff68b3455375441ffff89c708702e615ff185630
      https://github.com/llvm/llvm-project/commit/ff68b3455375441ffff89c708702e615ff185630
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-08 (Fri, 08 Apr 2016)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/CMakeLists.txt
    M bolt/DataReader.h
    M bolt/LLVMBuild.txt
    M bolt/llvm-bolt.cpp
    A bolt/merge-fdata/CMakeLists.txt
    A bolt/merge-fdata/LLVMBuild.txt
    A bolt/merge-fdata/Makefile
    A bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  Tool to merge .fdata files.

Summary:
merge-fdata tool takes multiple .fdata files and outputs to stdout
combined fdata. Takes about 2 seconds per each additional .fdata
file with hhvm production data.

(cherry picked from FBD3216430)


  Commit: 87a90ae133a270cfa3608848356d6fe7b59b7cdf
      https://github.com/llvm/llvm-project/commit/87a90ae133a270cfa3608848356d6fe7b59b7cdf
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-25 (Mon, 25 Apr 2016)

  Changed paths:
    M bolt/merge-fdata/CMakeLists.txt
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  Fix ninja install-* for BOLT utilities.

Summary:
Make sure we can install all tools needed for processing
BOLT .fdata files such as perf2bolt, merge-fdata, etc.

(cherry picked from FBD3223477)


  Commit: 3811673a0c39ed6bd2ad96ebf87ee883e31e31f9
      https://github.com/llvm/llvm-project/commit/3811673a0c39ed6bd2ad96ebf87ee883e31e31f9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-21 (Thu, 21 Apr 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Option to break in given functions.

Summary:
Added option "-break-funcs=func1,func2,...." to coredump in any
given function by introducing ud2 sequence at the beginning of the
function. Useful for debugging and validating stack traces.

Also renamed options containing "_" to use "-" instead.

Also run hhvm test with "-update-debug-sections".

(cherry picked from FBD3210248)


  Commit: 1258903b54421073123e92c8b3f99dce51c9c540
      https://github.com/llvm/llvm-project/commit/1258903b54421073123e92c8b3f99dce51c9c540
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-26 (Tue, 26 Apr 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix for functions in different segments.

Summary:
In a test binary some functions are placed in a segment
preceding the segment containing .text section. As a result,
we were miscalculating maximum function size as the calculation
was based on addresses only.

This diff fixes the calculation by checking if symbol after function
belongs to the same section.  If it does not, then we set the maximum
function size based on the size of the containing section and not
on the address distance to the next symbol.

(cherry picked from FBD3229205)


  Commit: de95a5b6a43d9e200d428f8b31285101f65d67ac
      https://github.com/llvm/llvm-project/commit/de95a5b6a43d9e200d428f8b31285101f65d67ac
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-04-27 (Wed, 27 Apr 2016)

  Changed paths:
    M bolt/DataReader.h

  Log Message:
  -----------
  Make merge-fdata generate smaller .fdata files.

Summary:
A lot of the space in the merged .fdata is taken by branches
to and from [heap], which is jitted code. On different machines,
or during different runs, jitted addresses are all different.
We don't use these addresses, but we need branch info to get
accurate function call counts.

This diff treats all [heap] addresses the same, resulting in a
simplified merged file. The size of the compressed file decreased
from 70MB to 8MB.

(cherry picked from FBD3233943)


  Commit: 459eb8c230e21312fb3b3bc08256260eec40b16d
      https://github.com/llvm/llvm-project/commit/459eb8c230e21312fb3b3bc08256260eec40b16d
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-28 (Thu, 28 Apr 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix "Cannot update ranges for DIE at offset" error messages.

Summary:
Fix the error message by not printing it :)

Explanation: a previous diff accidentally removed this error message from within
the DEBUG macro, and it's expected that we'll have a bunch of them since a lot
of the DIEs we try to update are empty or meaningless. For instance (and mainly), there
is a huge number of lexical block DIEs with no attributes in .debug_info.
In the first phase of collecting debugging info, we store the offsets of all
these DIEs, only later to realize that we cannot update their address
ranges because they have none.

A better fix would be to check this earlier and not store offsets of DIEs
we cannot update to begin with.

(cherry picked from FBD3236923)


  Commit: e6acc7bb53dd1c258cd433e44a4183b6b89edb3e
      https://github.com/llvm/llvm-project/commit/e6acc7bb53dd1c258cd433e44a4183b6b89edb3e
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-15 (Fri, 15 Apr 2016)

  Changed paths:
    A bolt/BinaryPassManager.cpp
    A bolt/BinaryPassManager.h
    A bolt/BinaryPasses.cpp
    M bolt/CMakeLists.txt
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Optimize calls to functions that are a single unconditional jump

Summary:
Many functions (around 600) in the HHVM binary are simply
a single unconditional jump instruction to another function. These can
be trivially optimized by modifying the call sites to directly call the
branch target instead (because it also happens with more than one jump
in sequence, we do it iteratively).

This diff also adds a very simple analysis/optimization pass system in
which this pass is the first one to be implemented. A follow-up to this
could be to move the current optimizations to other passes.

(cherry picked from FBD3211138)


  Commit: d1f525499e94edbd2bbe8278ec2ab8fc5239cbc8
      https://github.com/llvm/llvm-project/commit/d1f525499e94edbd2bbe8278ec2ab8fc5239cbc8
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-15 (Fri, 15 Apr 2016)

  Changed paths:
    A bolt/BinaryPass.cpp
    A bolt/BinaryPass.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Optimize calls to functions that are a single unconditional jump

Summary:
Many functions (around 600) in the HHVM binary are simply
a single unconditional jump instruction to another function. These can
be trivially optimized by modifying the call sites to directly call the
branch target instead (because it also happens with more than one jump
in sequence, we do it iteratively).

This diff also adds a very simple analysis/optimization pass system in
which this pass is the first one to be implemented. A follow-up to this
could be to move the current optimizations to other passes.

(cherry picked from FBD3211138)


  Commit: 5fa128e7485c6b5305b6348a8404f27ebe1ef99e
      https://github.com/llvm/llvm-project/commit/5fa128e7485c6b5305b6348a8404f27ebe1ef99e
  Author: Gabriel Poesia <gpoesia at fb.com>
  Date:   2016-04-25 (Mon, 25 Apr 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.h
    R bolt/BinaryPass.cpp
    R bolt/BinaryPass.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/BinaryPasses.cpp
    A bolt/BinaryPasses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Inlining of small functions.

Summary:
Added an optimization pass of inlining calls to small functions (with only one
basic block). Inlining is done in a very simple way, inserting instructions to
simulate the changes to the stack pointer that call/ret would make before/after the
inlined function executes. Also, the heuristic prefers to inline calls that happen
in the hottest blocks (by looking at their execution count). Calls in cold blocks are
ignored.

(cherry picked from FBD3233516)


  Commit: f7e7e25b888c3c8b1ba41b017f4b76bb7247b54b
      https://github.com/llvm/llvm-project/commit/f7e7e25b888c3c8b1ba41b017f4b76bb7247b54b
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-05-02 (Mon, 02 May 2016)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Put all optimization passes under the pass manager.

Summary:
Move eliminate unreachable code, block reordering, and CFI/exception fixup
into official optimization passes.

(cherry picked from FBD3248991)


  Commit: b445f5eb7b6b48da9fe8e8d42a35469488b8b1ee
      https://github.com/llvm/llvm-project/commit/b445f5eb7b6b48da9fe8e8d42a35469488b8b1ee
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-11 (Wed, 11 May 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix issue with garbage address in .debug_line.

Summary:
While emitting debug lines for a function we don't overwrite, we
don't have a code section context that is needed by default
writing routine. Hence we have to emit end_sequence after the
last address, not at the end of section.

(cherry picked from FBD3291533)


  Commit: e63984f3257f68a0633900add836f403d7d8f5c9
      https://github.com/llvm/llvm-project/commit/e63984f3257f68a0633900add836f403d7d8f5c9
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-05-02 (Mon, 02 May 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  Patch forward jumping tail calls to prevent branch mispredictions.

Summary:
A simple optimization to prevent branch misprediction for tail calls.
Convert the sequence:

        j<cc> L1
        ...
    L1: jmp foo # tail call

into:

        j<cc> foo

but only if 'j<cc> foo' turns out to be a forward branch.

(cherry picked from FBD3234207)


  Commit: f047b9d43ad495164827471ce2ba508c1fad3f9f
      https://github.com/llvm/llvm-project/commit/f047b9d43ad495164827471ce2ba508c1fad3f9f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-16 (Mon, 16 May 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Overwrite contents of .debug_line section.

Summary:
Overwrite contents of .debug_line section since we don't reference
the original contents anymore. This saves ~100MB of HHVM binary.

(cherry picked from FBD3314917)


  Commit: 7ab3db129bbfbe17b2034f74f4429119ef803718
      https://github.com/llvm/llvm-project/commit/7ab3db129bbfbe17b2034f74f4429119ef803718
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-17 (Tue, 17 May 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Create DW_AT_ranges for compile units.

Summary:
Some compile unit DIEs might be missing DW_AT_ranges because they were
compiled without "-ffunction-sections" option. This diff adds the
attribute to all compile units.

If the section is not present, we need to create it. Will do it in a
separate diff.

(cherry picked from FBD3314984)


  Commit: cfa5d753eb9fa23ecce0a01e05d08d49b13e96f2
      https://github.com/llvm/llvm-project/commit/cfa5d753eb9fa23ecce0a01e05d08d49b13e96f2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-23 (Mon, 23 May 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.h
    M bolt/DebugData.cpp
    M bolt/DebugData.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Miscellaneous fixes for debug info.

Summary:
* Fix several cases for handling debug info:
  - properly update CU DW_AT_ranges for function with folded body
    due to ICF optimization
  - convert ranges to DW_AT_ranges from hi/low PC for all DIEs
  - add support for [a, a) range
  - update CU ranges even when there are no functions registered
* Overwrite .debug_ranges section instead of appending.
* Convert assertions in debug info handling part into warnings.

(cherry picked from FBD3339383)


  Commit: 7b97793b94e9db4ec708d12f7c93ca18364569e3
      https://github.com/llvm/llvm-project/commit/7b97793b94e9db4ec708d12f7c93ca18364569e3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-24 (Tue, 24 May 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix for clang .debug_info.

Summary:
Clang uses different attribute for high_pc which
was incompatible with the way we were updating
ranges. This diff fixes it.

(cherry picked from FBD3345537)


  Commit: 06b9c5b34271d933e9263e5e8d6b398088f684d4
      https://github.com/llvm/llvm-project/commit/06b9c5b34271d933e9263e5e8d6b398088f684d4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-24 (Tue, 24 May 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Better .debug_line for non-simple functions.

Summary:
Generate .debug_line info for non-simple functions in a way
that if preferrable by 'objdump -S'.

(cherry picked from FBD3345485)


  Commit: fb5f18b2dc0751435c58492bea8434415d269811
      https://github.com/llvm/llvm-project/commit/fb5f18b2dc0751435c58492bea8434415d269811
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-05-23 (Mon, 23 May 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/DataReader.cpp
    M bolt/DataReader.h

  Log Message:
  -----------
  Correctly updating landing pad exec counts.

(cherry picked from FBD28110316)


  Commit: 485f9220b75cea2b67d38c452d29c2fbfc592b4b
      https://github.com/llvm/llvm-project/commit/485f9220b75cea2b67d38c452d29c2fbfc592b4b
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-05-24 (Tue, 24 May 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Taking LP counts into account for FT count inference

(cherry picked from FBD28110493)


  Commit: 65ac8bbdf2352d6edaf7581e484951ee1436d597
      https://github.com/llvm/llvm-project/commit/65ac8bbdf2352d6edaf7581e484951ee1436d597
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-05-26 (Thu, 26 May 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Better edge counts for fall through blocks in presence of C++ exceptions.

Summary: The inference algorithm for counts of fall through edges takes possible jumps to landing pad blocks into account. Also, the landing pad block execution counts are updated using profile data.

(cherry picked from FBD3350727)


  Commit: 4460da0d81668596e2846e0100221828a5930938
      https://github.com/llvm/llvm-project/commit/4460da0d81668596e2846e0100221828a5930938
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-27 (Fri, 27 May 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DebugData.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Improvements for debug info.

Summary:
Assembly functions could have no corresponding DW_AT_subprogram
entries, yet they are represented in module ranges (and .debug_aranges)
and will have line number information. Make sure we update those.

Eliminated unnecessary data structures and optimized some passes.

For .debug_loc unused location entries are no longer processed
resulting in smaller output files.

Overall it's a small processing time improvement and memory imporement.

(cherry picked from FBD3362540)


  Commit: 6da0d953260423c2d4048c4681e8ee3cb29cf3ea
      https://github.com/llvm/llvm-project/commit/6da0d953260423c2d4048c4681e8ee3cb29cf3ea
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-31 (Tue, 31 May 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix large functions debug info by default.

Summary:
Turn on -fix-debuginfo-large-functions by default.

In the process of testing I've discovered that we output cold code
for functions that were too large to be emitted. Fixed that.

(cherry picked from FBD3372697)


  Commit: 45e2219ae4085d54667df1c9044f05dc5702a076
      https://github.com/llvm/llvm-project/commit/45e2219ae4085d54667df1c9044f05dc5702a076
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Allocate BinaryBasicBlocks with new rather than storing them in the BasicBlocks vector.

Summary: This will help optimization passes that need to modify the CFG after it is constructed.  Otherwise, the BinaryBasicBlock pointers stored in the layout, successors and predecessors would need to be modified every time a new basic block is created.

(cherry picked from FBD3403372)


  Commit: 8bcfd9a39257e8df079f2c22a4611e9f92e4d22a
      https://github.com/llvm/llvm-project/commit/8bcfd9a39257e8df079f2c22a4611e9f92e4d22a
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-06-07 (Tue, 07 Jun 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h

  Log Message:
  -----------
  Indirect call optimization.

(cherry picked from FBD28110629)


  Commit: 980a06265af93a2170fce3f2b691698e416a1d95
      https://github.com/llvm/llvm-project/commit/980a06265af93a2170fce3f2b691698e416a1d95
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-06-08 (Wed, 08 Jun 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h

  Log Message:
  -----------
  Revert "Indirect call optimization."

This reverts commit 33966090e18545b64013614e7929ff1bdcdf10d5.

(cherry picked from FBD28110782)


  Commit: 88ac5d9d0e8ae85291dd0c3eeb79768642a7f47a
      https://github.com/llvm/llvm-project/commit/88ac5d9d0e8ae85291dd0c3eeb79768642a7f47a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-06-09 (Thu, 09 Jun 2016)

  Changed paths:
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [merge-fdata] Add option to print function list.

Summary:
Print total number of functions/objects that have profile
and add new options:

  -print      - print the list of objects with count to stderr
    =none     -   do not print objects/functions
    =exec     -   print functions sorted by execution count
    =branches -   print functions sorted by total branch count
  -q          - do not print merged data to stdout

(cherry picked from FBD3442288)


  Commit: 70f82d9371d39a0aa4e1ba3eb28406529046b0a3
      https://github.com/llvm/llvm-project/commit/70f82d9371d39a0aa4e1ba3eb28406529046b0a3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-06-15 (Wed, 15 Jun 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Reject profile data for functions that do not match.

Summary:
Verify profile data for a function and reject if there are branches
that don't correspond to any branches in the function CFG. Note that
we have to ignore branches resulting from recursive calls.

Fix printing instruction offsets in disassembled state.

Allow function to have non-zero execution count even if we don't
have branch information.

(cherry picked from FBD3451596)


  Commit: f1192a7118a5eac3c4314302cb84f42712ceab15
      https://github.com/llvm/llvm-project/commit/f1192a7118a5eac3c4314302cb84f42712ceab15
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-06-10 (Fri, 10 Jun 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Support for multiple function names.

Summary:
With ICF optimization in the linker we were getting mismatches of
function names in .fdata and BinaryFunction name. This diff adds
support for multiple function names for BinaryFunction and
does a match against all possible names for the profile.

(cherry picked from FBD3466215)


  Commit: d09b00ebff7b7b60b0f599e750e445ea8c209056
      https://github.com/llvm/llvm-project/commit/d09b00ebff7b7b60b0f599e750e445ea8c209056
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-06-16 (Thu, 16 Jun 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/CMakeLists.txt
    A bolt/ReorderAlgorithm.cpp
    A bolt/ReorderAlgorithm.h

  Log Message:
  -----------
  Refactoring of the reordering algorithms

Summary:
The various reorder and clustering algorithms have been refactored
into separate classes, so that it is easier to add new algorithms and/or
change the logic of algorithm selection.

(cherry picked from FBD3473656)


  Commit: 287fa51324aae8f8dfc393f1314504909586556d
      https://github.com/llvm/llvm-project/commit/287fa51324aae8f8dfc393f1314504909586556d
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-06-27 (Mon, 27 Jun 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Fix for ignoring fall-through profile data when jump is followed by no-op

Summary:
When a conditional jump is followed by one or more no-ops, the
destination of fall-through branch was recorded as the first no-op in
FuncBranchInfo. However the fall-through basic block after the jump
starts after the no-ops, so the profile data could not match the CFG
and was ignored.

(cherry picked from FBD3496084)


  Commit: 6eb4e5b6878a8bfb1bacf73925316d1b097fb737
      https://github.com/llvm/llvm-project/commit/6eb4e5b6878a8bfb1bacf73925316d1b097fb737
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-06-21 (Tue, 21 Jun 2016)

  Changed paths:
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  perf2bolt can extract branch records with histories

Summary:
Added perf2bolt functionality for extracting branch records
with histories of previous branches. The length of the histories
is user defined, and the default is 0 (previous functionality). Also,
DataReader can parse perf2bolt output with histories.
Note: creating profile data with long histories can increase their
size significantly (2x for history of length 1, 3x for length 2 etc).

(cherry picked from FBD3473983)


  Commit: 260f6fbdb6c2d0ab1ed6abc46a3dcdab380b9127
      https://github.com/llvm/llvm-project/commit/260f6fbdb6c2d0ab1ed6abc46a3dcdab380b9127
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-01 (Fri, 01 Jul 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Add option to dump CFGs in (simple) graphviz format during all passes.

Summary:
I noticed the BinaryFunction::viewGraph() method that hadn't been implemented
and decided I could use a simple DOT dumper for CFGs while working on the indirect
call optimization.

I've implemented the bare minimum for the dumper.  It's just nodes+BB labels with
dges. We can add more detailed information as needed/desired.

(cherry picked from FBD3509326)


  Commit: c20506c5709b7aa4a613176f138b43c2459a6bb0
      https://github.com/llvm/llvm-project/commit/c20506c5709b7aa4a613176f138b43c2459a6bb0
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-07-03 (Sun, 03 Jul 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Fix in inferFallthroughCounts

Summary:
This fixes the initialization of basic block execution counts, where
we should skip edges to the first basic block but we were not
skipping the corresponding profile info.

Also, I removed a check that was done twice.

(cherry picked from FBD3519265)


  Commit: 90c9323511de81a7b13a68c5fd89feb48b439259
      https://github.com/llvm/llvm-project/commit/90c9323511de81a7b13a68c5fd89feb48b439259
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-07 (Thu, 07 Jul 2016)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/ReorderAlgorithm.cpp
    M bolt/ReorderAlgorithm.h

  Log Message:
  -----------
  Use unordered_map instead of map in ReorderAlgorithm and BinaryFunction::BasicBlockIndices.

Summary:
Use unordered_map instead of map in ReorderAlgorithm and BinaryFunction::BasicBlockIndices.
Cuts about 30sec off the processing time for the hhvm binary. (~8.5 min to ~8min)

(cherry picked from FBD3530910)


  Commit: bdd4af21340591a9b9270867cc142b65d274bff8
      https://github.com/llvm/llvm-project/commit/bdd4af21340591a9b9270867cc142b65d274bff8
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-07 (Thu, 07 Jul 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Store index inside BinaryBasicBlock instead of in map on BinaryFunction.

Summary:
Store the basic block index inside the BinaryBasicBlock instead of a map in BinaryFunction.
This cut another 15-20 sec. from the processing time for hhvm.

(cherry picked from FBD3533606)


  Commit: 84b5b9e4628b5481ef903b2a27c972499c4f7d33
      https://github.com/llvm/llvm-project/commit/84b5b9e4628b5481ef903b2a27c972499c4f7d33
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-07-11 (Mon, 11 Jul 2016)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Create alternative name for local symbols.

Summary:
If a profile data was collected on a stripped binary but an input
to BOLT is unstripped, we would use a different mangling scheme for
local functions and ignore their profiles. To solve the issue this
diff adds alternative name for all local functions such that one
of the names would match the name in the profile.

If the input binary was stripped, we reject it, unless "-allow-stripped"
option was passed. It's more complicated to do a matching in this case
since we have less information than at the time of profile collection.
It's also not that simple to tell if the profile was gathered on a
stripped binary (in which case we would have no issue matching data).

(cherry picked from FBD3548012)


  Commit: 674dbcc0de71b082ae51c52481186e7aa7562e82
      https://github.com/llvm/llvm-project/commit/674dbcc0de71b082ae51c52481186e7aa7562e82
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-12 (Tue, 12 Jul 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix crash in patchELFPHDRTable when no functions are modified.

Summary:
patchELFPHDRTable was asserting that it could not find an entry
for .eh_frame_hdr in SectionMapInfo when no functions were modified
by BOLT.

This just changes code to skip modifying GNU_EH_FRAME program headers
hen SectionMapInfo is empty.  The existing header is copied and written
instead.

(cherry picked from FBD3557481)


  Commit: bf46263eed318fbba77a5ec386aab11792cbd3ee
      https://github.com/llvm/llvm-project/commit/bf46263eed318fbba77a5ec386aab11792cbd3ee
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-07-19 (Tue, 19 Jul 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Shorten instructions if possible.

Summary:
Generate short versions of branch instructions by default and rely on
relaxation to produce longer versions when needed.

Also produce short versions of arithmetic instructions if immediate
fits into one byte. This was only triggered once on HHVM binary.

(cherry picked from FBD3591466)


  Commit: f2d82919d07661958514723f081e4ef15e725449
      https://github.com/llvm/llvm-project/commit/f2d82919d07661958514723f081e4ef15e725449
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-05-31 (Tue, 31 May 2016)

  Changed paths:
    M bolt/CMakeLists.txt
    A bolt/DWARFRewriter.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Move debug-handling code into DWARFRewriter (NFC).

Summary: RewriteInstance.cpp is getting too big. Split the code.

(cherry picked from FBD3596103)


  Commit: c6d0c568d43b2657bdf691e09fdd60b9f1cdde1e
      https://github.com/llvm/llvm-project/commit/c6d0c568d43b2657bdf691e09fdd60b9f1cdde1e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-07-21 (Thu, 21 Jul 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Add BinaryContext::getSectionForAddress()

Summary: Interface for accessing section from BinaryContext.

(cherry picked from FBD3600854)


  Commit: ea53cffb2d363f75eceb4a8d36c12791a57519ed
      https://github.com/llvm/llvm-project/commit/ea53cffb2d363f75eceb4a8d36c12791a57519ed
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-21 (Thu, 21 Jul 2016)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Add movabs -> mov shortening optimization.  Add peephole optimization pass that does instruction shortening.

Summary:
Shorten when a mov instruction has a 64-bit immediate that can be repesented as
a sign extended 32-bit number, use the smaller mov instruction (MOV64ri -> MOV64ri32).

Add peephole optimization pass that does instruction shortening.

(cherry picked from FBD3603099)


  Commit: 17b846586cd0e46cc454a97f019f0468f8952a7f
      https://github.com/llvm/llvm-project/commit/17b846586cd0e46cc454a97f019f0468f8952a7f
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-05-26 (Thu, 26 May 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    A bolt/BinaryLoop.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Loop detection for BOLT's CFG.

Summary:
Loop detection for the CFG data structure. Added a GraphTraits
specialization for BOLT's CFG that allows us to use LLVM's loop
detection interface.

(cherry picked from FBD3604837)


  Commit: 156a55209c9bd421a6c75652c8139f042516a1e6
      https://github.com/llvm/llvm-project/commit/156a55209c9bd421a6c75652c8139f042516a1e6
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-06-03 (Fri, 03 Jun 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Simplification of loads from read-only data sections.

Summary:
Instructions that load data from the a read-only data section and their
target address can be computed statically (e.g. RIP-relative addressing)
are modified to corresponding instructions that use immediate operands.
We apply the transformation only when the resulting instruction will have
smaller or equal size.

(cherry picked from FBD3397112)


  Commit: 82401630a22b4051532a2203beb7d2cc6a021d01
      https://github.com/llvm/llvm-project/commit/82401630a22b4051532a2203beb7d2cc6a021d01
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-23 (Sat, 23 Jul 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Factor out instruction printing and size computation.

Summary:
I've factored out the instruction printing and size computation routines to
methods on BinaryContext.  I've also added some more debug print functions.

This was split off the ICP diff to simplify it a bit.

(cherry picked from FBD3610690)


  Commit: a9bb3320ad6f8e87e22b0ff60cd004f0de3f8157
      https://github.com/llvm/llvm-project/commit/a9bb3320ad6f8e87e22b0ff60cd004f0de3f8157
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-06-09 (Thu, 09 Jun 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Identical Code Folding (ICF) pass

Summary:
Added an ICF pass to BOLT, that can recognize identical functions
and replace references to these functions with references to just one
representative.

(cherry picked from FBD3460297)


  Commit: ab599fe71a7b02fa4f8ceaaadaca988c2c7dc1a1
      https://github.com/llvm/llvm-project/commit/ab599fe71a7b02fa4f8ceaaadaca988c2c7dc1a1
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-07-15 (Fri, 15 Jul 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/ReorderAlgorithm.cpp
    M bolt/ReorderAlgorithm.h

  Log Message:
  -----------
  Basic block clustering algorithm for minimizing branches.

Summary:
This algorithm is similar to our main clustering algorithm but uses
a different heuristic for selecting edges to become fall-throughs.
The weight of an edge is calculated as the win in branches if we choose
to layout this edge as a fall-through. For example, the edges A -> B with
execution count 100 and A -> C with execution count 500 (where B and C
are the only successors of A) have weights -400 and +400 respectively.

(cherry picked from FBD3606591)


  Commit: 50e011f4e54c317b2fe3e7d9406e20347ba4a5ee
      https://github.com/llvm/llvm-project/commit/50e011f4e54c317b2fe3e7d9406e20347ba4a5ee
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-23 (Sat, 23 Jul 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  CFG editing functions

Summary:
This diff adds a number of methods to BinaryFunction that can be used to edit the CFG after it is created.

The basic public functions are:
  - createBasicBlock - create a new block that is not inserted into the CFG.
  - insertBasicBlocks - insert a range of blocks (made with createBasicBlock) into the CFG.
  - updateLayout - update the CFG layout (either by inserting new blocks at a certain point or recomputing the entire layout).
  - fixFallthroughBranch - add a direct jump to the fallthrough successor for a given block.

There are a number of private helper functions used to implement the above.

This was split off the ICP diff to simplify it a bit.

(cherry picked from FBD3611313)


  Commit: 486ab273c7d003f30fe9cab8cd0ae81c7ede313f
      https://github.com/llvm/llvm-project/commit/486ab273c7d003f30fe9cab8cd0ae81c7ede313f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-07-28 (Thu, 28 Jul 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Add printing support for indirect tail calls.

Summary:
LLVM was missing assembler print string for indirect tail
calls which are synthetic instructions created by us.

(cherry picked from FBD3640197)


  Commit: 713e361f3616dd08ccaae53bfb1cab7a5bb66358
      https://github.com/llvm/llvm-project/commit/713e361f3616dd08ccaae53bfb1cab7a5bb66358
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-07-13 (Wed, 13 Jul 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h

  Log Message:
  -----------
  Fix for correct disassembling of conditional tail calls.

Summary:
BOLT attempts to convert jumps that serve as tail calls to dedicated tail call
instructions, but this is impossible when the jump is conditional because there is
no corresponding tail call instruction. This was causing the creation of a duplicate
fall-through edge for basic blocks terminated with a conditional jump serving as
a tail call when there is profile data available for the non-taken branch. In this
case, the first fall-through edge had a count taken from the profile data, while
the second has a count computed (incorrectly) by
BinaryFunction::inferFallThroughCounts.

(cherry picked from FBD3560504)


  Commit: 82d76ae18b084458e0a0c8992fe47320467eb1e8
      https://github.com/llvm/llvm-project/commit/82d76ae18b084458e0a0c8992fe47320467eb1e8
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-28 (Thu, 28 Jul 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/Exceptions.cpp

  Log Message:
  -----------
  Add MCInst annotation mechanism to MCInstrAnalysis class.

Summary:
Add three new MCOperand types: Annotation, LandingPad and GnuArgsSize.

Annotation is used for associating random data with MCInsts.  Clients can
construct their own annotation types (subclassed from MCAnnotation) and
associate them with instructions.  Annotations are looked up by string keys.

Annotations can be added, removed and queried using an instance of the
MCInstrAnalysis class.

The LandingPad operand is a MCSymbol, uint64_t pair used to encode exception
handling information for call instructions.

GnuArgsSize is used to annotate calls with the DW_CFA_GNU_args_size attribute.

(cherry picked from FBD3597877)


  Commit: 32739247ebd175a875f307a39504c38187c90cf9
      https://github.com/llvm/llvm-project/commit/32739247ebd175a875f307a39504c38187c90cf9
  Author: Theodoros Kasampalis <theo25 at fb.com>
  Date:   2016-07-29 (Fri, 29 Jul 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  More aggressive inlining pass

Summary:
This adds functionality for a more aggressive inlining pass, that can
inline tail calls and functions with more than one basic block.

(cherry picked from FBD3677856)


  Commit: 36df6057b01417df0842628a61bbbf09ff9bb2e6
      https://github.com/llvm/llvm-project/commit/36df6057b01417df0842628a61bbbf09ff9bb2e6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-08-07 (Sun, 07 Aug 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/DWARFRewriter.cpp
    M bolt/DebugData.cpp
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Refactoring. Mainly NFC.

Summary:
Eliminated BinaryFunction::getName(). The function was confusing since
the name is ambigous. Instead we have BinaryFunction::getPrintName()
used for printing and whenever unique string identifier is needed
one can use getSymbol()->getName(). In the next diff I'll have
a map from MCSymbol to BinaryFunction in BinaryContext to facilitate
function lookup from instruction operand expressions.

There's one bug fixed where the function was called only under assert()
in ICF::foldFunction().

For output we update all symbols associated with the function. At the
moment it has no effect on the generated binary but in the future we
would like to have all symbols in the symbol table updated.

(cherry picked from FBD3704790)


  Commit: 003d106c0b2b84b32397686456cdb58b3353845b
      https://github.com/llvm/llvm-project/commit/003d106c0b2b84b32397686456cdb58b3353845b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-08-11 (Thu, 11 Aug 2016)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/DebugData.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  More refactoring work.

Summary:
Avoid referring to BinaryFunction's by name.

Functions could be found by MCSymbol using
BinaryContext::getFunctionForSymbol().

(cherry picked from FBD3707685)


  Commit: 406aa6208399c9e8eec4c1e92a4d64df58b8667a
      https://github.com/llvm/llvm-project/commit/406aa6208399c9e8eec4c1e92a4d64df58b8667a
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-29 (Fri, 29 Jul 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Add additional info to BOLT graphviz CFG dumps.

Summary:
Add the following info the graphviz CFG dump:
- Edges are labeled with the jmp instruction that leads to that edge.
- Edges include the count and misprediction count.
- Nodes have (offset, BB index, BB layout index)
- Nodes optionally have tooltips which contain the code of the basic block.
  (enabled with -dot-tooltip-code)
- Added dashed edges to landing pads.

(cherry picked from FBD3646568)


  Commit: c1d1c2e7cda6fd6c0b47ebd8a2683b0b196e6813
      https://github.com/llvm/llvm-project/commit/c1d1c2e7cda6fd6c0b47ebd8a2683b0b196e6813
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-07-22 (Fri, 22 Jul 2016)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Check if operands are immediates before trying shortening.

Summary:
Operands in the initial instruction stream should all have immediate operands
for instructions that can be shortened.  But if a BOLT optimization pass adds
one of these instructions with a symbolic operand, the shortening operation
will assert.  This diff adds checks to make sure that the operands are
immediate.

I've also disabled shortening pass by default since it won't really be needed
until ICP is submitted.  It will still run at CFG creation time.

(cherry picked from FBD3610646)


  Commit: a10fb73ab3b939920356f879e3e5172fdf09bd01
      https://github.com/llvm/llvm-project/commit/a10fb73ab3b939920356f879e3e5172fdf09bd01
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-08-15 (Mon, 15 Aug 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/ReorderAlgorithm.cpp
    M bolt/ReorderAlgorithm.h

  Log Message:
  -----------
  Compute ClusterEdges only when necessary.

Summary:
We only need ClusterEdges in reordering algorithm optimized for
branches and the computation is quite resource-hungry, thus it
makes sense to only do it when needed.

Some refactoring too.

(cherry picked from FBD3721107)


  Commit: 42c5894fe246dd3f79ea7d799a8d4da9513b66aa
      https://github.com/llvm/llvm-project/commit/42c5894fe246dd3f79ea7d799a8d4da9513b66aa
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-08-19 (Fri, 19 Aug 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Write padding for .eh_frame_hdr to a file.

Summary:
We were applying padding to the calculated address but were never
writing it to a file triggering an assertion for cases when
.gcc_except_table size wasn't multiple of 4.

(cherry picked from FBD3744638)


  Commit: 97f598fd17bc7aafd056211b288a0d7e0466478c
      https://github.com/llvm/llvm-project/commit/97f598fd17bc7aafd056211b288a0d7e0466478c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-08-22 (Mon, 22 Aug 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Handling for indirect tail calls.

Summary:
Analyze indirect branches and convert them into indirect
tail calls when possible. We analyze the memory contents
when the address could be calculated statically and also
detect epilogue code.

(cherry picked from FBD3754395)


  Commit: 43acb6a28ab052cb3d4e8ca647dbdb3f4d883299
      https://github.com/llvm/llvm-project/commit/43acb6a28ab052cb3d4e8ca647dbdb3f4d883299
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-08-24 (Wed, 24 Aug 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Emit remember_state CFI in the same code region as restore_state.

Summary:
While creating remember_state/restore_state CFI sequences, we
were always placing remember_state instruction into the first
basic block. However, when we have hot-cold splitting, the cold
part has and independent FDE entry in .eh_frame, and thus the
restore_state instruction was missing its counter part.

The fix is to adjust the basic block that is used for placing
remember_state instruction whenever we see the hot-cold split
boundary.

(cherry picked from FBD3767102)


  Commit: c27a6a5c63dfabe0a53e2f4b2c1f372f96330035
      https://github.com/llvm/llvm-project/commit/c27a6a5c63dfabe0a53e2f4b2c1f372f96330035
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-02 (Fri, 02 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPasses.cpp
    M bolt/DWARFRewriter.cpp
    M bolt/DebugData.cpp
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Add verbosity level and clean up stream usage.

Summary:
I've added a verbosity level to help keep the BOLT spewage to a minimum.
The default level is pretty terse now, level 1 is closer to the original,
I've saved level 2 for the noisiest of messages.  Error messages should
never be suppressed by the verbosity level only warnings and info messages.

The rational behind stream usage is as follows:
outs() for info and debugging controlled by command line flags.
errs() for errors and warnings.
dbgs() for output within DEBUG().

With the exception of a few of the level 2 messages I don't have any strong feelings about the others.

(cherry picked from FBD3814259)


  Commit: 1cf200107edd2a2d7f4775d236f03c8e1704932f
      https://github.com/llvm/llvm-project/commit/1cf200107edd2a2d7f4775d236f03c8e1704932f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-06 (Tue, 06 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Fix tail call conversion and test cases.

Summary:
A previous diff accidentally disabled tail call conversion.

Additionally some test cases relied on output of "-v=2". Fix those.

(cherry picked from FBD3823760)


  Commit: dcaffe64d339a8436aae626a6f21d235f3f61101
      https://github.com/llvm/llvm-project/commit/dcaffe64d339a8436aae626a6f21d235f3f61101
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-02 (Fri, 02 Sep 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Inlining fixes/enhancements

Summary:
A number of fixes/enhancements to inline-small-functions
- Fixed size estimateHotSize to use computeCodeSize instead of the original layout offsets.
- Added -print-inline option to dump CFGs for functions that have been modified by inlining.
- Added flag to force consideration of functions without any profiling info (mostly for testing)
- Updated debug line info for inlined functions.
- Ignore the number of pseudo instructions when checking for candidates of suitable size.

Misc changes
- Moved most print flags to BinaryPasses.cpp

(cherry picked from FBD3812658)


  Commit: 48b55300e0ac4b084466669c0134b17139a83bb6
      https://github.com/llvm/llvm-project/commit/48b55300e0ac4b084466669c0134b17139a83bb6
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-07 (Wed, 07 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/Exceptions.cpp
    M bolt/ReorderAlgorithm.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  BOLT: Make most command line options ZeroOrMore.

Summary:
This will make it easier to run experiments with the same baseline
BOLT binary but different command line options.

(cherry picked from FBD3831978)


  Commit: 17e691915bfccbce750fa92eb208dfbdd11c1c4a
      https://github.com/llvm/llvm-project/commit/17e691915bfccbce750fa92eb208dfbdd11c1c4a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-08-29 (Mon, 29 Aug 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  Make BinaryFunction::fixBranches() more flexible and support CFG updates.

Summary:
The CFG represents "the ultimate source of truth". Transformations
on functions and blocks have to update the CFG and fixBranches() would
make sure the correct branch instructions are inserted at the end of
basic blocks (or removed when necessary).

We do require a conditional branch at the end of the basic block if
the block has 2 successors as CFG currently lacks the conditional
code support (it will probably stay that way). We only use this
branch instruction for its conditional code, the destination is
determined by CFG - first successor representing true/taken branch,
while the second successor - false/fall-through branch.

When we reverse the branch condition, the CFG is updated accordingly.

The previous version used to insert jumps after some terminating
instructions sometimes resulting in a larger code than needed. As a
result with the new version 1 extra function becomes overwritten for
HHVM binary.

With this diff we also convert conditional branches with one successor
(result of code from __builtin_unreachable()) into unconditional
jumps.

(cherry picked from FBD3802062)


  Commit: 6bef336cc2ebfefb3b724dedf9dc7fd23c147b7e
      https://github.com/llvm/llvm-project/commit/6bef336cc2ebfefb3b724dedf9dc7fd23c147b7e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-08-29 (Mon, 29 Aug 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Add dyno stats to BOLT.

Summary:
Add "-dyno-stats" option that prints instruction stats based on
the execution profile similar to below:

BOLT-INFO: program-wide dynostats after optimizations:
  executed forward branches : 109706407 (+8.1%)
  taken forward branches : 13769074 (-55.5%)
  executed backward branches : 24517582 (-25.0%)
  taken backward branches : 15330256 (-27.2%)
  executed unconditional branches : 6009826 (-35.5%)
  function calls : 17192114 (+0.0%)
  executed instructions : 837733057 (-0.4%)
  total branches : 140233815 (-2.3%)
  taken branches : 35109156 (-42.8%)

Also fixed pseudo instruction discrepancies and added assertions
for BinaryBasicBlock::getNumPseudos() to make sure the number is
synchronized with real number of pseudo instructions.

(cherry picked from FBD3826995)


  Commit: c4c518ee9d9bb45daaadd0b6b0094548373f6fde
      https://github.com/llvm/llvm-project/commit/c4c518ee9d9bb45daaadd0b6b0094548373f6fde
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-08 (Thu, 08 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Rewrite SCTC pass to do UCE and make it the last optimization pass.

Summary:
For now we make SCTC a special pass that runs at the end of all
optimizations and transformations right after fixupBranches().

Since it's the last pass, it has to do its own UCE.

(cherry picked from FBD3838051)


  Commit: 71be5679694c9b12928d4c6f63adbea770cdaba5
      https://github.com/llvm/llvm-project/commit/71be5679694c9b12928d4c6f63adbea770cdaba5
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-09 (Fri, 09 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  BOLT: Add per pass dyno stats + factor out post pass printing.

Summary:
I've added dyno stats printing per pass so we can see the results
of each optimization pass on the stats.  I've also factored out the
post pass function printing code since it was pretty much the same
after each pass.

(cherry picked from FBD3843587)


  Commit: 617c6a13b793917b249f72e37ac67ffad21ba08b
      https://github.com/llvm/llvm-project/commit/617c6a13b793917b249f72e37ac67ffad21ba08b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-09 (Fri, 09 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPasses.cpp
    M bolt/ReorderAlgorithm.cpp

  Log Message:
  -----------
  Use BB.getNumNonPseudos() in more places.

Summary:
Use BB.getNumNonPseudos() in more places.

Fix analyze_potential script to pass the new parameter.

(cherry picked from FBD3844416)


  Commit: 861d5a1586a4406f48b96f272487aead2fdb8dc0
      https://github.com/llvm/llvm-project/commit/861d5a1586a4406f48b96f272487aead2fdb8dc0
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-02 (Fri, 02 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  BOLT: Remove double jumps peephole.

Summary:
Replace jumps to other unconditional jumps with the final
destination, e.g.

  B0: ...
      jmp B1  (or jcc B1)

  B1: jmp B2

  ->

  B0: ...
      jmp B2  (or jcc B1)

This peephole removes 8928 double jumps from a test binary.

Note: after filtering out double jumps found in EH code and infinite
loops, the number of double jumps patched is 49 (24 for a clang
compiled test).  The 24 in the clang build are all from external
libraries which have probably been compiled with gcc.  This peephole
is still useful for cleaning up after ICP though.

(cherry picked from FBD3815420)


  Commit: 52bfc3f92f42b3b1f91139565315a230396cd2fd
      https://github.com/llvm/llvm-project/commit/52bfc3f92f42b3b1f91139565315a230396cd2fd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-12 (Mon, 12 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Fix switch table detection. Disassemble all instructions in non-simple functions.

Summary:
Switch table can contain __builtin_unreachable(). As a result,
a compiler may place an entry into a jump table that contains
an address immediately past the last instruction in the function.
Sometimes it may coincide with a start of the next function in
the binary. Thus when we check for switch tables in such cases
we have to check more than a single entry until we see either
an address inside containing function or some address outside
different from the address past the last instruction.

Additonally, don't stop disassembly after discovering that the
function was not simple. We need to detect all outside
references whenever possible.

(cherry picked from FBD3850825)


  Commit: b0f4031db33409d3c9c60bc7591e5e78976ad6ca
      https://github.com/llvm/llvm-project/commit/b0f4031db33409d3c9c60bc7591e5e78976ad6ca
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-11 (Sun, 11 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/ReorderAlgorithm.cpp
    M bolt/ReorderAlgorithm.h

  Log Message:
  -----------
  Add cluster randomization layout algorithm.

Summary:
Add "-reorder-blocks=cluster-shuffle" for performance experiments.
Use "-bolt-seed=<N>" to set a randomization seed.

(cherry picked from FBD3851035)


  Commit: 7483cd0fa694aec103b16029b07353a30548a919
      https://github.com/llvm/llvm-project/commit/7483cd0fa694aec103b16029b07353a30548a919
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-13 (Tue, 13 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp

  Log Message:
  -----------
  BOLT: Clean up interface between BinaryFunction and BinaryBasicBlock.

Summary:
This is just a bit of refactoring to make sure that BinaryFunction goes
through methods to get at the state in BinaryBasicBlock.  I did this so
that changing the way Index/LayoutIndex/Valid works will be easier.

(cherry picked from FBD3860899)


  Commit: 2f3a85977298a5dcd610bfa074940762e148ec1e
      https://github.com/llvm/llvm-project/commit/2f3a85977298a5dcd610bfa074940762e148ec1e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-14 (Wed, 14 Sep 2016)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/ReorderAlgorithm.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Add experimental jump table support.

Summary:
Option "-jump-tables=1" enables experimental support for jump tables.

The option hasn't been tested with optimizations other than block
re-ordering.

Only non-PIC jump tables are supported at the moment.

(cherry picked from FBD3867849)


  Commit: 8dbf0e2b3d7be8a5b97173c9c834c94b20e7fec0
      https://github.com/llvm/llvm-project/commit/8dbf0e2b3d7be8a5b97173c9c834c94b20e7fec0
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-15 (Thu, 15 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Add dyno stats for jump tables.

Summary: Add dyno stats for jump tables.

(cherry picked from FBD3871035)


  Commit: c4e36c1dd6bdd6172183d458aef0d65fbe20e2f5
      https://github.com/llvm/llvm-project/commit/c4e36c1dd6bdd6172183d458aef0d65fbe20e2f5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-15 (Thu, 15 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix issue with zero-size duplicate function symbols.

Summary:
While working on PLT dyno stats I've noticed that we were missing
BinaryFunctions for some symbols that were not PLT. Upon closer inspection
turned out that those symbols were marked as zero-sized functions in
symbol table, but they had duplicates with non-zero size. Since the
zero-size symbols were preceding other duplicates, we were not creating
BinaryFunction for them and they were not added as duplicates.

The 2 most prominent functions that were missing for a test were free() and
malloc().  There's not much to optimize in these functions, but they were
contributing quite significantly to dyno stats.

As a result dyno stats for this test needed an adjustment.

Also several assembly functions (e.g. _init()) had zero size, and now we
set the size to the max size and start processing those. It's good for
coverage but will not affect the performance.

(cherry picked from FBD3874622)


  Commit: 2c9bf9afd65701ce40ddb9802efc099ed16892ea
      https://github.com/llvm/llvm-project/commit/2c9bf9afd65701ce40ddb9802efc099ed16892ea
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-15 (Thu, 15 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Add PLT dyno stats.

Summary: Get PLT call stats.

(cherry picked from FBD3874799)


  Commit: 62bff426c3b90b5c471d3d2b7e0889ea02dc9a1c
      https://github.com/llvm/llvm-project/commit/62bff426c3b90b5c471d3d2b7e0889ea02dc9a1c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-16 (Fri, 16 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Do no collect dyno stats on functions with stale profile.

Summary:
Dyno stats collected on functions with invalid profile may appear
completely bogus. Skip them.

(cherry picked from FBD3879371)


  Commit: 510f227cbd3d4e699c535cc743036b6420ae3ee1
      https://github.com/llvm/llvm-project/commit/510f227cbd3d4e699c535cc743036b6420ae3ee1
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-20 (Tue, 20 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  BOLT: Add feature to sort functions by dyno stats.

Summary:
Add -print-sorted-by and -print-sorted-by-order command line options.
The first option takes a list of dyno stats keys used to sort functions
that are printed at the end of all optimization passes.  Only the top
100 functions are printed.  The -print-sorted-by-order option can be
either ascending or descending (descending is the default).

(cherry picked from FBD3898818)


  Commit: 2f1341b51da00ba6a4a15cde00350744fc70f2cd
      https://github.com/llvm/llvm-project/commit/2f1341b51da00ba6a4a15cde00350744fc70f2cd
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-13 (Tue, 13 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/DebugData.cpp
    M bolt/ReorderAlgorithm.cpp

  Log Message:
  -----------
  BOLT: Refactoring BinaryFunction interface.

Summary:
Get rid of all uses of getIndex/getLayoutIndex/getOffset outside of BinaryFunction.
Also made some other offset related methods private.

(cherry picked from FBD3861968)


  Commit: ecc4b9e713508b5c6cb41d12467b122ee51497ee
      https://github.com/llvm/llvm-project/commit/ecc4b9e713508b5c6cb41d12467b122ee51497ee
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-13 (Tue, 13 Sep 2016)

  Changed paths:
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  BOLT: Add ud2 after indirect tailcalls.

Summary:
Insert ud2 instructions after indirect tailcalls to prevent the CPU from
decoding instructions following the callsite.

A simple counter in the peephole pass shows 3260 tail call traps inserted.

(cherry picked from FBD3859737)


  Commit: 4464861a02e2a2815530d3ffd6edd68684d9d2de
      https://github.com/llvm/llvm-project/commit/4464861a02e2a2815530d3ffd6edd68684d9d2de
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-16 (Fri, 16 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Support for splitting jump tables.

Summary:
Add level for "-jump-tables=<n>" option:
  1 - all jump tables are output in the same section (default).
  2 - basic splitting, if the table is used it is output to hot section
      otherwise to cold one.
  3 - aggressively split compound jump tables and collect profile for
      all entries.

Option "-print-jump-tables" outputs all jump tables for debugging
and/or analyzing purposes. Use with "-jump-tables=3" to get profile
values for every entry in a jump table.

(cherry picked from FBD3912119)


  Commit: 4a0c494bc10eec3637fb1179aeea85137b1b1271
      https://github.com/llvm/llvm-project/commit/4a0c494bc10eec3637fb1179aeea85137b1b1271
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-07 (Wed, 07 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/DebugData.cpp

  Log Message:
  -----------
  BOLT: Remove restrictions on unreachable code elimination

Summary:
Allow UCE when blocks have EH info.  Since UCE may remove blocks
that are referenced from debugging info data structures, we don't
actually delete them.  We just mark them with an "invalid" index
and store them in a different vector to be cleaned up later once
the BinaryFunction is destroyed.  The debugging code just skips
any BBs that have an invalid index.

Eliminating blocks may also expose useless jmp instructions, i.e.
a jmp around a dead block could just be a fallthrough.  I've added
a new routine to cleanup these jmps.  Although, @maks is working on
changing fixBranches() so that it can be used instead.

(cherry picked from FBD3793259)


  Commit: 9cf5d74ffb983b250be5cccc836041d5681ddea3
      https://github.com/llvm/llvm-project/commit/9cf5d74ffb983b250be5cccc836041d5681ddea3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-27 (Tue, 27 Sep 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Support for PIC-style jump tables.

Summary:
Added support for jump tables in code compiled with "-fpic".
Code pattern generated for position-independent jump tables
is quite different, as is the format of the tables.
More details in comments.

Coverage increased slightly for a test, mostly due to the code
coming from external lib that was compiled with "-fpic".

(cherry picked from FBD3940771)


  Commit: e241e9c156b0a9036ee84ce2bebeb6627806acea
      https://github.com/llvm/llvm-project/commit/e241e9c156b0a9036ee84ce2bebeb6627806acea
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-29 (Thu, 29 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  New function discovery and support for multiple entries.

Summary:
Modified function discovery process to tolerate more functions and
symbols coming from assembly. The processing order now matches
the memory order of the functions (input symbol table is unsorted).

Added basic support for functions with multiple entries. When
a function references its internal address other than with
a branch instruction, that address could potentially escape.
We mark such addresses as entry points and make sure they
are treated as roots by unreachable code elimination.

Without relocations we have to mark multiple-entry functions
as non-simple.

(cherry picked from FBD3950243)


  Commit: 0eb2559feeff1060920d433ac41affa976c2e37e
      https://github.com/llvm/llvm-project/commit/0eb2559feeff1060920d433ac41affa976c2e37e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-10-07 (Fri, 07 Oct 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix EH for cold fragments that we fail to write.

Summary:
When we fail to write functions that are too big, we have to
effectively cancel their effect on exception handling by ignoring
their FDE entries in .eh_frame while writing .eh_frame_hdr.

This can happen to functions that we split too. In such cases
the cold part has its own FDE and we have to ignore that one too.
This doesn't happen very often - I've only seen one case on
hhvm binary, however it is a potential issue. The fix is to
add the cold part address to the list of failed-to-write
addresses.

(cherry picked from FBD3987984)


  Commit: 99dce7d05e4ee7f62e1a864de6e0d7a3643624fd
      https://github.com/llvm/llvm-project/commit/99dce7d05e4ee7f62e1a864de6e0d7a3643624fd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-10-16 (Sun, 16 Oct 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  Disable processing of functions with EVEX-encoded instructions (AVX-512).

Summary:
AVX-512 disassembler support in LLVM is not quite ready yet.
Before we feel more comfortable about it we disable processing
of all functions that use any EVEX-encoded instructions.

(cherry picked from FBD4028706)


  Commit: bc8cb088c0ec5e502f850a4420cbb99613f3e530
      https://github.com/llvm/llvm-project/commit/bc8cb088c0ec5e502f850a4420cbb99613f3e530
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-15 (Tue, 15 Nov 2016)

  Changed paths:
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Support DWARF expressions in CFI instructions

Summary:
Modify the MC layer (MCDwarf.h|cpp) to understand CFI
instructions dealing with DWARF expressions. Add code to emit DWARF
expressions in MCDwarf. Change llvm-bolt to pass these CFI instructions
to streamer instead of bailing on them. Change -dump-eh-frame option in
llvm-bolt to dump the EH frame of the rewritten binary in addition to
the one in the original binary, allowing us to proper test this patch.

(cherry picked from FBD4194452)


  Commit: 355dbd769e5ddab5e72ebc00e38567858309d730
      https://github.com/llvm/llvm-project/commit/355dbd769e5ddab5e72ebc00e38567858309d730
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-16 (Wed, 16 Nov 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Fix DW_CFA_def_cfa CFI duping in output binary

Summary:
CFI instructions may live in CIEs or FDEs. CIEs hold common
instructions used across many FDEs. When replaying CFIs to the output
binary, llvm-bolt needs to replay both instructions from CIE and the
corresponding FDE for the function. However, some instructions need not
to be replayed because MCStreamer/MCDwarf and friends will write them
by default in the output CIE. This patch fix the code that tried to
recognize one of these default instructions but was failing, resulting
in an extra CFI instruction in each FDE we outputted. With this patch,
the output binary should be a bit smaller.

(cherry picked from FBD4194753)


  Commit: 055dfe48e712baae4805d36f77f81c8fa40e8e5f
      https://github.com/llvm/llvm-project/commit/055dfe48e712baae4805d36f77f81c8fa40e8e5f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-11-09 (Wed, 09 Nov 2016)

  Changed paths:
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Another EH fix for cold fragments of functions that we fail to write.

Summary:
In a prev diff I disabled inclusion of FDEs for cold fragments that
we fail to write. The side effect of it was that we failed to
write FDE for the next function with a cold fragment since it
had the same assigned address that we had put in FailedAddresses.

The correct fix is to assign zero address to failed cold fragments
and ignore them when we write .eh_frame_hdr.

(cherry picked from FBD4156740)


  Commit: 809c28f585bb9e087ea2c449d2da0c9d829d25a2
      https://github.com/llvm/llvm-project/commit/809c28f585bb9e087ea2c449d2da0c9d829d25a2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-11-14 (Mon, 14 Nov 2016)

  Changed paths:
    M bolt/Exceptions.cpp
    M bolt/Exceptions.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Generate .eh_frame_hdr based on contents of .eh_frame's.

Summary:
We used to patch an existing .eh_frame_hdr and append contents
for split functions at the end. However, this approach does not
work in relocation mode since function addresses change and split
functions will not necessarily be at the end.

Instead of patching and appending we generate the new .eh_frame_hdr
based on contents of old and new .eh_frame sections.

(cherry picked from FBD4180756)


  Commit: a7fb610eba625df8797f98883ca8691b88c1090a
      https://github.com/llvm/llvm-project/commit/a7fb610eba625df8797f98883ca8691b88c1090a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-11-11 (Fri, 11 Nov 2016)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Exceptions.cpp
    M bolt/Exceptions.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Relocate old .eh_frame section next to the new one.

Summary:
In order to improve gdb experience with BOLT we have to make
sure the output file has a single .eh_frame section. Otherwise
gdb will use either old or new section for unwinding purposes.

This diff relocates the original .eh_frame section next to
the new one generated by LLVM. Later we merge two sections
into one and make sure only the newly created section has
.eh_frame name.

(cherry picked from FBD4203943)


  Commit: 8609ad51e504028fa23270caf59ccb966020a44b
      https://github.com/llvm/llvm-project/commit/8609ad51e504028fa23270caf59ccb966020a44b
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-17 (Thu, 17 Nov 2016)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Detect default CFI frame instructions for the target

Summary:
Make BOLT resilient to changes in the LLVM's X86 target library
by not hardwiring the list of default CIE instructions, but detecting it
at run time.

(cherry picked from FBD4200982)


  Commit: ac2621fbf456c40a3e2b9d9b52234307cef37634
      https://github.com/llvm/llvm-project/commit/ac2621fbf456c40a3e2b9d9b52234307cef37634
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-10-12 (Wed, 12 Oct 2016)

  Changed paths:
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  Add stats for "-optimize-bodyless-functions".

Summary: Print the number of calls eliminated.

(cherry picked from FBD4010698)


  Commit: 7115706d02175fc62384d9ae173c548e0e71bd20
      https://github.com/llvm/llvm-project/commit/7115706d02175fc62384d9ae173c548e0e71bd20
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-28 (Mon, 28 Nov 2016)

  Changed paths:
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Fix clang warning about switch covering all enums

Summary:
This is part of a series of clean-up patches to make bolt
cleanly compile with clang 4.0. This patch fixes the following warning:
default label in switch which covers all enumeration values

(cherry picked from FBD4242168)


  Commit: b21bc02ac4e5dfcc30beadadacc3802b6ac53b81
      https://github.com/llvm/llvm-project/commit/b21bc02ac4e5dfcc30beadadacc3802b6ac53b81
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-28 (Mon, 28 Nov 2016)

  Changed paths:
    M bolt/BinaryPasses.cpp

  Log Message:
  -----------
  Remove pessimizing std::move

Summary:
This is part of a series of clean-up patches to make bolt
cleanly compile with clang 4.0. This patch fixes the following warning:
moving a temporary object prevents copy elision

(cherry picked from FBD4242236)


  Commit: 5cc9c5841064b1ffa13efbd63d39c1edf9301911
      https://github.com/llvm/llvm-project/commit/5cc9c5841064b1ffa13efbd63d39c1edf9301911
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-28 (Mon, 28 Nov 2016)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Avoid const_iterator on std::vector::emplace

Summary:
This is part of a series of clean-up patches to make bolt
cleanly compile with clang 4.0. This patch fixes an error where clang
will fail to compile because it does not support passing a
const_iterator to std::vector<T>::emplace(Iter, ...).

(cherry picked from FBD4242546)


  Commit: a331fa396bc4a26067320f800f81a20abd0d4612
      https://github.com/llvm/llvm-project/commit/a331fa396bc4a26067320f800f81a20abd0d4612
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-29 (Tue, 29 Nov 2016)

  Changed paths:
    M bolt/DWARFRewriter.cpp

  Log Message:
  -----------
  Fix memory leak in DWARFRewriter

Summary:
Clang's Address Sanitizer caught this leak where MCAsmBackend
and MCObjectWriter instances were being created but not freed. Fix this.

(cherry picked from FBD4249941)


  Commit: 5c0e4b6a574198c9d02beed282adc68f47f24850
      https://github.com/llvm/llvm-project/commit/5c0e4b6a574198c9d02beed282adc68f47f24850
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-30 (Wed, 30 Nov 2016)

  Changed paths:
    M bolt/Exceptions.cpp

  Log Message:
  -----------
  Fix undefined behavior in DebugInfo

Summary:
The CFI instructions parser in libDebugInfo was relying on
undefined behavior to parse operands by assuming the order function
parameters are evaluated in a function call site is defined (it is
not). This patch fix this and makes our clang and gcc tests agree.
It also fixes wrong LIT tests in our codebase with respect to the
order of DW_CFA_def_cfa operands.

(cherry picked from FBD4255227)


  Commit: 3888c5604f73d2daafb28205c2e8b460372184ac
      https://github.com/llvm/llvm-project/commit/3888c5604f73d2daafb28205c2e8b460372184ac
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-11-30 (Wed, 30 Nov 2016)

  Changed paths:
    M bolt/Exceptions.h

  Log Message:
  -----------
  Remove unused private var in CFIReaderWriter (NFC)

Summary: This member variable is dead.

(cherry picked from FBD4255342)


  Commit: c570038d319a0ff30376b56c31ae8614db2a1978
      https://github.com/llvm/llvm-project/commit/c570038d319a0ff30376b56c31ae8614db2a1978
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-12-08 (Thu, 08 Dec 2016)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h

  Log Message:
  -----------
  Add option to time passes

Summary:
As we begin to work on optimization passes for bolt, it is important to
keep track of the time spent in each of these to measure their
contribution to the time bolt takes to finish rewriting a program.

(cherry picked from FBD4301136)


  Commit: 06caefdb1d1b2cc520ce6b1bbdc369bbd24cfd55
      https://github.com/llvm/llvm-project/commit/06caefdb1d1b2cc520ce6b1bbdc369bbd24cfd55
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-12-08 (Thu, 08 Dec 2016)

  Changed paths:
    M bolt/BinaryPassManager.cpp

  Log Message:
  -----------
  Fix typo in time passes

Summary:
Previously NamedRegionTimer's constructor was being called
with no local variable associated with it owing to a typo. We need a
local variable to keep track of the time spent in the scope. At the
end of the scope, the destructor will be called an then the timer will
stop.

(cherry picked from FBD4301844)


  Commit: 3a3dfc3dc25c36700f2367821d0f5ba360cad5d9
      https://github.com/llvm/llvm-project/commit/3a3dfc3dc25c36700f2367821d0f5ba360cad5d9
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-22 (Thu, 22 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  BOLT: Use profiling info to control branch simplification optimization.

Summary:
An optimization to simplify conditional tail calls by removing unnecessary branches.  It adds the following two command line options:

  -simplify-conditional-tail-calls  - simplify conditional tail calls by removing unnecessary jumps
  -sctc-mode                        - mode for simplify conditional tail calls
    =always                         -   always perform sctc
    =preserve                       -   only perform sctc when branch direction is preserved
    =heuristic                      -   use branch prediction data to control sctc

This optimization considers both of the following cases:

  foo: ...
       jcc L1   original
       ...
  L1:  jmp bar  # TAILJMP

->

  foo: ...
       jcc bar  iff jcc L1 is expected
       ...

  L1 is unreachable

OR

  foo: ...
       jcc  L2
  L1:  jmp  dest  # TAILJMP
  L2:  ...

->

  foo: jncc dest  # TAILJMP
  L2:  ...

  L1 is unreachable

For this particular case, the first basic block ends with a conditional branch and has two successors, one fall-through and one for when the condition is true.  The target of the conditional is a basic block with a single unconditional branch (i.e. tail call) to another function.  We don't care about the contents of the fall-through block.

(cherry picked from FBD3719617)


  Commit: a75bbfc6401aa209b2ad07aa67716aab32e16b76
      https://github.com/llvm/llvm-project/commit/a75bbfc6401aa209b2ad07aa67716aab32e16b76
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-12-05 (Mon, 05 Dec 2016)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/CMakeLists.txt
    A bolt/FrameOptimizerPass.cpp
    A bolt/FrameOptimizerPass.h

  Log Message:
  -----------
  Add a frame optimization pass

Summary:
This is a first attempt to perform data flow analyses on bolt
and try to rebuild the stack frame for functions. The goal of the frame
optimization pass is to detect instructions that are accessing stack and,
if loading values, evaluate whether this load is redundant and we can
substitute the memory operation for a register load or immediate load.
To find opportunities, this pass also builds a map of clobbered registers
by function, so we use this in our analysis at call sites. If a call site
is found out to not clobber a caller-saved register but the caller is
spilling it anyway to the stack (to comply with the ABI), we should
detect these cases and remove this unnecessary move.

(cherry picked from FBD4337238)


  Commit: 55fc5417f854dbc704254fe5de714b675553ab06
      https://github.com/llvm/llvm-project/commit/55fc5417f854dbc704254fe5de714b675553ab06
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-09-27 (Tue, 27 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/Exceptions.cpp
    M bolt/Exceptions.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Relocations support for BOLT.

Summary: Read relocation from linker and relocate all functions.

(cherry picked from FBD4223901)


  Commit: bc8a456309e62efae9afedc8340f97a510fa4ad9
      https://github.com/llvm/llvm-project/commit/bc8a456309e62efae9afedc8340f97a510fa4ad9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2016-12-21 (Wed, 21 Dec 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/ReorderAlgorithm.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  ICF improvements.

Summary:
Re-worked the way ICF operates. The pass now checks for more than just
call instructions, but also for all references including function
pointers. Jump tables are handled too.

(cherry picked from FBD4372491)


  Commit: 08949053730dc619e71885034b9295e216889900
      https://github.com/llvm/llvm-project/commit/08949053730dc619e71885034b9295e216889900
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-01-10 (Tue, 10 Jan 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPasses.cpp

  Log Message:
  -----------
  [ICF] Don't re-fold functions in non-relocation mode.

Summary:
In-non relocation mode, when we run ICF the second time,
we fold the same functions again since they were not
removed from the function set. This diff marks them as
folded and ignores them during ICF optimization. Note
that we still want to optimize such functions since they
are potentially called from the code not covered by BOLT
in non-relocation mode.

Folded functions are also excluded from dyno stats with
this diff

Also print the number of times folded functions were called.
When 2 functions -  f1() and f2() are folded, that number
would be min(call_frequency(f1), call_frequency(f2)).

(cherry picked from FBD4399993)


  Commit: 19859377f8c435a6f8e80be14385ea7c2a01cffd
      https://github.com/llvm/llvm-project/commit/19859377f8c435a6f8e80be14385ea7c2a01cffd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-01-18 (Wed, 18 Jan 2017)

  Changed paths:
    M bolt/DebugData.cpp
    M bolt/DebugData.h

  Log Message:
  -----------
  [BOLT] Fix debug info update for zero-length ranges.

Summary:
Due to a clowntown on my part we were generating wrong ranges
when an empty range was seen on input. We were basically expanding
the range to include all basic blocks following such range and setting
wrong sizes at the same time.

Add "-dump-cu" option to llvm-dwarfdump that allows to look at debug
info of a single compile unit only. Saves time if we are only interested
in a subset of information.

(cherry picked from FBD4430989)


  Commit: 503c741d430a3b7e71f87903d2845af8a15981c0
      https://github.com/llvm/llvm-project/commit/503c741d430a3b7e71f87903d2845af8a15981c0
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-01-23 (Mon, 23 Jan 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Report stale functions' percentage wrt all profiled functions.

Summary:
Report stale functions percentage with respect to all profiled
functions instead of all simple functions in the binary.
The new reporting format should make it more apparent if the
profile is out-of-date. Compare:

  BOLT-INFO: 341 (16.7% of all profiled) functions have invalid (possibly
stale) profile.

vs old:

  BOLT-INFO: 341 (0.3%)  functions have invalid (possibly stale) profile.

(cherry picked from FBD4451746)


  Commit: 6dfd16cb4c8b56df0ca2683a920086d89c16292d
      https://github.com/llvm/llvm-project/commit/6dfd16cb4c8b56df0ca2683a920086d89c16292d
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2016-12-28 (Wed, 28 Dec 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.h
    M bolt/FrameOptimizerPass.cpp
    M bolt/FrameOptimizerPass.h

  Log Message:
  -----------
  Cover RSP-indexed accesses in frame optimization

Summary:
Add a new dataflow analysis to recover the value of RSP at a
given point of the program. This value is expressed as an offset from
the CFA. Use this information to detect redundant load in memory
accesses performed via RSP as well, not only RBP as done previously.
Bail when RSP value (as an offset of the CFA) can't be reliably
determined with a simple dataflow analysis.

(cherry picked from FBD4372261)


  Commit: 6ff1795d969a918bd1b57641be13867ba3aae0b9
      https://github.com/llvm/llvm-project/commit/6ff1795d969a918bd1b57641be13867ba3aae0b9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-01-17 (Tue, 17 Jan 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DWARFRewriter.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Support overwriting jump tables in-place.

Summary:
Add an option to overwrite jump tables without moving and make it a
default:

  -jump-tables   - jump tables support (default=basic)
    =none        -   do not optimize functions with jump tables
    =basic       -   optimize functions with jump tables
    =move        -   move jump tables to a separate section
    =split       - split jump tables section into hot and cold based on
                   function execution frequency
    =aggressive  - aggressively split jump tables section based on usage of
                   the tables

(cherry picked from FBD4448499)


  Commit: d74997c3ccf333161c4d6712bd1efde942ff61b6
      https://github.com/llvm/llvm-project/commit/d74997c3ccf333161c4d6712bd1efde942ff61b6
  Author: Bill Nell <bnell at fb.com>
  Date:   2016-09-07 (Wed, 07 Sep 2016)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Indirect call promotion optimization.

Summary:
Perform indirect call promotion optimization in BOLT.

The code scans the instructions during CFG creation for all
indirect calls.  Right now indirect tail calls are not handled
since the functions are marked not simple.  The offsets of the
indirect calls are stored for later use by the ICP pass.

The indirect call promotion pass visits each indirect call and
examines the BranchData for each.  If the most frequent targets
from that callsite exceed the specified threshold (default 90%),
the call is promoted.  Otherwise, it is ignored.  By default,
only one target is considered at each callsite.

When an candiate callsite is processed, we modify the callsite
to test for the most common call targets before calling through
the original generic call mechanism.

The CFG and layout are modified by ICP.

A few new command line options have been added:
-indirect-call-promotion
-indirect-call-promotion-threshold=<percentage>
-indirect-call-promotion-topn=<int>

The threshold is the minimum frequency of a call target needed
before ICP is triggered.

The topn option controls the number of targets to consider for
each callsite, e.g. ICP is triggered if topn=2 and the total
requency of the top two call targets exceeds the threshold.

Example of ICP:

C++ code:

  int B_count = 0;
  int C_count = 0;

  struct A { virtual void foo() = 0; }
  struct B : public A { virtual void foo() { ++B_count; }; };
  struct C : public A { virtual void foo() { ++C_count; }; };

  A* a = ...
  a->foo();
  ...

original:
  400863:	49 8b 07             	mov    (%r15),%rax
  400866:	4c 89 ff             	mov    %r15,%rdi
  400869:	ff 10                	callq  *(%rax)
  40086b:	41 83 e6 01          	and    $0x1,%r14d
  40086f:	4d 89 e6             	mov    %r12,%r14
  400872:	4c 0f 44 f5          	cmove  %rbp,%r14
  400876:	4c 89 f7             	mov    %r14,%rdi
  ...

after ICP:
  40085e:	49 8b 07             	mov    (%r15),%rax
  400861:	4c 89 ff             	mov    %r15,%rdi
  400864:	49 ba e0 0b 40 00 00 	movabs $0x400be0,%r10
  40086b:	00 00 00
  40086e:	4c 3b 10             	cmp    (%rax),%r10
  400871:	75 29                	jne    40089c <main+0x9c>
  400873:	41 ff d2             	callq  *%r10
  400876:	41 83 e6 01          	and    $0x1,%r14d
  40087a:	4d 89 e6             	mov    %r12,%r14
  40087d:	4c 0f 44 f5          	cmove  %rbp,%r14
  400881:	4c 89 f7             	mov    %r14,%rdi
  ...

  40089c:	ff 10                	callq  *(%rax)
  40089e:	eb d6                	jmp    400876 <main+0x76>

(cherry picked from FBD3612218)


  Commit: e212805ea6f5454f4eb7928deb935a001f19389b
      https://github.com/llvm/llvm-project/commit/e212805ea6f5454f4eb7928deb935a001f19389b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-07 (Tue, 07 Feb 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Update section names in output file.

Summary:
Re-write section header string table to reflect new names
given to sections. Old sections get ".bolt.org" prefix.

E.g. when we write ".eh_frame" section, we keep the old copy
but rename it to ".bolt.org.eh_frame".

Note: the new code section is named ".bolt.text" - it contains split
function bodies, while original ".text" name is left unchanged.

(cherry picked from FBD4524935)


  Commit: c89821cee3426a7fe20efca3ef39570a8bdf597c
      https://github.com/llvm/llvm-project/commit/c89821cee3426a7fe20efca3ef39570a8bdf597c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-07 (Tue, 07 Feb 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Detect and prevent re-optimization attempts.

Summary:
Whenever we try to re-optimize a binary with BOLT we should
issue an error and exit.

(cherry picked from FBD4525228)


  Commit: 6b0b5bbae7034b27823c2a09d9844c0f6fc31f47
      https://github.com/llvm/llvm-project/commit/6b0b5bbae7034b27823c2a09d9844c0f6fc31f47
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-07 (Tue, 07 Feb 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Reject sanitized binaries.

Summary:
Whenever input binary is suspected to have been sanitized we print an error
message and exit. I've checked that "__asan_init*" symbol
presence is the most conservative way to detect "sanitization".

(cherry picked from FBD4525478)


  Commit: 734a7a5437d92463c86c3cc5371ae27571d7adfe
      https://github.com/llvm/llvm-project/commit/734a7a5437d92463c86c3cc5371ae27571d7adfe
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-08 (Wed, 08 Feb 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Skip disassembly of padding at function end.

Summary:
Some functions coming from assembly may not have been marked
with size. We assume the size to include all bytes up to
the next function/object in the file. As a result,
function body will include any padding inserted by the linker.
If linker inserts 0-value bytes this could be misinterpreted
as invalid instruction and BOLT will bail out on such functions
in non-relocation mode, and give up on a binary in relocation
mode.

This diff detects zero-padding, ignores it, and continues processing
as normal.

(cherry picked from FBD4528893)


  Commit: 82965b963f366d106595d32e445a089e1a890092
      https://github.com/llvm/llvm-project/commit/82965b963f366d106595d32e445a089e1a890092
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-13 (Mon, 13 Feb 2017)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPasses.cpp
    M bolt/BinaryPasses.h

  Log Message:
  -----------
  [BOLT] Emit short tail calls in relocation mode.

Summary:
To minimize size of the output code we should emit tail calls
that are as short as possible. For this we have to convert a synthetic
TAILJMPd into JMP_1 instruction. This should be one of the last passes
as most of analysis passes could break since tail calls will no longer
be marked as such.

The total size of the code is smaller, but not by much - hot text was
reduced by 192 bytes.

(cherry picked from FBD4557804)


  Commit: f06a1455eac57aa3ddcbc156c8b9496224dc9539
      https://github.com/llvm/llvm-project/commit/f06a1455eac57aa3ddcbc156c8b9496224dc9539
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-14 (Tue, 14 Feb 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add support for *GOTPCRELX relocation type.

Summary:
gcc5 can generate new types of relocations that give linker a freedom
to substitute instructions. These relocations are PC-relative, and
since we manually process such relocations they don't present
much of a problem.

Additionally, detect non-pc-relative access from code into a middle of
a function. Occasionally I've seen such code, but don't know exactly
how to trigger its generation. Just issue a warning for now.

(cherry picked from FBD4566473)


  Commit: 88244a10bb205f650a44590dcc8e184cd240a26d
      https://github.com/llvm/llvm-project/commit/88244a10bb205f650a44590dcc8e184cd240a26d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-16 (Thu, 16 Feb 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/CMakeLists.txt
    R bolt/FrameOptimizerPass.cpp
    R bolt/FrameOptimizerPass.h
    A bolt/Passes/BinaryPasses.cpp
    A bolt/Passes/BinaryPasses.h
    A bolt/Passes/CMakeLists.txt
    A bolt/Passes/FrameOptimizer.cpp
    A bolt/Passes/FrameOptimizer.h
    A bolt/Passes/Inliner.cpp
    A bolt/Passes/Inliner.h
    A bolt/Passes/ReorderAlgorithm.cpp
    A bolt/Passes/ReorderAlgorithm.h

  Log Message:
  -----------
  [BOLT] Move BOLT passes under Passes subdirectory (NFC).

Summary:
Move passes under Passes subdirectory.

Move inlining passes under Passes/Inliner.*

(cherry picked from FBD4575832)


  Commit: d3e33b6edc12c12fffd2f53b6af64e94ec874f5c
      https://github.com/llvm/llvm-project/commit/d3e33b6edc12c12fffd2f53b6af64e94ec874f5c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-21 (Tue, 21 Feb 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix -jump-tables=basic in relocation mode.

Summary:
In a prev diff I added an option to update jump tables in-place (on by default)
and accidentally broke the default handling of jump tables in relocation
mode. The update should be happening semi-automatically, but because
we ignore relocations for jump tables it wasn't happening (derp).

Since we mostly use '-jump-tables=move' this hasn't been noticed for
some time.

This diff gets rid of IgnoredRelocations and removes relocations
from a relocation set when they are no longer needed. If relocations
are created later for jump tables they are no longer ignored.

(cherry picked from FBD4595159)


  Commit: 88a461014b6c064dc23151912e692d0796cf66e4
      https://github.com/llvm/llvm-project/commit/88a461014b6c064dc23151912e692d0796cf66e4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-22 (Wed, 22 Feb 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Don't set code skew in relocations mode.

Summary:
We use code skew in non-relocation mode since functions have fixed
addresses, and internal alignment has to be adjusted wrt the skew.
However in relocation mode it interferes with effective code
alignment, and has to be disabled. I missed it when was re-basing
the relocation diff.

(cherry picked from FBD4599670)


  Commit: 2029458f347c7a9658e0464b22298f83b0c70093
      https://github.com/llvm/llvm-project/commit/2029458f347c7a9658e0464b22298f83b0c70093
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-23 (Thu, 23 Feb 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h

  Log Message:
  -----------
  [BOLT] Strip 'repz' prefix from 'repz retq'.

Summary:
Add pass to strip 'repz' prefix from 'repz retq' sequence. The prefix
is not used in Intel CPUs afaik. The pass is on by default.

(cherry picked from FBD4610329)


  Commit: 965a373dc491064cf7fd05113247f275e984c00d
      https://github.com/llvm/llvm-project/commit/965a373dc491064cf7fd05113247f275e984c00d
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-02-27 (Mon, 27 Feb 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/Passes/BinaryPasses.h

  Log Message:
  -----------
  Fix warnings when compiling with clang (NFC)

Summary:
Fix inconsistent override keyword usages and initializes a
missing field of a Relocation object when using braced initializers.

(cherry picked from FBD4622856)


  Commit: 6dc2351505b3a1d570bf4d9ae9a5dc6e55dd6e1b
      https://github.com/llvm/llvm-project/commit/6dc2351505b3a1d570bf4d9ae9a5dc6e55dd6e1b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-24 (Fri, 24 Feb 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/Exceptions.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] New CFI handling policy.

Summary:
The new interface for handling Call Frame Information:

  * CFI state at any point in a function (in CFG state) is defined by
    CFI state at basic block entry and CFI instructions inside the
    block. The state is independent of basic blocks layout order
    (this is implied by CFG state but wasn't always true in the past).
  * Use BinaryBasicBlock::getCFIStateAtInstr(const MCInst *Inst) to
    get CFI state at any given instruction in the program.
  * No need to call fixCFIState() after any given pass. fixCFIState()
    is called only once during function finalization, and any function
    transformations after that point are prohibited.
  * When introducing new basic blocks, make sure CFI state at entry
    is set correctly and matches CFI instructions in the basic block
    (if any).
  * When splitting basic blocks, use getCFIStateAtInstr() to get
    a state at the split point, and set the new basic block's CFI
    state to this value.

Introduce CFG_Finalized state to indicate that no further optimizations
are allowed on the function. This state is reached after we have synced
CFI instructions and updated EH info.

Rename "-print-after-fixup" option to "-print-finalized".

This diffs fixes CFI for cases when we split conditional tail calls,
and for indirect call promotion optimization.

(cherry picked from FBD4629307)


  Commit: f241e252fc987de8d382432dc6a2b16abe66c0d6
      https://github.com/llvm/llvm-project/commit/f241e252fc987de8d382432dc6a2b16abe66c0d6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-03 (Fri, 03 Mar 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/CMakeLists.txt
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/CMakeLists.txt
    A bolt/Passes/HFSort.cpp
    A bolt/Passes/HFSort.h
    A bolt/Passes/HFSortPlus.cpp
    M bolt/Passes/ReorderAlgorithm.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Detect and handle __builtin_unreachable().

Summary:
Calls to __builtin_unreachable() can result in a inconsistent CFG.
It was possible for basic block to end with a conditional branche
and have a single successor. Or there could exist non-terminated
basic block without successors.

We also often treated conditional jumps with destination past the end
of a function as conditional tail calls. This can be prevented
reliably at least when the byte past the end of the function does
not belong to the next function.

This diff includes several changes:
  * At disassembly stage jumps past the end of a function are converted
    into 'nops'. This is done only for cases when we can guarantee that
    the jump is not a tail call. Conversion to nop is required since the
    instruction could be referenced either by exception handling
    tables and/or debug info. Nops are later removed.
  * In CFG insert 'ret' into non-terminated basic blocks without
    successors (this almost never happens).
  * Conditional jumps at the end of the function are removed from
    CFG. The block will still have a single successor.
  * Cases where a destination of a jump instruction is the start
    of the next function, are still conservatively handled as
    (conditional) tail calls.

(cherry picked from FBD4655046)


  Commit: 0acba2bcf0cfbcc60755d9bae45b328bf905d435
      https://github.com/llvm/llvm-project/commit/0acba2bcf0cfbcc60755d9bae45b328bf905d435
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-02-21 (Tue, 21 Feb 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Detect unmarked data in text.

Summary:
Sometimes a code written in assembly will have unmarked data (such as
constants) embedded into text.

Typically such data falls into a "padding" address space of a function.

This diffs detects such references, and adjusts the padding space to
prevent overwriting of code in data.

Note that in relocation mode we prefer to overwrite the original code
(-use-old-text) and thus cannot simply ignore data in text.

(cherry picked from FBD4662780)


  Commit: fed0980139e4ee4d0de1316f2908942619f21fad
      https://github.com/llvm/llvm-project/commit/fed0980139e4ee4d0de1316f2908942619f21fad
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-02-27 (Mon, 27 Feb 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp

  Log Message:
  -----------
  [BOLT] Update tests

Summary:
Fix validateCFG to handle BBs that were generated from code that used
_builtin_unreachable().
Add -verify-cfg option to run CFG validation after every optimization
pass.

(cherry picked from FBD4641174)


  Commit: 98737b34bb987b9799a1bc6e821153b3f5dc3538
      https://github.com/llvm/llvm-project/commit/98737b34bb987b9799a1bc6e821153b3f5dc3538
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-07 (Tue, 07 Mar 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix verbose output.

Summary:
Inadvertently, output of BOLT became way too verbose. Discovered while
building HHVM on master.

(cherry picked from FBD4669881)


  Commit: f4825ea4171ae557b8ef2db1c401d4eb9086b674
      https://github.com/llvm/llvm-project/commit/f4825ea4171ae557b8ef2db1c401d4eb9086b674
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-07 (Tue, 07 Mar 2017)

  Changed paths:
    M bolt/BinaryPassManager.cpp

  Log Message:
  -----------
  [BOLT] Fix gcc5 build.

Summary: A <numeric> include is required for gcc5 build.

(cherry picked from FBD4671953)


  Commit: 2e5c2e689f750587d3a4f3f73a39fd93628c7692
      https://github.com/llvm/llvm-project/commit/2e5c2e689f750587d3a4f3f73a39fd93628c7692
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-03-07 (Tue, 07 Mar 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  Fix hfsort callgraph stats, add hfsort test.

Summary:
The stats for call sites that are not included in the call graph were broken.
The intention is to count the total number of call sites vs. the number of call sites that are ignored because they have targets that are not BinaryFunctions.

Also add a new test for hfsort.

(cherry picked from FBD4668631)


  Commit: 351af0c895bcebfa82fb15b3b6451901c6c6c0f0
      https://github.com/llvm/llvm-project/commit/351af0c895bcebfa82fb15b3b6451901c6c6c0f0
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-12 (Sun, 12 Mar 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Do not process empty functions.

Summary:
While running on a recent test binary BOLT failed with an error. We were
trying to process '__hot_end' (which is not really a function), and asserted
that it had no basic blocks.

This diff marks functions with empty basic blocks list as non-simple since
there's no need to process them.

(cherry picked from FBD4696517)


  Commit: 559a57a18186174322b361d0918eadb7e7c10022
      https://github.com/llvm/llvm-project/commit/559a57a18186174322b361d0918eadb7e7c10022
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-14 (Tue, 14 Mar 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Improve dynostats output.

Summary:
Reduce verbosity of dynostats to make them more readable.

  * Don't print "before" dynostats twice.
  * Detect if dynostats have changed after optimization and print
    before/after only if at least one metric have changed. Otherwise
    just print dynostats once and indicate "no change".
  * If any given metric hasn't changed, then print the difference as
    "(=)" as opposed to (+0.0%).

(cherry picked from FBD4705920)


  Commit: 6cfd7ac2d586f3a86f0d4d0f45d291a12f20b20e
      https://github.com/llvm/llvm-project/commit/6cfd7ac2d586f3a86f0d4d0f45d291a12f20b20e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-15 (Wed, 15 Mar 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Do not overwrite starting address in non-relocation mode.

Summary:
In non-relocation mode we shouldn't attemtp to change ELF
entry point.

What made matters worse - it broke '-max-funcs=' and '-funcs=' options
since an entry function more often than not was excluded from the list
of processed functions, and we were setting entry point to 0.

(cherry picked from FBD4720044)


  Commit: e6f96de4d0f97afb3769e9f6575ce66643878d2a
      https://github.com/llvm/llvm-project/commit/e6f96de4d0f97afb3769e9f6575ce66643878d2a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-17 (Fri, 17 Mar 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Add option to print only specific functions.

Summary:
Add option '-print-only=func1,func2,...' to print only functions
of interest. The rest of the functions are still processed and
optimized (e.g. inlined), but only the ones on the list are printed.

(cherry picked from FBD4734610)


  Commit: b1ef186ca94bad96ccbb9fe39059d3f9c7085361
      https://github.com/llvm/llvm-project/commit/b1ef186ca94bad96ccbb9fe39059d3f9c7085361
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-03-18 (Sat, 18 Mar 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Don't allow non-symbol targets in ICP

Summary:
ICP was letting through call targets that weren't symbols.  This diff
filters out the non-symbol targets before running ICP.

(cherry picked from FBD4735358)


  Commit: ad81bd677999174d6b841f0926e484d959bac871
      https://github.com/llvm/llvm-project/commit/ad81bd677999174d6b841f0926e484d959bac871
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-03-17 (Fri, 17 Mar 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  Change dynostats dynamic instruction count policy

Summary:
Also add LOAD/STORE counters.

(cherry picked from FBD4732284)


  Commit: d5a0264a9e678e2b62768b4c36010059b05b3706
      https://github.com/llvm/llvm-project/commit/d5a0264a9e678e2b62768b4c36010059b05b3706
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-22 (Wed, 22 Mar 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Issue error in relocs mode if input is lacking relocations.

Summary:
If we specify "-relocs" flag and an input has no relocations we
proceed with assumptions that relocations were there and break the
binary.

Detect the condition above, and reject the input.

(cherry picked from FBD4761239)


  Commit: 0bde796e50bae4d15c0e705e803e1c35bd5fa49a
      https://github.com/llvm/llvm-project/commit/0bde796e50bae4d15c0e705e803e1c35bd5fa49a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-28 (Tue, 28 Mar 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/Exceptions.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/Inliner.cpp
    M bolt/Passes/ReorderAlgorithm.cpp
    M bolt/RewriteInstance.cpp
    M bolt/llvm-bolt.cpp
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT] Organize options in categories for pretty printing (near NFC).

Summary:
Each BOLT-specific option now belongs to BoltCategory or BoltOptCategory.

Use alphabetical order for options in source code (does not affect
output).

The result is a cleaner output of "llvm-bolt -help" which does not
include any unrelated llvm options and is close to the following:

.....

BOLT generic options:

  -data=<string>                                       - <data file>
  -dyno-stats                                          - print execution info based on profile
  -hot-text                                            - hot text symbols support (relocation mode)
  -o=<string>                                          - <output file>
  -relocs                                              - relocation mode - use relocations to move functions in the binary
  -update-debug-sections                               - update DWARF debug sections of the executable
  -use-gnu-stack                                       - use GNU_STACK program header for new segment (workaround for issues with strip/objcopy)
  -use-old-text                                        - re-use space in old .text if possible (relocation mode)
  -v=<uint>                                            - set verbosity level for diagnostic output

BOLT optimization options:

  -align-blocks                                        - try to align BBs inserting nops
  -align-functions=<uint>                              - align functions at a given value (relocation mode)
  -align-functions-max-bytes=<uint>                    - maximum number of bytes to use to align functions
  -boost-macroops                                      - try to boost macro-op fusions by avoiding the cache-line boundary
  -eliminate-unreachable                               - eliminate unreachable code
  -frame-opt                                           - optimize stack frame accesses
  ......

(cherry picked from FBD4793684)


  Commit: c166a8c1a721942fa3b48ad84c047050313f35a6
      https://github.com/llvm/llvm-project/commit/c166a8c1a721942fa3b48ad84c047050313f35a6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-04-03 (Mon, 03 Apr 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Fix debug info update for inlining.

Summary:
When inlining, if a callee has debug info and a caller does not
(i.e. a containing compilation unit was compiled without "-g"), we try
to update a nonexistent compilation unit. Instead we should skip
updating debug info in such cases.

Minor refactoring of line number emitting code.

(cherry picked from FBD4823982)


  Commit: f7d32f7e7ddb6b8a58c89cad1c04ce217121a3dd
      https://github.com/llvm/llvm-project/commit/f7d32f7e7ddb6b8a58c89cad1c04ce217121a3dd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-03-31 (Fri, 31 Mar 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Detect and reject binaries built for coverage.

Summary: Don't attempt to optimize binaries built with coverage support.

(cherry picked from FBD4810330)


  Commit: 6c5c65e3a313f913f0fe837c5f53b126e6ac36dd
      https://github.com/llvm/llvm-project/commit/6c5c65e3a313f913f0fe837c5f53b126e6ac36dd
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-03-20 (Mon, 20 Mar 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h

  Log Message:
  -----------
  [BOLT] Fix double jump peephole, remove useless conditional branches.

Summary:
I split some of this out from the jumptable diff since it fixes the
double jump peephole.

I've changed the pass manager so that UCE and peepholes are not called
after SCTC.  I've incorporated a call to the double jump fixer to SCTC
since it is needed to fix things up afterwards.

While working on fixing the double jump peephole I discovered a few
useless conditional branches that could be removed as well.  I highly
doubt that removing them will improve perf at all but it does seem
odd to leave in useless conditional branches.

There are also some minor logging improvements.

(cherry picked from FBD4751875)


  Commit: a99005397f893ba271efa7364806921abaf8a244
      https://github.com/llvm/llvm-project/commit/a99005397f893ba271efa7364806921abaf8a244
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-04-05 (Wed, 05 Apr 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix branch count in removeDuplicateConditionalSuccessor().

Summary:
When we merge the original branch counts we have to make sure
both of them have a profile. Otherwise set the count to COUNT_NO_PROFILE.

The misprediction count should be 0.

(cherry picked from FBD4837774)


  Commit: 34c8a7c21beecc18200fd342fe9cde8802c8ce87
      https://github.com/llvm/llvm-project/commit/34c8a7c21beecc18200fd342fe9cde8802c8ce87
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-04-05 (Wed, 05 Apr 2017)

  Changed paths:
    M bolt/DWARFRewriter.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Relocation support for non-allocatable sections.

Summary:
Relocations can be created for non-allocatable (aka Note) sections.

To start using this for debug info, the emission has to be moved
earlier in the pipeline for relocation processing to kick in.

(cherry picked from FBD4835204)


  Commit: c7cccacc4f39d9c74a0393b7916f153a6289083c
      https://github.com/llvm/llvm-project/commit/c7cccacc4f39d9c74a0393b7916f153a6289083c
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-04-05 (Wed, 05 Apr 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Enable SCTC by default.

(cherry picked from FBD4837849)


  Commit: 075f076503ae495107bcaa7610f86ea49c06e08f
      https://github.com/llvm/llvm-project/commit/075f076503ae495107bcaa7610f86ea49c06e08f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-04-06 (Thu, 06 Apr 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Don't abort on processing binaries with .gdb_index section

Summary:
While writing non-allocatable sections we had an assumption that the
size of such section is congruent to the alignment, as typically
such sections are a collections of fixed-sized elements. .gdb_index
breaks this assumption.

This diff removes the assertion that was triggered by a presence of
.gdb_index section, and makes sure that we insert a padding if we are
appending to a section with a size not congruent to section alignment.

(cherry picked from FBD4844553)


  Commit: 13c89e6ef19b3b543ebaa6f1af8e635268eeb913
      https://github.com/llvm/llvm-project/commit/13c89e6ef19b3b543ebaa6f1af8e635268eeb913
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-04-18 (Tue, 18 Apr 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Fix branch data for __builtin_unreachable().

Summary:
When we have a conditional branch past the end of function (a result
of a call to__builtin_unreachable()), we replace the branch with nop,
but keep branch information for validation purposes. If that branch
has a recorded profile we mistakenly create an additional successor
to a containing basic block (a 3rd successor).

Instead of adding the branch to FTBranches list we should be adding
to IgnoredBranches.

(cherry picked from FBD4912840)


  Commit: 3f42fdf7daf268880e0fb3fdc87ee4882012a6c9
      https://github.com/llvm/llvm-project/commit/3f42fdf7daf268880e0fb3fdc87ee4882012a6c9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-08 (Mon, 08 May 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Update function address and size in relocation mode.

Summary:
Set function addresses after code emission but before we update
debug info and symbol table entries.

(cherry picked from FBD5029609)


  Commit: 3adb52d80e909eee36aaca50d8a2fc0d50a6c76b
      https://github.com/llvm/llvm-project/commit/3adb52d80e909eee36aaca50d8a2fc0d50a6c76b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-15 (Mon, 15 May 2017)

  Changed paths:
    M bolt/DWARFRewriter.cpp
    M bolt/DebugData.cpp
    M bolt/DebugData.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Update .gdb_index section.

Summary: Update address table in .gdb_index section.

(cherry picked from FBD5068255)


  Commit: 69b586326c2b3ff836c84c747837d840a67b7216
      https://github.com/llvm/llvm-project/commit/69b586326c2b3ff836c84c747837d840a67b7216
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-16 (Tue, 16 May 2017)

  Changed paths:
    M bolt/DWARFRewriter.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Support adding new non-allocatable sections.

Summary:
We had the ability to add allocatable sections before. This diff
expands this capability to non-allocatable sections.

(cherry picked from FBD5082018)


  Commit: c789d5137b40d68f30801f37caa516849e837579
      https://github.com/llvm/llvm-project/commit/c789d5137b40d68f30801f37caa516849e837579
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-17 (Wed, 17 May 2017)

  Changed paths:
    M bolt/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT] Add option to keep/generate .debug_aranges.

Summary:
GOLD linker removes .debug_aranges while generating .gdb_index.
Some tools however rely on the presence of this section.
Add an option to generate .debug_aranges if it was removed,
or keep it in the file if it was present.

Generally speaking .debug_aranges duplicates information present
in .gdb_index addresses table.

(cherry picked from FBD5084808)


  Commit: 4806b1383591eab7139b65a25d80a70791ff6fd9
      https://github.com/llvm/llvm-project/commit/4806b1383591eab7139b65a25d80a70791ff6fd9
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-03-08 (Wed, 08 Mar 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/CMakeLists.txt
    A bolt/Passes/IndirectCallPromotion.cpp
    A bolt/Passes/IndirectCallPromotion.h
    M bolt/Passes/Inliner.cpp

  Log Message:
  -----------
  [BOLT] Add jump table support to ICP

Summary:
Add jump table support to ICP.  The optimization is basically the same
as ICP for tail calls.  The big difference is that the profiling data
comes from the jump table and the targets are local symbols rather than
global.

I've removed an instruction from ICP for tail calls.  The code used to
have a conditional jump to a block with a direct jump to the target, i.e.

  B1: cmp foo,(%rax)
      jne B3
  B2: jmp foo
  B3: ...

this code is now:

  B1: cmp foo,(%rax)
      je  foo
  B2: ...

The other changes in this diff:
- Move ICP + new jump table support to separate file in Passes.
- Improve the CFG validation to handle jump tables.
- Fix the double jump peephole so that the successor of the modified
  block is updated properly.  Also make sure that any existing branches
  in the block are modified to properly reflect the new CFG.
- Add an invocation of the double jump peephole to SCTC.  This allows
  us to remove a call to peepholes/UCE occurring after fixBranches() in
  the pass manager.
- Miscellaneous cleanups to BOLT output.

(cherry picked from FBD4727757)


  Commit: 457b7f14b9e07850b791d7df5fff0171cabd5315
      https://github.com/llvm/llvm-project/commit/457b7f14b9e07850b791d7df5fff0171cabd5315
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-22 (Mon, 22 May 2017)

  Changed paths:
    M bolt/DWARFRewriter.cpp
    M bolt/DebugData.cpp
    M bolt/DebugData.h

  Log Message:
  -----------
  [BOLT] Fix debug info for input with continuous range.

Summary:
When we see a compilation unit with continuous range on input,
it has two attributes: DW_AT_low_pc and DW_AT_high_pc. We convert the
range to a non-continuous one and change the attributes to
DW_AT_ranges and DW_AT_producer. However, gdb seems to expect
every compilation unit to have a base address specified via
DW_AT_low_pc, even when its value is always 0. Otherwise gdb will
not show proper debug info for such modules.

With this diff we produce DW_AT_ranges followed by DW_AT_low_pc.
The problem is that the first attribute takes DW_FORM_sec_offset
which is exactly 4 bytes, and in many cases we are left with
12 bytes to fill in. We used to fill this space with DW_AT_producer,
which took an arbitrary-length field. For DW_AT_low_pc we can
use a trick of using DW_FORM_udata (unsigned ULEB128 encoded
integer) which can take up to 12 bytes, even when the value is 0.

(cherry picked from FBD5109798)


  Commit: 511a1c78b2cd5aa35b1e8d13a53855034dce1bbf
      https://github.com/llvm/llvm-project/commit/511a1c78b2cd5aa35b1e8d13a53855034dce1bbf
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-05-01 (Mon, 01 May 2017)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/Passes/CMakeLists.txt
    A bolt/Passes/DataflowAnalysis.cpp
    A bolt/Passes/DataflowAnalysis.h
    A bolt/Passes/DataflowInfoManager.cpp
    A bolt/Passes/DataflowInfoManager.h
    A bolt/Passes/DominatorAnalysis.h
    A bolt/Passes/FrameAnalysis.cpp
    A bolt/Passes/FrameAnalysis.h
    M bolt/Passes/FrameOptimizer.cpp
    A bolt/Passes/LivenessAnalysis.cpp
    A bolt/Passes/LivenessAnalysis.h
    A bolt/Passes/ReachingDefOrUse.h
    A bolt/Passes/ReachingInsns.h
    A bolt/Passes/StackPointerTracking.cpp
    A bolt/Passes/StackPointerTracking.h

  Log Message:
  -----------
  [BOLT] Add dataflow infrastructure

Summary:
This diff introduces a common infrastructure for performing
dataflow analyses in BinaryFunctions as well as a few analyses that are
useful in a variety of scenarios. The largest user of this
infrastructure so far is shrink wrapping, which will be added in a
separate diff.

(cherry picked from FBD4983671)


  Commit: 96adec51eb703c4ab79999ac907548ec67dc7493
      https://github.com/llvm/llvm-project/commit/96adec51eb703c4ab79999ac907548ec67dc7493
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-16 (Tue, 16 May 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DWARFRewriter.cpp
    M bolt/DebugData.cpp
    M bolt/DebugData.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Rework debug info processing.

Summary:
Multiple improvements to debug info handling:
  * Add support for relocation mode.
  * Speed-up processing.
  * Reduce memory consumption.
  * Bug fixes.

The high-level idea behind the new debug handling is that we don't save
intermediate state for ranges and location lists. Instead we depend
on function and basic block address transformations to update the info
as a final post-processing step.

For HHVM in non-relocation mode the peak memory went down from 55GB to 35GB. Processing time went from over 6 minutes to under 5 minutes.

(cherry picked from FBD5113431)


  Commit: 3a3bcd767eddb90bc06a67c0382323434883cf93
      https://github.com/llvm/llvm-project/commit/3a3bcd767eddb90bc06a67c0382323434883cf93
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-05-19 (Fri, 19 May 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  Don't add useless uncond branch to fallthroughs when running SCTC.

Summary:
SCTC was sometimes adding unconditional branches to fallthrough blocks.
This diff checks to see if the unconditional branch is really necessary, e.g.
it's not to a fallthrough block.

(cherry picked from FBD5098493)


  Commit: 2ee4bbd3c1c7c091632cc1cb5085009f9e9c8cdb
      https://github.com/llvm/llvm-project/commit/2ee4bbd3c1c7c091632cc1cb5085009f9e9c8cdb
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-05-01 (Mon, 01 May 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameAnalysis.h
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/IndirectCallPromotion.h

  Log Message:
  -----------
  [BOLT] Optimize jump tables with hot entries

Summary:
This diff is similar to Bill's diff for optimizing jump tables
(and is built on top of it), but it differs in the strategy used to
optimize the jump table. The previous approach loads the target address
from the jump table and compare it to check if it is a hot target. This
accomplishes branch misprediction reduction by promote the indirect jmp
to a (more predictable) direct jmp.

  load  %r10, JMPTABLE
  cmp   %r10, HOTTARGET
  je    HOTTARGET
  ijmp  [JMPTABLE + %index * scale]

The idea in this diff is instead to make dcache better by avoiding the
load of the jump table, leaving branch mispredictions as a secondary
target. To do this we compare the index used in the indirect jmp and if
it matches a known hot entry, it performs a direct jump to the target.

  cmp  %index, HOTINDEX
  je   CORRESPONDING_TARGET
  ijmp [JMPTABLE + %index * scale]

The downside of this approach is that we may have multiple indices
associated with a single target, but we only have profiling to show
which targets are hot and we have no clue about which indices are hot.

  INDEX    TARGET
  0        4004f8
  8        4004f8
  10       4003d0
  18       4004f8

  Profiling data:
  TARGET   COUNT
  4004f8   10020
  4003d0   17

In this example, we know 4004f8 is hot, but to make a direct call to it
we need to check for indices 0, 8 and 18 -- 3 comparisons instead of 1.

Therefore, once we know a target is hot, we must generate code to
compare against all possible indices associated with this target because
we don't know which index is the hot one (IF there's a hotter index).

  cmp %index, 0
  je  4004f8
  cmp %index, 8
  je  4004f8
  cmp %index, 18
  je  4004f8
  (... up to N comparisons as in --indirect-call-promotion-topn=N )
  ijmp [JMPTABLE + %index * scale]

(cherry picked from FBD5005620)


  Commit: 5cd58961a93599c051945c286921326034515e42
      https://github.com/llvm/llvm-project/commit/5cd58961a93599c051945c286921326034515e42
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-05-24 (Wed, 24 May 2017)

  Changed paths:
    M bolt/CMakeLists.txt
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h
    M bolt/llvm-bolt.cpp

  Log Message:
  -----------
  Add .bolt_info notes section containing BOLT revision and command line args.

Summary:
Optinally add a .bolt_info notes section containing BOLT revision and command line args.
The new section is controlled by the -add-bolt-info flag which is on by default.

(cherry picked from FBD5125890)


  Commit: 174e3a825bba60a96d772c72f5e3a346e8a1707f
      https://github.com/llvm/llvm-project/commit/174e3a825bba60a96d772c72f5e3a346e8a1707f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-24 (Wed, 24 May 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix C++ ABI function alignment.

Summary: C++ functions have to be aligned at 2-bytes minimum on x86-64.

(cherry picked from FBD5128185)


  Commit: 2428567f7ddbc48a07781d2479faff80635175a2
      https://github.com/llvm/llvm-project/commit/2428567f7ddbc48a07781d2479faff80635175a2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-25 (Thu, 25 May 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryFunction.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/Inliner.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix no-assertions build.

(cherry picked from FBD5130285)


  Commit: 96943d2f4b97eabd3be3f70d2803341a51af35e9
      https://github.com/llvm/llvm-project/commit/96943d2f4b97eabd3be3f70d2803341a51af35e9
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-05-24 (Wed, 24 May 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Add option to generate function order file.

Summary: Add -generate-function-order=<filename> option to write the computed function order to a file.  We can read this order in later rather than recomputing each time we process a binary with BOLT.

(cherry picked from FBD5127915)


  Commit: 2e744e6867836d0780aca5bbc47227a60708c05c
      https://github.com/llvm/llvm-project/commit/2e744e6867836d0780aca5bbc47227a60708c05c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-24 (Wed, 24 May 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT] Emit sorted DWARF ranges and location lists.

Summary:
When producing address ranges and location lists for debug info
add a post-processing step that sorts them and merges adjacent
entries.

Fix a memory allocation/free issue for .debug_ranges section.

(cherry picked from FBD5130583)


  Commit: 35d2530a40f79acc9e97952e3c9401cd08ef15f2
      https://github.com/llvm/llvm-project/commit/35d2530a40f79acc9e97952e3c9401cd08ef15f2
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-05-30 (Tue, 30 May 2017)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix SCTC again.

Summary: Respect hot/cold boundaries when using BinaryFunction::getBasicBlockAfter().

(cherry picked from FBD5153379)


  Commit: 6c32079d57a897b091596bf436e0b99c0c2908fb
      https://github.com/llvm/llvm-project/commit/6c32079d57a897b091596bf436e0b99c0c2908fb
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-05-31 (Wed, 31 May 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DWARFRewriter.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Update addresses for DW_TAG_GNU_call_site and DW_TAG_label.

Summary:
Some DWARF tags (such as GNU_call_site and label) reference instruction
addresses in the input binary. When we update debug info we need to
update these tags too with new addresses.

Also fix base address used for calculation of output addresses in
relocation mode.

(cherry picked from FBD5155814)


  Commit: 9b190cc74bbc5dc1bd9f15fb128824f845b707b4
      https://github.com/llvm/llvm-project/commit/9b190cc74bbc5dc1bd9f15fb128824f845b707b4
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-05-31 (Wed, 31 May 2017)

  Changed paths:
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Fix SCTC again again.

Summary: I put the const_cast<BinaryFunction *>(this) on the wrong version of getBasicBlockAfter().  It's on the right one now.

(cherry picked from FBD5159127)


  Commit: 733e8c464fc2c9caf500ebacbd193f713e57e3e8
      https://github.com/llvm/llvm-project/commit/733e8c464fc2c9caf500ebacbd193f713e57e3e8
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-05-26 (Fri, 26 May 2017)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/CMakeLists.txt
    A bolt/Passes/CallGraph.cpp
    A bolt/Passes/CallGraph.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameAnalysis.h
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/FrameOptimizer.h
    M bolt/Passes/HFSort.cpp
    M bolt/Passes/HFSort.h
    M bolt/Passes/HFSortPlus.cpp
    A bolt/Passes/PettisAndHansen.cpp
    A bolt/Passes/ReorderFunctions.cpp
    A bolt/Passes/ReorderFunctions.h

  Log Message:
  -----------
  HFSort/call graph refactoring

Summary:
I've factored out the call graph code from dataflow and function reordering code and done a few small renames/cleanups.  I've also moved the function reordering pass into a separate file because it was starting to get big.

I've got more refactoring planned for hfsort/call graph but this is a start.

(cherry picked from FBD5140771)


  Commit: 95ab659fe4a8987924d9cdef07806da921616226
      https://github.com/llvm/llvm-project/commit/95ab659fe4a8987924d9cdef07806da921616226
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-06-01 (Thu, 01 Jun 2017)

  Changed paths:
    M bolt/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT] Do not assert on an empty location list.

Summary:
Clang generates an empty debug location list, which doesn't make sense,
but we probably shouldn't assert on it and instead issue a warning
in verbosity mode. There is only a single empty location list in the
whole llvm binary.

(cherry picked from FBD5166666)


  Commit: 5feee9f1d896b37ffca49ffbd23b84ac1d364ba6
      https://github.com/llvm/llvm-project/commit/5feee9f1d896b37ffca49ffbd23b84ac1d364ba6
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-05-26 (Fri, 26 May 2017)

  Changed paths:
    A bolt/Passes/BinaryFunctionCallGraph.cpp
    A bolt/Passes/BinaryFunctionCallGraph.h
    M bolt/Passes/CMakeLists.txt
    M bolt/Passes/CallGraph.cpp
    M bolt/Passes/CallGraph.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameAnalysis.h
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/FrameOptimizer.h
    M bolt/Passes/HFSort.cpp
    M bolt/Passes/HFSort.h
    M bolt/Passes/HFSortPlus.cpp
    M bolt/Passes/PettisAndHansen.cpp
    M bolt/Passes/ReorderFunctions.cpp
    M bolt/Passes/ReorderFunctions.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] More CG refactoring

Summary:
Do some additional refactoring of the CallGraph class.  Add a BinaryFunctionCallGraph class that has the BOLT specific bits.  This is in preparation to moving the generic CallGraph class into a library that both BOLT and HHVM can use.

Make data members of CallGraph private and add the appropriate accessor methods.

(cherry picked from FBD5143468)


  Commit: 382c660ee5f30f867faacb6832e61600039a7622
      https://github.com/llvm/llvm-project/commit/382c660ee5f30f867faacb6832e61600039a7622
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-05-26 (Fri, 26 May 2017)

  Changed paths:
    M bolt/Passes/HFSort.cpp
    M bolt/Passes/HFSort.h
    M bolt/Passes/HFSortPlus.cpp

  Log Message:
  -----------
  [BOLT] Make hfsort+ deterministic and add test case

Summary:
Make hfsort+ algorithm deterministic.
We only had a test for hfsort.  Since hfsort+ is going to be the default, I've added a test for that too.

(cherry picked from FBD5143143)


  Commit: 4b485f4167a89076259f7d79eaed196f3a3809c2
      https://github.com/llvm/llvm-project/commit/4b485f4167a89076259f7d79eaed196f3a3809c2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-06-02 (Fri, 02 Jun 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Fix misc issues in relocation mode.

Summary:
Fix issues discovered while testing LTO mode with bfd linker:

  * Correctly update absolute function references from code
    with addend.
  * Support .got.plt section generated by bfd linker.
  * Support quirks of .tbss section.
  * Don't ignore functions if the size in FDE doesn't match the
    size in the symbol table. Instead keep processing using the
    maximum indicated size.

(cherry picked from FBD5178831)


  Commit: d850ca36222f4ee58bee17bac22385e8c9ffa2d1
      https://github.com/llvm/llvm-project/commit/d850ca36222f4ee58bee17bac22385e8c9ffa2d1
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-05-01 (Mon, 01 May 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    A bolt/Passes/AllocCombiner.cpp
    A bolt/Passes/AllocCombiner.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/CMakeLists.txt
    M bolt/Passes/DataflowAnalysis.h
    M bolt/Passes/DataflowInfoManager.cpp
    M bolt/Passes/DataflowInfoManager.h
    M bolt/Passes/DominatorAnalysis.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/FrameOptimizer.h
    M bolt/Passes/LivenessAnalysis.h
    M bolt/Passes/ReachingDefOrUse.h
    M bolt/Passes/ReachingInsns.h
    A bolt/Passes/ShrinkWrapping.cpp
    A bolt/Passes/ShrinkWrapping.h
    A bolt/Passes/StackAllocationAnalysis.cpp
    A bolt/Passes/StackAllocationAnalysis.h
    A bolt/Passes/StackAvailableExpressions.cpp
    A bolt/Passes/StackAvailableExpressions.h
    M bolt/Passes/StackPointerTracking.h
    A bolt/Passes/StackReachingUses.cpp
    A bolt/Passes/StackReachingUses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add shrink wrapping pass

Summary:
Add an implementation for shrink wrapping, a frame optimization
that moves callee-saved register spills from hot prologues to cold
successors.

(cherry picked from FBD4983706)


  Commit: 2c2309429905bcfa25fa0ebd50852c7fd2a7a637
      https://github.com/llvm/llvm-project/commit/2c2309429905bcfa25fa0ebd50852c7fd2a7a637
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-06-02 (Fri, 02 Jun 2017)

  Changed paths:
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/CMakeLists.txt
    A bolt/Passes/CallGraphWalker.cpp
    A bolt/Passes/CallGraphWalker.h
    M bolt/Passes/DataflowInfoManager.cpp
    M bolt/Passes/DataflowInfoManager.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameAnalysis.h
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/FrameOptimizer.h
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/LivenessAnalysis.h
    M bolt/Passes/ReachingDefOrUse.h
    A bolt/Passes/RegAnalysis.cpp
    A bolt/Passes/RegAnalysis.h
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/StackAvailableExpressions.cpp
    M bolt/Passes/StackAvailableExpressions.h
    M bolt/Passes/StackReachingUses.cpp

  Log Message:
  -----------
  Split FrameAnalysis and improve LivenessAnalysis

Summary:
Split FrameAnalysis into FrameAnalysis and RegAnalysis, since
some optimizations only require register information about functions,
not frame information. Refactor callgraph walking code into the
CallGraphWalker class, allowing any analysis that depend on the call
graph to easily traverse it via a visitor pattern. Also fix
LivenessAnalysis, which was broken because it was not considering
registers read into callees and incorporating this into caller.

(cherry picked from FBD5177901)


  Commit: f9436bc9033d3c81b7fdaad30ae6ae2630508321
      https://github.com/llvm/llvm-project/commit/f9436bc9033d3c81b7fdaad30ae6ae2630508321
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-06-07 (Wed, 07 Jun 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix ELF inter-section references

Summary:
Since we are stripping non-allocatable relocation sections from
the binary and adding new sections it changes section indices
in the binary. Some sections refer to other sections by their index
which is stored in sh_link or sh_info field. Hence we need to update
these field.

In the past update of indices was done ad-hoc and as we started
adding more complex updates to section header table the update
mechanism became broken in some cases. As a result, we were putting
wrong indices into sh_link/sh_info.

The broken case was discovered while investigating a problem with
a stripped BOLTed binary. In BOLTed binary .rela.plt was incorrectly
pointing to one of the debug sections and strip command removed
the debug section together with .rela section that was referencing it.

The new update mechanism computes complete old to new section index
mapping and updates sh_link/sh_info fields based on the mapping
before writing section header entries into an output file.

(cherry picked from FBD5207378)


  Commit: 8eaa2fdd9f7674ab5ac924b753c60e6667880dcd
      https://github.com/llvm/llvm-project/commit/8eaa2fdd9f7674ab5ac924b753c60e6667880dcd
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-06-07 (Wed, 07 Jun 2017)

  Changed paths:
    M bolt/Passes/HFSortPlus.cpp

  Log Message:
  -----------
  [BOLT] Fix hfsort+ crash when no perf data is present.

Summary: hfsort+ was trying to access the back() of an empty vector when no perf data is present.  Just add a guard around that code.

(cherry picked from FBD5206962)


  Commit: 2baa4c7a2c8b520e4dfa4f7f84ce77ea6c5c9fa0
      https://github.com/llvm/llvm-project/commit/2baa4c7a2c8b520e4dfa4f7f84ce77ea6c5c9fa0
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-06-08 (Thu, 08 Jun 2017)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/CallGraphWalker.cpp
    M bolt/Passes/CallGraphWalker.h
    M bolt/Passes/DominatorAnalysis.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/LivenessAnalysis.h
    M bolt/Passes/ReachingDefOrUse.h
    M bolt/Passes/ReachingInsns.h
    M bolt/Passes/RegAnalysis.cpp
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/StackAllocationAnalysis.h
    M bolt/Passes/StackAvailableExpressions.h
    M bolt/Passes/StackPointerTracking.h
    M bolt/Passes/StackReachingUses.h

  Log Message:
  -----------
  [BOLT] Only print stats when requested

Summary:
Make LLVM timers only output numbers when the -time-opts option
is used.

(cherry picked from FBD5212221)


  Commit: 583790ee22f8334895e1fd05c79841e7fe3b4add
      https://github.com/llvm/llvm-project/commit/583790ee22f8334895e1fd05c79841e7fe3b4add
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-06-07 (Wed, 07 Jun 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h

  Log Message:
  -----------
  Fix dynostats for conditional tail calls

Summary:
Don't treat conditional tail calls as branches for dynostats. Count
taken conditional tails calls as calls. Change SCTC to report dynamic
numbers after it is done.

(cherry picked from FBD5203708)


  Commit: ea5306628750edf058ef2402b65cfbb2b8279436
      https://github.com/llvm/llvm-project/commit/ea5306628750edf058ef2402b65cfbb2b8279436
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-06-06 (Tue, 06 Jun 2017)

  Changed paths:
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/CallGraph.cpp
    M bolt/Passes/CallGraph.h
    M bolt/Passes/HFSort.cpp
    M bolt/Passes/HFSort.h
    M bolt/Passes/HFSortPlus.cpp
    M bolt/Passes/PettisAndHansen.cpp

  Log Message:
  -----------
  [BOLT] Fix hfsort+ caching mechanism

Summary:
There's good news and bad news.

The good news is that this fixes the caching mechanism used by hfsort+ so that we always get the correct end results, i.e. the order is the same whether the cache is enabled or not.
The bad news is that it takes about the same amount of time as the original to run. (~6min)
The good news is that I can make some improvements on this implementation which I'll put up in another diff.

The problem with the old caching mechanism is that it was caching values that were dependent on adjacent sets of clusters.  It only invalidated the clusters being merged and none of other clusters that might have been affected.  This version computes the adjacency information up front and updates it after every merge, rather than recomputing it for each iteration.  It uses the adjacency data to properly invalidate any cached values.

(cherry picked from FBD5203023)


  Commit: eb63a0b295eac25fc11cde2f96533976254661b8
      https://github.com/llvm/llvm-project/commit/eb63a0b295eac25fc11cde2f96533976254661b8
  Author: Bohan Ren <brian0129 at fb.com>
  Date:   2017-05-22 (Mon, 22 May 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Expand BOLT report for basic block ordering

Summary:
Add a new positional option onto bolt: "-print-function-statistics=<uint64>"
which prints information about block ordering for requested number of functions.

(cherry picked from FBD5105323)


  Commit: eeea415dd2ebb884ba952fcbd30c3105e7f32b7b
      https://github.com/llvm/llvm-project/commit/eeea415dd2ebb884ba952fcbd30c3105e7f32b7b
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-06-09 (Fri, 09 Jun 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix SCTC execution count assertion

Summary:
SCTC is currently asserting (my fault :-) when running in
combination with hot jump table entries optimization. This optimization
sets the frequency for edges connecting basic blocks it creates and jump
table targets based on the execution count of the original BB containing
the indirect jump.

This is OK as an estimation, but it breaks our assumption that the sum of
the frequency of preds edges equals to our BB frequency. This happens
because the frequency of the BB is rarely equal to its outgoing edges
frequency.

SCTC, in turn, was updating the execution count for BBs with tail calls
by subtracting the frequency count of predecessor edges. Because hot
jump table entries optimization broke the BB exec count = sum(preds freq)
invariant, SCTC was asserting.

To trigger this, the input program must have a jump table where each
entry contains a tail call. This happens in the HHVM binary for func
_ZN4HPHP11collections5issetEPNS_10ObjectDataEPKNS_10TypedValueE.

(cherry picked from FBD5222504)


  Commit: f819f53d27413fad24723606a02410722a48ae21
      https://github.com/llvm/llvm-project/commit/f819f53d27413fad24723606a02410722a48ae21
  Author: Bohan Ren <brian0129 at fb.com>
  Date:   2017-06-07 (Wed, 07 Jun 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/Passes/ReorderAlgorithm.cpp

  Log Message:
  -----------
  Normalize Clusters Twice

Summary:
This one will normalize cluster twice, leaving edges connecting two
basic block untouched

(cherry picked from FBD5207416)


  Commit: dc4dd648002b15538acd2e393b5bdf72b27f2cfc
      https://github.com/llvm/llvm-project/commit/dc4dd648002b15538acd2e393b5bdf72b27f2cfc
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-06-08 (Thu, 08 Jun 2017)

  Changed paths:
    M bolt/Passes/CallGraph.h
    M bolt/Passes/HFSort.h
    M bolt/Passes/HFSortPlus.cpp
    M bolt/Passes/PettisAndHansen.cpp
    M bolt/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  [BOLT] More HFSort+ refactoring

Summary: Move most of hfsort+ into a class so the state can more easily be shared.

(cherry picked from FBD5216206)


  Commit: 37d0f81df500afb69c4fec71d8e49e5794624ee5
      https://github.com/llvm/llvm-project/commit/37d0f81df500afb69c4fec71d8e49e5794624ee5
  Author: Yue Zhao <yzhao30 at fb.com>
  Date:   2017-06-16 (Fri, 16 Jun 2017)

  Changed paths:
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  BinaryFunction.h: Clarify commet for getSize(), add getNumNonPseudos()

Summary: Minor fix and add new function

(cherry picked from FBD5270376)


  Commit: 8233c7d204fcaf249f14a895b08426fad6ea8514
      https://github.com/llvm/llvm-project/commit/8233c7d204fcaf249f14a895b08426fad6ea8514
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-06-16 (Fri, 16 Jun 2017)

  Changed paths:
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/RegAnalysis.cpp
    M bolt/Passes/StackPointerTracking.h

  Log Message:
  -----------
  [BOLT] Bail frame analysis on PUSHes escaping vars

Summary:
Some PUSH instructions may contain memory addresses pushed to
the stack. If this memory address is from an object in the stack, cancel
further frame analysis for this function since it may be escaping a
variable.

This fixes a bug with deleting used stores (in frameopt) in hhvm trunk.

(cherry picked from FBD5270590)


  Commit: 59e90f0f43cb38b4ac200b61111129a9e9a5c3f1
      https://github.com/llvm/llvm-project/commit/59e90f0f43cb38b4ac200b61111129a9e9a5c3f1
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-06-09 (Fri, 09 Jun 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/BinaryFunctionCallGraph.h
    M bolt/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  [BOLT] Make function reordering more robust with stale data.

Summary:
Rewrote the guts of buildCallGraph.  There are two new options to control how the CG is created.  UsePerfData controls whether we use the perf data directly to construct the CG for functions with a stale profile.  IgnoreRecursiveCalls omits recursive calls from the CG since they might be skewing results unfairly for heavily recursive functions.

I've changed the way BinaryFunction::estimateHotSize() works.  If the function is marked as split, I count the size of all the non-cold blocks.  This gives a different but more accurate answer than the old method.

I've improved and updated the CG build stats with extra information.

(cherry picked from FBD5224183)


  Commit: 3469396269318b409bcd4ffcae154fe5f6de8764
      https://github.com/llvm/llvm-project/commit/3469396269318b409bcd4ffcae154fe5f6de8764
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-06-16 (Fri, 16 Jun 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Set local symbols in relocation mode to zero

Summary:
Strobelight is getting confused by local symbols that we do not
update in relocation mode. These symbols were preserved by the linker in
relocation mode in order support emitting relocations against local
labels, but they are unused.

Issue a quick fix to this by detecting such symbols and setting their
value to zero.

This patch also fixes an issue with the symbol table that was assigning
the wrong section index to symbols associated with the .text section.

(cherry picked from FBD5271277)


  Commit: ec304396c3e5b57a84aa26a99b6de70eab3637e6
      https://github.com/llvm/llvm-project/commit/ec304396c3e5b57a84aa26a99b6de70eab3637e6
  Author: Bohan Ren <brian0129 at fb.com>
  Date:   2017-06-13 (Tue, 13 Jun 2017)

  Changed paths:
    M bolt/CMakeLists.txt
    A bolt/CalcCacheMetrics.cpp
    A bolt/CalcCacheMetrics.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Call Distance Metric

Summary:
Designed a new metric, which shows 93.46% correltation with Cache Miss
and 86% correlation with CPU Time.

Definition:

One can get all the traversal path for each function. And for each traversal,
we will define a distance. The distance represents how far two connected
basic blocks are. Therefore, for each traversal, I will go through the
basic blocks one by one, until the end of the traversal and sum up the
distance for the neighboring basic blocks.
Distance between two connected basic blocks is the distance of the
centers of two blocks in the binary file.

(cherry picked from FBD5242526)


  Commit: 4ecd3856e9808e472026b8830c2f31f02a736861
      https://github.com/llvm/llvm-project/commit/4ecd3856e9808e472026b8830c2f31f02a736861
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-06-22 (Thu, 22 Jun 2017)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/ShrinkWrapping.h
    M bolt/Passes/StackReachingUses.cpp
    M bolt/Passes/StackReachingUses.h

  Log Message:
  -----------
  [BOLT] Fix shrink-wrapping bugs

Summary:
Make shrink-wrapping more stable. Changes:

* Correctly detect landing pads at the dominance frontier, bailing
  on such cases because we are not prepared to split LPs that are target
  of a critical edge.
* Disable FOP's store removal by default - this is experimental and
  shouldn t go to prod because removing a store that we failed to detect
  it's actually necessary is disastrous. This pass currently doesn't
  have a great impact on the number of stores reduced, so it is not a
  problem. Most stores reduced are due shrink wrapping anyway.
* Fix stack access identification - correctly estimate memory length of
  weird instructions, bail if we don't know.
* Make rules for shrink-wrapping more strict: cancel shrink wrapping on
  a number of cases when we are not 100% sure that we are dealing with a
  regular callee-saved register.
* Add basic block folding to SW. Sometimes when splitting critical edges
  we create a lot of redundant BBs with the same instructions, same
  successor but different predecessor. Fold all identical BBs created by
  splitting critical edges.
* Change defaults: now the threshold used to determine when to perform
  SW is more conservative, to be sure we are moving a spill to a colder
  area. This effort, along with BB folding, helps us to avoid hurting
  icache performance by indiscriminately increasing code size.

(cherry picked from FBD5315086)


  Commit: 4d34471eeb0ce8ebf8bc00fcca5ddfec18923205
      https://github.com/llvm/llvm-project/commit/4d34471eeb0ce8ebf8bc00fcca5ddfec18923205
  Author: Bohan Ren <brian0129 at fb.com>
  Date:   2017-07-04 (Tue, 04 Jul 2017)

  Changed paths:
    M bolt/CalcCacheMetrics.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Improved Jump-Distance Metric

Summary:
Current existing Jump-Distance Metric (Previously named Call-Distance) will ignore some traversals.
This modified version adds those missing traversals back.

The correlation remains the same: around 97% correlation with CPU and
Cache Miss (which implies that even though some traversals are ignored,
it doesn't affect correlation that much.)

(cherry picked from FBD5369653)


  Commit: 4e29afeb1801973a8961271d0c37765ba5c0411d
      https://github.com/llvm/llvm-project/commit/4e29afeb1801973a8961271d0c37765ba5c0411d
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-06-27 (Tue, 27 Jun 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Add cold symbols to the symbol table

Summary:
Create new .symtab and .strtab sections, so we can change their
sizes and not only patch them. Remove local symbols and add symbols to
identify the cold part of split functions.

(cherry picked from FBD5345460)


  Commit: 6d845719ce08332e88a2f9183625781e0f26fb17
      https://github.com/llvm/llvm-project/commit/6d845719ce08332e88a2f9183625781e0f26fb17
  Author: Yue Zhao <yzhao30 at fb.com>
  Date:   2017-06-13 (Tue, 13 Jun 2017)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/CMakeLists.txt
    M bolt/Passes/RegAnalysis.h
    A bolt/Passes/StokeInfo.cpp
    A bolt/Passes/StokeInfo.h

  Log Message:
  -----------
  get analysis information of functions

Summary:
complete the StokeInfo pass,
ignore previous arc diff

(cherry picked from FBD5306863)


  Commit: 70bad8d34db548ce459da5cc88da8ba4cc26b7ad
      https://github.com/llvm/llvm-project/commit/70bad8d34db548ce459da5cc88da8ba4cc26b7ad
  Author: Yue Zhao <yzhao30 at fb.com>
  Date:   2017-07-13 (Thu, 13 Jul 2017)

  Changed paths:
    M bolt/Passes/StokeInfo.cpp
    M bolt/Passes/StokeInfo.h

  Log Message:
  -----------
  add: get function score to find hot functions refine the dumped csv format

Summary: minor modification of the bolt stoke pass

(cherry picked from FBD5471011)


  Commit: 787db1cf3e895ec3868657b125a44936bf7c18fd
      https://github.com/llvm/llvm-project/commit/787db1cf3e895ec3868657b125a44936bf7c18fd
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-07-25 (Tue, 25 Jul 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  Recognize AArch64 as a valid input

Summary:
BOLT needs to be configured with the LLVM
AArch64 backend. If the backend is linked into the LLVM
library, start processing AArch64 binaries.

(cherry picked from FBD5489369)


  Commit: 87481cb4946601fe48b7117dc6284e14ce2c1be3
      https://github.com/llvm/llvm-project/commit/87481cb4946601fe48b7117dc6284e14ce2c1be3
  Author: Bohan Ren <brian0129 at fb.com>
  Date:   2017-07-25 (Tue, 25 Jul 2017)

  Changed paths:
    M bolt/CalcCacheMetrics.cpp

  Log Message:
  -----------
  [BOLT] Improve Jump-Distance Metric -- Consider Function Execution Count

Summary:
Function execution count is very important. When calculating metric, we
should care more about functions which are known to be executed.

The correlations between this metric and both CPU time is slightly improved
to be close to  96% and the correlation between this metric and Cache Miss
remains the same 96%.

Thanks the suggestion from Sergey!

(cherry picked from FBD5494720)


  Commit: eb64d03b73662a4e63fa491df6f276287a5a8c50
      https://github.com/llvm/llvm-project/commit/eb64d03b73662a4e63fa491df6f276287a5a8c50
  Author: Yue Zhao <yzhao30 at fb.com>
  Date:   2017-07-27 (Thu, 27 Jul 2017)

  Changed paths:
    M bolt/Passes/StokeInfo.cpp
    M bolt/Passes/StokeInfo.h

  Log Message:
  -----------
  Reformat the register strings in the output so Stoke can parse without preprocessing.

Summary:
Minor change. Reformat the def-in, live-out register strings so that Stoke can parse
without doing preprocessing.

(cherry picked from FBD5537421)


  Commit: d27b31ee07cd27743005c4815fc24a6c8f83124b
      https://github.com/llvm/llvm-project/commit/d27b31ee07cd27743005c4815fc24a6c8f83124b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-08-01 (Tue, 01 Aug 2017)

  Changed paths:
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix reading LSDA address for PIC code

Summary:
Fix a bug while reading LSDA address in PIC format. The base address was
wrong for PC-relative value. There's more work involved in making PIC
code with C++ exceptions work.

(cherry picked from FBD5538755)


  Commit: ae409f0b277bb2954e60b63ae13dfc3dd1f51d7c
      https://github.com/llvm/llvm-project/commit/ae409f0b277bb2954e60b63ae13dfc3dd1f51d7c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-07-17 (Mon, 17 Jul 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Better match LTO functions profile.

Summary:
* Improve profile matching for LTO binaries that don't match 100%.
* Fix profile matching for '.LTHUNK*' functions.
* Add external outgoing branches (calls) for profile validation.

There's an improvement for 100% match profile and for stale LTO
profile. However, we are still not fully closing the gap with
stale profile when LTO is enabled.

(NOTE: I haven't updated all test cases yet)

(cherry picked from FBD5529293)


  Commit: e4290d083fbe2693eb22b03c2d72a099e54f89cb
      https://github.com/llvm/llvm-project/commit/e4290d083fbe2693eb22b03c2d72a099e54f89cb
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-08-04 (Fri, 04 Aug 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Disable last basic block assertion.

Summary:
While converting code from __builtin_unreachable() we were asserting
that a basic block with a conditional jump and a single CFG successor
was the last one before converting the jump to an unconditional one.

However, if that code was executed after a conditional tail call
conversion in the same function, the original last basic block
will no longer be the last one in the post-conversion layout.

I'm disabling the assertion since it doesn't seem worth it to add
extra checks for the basic block that used to be the last one.

(cherry picked from FBD5570298)


  Commit: b81ff8a8fcafeccc5c0466cba88344db2fbd8ba7
      https://github.com/llvm/llvm-project/commit/b81ff8a8fcafeccc5c0466cba88344db2fbd8ba7
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-08-04 (Fri, 04 Aug 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix SCTC issue with hot-cold split

Summary:
SCTC was deleting an unconditional branch to a block in the
cold area because it was the next block in the layout vector. Fix the
condition to only delete such branches when source and target are in
the same allocation area (either both hot or both cold).

(cherry picked from FBD5570300)


  Commit: 21c48f7d78249482cd0f8174ea20f76d9e628bdb
      https://github.com/llvm/llvm-project/commit/21c48f7d78249482cd0f8174ea20f76d9e628bdb
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-08-02 (Wed, 02 Aug 2017)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  Fix profiling for functions with multiple entry points

Summary:
Fix issue in memcpy where one of its entry points was getting
no profiling data and was wrongly considered cold, being put in the cold
region.

(cherry picked from FBD5569156)


  Commit: 0c07445110407d408f4f227070ae699c9486d5b4
      https://github.com/llvm/llvm-project/commit/0c07445110407d408f4f227070ae699c9486d5b4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-08-10 (Thu, 10 Aug 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/Passes/BinaryPasses.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix printing of dyno-stats

Summary:
We used to print dyno-stats after instruction lowering
which was skewing our metrics as tail calls were no longer
recognized as calls for one thing. The fix is to control
the point at which dyno-stats printing pass is run and run
it immediately before instruction lowering. In the future we
may decide to run the pass before some other intervening pass.

(cherry picked from FBD5605639)


  Commit: 49d1f5698d5cae27863927c5b06512f18b2740ae
      https://github.com/llvm/llvm-project/commit/49d1f5698d5cae27863927c5b06512f18b2740ae
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-08-04 (Fri, 04 Aug 2017)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/Exceptions.cpp
    M bolt/Passes/CMakeLists.txt
    A bolt/Passes/PLTCall.cpp
    A bolt/Passes/PLTCall.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] PLT optimization

Summary:
Add an option to optimize PLT calls:

  -plt  - optimize PLT calls (requires linking with -znow)
    =none - do not optimize PLT calls
    =hot  - optimize executed (hot) PLT calls
    =all  - optimize all PLT calls

When optimized, the calls are converted to use GOT reference
indirectly. GOT entries are guaranteed to contain a valid
function pointer if lazy binding is disabled - hence the
requirement for linker's -znow option.

Note: we can add an entry to .dynamic and drop a requirement
for -znow if we were moving .dynamic to a new segment.

(cherry picked from FBD5579789)


  Commit: bd8e4b9e879ad6a084ea66fea697bce2ba6ca778
      https://github.com/llvm/llvm-project/commit/bd8e4b9e879ad6a084ea66fea697bce2ba6ca778
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-08-27 (Sun, 27 Aug 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.h
    M bolt/Exceptions.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Support PIC-style exception tables

Summary:
Exceptions tables for PIC may contain indirect type references
that are also encoded using relative addresses.

This diff adds support for such encodings. We read PIC-style
type info table, and write it using new encoding.

(cherry picked from FBD5716060)


  Commit: ec5b3b0a655fbe01e4f4a08b54d70a2dd2959088
      https://github.com/llvm/llvm-project/commit/ec5b3b0a655fbe01e4f4a08b54d70a2dd2959088
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-08-31 (Thu, 31 Aug 2017)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix bug in SCTC

Summary:
After SCTC optimization fixDoubleJumps() was relying on CFG information
on the number of successors of a basic block. It ignored the fact that
conditional tail call had a successor outside of the function and
deleted a containing basic block.

Discovered while testing old HHVM with disabled jump tables.

(cherry picked from FBD5752903)


  Commit: 29d4f4cfac2891514548e93af94454668357d8e5
      https://github.com/llvm/llvm-project/commit/29d4f4cfac2891514548e93af94454668357d8e5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-09-13 (Wed, 13 Sep 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Ignore TLS relocations types

Summary:
No special handling is required for TLS relocations types,
and if we see them in the binary we can safely ignore those
types.

(cherry picked from FBD5853889)


  Commit: 9df155ce116bdd5fe6d870ea9c307fd537fe6e98
      https://github.com/llvm/llvm-project/commit/9df155ce116bdd5fe6d870ea9c307fd537fe6e98
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-08-02 (Wed, 02 Aug 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/Passes/CMakeLists.txt
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT] Introduce non-LBR mode

Summary:
Add support to read profiles collected without LBR. This
involves adapting our data aggregator perf2bolt and adding support
in llvm-bolt itself to read this data.

This patch also introduces different options to convert basic block
execution count to edge count, so BOLT can operate with its regular
algorithms to perform basic block layout. The most successful approach
is the default one.

(cherry picked from FBD5664735)


  Commit: ef0ec9edf9c93e61119fb9af5b5c09a132c73484
      https://github.com/llvm/llvm-project/commit/ef0ec9edf9c93e61119fb9af5b5c09a132c73484
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-09-18 (Mon, 18 Sep 2017)

  Changed paths:
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/StackPointerTracking.h

  Log Message:
  -----------
  [BOLT] Fix frameopt=all for gcc

Summary:
Fix two bugs. First, stack pointer tracking, the dataflow
analysis, was converging to the "superposition" state (meaning that at
this point there are multiple and conflicting states) too early in case
the entry state in the BB was "empty" AND there was an SP computation in
the block. In these cases, we need to propagate an "empty" value as well
and wait for an iteration where the input is not empty (only entry BBs
start with a non-empty well-defined value). Previously, it was
propagating "superposition", meaning there is a conflict of states in
this block, which is not true, since the input is empty and, therefore,
there is no preceding state to justify a collision of states.

Second, if SPT failed and has no idea about the stack values in a block
(if it is in the superposition state at a given point in a BB), shrink
wrapping should not attempt to insert computation into those blocks
that we do not understand what is happening. Fix it to bail on those
cases.

(cherry picked from FBD5858402)


  Commit: b006d2a8604daf4f3bdb29513bec42642bcea160
      https://github.com/llvm/llvm-project/commit/b006d2a8604daf4f3bdb29513bec42642bcea160
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-09-20 (Wed, 20 Sep 2017)

  Changed paths:
    M bolt/Exceptions.cpp

  Log Message:
  -----------
  [BOLT] Fix issue with exception handlers splitting

Summary:
A cold part of a function can start with a landing pad. As a
result, this landing pad will have offset 0 from the start
of the corresponding FDE, and it wouldn't get registered by
exception-handling runtime.

The solution is to use a different landing pad base address
(LPStart), such as (FDE_start - 1).

(cherry picked from FBD5876561)


  Commit: 156fc73157284b69817127fba9f41b6f52c20cfc
      https://github.com/llvm/llvm-project/commit/156fc73157284b69817127fba9f41b6f52c20cfc
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-09-19 (Tue, 19 Sep 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix SCTC bug

Summary:
If conditional branch has been converted to conditional tail call,
it may be considered for SCTC optimization later since it will
appear as a tail call. We have to make sure that the tail call
we are considering is not a conditional branch.

(cherry picked from FBD5884777)


  Commit: 42f957bb75d9cd755dd7a1040d82550991e38763
      https://github.com/llvm/llvm-project/commit/42f957bb75d9cd755dd7a1040d82550991e38763
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-09-01 (Fri, 01 Sep 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/CMakeLists.txt
    A bolt/DataAggregator.cpp
    A bolt/DataAggregator.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h
    M bolt/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLT] Integrate perf2bolt into llvm-bolt

Summary:
Move the data aggregator logic from our python script to
our C++ LLVM/BOLT libs. This has a dramatic reduction in processing
time for profiling data (from 45 minutes for HHVM to 5 minutes) because
we directly use BOLT as a disassembler in order to validate traces found
in the LBR and to add the fallthrough counts. Previously, the python
approach relied on parsing the output objdump to check traces.

(cherry picked from FBD5761313)


  Commit: aa05dc91c51d5b9acac3cf1c0f43ef386fd44e9f
      https://github.com/llvm/llvm-project/commit/aa05dc91c51d5b9acac3cf1c0f43ef386fd44e9f
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-09-21 (Thu, 21 Sep 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  Fix SCTC bug when two pred/succ BB are in a loop.

Summary: It's possible that two basic blocks being conidered for SCTC are in a loop in the CFG.  In this case a block that is both a predecessor and a successor may have been processed and marked invalid by a previous iteration of the SCTC loop. We should skip rewriting in this case.

(cherry picked from FBD5886721)


  Commit: f32784f4cb410514ae1f57a6b43dc3fbcb9cba7f
      https://github.com/llvm/llvm-project/commit/f32784f4cb410514ae1f57a6b43dc3fbcb9cba7f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-09-25 (Mon, 25 Sep 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Ignore Clang LTO artifact file symbol

Summary:
The presence of ld-temp.o symbol is somewhat indeterministic.
I couldn't find out exactly when it's generated, it could be
related to LTO vs ThinLTO, but not always.

If the symbol is there, it could affect names of most
of functions in LTO binary. The status of the symbol
may change between the binary the profile was collected on,
and the binary BOLT is called on. As a result, we may mismatch
many function names.

It is safe to ignore this symbol.

(cherry picked from FBD5908955)


  Commit: f02c8c29ee578a52b9710da2315e352f4036c3d3
      https://github.com/llvm/llvm-project/commit/f02c8c29ee578a52b9710da2315e352f4036c3d3
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-09-26 (Tue, 26 Sep 2017)

  Changed paths:
    M bolt/DataAggregator.cpp

  Log Message:
  -----------
  [PERF2BOLT] Improve user messages about profiling stats

Summary:
Improve messages and color-code bad traces percentage, warning
user about a potential input binary mismatch.

(cherry picked from FBD5915934)


  Commit: 9df6dce2348d2e4976207af8e4cb3f0a29c1a7a2
      https://github.com/llvm/llvm-project/commit/9df6dce2348d2e4976207af8e4cb3f0a29c1a7a2
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-10-09 (Mon, 09 Oct 2017)

  Changed paths:
    M bolt/DataAggregator.cpp

  Log Message:
  -----------
  [PERF2BOLT] Fix aggregator wrt new output format of perf

Summary:
Perf is now outputting one less space, which broke our previous
(flaky) assumptions about field separators when processing the output
file. Make it more resilient by accepting any number of spaces before
reading LBR entries.

(cherry picked from FBD6014941)


  Commit: f77a6acd7192947310ade878c932ec7fe05c8382
      https://github.com/llvm/llvm-project/commit/f77a6acd7192947310ade878c932ec7fe05c8382
  Author: spupyrev <spupyrev at fb.com>
  Date:   2017-10-09 (Mon, 09 Oct 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  fixing sizes

Summary: In some (weird) cases, a Function is marked 'split' but doesn't contain any 'cold' basic block. In that case, the size of the last basic block of the function is computed incorrectly. Hence, this fix.

(cherry picked from FBD6012963)


  Commit: 0ed144a188d042fe729f135555be8a5c14962324
      https://github.com/llvm/llvm-project/commit/0ed144a188d042fe729f135555be8a5c14962324
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-10-06 (Fri, 06 Oct 2017)

  Changed paths:
    M bolt/DataAggregator.cpp
    M bolt/DataAggregator.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [PERF2BOLT] Check build-ids of binaries when aggregating

Summary:
Check the build-id of the input binary against the build-id of
the binary used during profiling data collection with perf, as reported
in perf.data. If they differ, issue a warning, since the user should use
exactly the same binary. If we cannot determine the build-id of either
the input binary or the one registered in the input perf.data, cancel the
build-id check but print a log message.

(cherry picked from FBD6001917)


  Commit: 0cc2a62f6a2f3b28922e0acebded492e92058244
      https://github.com/llvm/llvm-project/commit/0cc2a62f6a2f3b28922e0acebded492e92058244
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-10-06 (Fri, 06 Oct 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Write bolt info according to ELF spec

Summary:
Follow ELF spec for NOTE sections when writing bolt info.
Since tools such as "readelf -n" will not recognize a custom code
identifying our new note section, we use GNU "gold linker version"
note, tricking readelf into printing bolt info.

(cherry picked from FBD6010153)


  Commit: 7689cf2417c5b0d42da7bd2fcc3271d7f9897a6e
      https://github.com/llvm/llvm-project/commit/7689cf2417c5b0d42da7bd2fcc3271d7f9897a6e
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-10-10 (Tue, 10 Oct 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix bolt_info ELF note

Summary:
Small fix - align the end of the descriptor string as well,
since readelf will detect when it is not aligned and print an error
instead of printing BOLT version and command line.

(cherry picked from FBD6023643)


  Commit: 3d3fefff46721d9a24d9f93c06e9cd4a38b98c62
      https://github.com/llvm/llvm-project/commit/3d3fefff46721d9a24d9f93c06e9cd4a38b98c62
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-10-10 (Tue, 10 Oct 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Use 32 as the default max bytes for function alignment

Summary:
Several benchmarks (hhvm, compilers) show that 32 provides a good
balance between I-Cache performance and iTLB misses.

(cherry picked from FBD6026476)


  Commit: 1605f07f5c55a2c8a46a57e67287c94468a4b593
      https://github.com/llvm/llvm-project/commit/1605f07f5c55a2c8a46a57e67287c94468a4b593
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-10-10 (Tue, 10 Oct 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Create symbol table entries under -hot-text if they did not exist

Summary:
If "-hot-text" options is specified and the input binary did not
have __hot_start/__hot_end symbols, then add them to the symbol table.

(cherry picked from FBD6027737)


  Commit: bee9132a54b48deb5932530ee660b5314664a8c7
      https://github.com/llvm/llvm-project/commit/bee9132a54b48deb5932530ee660b5314664a8c7
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-10-16 (Mon, 16 Oct 2017)

  Changed paths:
    M bolt/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  [BOLT] Change function order file format for linker script

Summary:
Change output of "-generate-function-order=<file>" to match expected
format used for a linker script:

  * Prefix function names with ".text".
  * Strip internal suffix from local function names. E.g. for function
    with names "foo/1" and "foo/foo.c/1" we will only output "foo".
  * Output (with indentation) duplicate names for folded functions.

(cherry picked from FBD6071020)


  Commit: 4c8f48be3d3b7968be47dffe7103c0c694730aa6
      https://github.com/llvm/llvm-project/commit/4c8f48be3d3b7968be47dffe7103c0c694730aa6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-10-17 (Tue, 17 Oct 2017)

  Changed paths:
    M bolt/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  [BOLT] Fix function order output option

Summary:
Add support to output both function order and section order files
as the former is useful for offloading functions sorting and
the latter is useful for linker script generation:

  -generate-function-order=<file>
  -generate-link-sections=<file>

(cherry picked from FBD6078446)


  Commit: b77172ce2f42769631f24164a80c6b4453ebe42d
      https://github.com/llvm/llvm-project/commit/b77172ce2f42769631f24164a80c6b4453ebe42d
  Author: spupyrev <spupyrev at fb.com>
  Date:   2017-10-16 (Mon, 16 Oct 2017)

  Changed paths:
    M bolt/CMakeLists.txt
    A bolt/CacheMetrics.cpp
    A bolt/CacheMetrics.h
    R bolt/CalcCacheMetrics.cpp
    R bolt/CalcCacheMetrics.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  updating cache metrics

Summary:
This is a replacement of a previous diff. The implemented metric
('graph distance') is not very useful at the moment but I plan to add
more relevant metrics in the subsequent diff. This diff fixes some
obvious problems and moves the call of CalcMetrics::printAll to the
right place.

(cherry picked from FBD6072312)


  Commit: 1e1833c8a2c51041cbf2511a8fecc340ecbdcf2e
      https://github.com/llvm/llvm-project/commit/1e1833c8a2c51041cbf2511a8fecc340ecbdcf2e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-10-12 (Thu, 12 Oct 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/Inliner.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][Refactoring] Make CTC first class operand, etc.

Summary:
This diff is a preparation for decoupling function disassembly,
profile association, and CFG construction phases.

We used to have multiple ways to mark conditional tail calls with
annotations or TailCallOffsets map. Since CTC information is affecting
the correctness, it is justifiable to have it as a operand class for
instruction with a destination (0 is a valid one).

"Offset" annotation now replaces "EdgeCountData" and
"IndirectBranchData" annotations to extract profile data for any
given instruction.

Inlining for small functions was broken in a presence of
profiled (annotated) instructions and hence I had to remove
"-inline-small-functions" from the test case.

Also fix an issue with UNDEF section for created __hot_start/__hot_end
symbols. Now the symbols use ABS section.

(cherry picked from FBD6087284)


  Commit: 2ab74723291a7573cde1c867eb306c0d8419ee7b
      https://github.com/llvm/llvm-project/commit/2ab74723291a7573cde1c867eb306c0d8419ee7b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-10-10 (Tue, 10 Oct 2017)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Account for FDE functions when calculating max function size

Summary:
When we calculate maximum function size we only used to rely on the
symbol table information, and ignore function info coming from FDEs.
Invalid maximum function size can lead to code emission over
the code of neighbouring function.

Fix this by considering FDE functions when determining the maximum
function size.

(cherry picked from FBD6025613)


  Commit: c58996fd559f282988432f95adc177a6b55781e1
      https://github.com/llvm/llvm-project/commit/c58996fd559f282988432f95adc177a6b55781e1
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-10-19 (Thu, 19 Oct 2017)

  Changed paths:
    M bolt/Passes/DataflowAnalysis.cpp
    M bolt/Passes/DataflowAnalysis.h
    M bolt/Passes/LivenessAnalysis.h

  Log Message:
  -----------
  [BOLT] Add ability to specify custom printers for annotations.

Summary:
This will give us the ability to print annotations in a more meaningful way.  Especially annotations that could be interpreted in multiple ways.  I've added one register name printer for liveness analysis.  We can update the other dataflow annotations as needed.

I also noticed that BitVector annotations were leaking since they contain heap allocated memory.  I made removeAnnotation call the annotation destructor explicitly to mitigate this but it won't fix the problem when annotations are just dropped en masse.

(cherry picked from FBD6105999)


  Commit: 61e5fbf8c34e0806f7cb0165ab385bbbb5c6d81e
      https://github.com/llvm/llvm-project/commit/61e5fbf8c34e0806f7cb0165ab385bbbb5c6d81e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-10-23 (Mon, 23 Oct 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DataReader.h
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT][Refactoring] Get rid of TailCallTerminatedBlocks, etc.

Summary:
More changes to allow separation of CFG construction and
profile assignment. Misc cleanups.

(cherry picked from FBD6158653)


  Commit: 244a476a2e53cbffcccb337daec23ad414f40bf4
      https://github.com/llvm/llvm-project/commit/244a476a2e53cbffcccb337daec23ad414f40bf4
  Author: spupyrev <spupyrev at fb.com>
  Date:   2017-10-18 (Wed, 18 Oct 2017)

  Changed paths:
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/BinaryFunctionCallGraph.h
    M bolt/Passes/CallGraph.cpp
    M bolt/Passes/CallGraph.h
    M bolt/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  using offsets for CG

Summary: Arc->AvgOffset can be used for function/block ordering to distinguish between calls from the beggining of a function and calls from the end of the function. This makes a difference for large functions.

(cherry picked from FBD6094221)


  Commit: 1288c81c9b5eaa5a3e87c67908f2904e56fea919
      https://github.com/llvm/llvm-project/commit/1288c81c9b5eaa5a3e87c67908f2904e56fea919
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-10-26 (Thu, 26 Oct 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Exceptions.cpp

  Log Message:
  -----------
  [BOLT][Refactoring] Change landing pads handling

Summary: Change the way we store and handle landing pads and throwers.

(cherry picked from FBD6169992)


  Commit: 9e42885d045eb09d316363bc5d74e9ad9cd9382f
      https://github.com/llvm/llvm-project/commit/9e42885d045eb09d316363bc5d74e9ad9cd9382f
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-10-16 (Mon, 16 Oct 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/DataAggregator.cpp
    M bolt/DataAggregator.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT] Add value profiling to BOLT

Summary:
Add support for reading value profiling info from perf data.  This diff adds support in DataReader/DataAggregator for value profiling data.  Each event is recorded as two Locations (a PC and an address/value) and a count.

For now, I'm assuming that the value profiling data is in the same file as the usual BOLT profiling data.  Collecting both at the same time seems to work.

(cherry picked from FBD6076877)


  Commit: 46866f5fa0248520a2da699e897ea2d44cb2b523
      https://github.com/llvm/llvm-project/commit/46866f5fa0248520a2da699e897ea2d44cb2b523
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-01 (Wed, 01 Nov 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Exceptions.cpp
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/LivenessAnalysis.h
    M bolt/Passes/ReachingDefOrUse.h
    M bolt/Passes/RegAnalysis.cpp
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/StackPointerTracking.h
    M bolt/Passes/StokeInfo.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Refactor branch analysis code.

Summary:
Move the indirect branch analysis code from BinaryFunction to MCInstrAnalysis/X86MCTargetDesc.cpp.

In the process of doing this, I've added an MCRegInfo to MCInstrAnalysis which allowed me to remove a bunch of extra method parameters.  I've also had to refactor how BinaryFunction held on to instructions/offsets so that it would be easy to pass a sequence of instructions to the analysis code (rather than a map keyed by offset).

Note: I think there are a bunch of MCInstrAnalysis methods that have a BitVector output parameter that could be changed to a return value since the size of the vector is based on the number of registers, i.e. from MCRegisterInfo.  I haven't done this in order to keep the diff a more manageable size.

(cherry picked from FBD6213556)


  Commit: e838b354ce21bce707c315d06bc89f3e07aac7ce
      https://github.com/llvm/llvm-project/commit/e838b354ce21bce707c315d06bc89f3e07aac7ce
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-11-06 (Mon, 06 Nov 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h

  Log Message:
  -----------
  [BOLT][Refactoring] Move basic block reordering to BinaryPasses

Summary:
Refactor basic block reordering code out of the BinaryFunction.

BinaryFunction::isSplit() is now checking if the first and the last
blocks in the layout belong to the same fragment. As a result,
it no longer returns true for functions that have their cold part
optimized away.

Change type for returned "size" from unsigned to size_t.

Fix lines over 80 characters long.

(cherry picked from FBD6250825)


  Commit: 0b967eb01262e88d30dfbcb9a7074f1083b4398e
      https://github.com/llvm/llvm-project/commit/0b967eb01262e88d30dfbcb9a7074f1083b4398e
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-06 (Mon, 06 Nov 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Always call fixBranches in relocation mode.

Summary:
If you attempted to use a function filter on a binary when in relocation mode, the resulting binary would probably crash.  This is because we weren't calling fixBranches on all functions.  This was breaking bughunter.sh

I also strengthened the validation of basic blocks.  The cond branch should always be non-null when there are two successors.

(cherry picked from FBD6261930)


  Commit: 848cb78080ad5c07515745c8dc90a884451cc2c7
      https://github.com/llvm/llvm-project/commit/848cb78080ad5c07515745c8dc90a884451cc2c7
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-07 (Tue, 07 Nov 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/HFSortPlus.cpp

  Log Message:
  -----------
  [BOLT] Fix BOLT build

Summary: The latest change to MCInstrAnalysis broke then clang build.  This fixes it.

(cherry picked from FBD6262308)


  Commit: 19fea927927634b255176d070b76aebf31cb909e
      https://github.com/llvm/llvm-project/commit/19fea927927634b255176d070b76aebf31cb909e
  Author: spupyrev <spupyrev at fb.com>
  Date:   2017-10-27 (Fri, 27 Oct 2017)

  Changed paths:
    M bolt/Passes/CallGraph.cpp
    M bolt/Passes/CallGraph.h
    M bolt/Passes/HFSort.h
    M bolt/Passes/HFSortPlus.cpp
    M bolt/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  improving hfsort+ algorithm

Summary:
A few improvements for hfsort+ algorithm. The goal of the diff is (i) to make the resulting function order more i-cache "friendly" and (ii) fix a bug with incorrect input edge weights. A specific list of changes is as follows:
- The "samples" field of CallGraph.Node should be at least the sum of incoming edge weights. Fixed with a new method CallGraph::adjustArcWeights()
- A new optimization pass for hfsort+ in which pairs of functions that call each other with very high probability (>=0.99) are always merged. This improves the resulting i-cache but may worsen i-TLB. See a new method HFSortPlus::runPassOne()
- Adjusted optimization goal to make the resulting ordering more i-cache "friendly", see HFSortPlus::expectedCalls and HFSortPlus::mergeGain
- Functions w/o samples are now reordered too (they're placed at the end of the list of hot functions). These functions do appear in the call graph, as some of their basic blocks have samples in the LBR dataset. See HfSortPlus::initializeClusters

(cherry picked from FBD6248850)


  Commit: fe6e9b4ab5b439b41c8e0c215529b4a8218b4778
      https://github.com/llvm/llvm-project/commit/fe6e9b4ab5b439b41c8e0c215529b4a8218b4778
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-08-24 (Thu, 24 Aug 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/StokeInfo.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT-AArch64] Support rewriting bzip2

Summary:
Add basic AArch64 read/write capability to be able to
disassemble bzip2 for AArch64 compiled with gcc 5.4.0 and write
it back after going through the basic BOLT pipeline with no block
reordering (NOPs/unreachable blocks get removed).

This is not for relocation mode.

(cherry picked from FBD5701994)


  Commit: 76d7740cc9a0d7828cfed55f3fc95937821b5cbc
      https://github.com/llvm/llvm-project/commit/76d7740cc9a0d7828cfed55f3fc95937821b5cbc
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-08-31 (Thu, 31 Aug 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/CMakeLists.txt
    A bolt/Passes/LongJmp.cpp
    A bolt/Passes/LongJmp.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT-AArch64] Support reordering bzip2 no relocs

Summary:
Add functionality to support reordering bzip2 compiled to
AArch64, with function splitting but without relocations:

 * Expand the AArch64 backend to support inverting branches and
analyzing branches so BOLT reordering machinery is able to shuffle
blocks and fix branches correctly;
 * Add a new pass named LongJmp to add stubs whenever code needs to
jump to the cold area, when using function splitting, because of the
limited target encoding capability in AArch64 (as a RISC architecture).

(cherry picked from FBD5748184)


  Commit: 624b2d984a9e2c1bcd9f35775da62c8be476b628
      https://github.com/llvm/llvm-project/commit/624b2d984a9e2c1bcd9f35775da62c8be476b628
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-09-20 (Wed, 20 Sep 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/LongJmp.cpp
    M bolt/Passes/LongJmp.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT-AArch64] Support relocation mode for bzip2

Summary:
As we deal with incomplete addresses in address-computing
sequences of code in AArch64, we found it is easier to handle them in
relocation mode in the presence of relocations.

Incomplete addresses may mislead BOLT into thinking there are
instructions referring to a basic block when, in fact, this may be the
base address of a data reference. If the relocation is present, we can
easily spot such cases.

This diff contains extensions in relocation mode to understand and
deal with AArch64 relocations. It also adds code to process data inside
functions as marked by AArch64 ABI (symbol table entries named "$d").
In our code, this is called constant islands handling. Last, it extends
bughunter with a "cross" mode, in which the host generates the binaries
and the user test them (uploading to the target), useful when debugging
in AArch64.

(cherry picked from FBD6024570)


  Commit: 69ddcfa5cb277da2c818f0a888af0c573d820831
      https://github.com/llvm/llvm-project/commit/69ddcfa5cb277da2c818f0a888af0c573d820831
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-11-06 (Mon, 06 Nov 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/ReorderAlgorithm.cpp

  Log Message:
  -----------
  [BOLT] Fix implementation for TSP solution

Summary:
Fix a bug in reconstruction of an optimal path. When calculating the
best path we need to take into account a path from new "last" node
to the current last node.

Add "-tsp-threshold" (defaults to 10) to control when the TSP
algorithm should be used.

(cherry picked from FBD6253461)


  Commit: dd6ecdd782408de3e6e2b8b2735ddd8d92e358dd
      https://github.com/llvm/llvm-project/commit/dd6ecdd782408de3e6e2b8b2735ddd8d92e358dd
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-10-16 (Mon, 16 Oct 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/LongJmp.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT-AArch64] Support reordering spec06 gcc relocs

Summary:
Enhance the basic infrastructure for relocation mode for
AArch64 to make a reasonably large program work after reordering (gcc).

Detect jump table patterns and skip optimizing functions with jump
tables in AArch64, as those will require extra future effort to fully
decode. To make these work in relocation mode, we skip changing
the function body and introduce a mode to preserve even the original
nops. By not changing any local offsets in the function, the input
original jump tables should just work.

Functions with no jump tables are optimized with BB reordering. No other
optimizations have been tested.

(cherry picked from FBD6130117)


  Commit: a0c041f72a56bd79ccbc99f914a8bf86895b836e
      https://github.com/llvm/llvm-project/commit/a0c041f72a56bd79ccbc99f914a8bf86895b836e
  Author: spupyrev <spupyrev at fb.com>
  Date:   2017-10-27 (Fri, 27 Oct 2017)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    A bolt/Passes/Aligner.cpp
    A bolt/Passes/Aligner.h
    M bolt/Passes/CMakeLists.txt
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Custom function alignment

Summary:
A new 'compact' function aligner that takes function sizes in consideration. The approach is based on the following assumptions:
-- It is not desirable to introduce a large offset when aligning short functions, as it leads to a lot of "wasted" address space.
-- For longer functions, the offset can be larger than the default 32 bytes; However, using 64 bytes for the offset still worsen performance, as again a lot of address space is wasted.
-- Cold parts of functions can still use the default max-32 offset.

The algorithm is switched on/off by flag 'use-compact-aligner' and is controlled by parameters align-functions-max-bytes and align-cold-functions-max-bytes described above. In my tests the best performance is produced with '-use-compact-aligner=true -align-functions-max-bytes=48 -align-cold-functions-max-bytes=32'.

(cherry picked from FBD6194092)


  Commit: f8e6f66c1e95e3dbe00df1d25ab53112b4f86635
      https://github.com/llvm/llvm-project/commit/f8e6f66c1e95e3dbe00df1d25ab53112b4f86635
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-11-08 (Wed, 08 Nov 2017)

  Changed paths:
    M bolt/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Fix segfault in debug print

Summary:
With "-debug" flag we are using a dump in intermediate state when
basic block's list is initialized, but layout is not. In new isSplit()
funciton we were checking the size() which uses basic block list,
and then we were accessing the (uninitiazed) layout.
Instead of checking size() we should be checking layout_size().

(cherry picked from FBD6277770)


  Commit: e9aa6e1a33179c809414cef9b549dd7bdacf0176
      https://github.com/llvm/llvm-project/commit/e9aa6e1a33179c809414cef9b549dd7bdacf0176
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-07 (Tue, 07 Nov 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h

  Log Message:
  -----------
  [BOLT] Fix N-1'th sctc bug.

Summary:
The logic to append an unconditional branch at the end of a block that had
the condition flipped on its conditional tail was broken.  It should have
been looking at the successor to PredBB instead of BB.  It also wasn't skipping
invalid blocks when finding the fallthrough block.

This fixes the SCTC bug uncovered by @spupyrev's work on block reordering.

(cherry picked from FBD6269493)


  Commit: a3b719e0f9fbcb47b6e6d3827c18a69cf364eebf
      https://github.com/llvm/llvm-project/commit/a3b719e0f9fbcb47b6e6d3827c18a69cf364eebf
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-11-08 (Wed, 08 Nov 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/DWARFRewriter.cpp
    M bolt/DebugData.h

  Log Message:
  -----------
  [BOLT] Fix ASAN bugs

Summary:
Fix a leak in DEBUGRewriter.cpp and an address out of bounds
issue in edit distance calculation.

(cherry picked from FBD6290026)


  Commit: 7eaaaaba96fc7dcfbcf448e0c2dfe74d959518c9
      https://github.com/llvm/llvm-project/commit/7eaaaaba96fc7dcfbcf448e0c2dfe74d959518c9
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-08 (Wed, 08 Nov 2017)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Add finer control of peephole pass.

Summary: Add selective control over peephole options.  This makes it easier to test which ones might have a positive effect.

(cherry picked from FBD6289659)


  Commit: 0836fa7d086837106f1a6e3055cd56d32fae410e
      https://github.com/llvm/llvm-project/commit/0836fa7d086837106f1a6e3055cd56d32fae410e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-11-13 (Mon, 13 Nov 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix handling of RememberState CFI

Summary:
When RememberState CFI happens to be the last CFI in a basic block, we
used to set the state of the next basic block to a CFI prior to
executing RememberState instruction. This contradicts comments in
annotateCFIState() function and also differs form behaviour of
getCFIStateAtInstr(). As a result we were getting code like the
following:

  .LBB0121166 (21 instructions, align : 1)
    CFI State : 0
    ....
      0000001a:   !CFI    $1      ; OpOffset Reg6 -16
      0000001a:   !CFI    $2      ; OpRememberState
    ....
    Successors: .Ltmp4167600, .Ltmp4167601
    CFI State: 3

  .Ltmp4167601 (13 instructions, align : 1)
    CFI State : 2
    ....

Notice that the state at the entry of the 2nd basic block is less than
the state at the exit of the previous basic block.

In practice we have never seen basic blocks where RememberState was the
last CFI instruction in the basic block, and hence we've never run into
this issue before.

The fix is a synchronization of handling of last RememberState
instruction by annotateCFIState() and getCFIStateAtInstr().
In the example above, the CFI state at the entry to the second BB will
be 3 after this diff.

(cherry picked from FBD6314916)


  Commit: 1475c4da7116bd2cec7eeb9b12136c439d47fadc
      https://github.com/llvm/llvm-project/commit/1475c4da7116bd2cec7eeb9b12136c439d47fadc
  Author: spupyrev <spupyrev at fb.com>
  Date:   2017-11-15 (Wed, 15 Nov 2017)

  Changed paths:
    M bolt/Passes/HFSort.h
    M bolt/Passes/HFSortPlus.cpp
    M bolt/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  speeding up caches for hfsort+

Summary:
When running hfsort+, we invalidate too many cache entries, which leads to inefficiencies. It seems we only need to invalidate cache for pairs of clusters (Into, X) and (X, Into) when modifying cluster Into (for all clusters X).
With the modification, we do not really need ShortCache, since it is computed only once per pair of clusters.

(cherry picked from FBD6341039)


  Commit: c4d7460ed6d61febbe21a51da9b340d18e44aaaf
      https://github.com/llvm/llvm-project/commit/c4d7460ed6d61febbe21a51da9b340d18e44aaaf
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-10-20 (Fri, 20 Oct 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/DataAggregator.cpp
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/IndirectCallPromotion.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Improve ICP for virtual method calls and jump tables using value profiling.

Summary:
Use value profiling data to remove the method pointer loads from vtables when doing ICP at virtual function and jump table callsites.

The basic process is the following:
1. Work backwards from the callsite to find the most recent def of the call register.
2. Work back from the call register def to find the instruction where the vtable is loaded.
3. Find out of there is any value profiling data associated with the vtable load.  If so, record all these addresses as potential vtables + method offsets.
4. Since the addresses extracted by #3 will be vtable + method offset, we need to figure out the method offset in order to determine the actual vtable base address.  At this point I virtually execute all the instructions that occur between #3 and #2 that touch the method pointer register.  The result of this execution should be the method offset.
5. Fetch the actual method address from the appropriate data section containing the vtable using the computed method offset.  Make sure that this address maps to an actual function symbol.
6. Try to associate a vtable pointer with each target address in SymTargets.  If every target has a vtable, then this is almost certainly a virtual method callsite.
7. Use the vtable address when generating the promoted call code.  It's basically the same as regular ICP code except that the compare is against the vtable and not the method pointer.  Additionally, the instructions to load up the method are dumped into the cold call block.

For jump tables, the basic idea is the same.  I use the memory profiling data to find the hottest slots in the jumptable and then use that information to compute the indices of the hottest entries. We can then compare the index register to the hot index values and avoid the load from the jump table.

Note: I'm assuming the whole call is in a single BB.  According to @rafaelauler, this isn't always the case on ARM.    This also isn't always the case on X86 either.  If there are non-trivial arguments that are passed by value, there could be branches in between the setup and the call.  I'm going to leave fixing this until later since it makes things a bit more complicated.

I've also fixed a bug where ICP was introducing a conditional tail call.  I made sure that SCTC fixes these up afterwards.  I have no idea why I made it introduce a CTC in the first place.

(cherry picked from FBD6120768)


  Commit: b2f132c7c2d0867a9d2232cd4a5bedeb8bbbed54
      https://github.com/llvm/llvm-project/commit/b2f132c7c2d0867a9d2232cd4a5bedeb8bbbed54
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-04 (Sat, 04 Nov 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Exceptions.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/Inliner.cpp

  Log Message:
  -----------
  [RFC] [BOLT] Use iterators for MC branch/call analysis code.

Summary:
Here's an implementation of an abstract instruction iterator for the branch/call
analysis code in MCInstrAnalysis.  I'm posting it up to see what you guys think.
It's a bit sloppy with constness and probably needs more tidying up.

(cherry picked from FBD6244012)


  Commit: dc23def477069b5a0e950fb22884c4033206ce6d
      https://github.com/llvm/llvm-project/commit/dc23def477069b5a0e950fb22884c4033206ce6d
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-11-27 (Mon, 27 Nov 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [PERF2BOLT] Fix aggregator wrt traces with REP RET

Summary:
Previously the perf2bolt aggregator was rejecting traces
finishing with REP RET (return instruction with REP prefix) as a
result of the migration from objdump output to LLVM disassembler,
which decodes REP as a separate instruction. Add code to detect
REP RET and treat it as a single return instruction.

(cherry picked from FBD6417496)


  Commit: 591e0ef3ba489dfa730dfa8443e4d2d7e743075f
      https://github.com/llvm/llvm-project/commit/591e0ef3ba489dfa730dfa8443e4d2d7e743075f
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-27 (Mon, 27 Nov 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Add timers for non-optimization related phases.

Summary: Add timers for non-optimization related phases.  There are two new options, -time-build for disassembling functions and building CFGs, and -time-rewrite for phases in executeRewritePass().

(cherry picked from FBD6422006)


  Commit: 0bab742949a413940f8587686084f72ee1e5d431
      https://github.com/llvm/llvm-project/commit/0bab742949a413940f8587686084f72ee1e5d431
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-19 (Sun, 19 Nov 2017)

  Changed paths:
    M bolt/Passes/IndirectCallPromotion.cpp

  Log Message:
  -----------
  [BOLT] Fix icp-top-callsites option, remove icp-always-on.

Summary: The icp-top-callsites option was using basic block counts to pick the top callsites while the ICP main loop was using branch info from the targets of each call.  These numbers do not exactly match up so there was a dispcrepancy in computing the top calls.  I've switch top callsites over to use the same stats as the main loop.  The icp-always-on option was redundant with -icp-top-callsites=100, so I removed it.

(cherry picked from FBD6370977)


  Commit: a71b5700c0ab2510bd2f17d5807dc1aa2aa5b3b2
      https://github.com/llvm/llvm-project/commit/a71b5700c0ab2510bd2f17d5807dc1aa2aa5b3b2
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-29 (Wed, 29 Nov 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h

  Log Message:
  -----------
  [BOLT] Fix bug in shortening peephole.

Summary: The arithmetic shortening code on x86 was broken.  It would sometimes shorten instructions with immediate operands that wouldn't fit into 8 bits.

(cherry picked from FBD6444699)


  Commit: 39a8c36697784b34ee8c05e37b415d23ef0b5b42
      https://github.com/llvm/llvm-project/commit/39a8c36697784b34ee8c05e37b415d23ef0b5b42
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-30 (Thu, 30 Nov 2017)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Use getNumPrimeOperands in shortenInstruction.

Summary: Apply maks' review comments

(cherry picked from FBD6451164)


  Commit: 21eb2139ee3eb52dd71e124fff137310a649604e
      https://github.com/llvm/llvm-project/commit/21eb2139ee3eb52dd71e124fff137310a649604e
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-11-02 (Thu, 02 Nov 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/CMakeLists.txt
    M bolt/Passes/DataflowAnalysis.cpp
    A bolt/Passes/JTFootprintReduction.cpp
    A bolt/Passes/JTFootprintReduction.h
    M bolt/Passes/LivenessAnalysis.h

  Log Message:
  -----------
  Introduce pass to reduce jump tables footprint

Summary:
Add a pass to identify indirect jumps to jump tables and reduce
their entries size from 8 to 4 bytes. For PIC jump tables, it will
convert the PIC code to non-PIC (since BOLT only processes static code,
it makes no sense to use expensive PIC-style jumps in static code). Add
corresponding improvements to register scavenging pass and add a MCInst
matcher machinery.

(cherry picked from FBD6421582)


  Commit: 48a53a7b551ffd245d735771941c1b70199cfc5b
      https://github.com/llvm/llvm-project/commit/48a53a7b551ffd245d735771941c1b70199cfc5b
  Author: spupyrev <spupyrev at fb.com>
  Date:   2017-11-14 (Tue, 14 Nov 2017)

  Changed paths:
    M bolt/CacheMetrics.cpp
    M bolt/CacheMetrics.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  a new i-cache metric

Summary:
The diff introduces two measures for i-cache performance: a TSP measure (currently used for optimization) and an "extended" TSP measure that takes into account jumps between non-consecutive basic blocks. The two measures are computed for estimated addresses/sizes of basic blocks and for the actually omitted addresses/sizes.

Intuitively, the Extended-TSP metric quantifies the expected number of i-cache misses for a given ordering of basic blocks. It has 5 parameters:
 - FallthroughWeight is the impact of fallthrough jumps on the score
 - ForwardWeight is the impact of forward (but not fallthrough) jumps
 - BackwardWeight is the impact of backward jumps
 - ForwardDistance is the max distance of a forward jump affecting the score
 - BackwardDistance is the max distance of a backward jump affecting the score
We're still learning the "best" values for the options but default values look reasonable so far.

(cherry picked from FBD6331418)


  Commit: cd0a075a08f90b29cd6bd37ba183c5a6a197e12b
      https://github.com/llvm/llvm-project/commit/cd0a075a08f90b29cd6bd37ba183c5a6a197e12b
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-29 (Wed, 29 Nov 2017)

  Changed paths:
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/IndirectCallPromotion.h

  Log Message:
  -----------
  [BOLT] Fix ICP nested jump table handling and general stats.

Summary: Load elimination for ICP wasn't handling nested jump tables correctly.  It wasn't offseting the indices by the range of the nested table.  I also wasn't computing some of the stats ICP correctly in all cases which was leading to weird results in the stats.

(cherry picked from FBD6453693)


  Commit: 70d44ab20ab806f2956d8c2b465733a93db6c351
      https://github.com/llvm/llvm-project/commit/70d44ab20ab806f2956d8c2b465733a93db6c351
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-11-14 (Tue, 14 Nov 2017)

  Changed paths:
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/CMakeLists.txt
    M bolt/Passes/JTFootprintReduction.cpp
    M bolt/Passes/LivenessAnalysis.h
    A bolt/Passes/RegReAssign.cpp
    A bolt/Passes/RegReAssign.h

  Log Message:
  -----------
  [BOLT] Add REX prefix rebalancing pass

Summary:
Add a pass to rebalance the usage of REX prefixes, moving them
from the hot code path to the cold path whenever possible. To do this, we
rank the usage frequency of each register and exchange an X86 classic reg
with an extended one (which requires a REX prefix) whenever the classic
register is being used less times than the extended one. There are two
versions of this pass: regular one will only consider RBX as classic and
R12-R15 as extended registers because those are callee-saved, which means
their scope is local to the function and therefore they can be easily
interchanged within the function without further consequences. The
aggressive version relies on liveness analysis to detect if the value of
a register is being used as a caller-saved value (written to without
being read first), which also is eligible for reallocation. However, it
showed limited results and is not the default option because it is
expensive.

Currently, this pass does not update debug info. This means that if a
substitution is made, the AT_LOCATION of a variable inside a function may
be outdated and GDB will display the wrong value if you ask it to print
the value of the affected variable. Updating DWARF involves a painful
task of writing a new DWARF expression parser/writer similar to the one
we already have for CFI expressions. I'll defer the task of writing this
until we determine this optimization is enabled in production. So far,
it is experimental to be combined with other optimizations to help us
find a new set of optimizations that is beneficial.

(cherry picked from FBD6476659)


  Commit: 10274633eed30ea17070bba614c860a4dd9a663b
      https://github.com/llvm/llvm-project/commit/10274633eed30ea17070bba614c860a4dd9a663b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Options to facilitate debugging

Summary:
Some helpful options:

  -print-dyno-stats-only
    while printing functions output dyno-stats and skip instructions

  -report-stale
    print a list of functions with a stale profile

(cherry picked from FBD6505141)


  Commit: 2b9bafed836e46c5ea474ea63ef774b5a4127200
      https://github.com/llvm/llvm-project/commit/2b9bafed836e46c5ea474ea63ef774b5a4127200
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-12-08 (Fri, 08 Dec 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Consistent DFS ordering for landing pads

Summary:
The list of landing pads in BinaryBasicBlock was sorted by their address
in memory. As a result, the DFS order was not always deterministic.
The change is to store landing pads in the order they appear in invoke
instructions while keeping them unique.

Also, add Throwers verification to validateCFG().

(cherry picked from FBD6529032)


  Commit: b6f7c68a6c9a5e97dcc84cacc117f13ca01d42f1
      https://github.com/llvm/llvm-project/commit/b6f7c68a6c9a5e97dcc84cacc117f13ca01d42f1
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-12-09 (Sat, 09 Dec 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/DWARFRewriter.cpp
    M bolt/Passes/Aligner.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/JTFootprintReduction.cpp
    M bolt/Passes/LongJmp.cpp
    M bolt/Passes/RegReAssign.cpp
    M bolt/Passes/ReorderFunctions.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Automatically detect and use relocations

Summary:
If relocations are available in the binary, use them by default.
If "-relocs" is specified, then require relocations for further
processing. Use "-relocs=0" to forcefully ignore relocations.

Instead of `opts::Relocs` use `BinaryContext::HasRelocations` to check
for the presence of the relocations.

(cherry picked from FBD6530023)


  Commit: d15b93badec2ffdfc6e5a01b9386cdefb4ea59ac
      https://github.com/llvm/llvm-project/commit/d15b93badec2ffdfc6e5a01b9386cdefb4ea59ac
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-11-28 (Tue, 28 Nov 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    A bolt/BinaryFunctionProfile.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/CMakeLists.txt
    M bolt/DataAggregator.cpp
    M bolt/DataAggregator.h
    M bolt/DataReader.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/ReorderFunctions.cpp
    M bolt/Passes/ReorderFunctions.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h
    M bolt/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLT] Major overhaul of profiling in BOLT

Summary:
Profile reading was tightly coupled with building CFG. Since I plan
to move to a new profile format that will be associated with CFG
it is critical to decouple the two phases.

We now have read profile right after the cfg was constructed, but
before it is "canonicalized", i.e. CTCs will till be there.

After reading the profile, we do a post-processing pass that fixes
CFG and does some post-processing for debug info, such as
inference of fall-throughs, which is still required with the current
format.

Another good reason for decoupling is that we can use profile with
CFG to more accurately record fall-through branches during
aggregation.

At the moment we use "Offset" annotations to facilitate location
of instructions corresponding to the profile. This might not be
super efficient. However, once we switch to the new profile format
the offsets would be no longer needed. We might keep them for
the aggregator, but if we have to trust LBR data that might
not be strictly necessary.

I've tried to make changes while keeping backwards compatibly. This makes
it easier to verify correctness of the changes, but that also means
that we lose accuracy of the profile.

Some refactoring is included.

Flag "-prof-compat-mode" (on by default) is used for bug-level
backwards compatibility. Disable it for more accurate tracing.

(cherry picked from FBD6506156)


  Commit: 67cef1f5362048d39462ceffff41f3abca529408
      https://github.com/llvm/llvm-project/commit/67cef1f5362048d39462ceffff41f3abca529408
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-12-11 (Mon, 11 Dec 2017)

  Changed paths:
    M bolt/Passes/IndirectCallPromotion.cpp

  Log Message:
  -----------
  debug

(cherry picked from FBD28110897)


  Commit: 85f5f4fb631959ed55d818c3994e2d922a0ad948
      https://github.com/llvm/llvm-project/commit/85f5f4fb631959ed55d818c3994e2d922a0ad948
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-12-11 (Mon, 11 Dec 2017)

  Changed paths:
    M bolt/Passes/IndirectCallPromotion.cpp

  Log Message:
  -----------
  [BOLT] Fix debugging derp

(cherry picked from FBD28110992)


  Commit: 660daac2d0489045f2bb142a9f7eb5b7737f3594
      https://github.com/llvm/llvm-project/commit/660daac2d0489045f2bb142a9f7eb5b7737f3594
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-12-11 (Mon, 11 Dec 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix -simplify-rodata-loads wrt data chunks with relocs

Summary:
The pass was previously copying data that would change after layout
because it had a relocation at the copied address.

(cherry picked from FBD6541334)


  Commit: 1fa80594cf8b9e709cf8f7917e176993becfb139
      https://github.com/llvm/llvm-project/commit/1fa80594cf8b9e709cf8f7917e176993becfb139
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-12-13 (Wed, 13 Dec 2017)

  Changed paths:
    M bolt/Exceptions.cpp

  Log Message:
  -----------
  [BOLT] Do not assign a LP to tail calls

Summary:
Do not assign a LP to tail calls. They are not calls in the
view of an unwinder, they are just regular branches. We were hitting an
assertion in BinaryFunction::removeConditionalTailCalls() complaining
about landing pads in a CTC, however it was in fact a
builtin_unreachable being conservatively treated as a CTC.

(cherry picked from FBD6564957)


  Commit: a599fe1bbc90d8151a468e23e453321abda57a24
      https://github.com/llvm/llvm-project/commit/a599fe1bbc90d8151a468e23e453321abda57a24
  Author: spupyrev <spupyrev at fb.com>
  Date:   2017-12-01 (Fri, 01 Dec 2017)

  Changed paths:
    M bolt/CacheMetrics.cpp
    M bolt/CacheMetrics.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/CMakeLists.txt
    A bolt/Passes/CachePlusReorderAlgorithm.cpp
    M bolt/Passes/HFSortPlus.cpp
    M bolt/Passes/ReorderAlgorithm.h
    A bolt/Passes/ReorderUtils.h

  Log Message:
  -----------
  [BOLT] a new block reordering algorithm

Summary:
A new block reordering algorithm, cache+, that is designed to optimize
i-cache performance.

On a high level, this algorithm is a greedy heuristic that merges
clusters (ordered sequences) of basic blocks, similarly to how it is
done in OptimizeCacheReorderAlgorithm. There are two important
differences: (a) the metric that is optimized in the procedure, and
(b) how two clusters are merged together.
Initially all clusters are isolated basic blocks. On every iteration,
we pick a pair of clusters whose merging yields the biggest increase
in the ExtTSP metric (see CacheMetrics.cpp for exact implementation),
which models how i-cache "friendly" a pecific cluster is. A pair of
clusters giving the maximum gain is merged to a new clusters. The
procedure stops when there is only one cluster left, or when merging
does not increase ExtTSP. In the latter case, the remaining clusters
are sorted by density.
An important aspect is the way two clusters are merged. Unlike earlier
algorithms (e.g., OptimizeCacheReorderAlgorithm or Pettis-Hansen), two
clusters, X and Y, are first split into three, X1, X2, and Y. Then we
consider all possible ways of gluing the three clusters (e.g., X1YX2,
X1X2Y, X2X1Y, X2YX1, YX1X2, YX2X1) and choose the one producing the
largest score. This improves the quality of the final result (the
search space is larger) while keeping the implementation sufficiently
fast.

(cherry picked from FBD6466264)


  Commit: f8f52d01d012404ed76ea3dca703bd0776fd3b05
      https://github.com/llvm/llvm-project/commit/f8f52d01d012404ed76ea3dca703bd0776fd3b05
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-11-09 (Thu, 09 Nov 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/LongJmp.cpp
    M bolt/Passes/LongJmp.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT-AArch64] Support SPEC17 programs and organize AArch64 tests

Summary:
Add a few new relocation types to support a wider variety of
binaries, add support for constant island duplication (so we can split
functions in large binaries) and make LongJmp pass really precise with
respect to layout, so we don't miss stubs insertions at the correct
places for really large binaries. In LongJmp, introduce "freeze"
annotations so fixBranches won't mess the jumps we carefully determined
that needed a stub.

(cherry picked from FBD6294390)


  Commit: b6cb112febefef75d479f528fc09a52b806fb333
      https://github.com/llvm/llvm-project/commit/b6cb112febefef75d479f528fc09a52b806fb333
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-12-13 (Wed, 13 Dec 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryFunctionProfile.cpp
    M bolt/CMakeLists.txt
    M bolt/DataAggregator.cpp
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/IndirectCallPromotion.h
    M bolt/Passes/PLTCall.cpp
    A bolt/ProfileReader.cpp
    A bolt/ProfileReader.h
    A bolt/ProfileWriter.cpp
    A bolt/ProfileWriter.h
    A bolt/ProfileYAMLMapping.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] New profile format

Summary:
A new profile that is more resilient to minor binary modifications.

BranchData is eliminated. For calls, the data is converted into instruction
annotations if the profile matches a function. If a profile cannot be matched,
AllCallSites data should have call sites profiles.

The new profile format is YAML, which is quite verbose. It still takes
less space than the older format because we avoid function name repetition.

The plan is to get rid of the old profile format eventually.

merge-fdata does not work with the new format yet.

(cherry picked from FBD6753747)


  Commit: 907ca25841288975bfbed5d44a3992098ce47268
      https://github.com/llvm/llvm-project/commit/907ca25841288975bfbed5d44a3992098ce47268
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-11-22 (Wed, 22 Nov 2017)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/LongJmp.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT-AArch64] Support large test binary

Summary:
Rewrite how data/code markers are interpreted, so the code
can have constant islands essentially anywhere. This is necessary to
accomodate custom AArch64 assembly code coming from mozjpeg. Allow
any function to refer to the constant island owned by any other
function. When this happens, we pull the constant island from the
referred function and emit it as our own, so it will live nearby
the code that refers to it, allowing us to freely reorder functions
and code pieces. Make bolt more strict about not changing anything
in non-simple ARM functions, as we need to preserve offsets for
those functions we don't interpret their jump tables (currently
any function with jump tables in ARM is non-simple and is left
untouched).

(cherry picked from FBD6402324)


  Commit: 2640b4071f4790832d2c3d0ea4ed944991204579
      https://github.com/llvm/llvm-project/commit/2640b4071f4790832d2c3d0ea4ed944991204579
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-01-23 (Tue, 23 Jan 2018)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    A bolt/BinarySection.cpp
    A bolt/BinarySection.h
    M bolt/CMakeLists.txt
    M bolt/DWARFRewriter.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactoring - add BinarySection class

Summary: Add BinarySection class that is a wrapper around SectionRef.  This is refactoring work for static data reordering.

(cherry picked from FBD6792785)


  Commit: 89feb847ea9446afa870c6c43098fcd6061008b5
      https://github.com/llvm/llvm-project/commit/89feb847ea9446afa870c6c43098fcd6061008b5
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-01-24 (Wed, 24 Jan 2018)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinarySection.cpp
    M bolt/BinarySection.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactor relocation analysis code.

Summary:
Refactor the relocation anaylsis code.  It should be a little better at validating
that the relocation value matches up with the symbol address + addend stored in the
relocation (except on aarch64).  It is also a little better at finding the symbol
address used to do the lookup in BinaryContext, rather than just using symbol
address + addend.

(cherry picked from FBD6814702)


  Commit: 626e977c4a346e05b6be959b6d4145fe83498e81
      https://github.com/llvm/llvm-project/commit/626e977c4a346e05b6be959b6d4145fe83498e81
  Author: spupyrev <spupyrev at fb.com>
  Date:   2018-01-24 (Wed, 24 Jan 2018)

  Changed paths:
    M bolt/Passes/CachePlusReorderAlgorithm.cpp

  Log Message:
  -----------
  [BOLT] faster cache+ implementation

Summary:
Speeding up cache+ algorithm.

The idea is to find and merge "fallthrough" successors before main
optimization. For a pair of blocks, A and B, block B is the fallthrough
successor of A, if (i) all jumps (based on profile) from A goes to B
and (ii) all jumps to B are from A.
Such blocks should be adjacent in an optimal ordering, and should
not be considered for splitting. (This gives the speed up).

The gap between cache and cache+ reduced from ~2m to ~1m.

(cherry picked from FBD6799900)


  Commit: 48370744d98e1855557c91285ae3c911f6b186c0
      https://github.com/llvm/llvm-project/commit/48370744d98e1855557c91285ae3c911f6b186c0
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-01-29 (Mon, 29 Jan 2018)

  Changed paths:
    M bolt/BinaryFunctionProfile.cpp

  Log Message:
  -----------
  [BOLT] Do not assert on bad data

Summary:
A test is asserting on impossible addresses coming from
perf.data, instead of just reporting it as bad data. Fix this behavior.

(cherry picked from FBD6835590)


  Commit: 304c8ba80a097d03d174dd0aba312deb74e9666d
      https://github.com/llvm/llvm-project/commit/304c8ba80a097d03d174dd0aba312deb74e9666d
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-01-30 (Tue, 30 Jan 2018)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Handle multiple sections with the same name

Summary: Multiple sections can have the same name, so we need to make the NameToSectionMap into a multimap.

(cherry picked from FBD6847622)


  Commit: d114ef1fa5ed182741542902982b4d128c98bf68
      https://github.com/llvm/llvm-project/commit/d114ef1fa5ed182741542902982b4d128c98bf68
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-01-23 (Tue, 23 Jan 2018)

  Changed paths:
    M bolt/BinaryFunctionProfile.cpp

  Log Message:
  -----------
  [BOLT] Fix profile for multi-entry functions

Summary:
When we read profile for functions, we initialize counts for entry
blocks first, and then populate counts for all blocks based
on incoming edges.

During the second phase we ignore the entry blocks because we expect
them to be already initialized. For the primary entry at offset 0 it's
the correct thing to do, since we treat all incoming branches as calls
or tail calls. However, for secondary entries we only consider external
edges to be from calls and don't increase entry count if an edge
originates from inside the function. Thus we need to update the
secondary entry basic block counts with internal edges too.

(cherry picked from FBD6836817)


  Commit: 2b8194fa501578597bec5cab06fea0560d801001
      https://github.com/llvm/llvm-project/commit/2b8194fa501578597bec5cab06fea0560d801001
  Author: Qinfan Wu <wqfish at fb.com>
  Date:   2018-01-31 (Wed, 31 Jan 2018)

  Changed paths:
    M bolt/DWARFRewriter.cpp

  Log Message:
  -----------
  Handle types CU list in updateGdbIndexSection

Summary:
Handle types CU list in `updateGdbIndexSection`.

It looks like the types part of `.gdb_index` isn't empty when `-fdebug-types-section` is used. So instead of aborting, we copy the part to new `.gdb_index` section.

(cherry picked from FBD6770460)


  Commit: 1207e1d229d7ef68741f69ac435ab11a39465fd8
      https://github.com/llvm/llvm-project/commit/1207e1d229d7ef68741f69ac435ab11a39465fd8
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-01-31 (Wed, 31 Jan 2018)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinarySection.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix lookup of non-allocatable sections in RewriteInstance

Summary: Register all sections with BinaryContext.  Store all sections in a set ordered by (address, size, name).  Add two separate maps to lookup sections by address or by name.  Non-allocatable sections are not stored in the address->section map since they all "start" at 0.

(cherry picked from FBD6862973)


  Commit: 501601259b4efac4e37b0e6ff07a5273a3f77278
      https://github.com/llvm/llvm-project/commit/501601259b4efac4e37b0e6ff07a5273a3f77278
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-02-01 (Thu, 01 Feb 2018)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix branch info stats after SCTC

Summary:
SCTC was incorrectly swapping BranchInfo when reversing the branch condition.  This was wrong because when we remove the successor BB later, it removes the BranchInfo for that BB.  In this case the successor would be the BB with the stats we had just swapped.

Instead leave BranchInfo as it is and read the branch count from the false or true branch depending on whether we reverse or replace the branch, respectively.  The call to removeSuccessor later will remove the unused BranchInfo we no longer care about.

(cherry picked from FBD6876799)


  Commit: f85264ae18f8afc09baf2613dcaa7c058b52ace6
      https://github.com/llvm/llvm-project/commit/f85264ae18f8afc09baf2613dcaa7c058b52ace6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-02-01 (Thu, 01 Feb 2018)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Reduce the usage of "Offset" annotation

Summary:
Limiting "Offset" annotation only to instructions that actually
need it, improves the memory consumption on HHVM binary by 1GB.

(cherry picked from FBD6878943)


  Commit: 600cf0ecf609d975d8aa85ebae251b2963087365
      https://github.com/llvm/llvm-project/commit/600cf0ecf609d975d8aa85ebae251b2963087365
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-02-02 (Fri, 02 Feb 2018)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix memory regression

Summary:
This fixes the increased memory consumption introduced in an earlier
diff while I was working on new profiling infra.

The increase came from a delayed release of memory allocated to
intermediate structures used to build CFG. In this diff we release
them ASAP, and don't keep them for all functions at the same time.

(cherry picked from FBD6890067)


  Commit: 8a5a30156e1e9c48dedc67c2b2413f69502715df
      https://github.com/llvm/llvm-project/commit/8a5a30156e1e9c48dedc67c2b2413f69502715df
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-02-06 (Tue, 06 Feb 2018)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryFunctionProfile.cpp
    M bolt/BinaryLoop.h
    M bolt/BinaryPassManager.cpp
    M bolt/BinaryPassManager.h
    M bolt/BinarySection.cpp
    M bolt/BinarySection.h
    M bolt/CMakeLists.txt
    M bolt/DWARFRewriter.cpp
    M bolt/DataAggregator.cpp
    M bolt/DebugData.cpp
    M bolt/DebugData.h
    M bolt/Exceptions.cpp
    M bolt/Exceptions.h
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/CMakeLists.txt
    M bolt/Passes/CallGraphWalker.cpp
    M bolt/Passes/DominatorAnalysis.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/LivenessAnalysis.h
    M bolt/Passes/LongJmp.cpp
    M bolt/Passes/PLTCall.cpp
    M bolt/Passes/ReachingDefOrUse.h
    M bolt/Passes/ReachingInsns.h
    M bolt/Passes/ReorderFunctions.cpp
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/StackAllocationAnalysis.h
    M bolt/Passes/StackAvailableExpressions.h
    M bolt/Passes/StackPointerTracking.h
    M bolt/Passes/StackReachingUses.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h
    M bolt/llvm-bolt.cpp
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT rebase] Rebase fixes on top of LLVM Feb2018

Summary:
This commit includes all code necessary to make BOLT working again
after the rebase. This includes a redesign of the EHFrame work,
cherry-pick of the 3dnow disassembly work, compilation error fixes,
and port of the debug_info work. The macroop fusion feature is not
ported yet.

The rebased version has minor changes to the "executed instructions"
dynostats counter because REP prefixes are considered a part of the
instruction it applies to. Also, some X86 instructions had the "mayLoad"
tablegen property removed, which BOLT  uses to identify and account
for loads, thus reducing the total number of loads reported by
dynostats. This was observed in X86::MOVDQUmr. TRAP instructions are
not terminators anymore, changing our CFG. This commit adds compensation
to preserve this old behavior and minimize tests changes. debug_info
sections are now slightly larger. The discriminator field in the line
table is slightly different due to a change upstream. New profiles
generated with the other bolt are incompatible with this version
because of different hash values calculated for functions, so they will
be considered 100% stale. This commit changes the corresponding test
to XFAIL so it can be updated. The hash function changes because it
relies on raw opcode values, which change according to the opcodes
described in the X86 tablegen files. When processing HHVM, bolt was
observed to be using about 800MB more memory in the rebased version
and being about 5% slower.

(cherry picked from FBD7078072)


  Commit: 1298d99a41532db677b3842bb2a87933794a2846
      https://github.com/llvm/llvm-project/commit/1298d99a41532db677b3842bb2a87933794a2846
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-02-02 (Fri, 02 Feb 2018)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Limited "support" for AVX-512

Summary:
In relocation mode trap on entry to any function that has AVX-512
instructions. This is controlled by "-trap-avx512" option which is on
by default. If the option is disabled and AVX-512 instruction is seen
in relocation mode, then we abort while re-writing the binary.

(cherry picked from FBD6893165)


  Commit: a24c5543eac713c28e1047b1c3fc15b861572067
      https://github.com/llvm/llvm-project/commit/a24c5543eac713c28e1047b1c3fc15b861572067
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-02-14 (Wed, 14 Feb 2018)

  Changed paths:
    M bolt/Passes/BinaryPasses.cpp
    M bolt/ProfileReader.cpp
    M bolt/ProfileReader.h

  Log Message:
  -----------
  [BOLT] Improved function profile matching

Summary:
Prioritize functions with 100% name match when doing LTO "fuzzy"
name matching. Avoid re-assigning profile to a function.

(cherry picked from FBD6992179)


  Commit: 5599c019117a0b294e6f2b68f979b5014db10e96
      https://github.com/llvm/llvm-project/commit/5599c019117a0b294e6f2b68f979b5014db10e96
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-02-13 (Tue, 13 Feb 2018)

  Changed paths:
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryFunctionProfile.cpp
    M bolt/ProfileReader.cpp

  Log Message:
  -----------
  [BOLT] Fixes for new profile

Summary:
Do a better job of recording fall-through branches in new profile mode
(-prof-compat-mode=0). For this we need to record offsets for all
instructions that are last in the containing basic block.

Change the way we convert conditional tail calls. Now we never reverse
the condition. This is required for better profile matching.
The original approach of preserving the direction was controversial
to start with.

Add "-infer-fall-throughs" option (on by default) to allow disabling
inference of fall-through edge counts.

(cherry picked from FBD6994293)


  Commit: e15623058e7942cf16cf1c2ae2d3bf83ae393dfa
      https://github.com/llvm/llvm-project/commit/e15623058e7942cf16cf1c2ae2d3bf83ae393dfa
  Author: Andy Newell <newella at fb.com>
  Date:   2018-02-09 (Fri, 09 Feb 2018)

  Changed paths:
    M bolt/CacheMetrics.cpp
    M bolt/Passes/CachePlusReorderAlgorithm.cpp

  Log Message:
  -----------
  Cache+ speed, reduce mallocs

Summary:
Speed of cache+ by skipping mallocs on vectors.

Although this change speeds up the algorithm by 2x, this is still not
enough for some binaries where some functions have ~2500 hot basic
blocks. Hence, introduce a threshold for expensive optimizations in
CachePlusReorderAlgorithm. If the number of hot basic blocks exceeds
the threshold (2048 by default), we use a cheaper version, which is
quite fast.

(cherry picked from FBD6928075)


  Commit: 6744f0dbeb81832486a9e9619d0a3f9fca542f92
      https://github.com/llvm/llvm-project/commit/6744f0dbeb81832486a9e9619d0a3f9fca542f92
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-02-22 (Thu, 22 Feb 2018)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix jump table placement for non-simple functions

Summary:
When we move a jump table to either hot or cold new section
(-jump-tables=move), we rely on a number of taken branches from the table
to decide if it's hot or cold. However, if the function is non-simple, we
always get 0 count, and always move the table to the cold section.
Instead, we should make a conservative decision based on the execution
count of the function.

(cherry picked from FBD7058127)


  Commit: ddefc770b0ea21fef706a96faac57202b8a055fd
      https://github.com/llvm/llvm-project/commit/ddefc770b0ea21fef706a96faac57202b8a055fd
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-02-01 (Thu, 01 Feb 2018)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinarySection.cpp
    M bolt/BinarySection.h
    M bolt/DWARFRewriter.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactoring of section handling code

Summary:
This is a big refactoring of the section handling code.  I've removed the SectionInfoMap and NoteSectionInfo and stored all the associated info about sections in BinaryContext and BinarySection classes.  BinarySections should now hold all the info we care about for each section.  They can be initialized from SectionRefs but don't necessarily require one to be created.  There are only one or two spots that needed access to the original SectionRef to work properly.

The trickiest part was making sure RewriteInstance.cpp iterated over the proper sets of sections for each of it's different types of processing.  The different sets are broken down roughly as allocatable and non-alloctable and "registered" (I couldn't think up a better name).  "Registered" means that the section has been updated to include output information, i.e. contents, file offset/address, new size, etc.  It may help to have special iterators on BinaryContext to iterate over the different classes to make things easier.  I can do that if you guys think it is worthwhile.

I found pointee_iterator in the llvm ADT code.  Use that for iterating over BBs in BinaryFunction rather than the custom iterator class.

(cherry picked from FBD6879086)


  Commit: 6d0401ccfb2eec19f5193efc2a5292496ec33313
      https://github.com/llvm/llvm-project/commit/6d0401ccfb2eec19f5193efc2a5292496ec33313
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-02-26 (Mon, 26 Feb 2018)

  Changed paths:
    M bolt/Exceptions.cpp

  Log Message:
  -----------
  [BOLT/LSDA] Fix alignment

Summary:
Fix a bug introduced by rebasing with respect to aligned ULEBs.
This wasn't breaking anything but it is good to keep LDSA aligned.

(cherry picked from FBD7094742)


  Commit: 32b332ad2dc637208403274b5dc0592fbd6aaeec
      https://github.com/llvm/llvm-project/commit/32b332ad2dc637208403274b5dc0592fbd6aaeec
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-12-14 (Thu, 14 Dec 2017)

  Changed paths:
    M bolt/Passes/AllocCombiner.cpp
    M bolt/Passes/AllocCombiner.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/FrameOptimizer.h
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/ShrinkWrapping.h

  Log Message:
  -----------
  [BOLT] Fix ShrinkWrapping bugs and enable testing

Summary:
Fix a few ShrinkWrapping bugs:

 - Using push-pop mode in a function that required aligned stack
 - Correctly update the edges in jump tables after splitting critical
   edges
 - Fix stack pointer restores based on RBP + offset, when we change the
   stack layout in push-pop mode.

(cherry picked from FBD6755232)


  Commit: 0e4d86bf19fba5b62d6435603b79a71ee9c33ff2
      https://github.com/llvm/llvm-project/commit/0e4d86bf19fba5b62d6435603b79a71ee9c33ff2
  Author: Bill Nell <bnell at fb.com>
  Date:   2017-11-14 (Tue, 14 Nov 2017)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    A bolt/BinaryData.cpp
    A bolt/BinaryData.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryFunctionProfile.cpp
    M bolt/BinarySection.cpp
    M bolt/BinarySection.h
    M bolt/CMakeLists.txt
    M bolt/DWARFRewriter.cpp
    M bolt/DataAggregator.cpp
    M bolt/Exceptions.cpp
    A bolt/JumpTable.cpp
    A bolt/JumpTable.h
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/IndirectCallPromotion.h
    M bolt/Passes/JTFootprintReduction.cpp
    M bolt/Passes/JTFootprintReduction.h
    M bolt/Passes/LongJmp.cpp
    M bolt/Passes/ReorderFunctions.cpp
    M bolt/ProfileWriter.cpp
    A bolt/Relocation.cpp
    A bolt/Relocation.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactor global symbol handling code.

Summary:
This is preparation work for static data reordering.

I've created a new class called BinaryData which represents a symbol
contained in a section.  It records almost all the information relevant
for dealing with data, e.g. names, address, size, alignment, profiling
data, etc.  BinaryContext still stores and manages BinaryData objects
similar to how it managed symbols and global addresses before.  The
interfaces are not changed too drastically from before either.  There is
a bit of overlap between BinaryData and BinaryFunction.  I would have
liked to do some more refactoring to make a BinaryFunctionFragment that
subclassed from BinaryData and then have BinaryFunction be composed or
associated with BinaryFunctionFragments.

I've also attempted to use (symbol + offset) for when addresses are
pointing into the middle of symbols with known sizes.  This changes the
simplify rodata loads optimization slightly since the expression on an
instruction can now also be a (symbol + offset) rather than just a symbol.

One of the overall goals for this refactoring is to make sure every
relocation is associated with a BinaryData object.  This requires adding
"hole" BinaryData's wherever there are gaps in a section's address space.
Most of the holes seem to be data that has no associated symbol info. In
this case we can't do any better than lumping all the adjacent hole
symbols into one big symbol (there may be more than one actual data
object that contributes to a hole). At least the combined holes should
be moveable.

Jump tables have similar issues. They appear to mostly be sub-objects
for top level local symbols. The main problem is that we can't recognize
jump tables at the time we scan the symbol table, we have to wait til
disassembly. When a jump table is discovered we add it as a sub-object
to the existing local symbol. If there are one or more existing
BinaryData's that appear in the address range of a newly created jump
table, those are added as sub-objects as well.

(cherry picked from FBD6362544)


  Commit: d660f8b1fea7ed07c172cf0ad46238ba1e942993
      https://github.com/llvm/llvm-project/commit/d660f8b1fea7ed07c172cf0ad46238ba1e942993
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-02-14 (Wed, 14 Feb 2018)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Disassemble all functions before building CFGs

Summary:
This makes it possible to do adjustments to all functions based on
information gained during disassembly. E.g. if we detect an entry point
after the CFG for a function is constructed, we have to take a
conservative approach, and mark such function as non-simple. Now we have
this information before building the CFG. This could also be used to do
other processing/post-processing on disassembled functions that might
affect CFG construction of other functions (e.g. early detection of
functions that never return).

The drawback of this approach is that we lose cache locality and some
processing performance as a result. I've measured 5 second difference
on HHVM binary.

(cherry picked from FBD7258466)


  Commit: 6644548c743dba42a1de454b7bdab95a5104d625
      https://github.com/llvm/llvm-project/commit/6644548c743dba42a1de454b7bdab95a5104d625
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2017-12-07 (Thu, 07 Dec 2017)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    A bolt/BoltDiff.cpp
    M bolt/CMakeLists.txt
    M bolt/DataReader.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h
    M bolt/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLTDIFF] Add a tool to audit performance differences

Summary:
This is a simple bolt-based tool that instantiates two
RewriteInstances objects and compares them. Add a method to
RewriteInstance to enable us to compare two objects. Include a mechanism
to match functions from binary 1 to binary 2 and finally print the
largest differences in profiling data from one binary to another.

(cherry picked from FBD6517076)


  Commit: 2fe37b443519f93ce5fa26811196228d43b06a13
      https://github.com/llvm/llvm-project/commit/2fe37b443519f93ce5fa26811196228d43b06a13
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-03-12 (Mon, 12 Mar 2018)

  Changed paths:
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/StackReachingUses.cpp

  Log Message:
  -----------
  [BOLT] Fix remove-unused-stores in rebased bolt

Summary:
Rebased version revealed a mistake when computing the dataflow
for the "remove-unused-stores" optimization. This is disabled in prod but
it doesn't hurt to fix it, so the tests for the rebased bolt go green
again.

(cherry picked from FBD7253418)


  Commit: 8c16594f2e1389e0e8f0d4b2d08fd47a49f20473
      https://github.com/llvm/llvm-project/commit/8c16594f2e1389e0e8f0d4b2d08fd47a49f20473
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-03-14 (Wed, 14 Mar 2018)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix ORC to properly update symbols

Summary:
In new ORC, the sequence of how sections are allocated and loaded is
changed. Now everything is delayed until emitAndFinalize() is called,
and all actions are supposed to happen via notification functors.
There are two functors that we pass to new ObjectLinkingLayer object.
One is used to notify when objects are loaded, and the other - once they
are finalized. We use the first one to remap sections to proper
addresses, and that's the earliest place where we can do it. However,
ORC decides to update symbols right before that, and as a result they
are updated with non-mapped values.

There are two possible fixes for that. This diff postpones the update to
the symbol table until the notifier is called. I don't know what other
tools depend on the existing sequence, and the proper fix may involve
creating a third notifier to be called before the symbol table update.

(cherry picked from FBD7280973)


  Commit: 48ae32a33bea49a4bedf51332536e3f0aa0b03af
      https://github.com/llvm/llvm-project/commit/48ae32a33bea49a4bedf51332536e3f0aa0b03af
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-03-09 (Fri, 09 Mar 2018)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryFunctionProfile.cpp
    M bolt/CMakeLists.txt
    M bolt/CacheMetrics.cpp
    M bolt/Exceptions.cpp
    A bolt/MCPlusBuilder.cpp
    A bolt/MCPlusBuilder.h
    M bolt/Passes/AllocCombiner.cpp
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/DataflowAnalysis.cpp
    M bolt/Passes/DataflowAnalysis.h
    M bolt/Passes/DominatorAnalysis.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/FrameOptimizer.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/IndirectCallPromotion.h
    M bolt/Passes/Inliner.cpp
    M bolt/Passes/JTFootprintReduction.cpp
    M bolt/Passes/LivenessAnalysis.h
    M bolt/Passes/LongJmp.cpp
    M bolt/Passes/PLTCall.cpp
    M bolt/Passes/ReachingDefOrUse.h
    M bolt/Passes/ReachingInsns.h
    M bolt/Passes/RegAnalysis.cpp
    M bolt/Passes/RegReAssign.cpp
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/ShrinkWrapping.h
    M bolt/Passes/StackAllocationAnalysis.cpp
    M bolt/Passes/StackPointerTracking.h
    M bolt/Passes/StokeInfo.cpp
    M bolt/ProfileReader.cpp
    M bolt/ProfileWriter.cpp
    M bolt/RewriteInstance.cpp
    A bolt/Target/AArch64/AArch64MCPlusBuilder.cpp
    A bolt/Target/AArch64/CMakeLists.txt
    A bolt/Target/CMakeLists.txt
    A bolt/Target/X86/CMakeLists.txt
    A bolt/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Introduce MCPlus layer

Summary:
Refactor architecture-specific code out of llvm into llvm-bolt.

Introduce MCPlusBuilder, a class that is taking over MCInstrAnalysis
responsibilities, i.e. creating, analyzing, and modifying instructions.
To access the builder use BC->MIB, i.e. substitute MIA with MIB.
MIB is an acronym for MCInstBuilder, that's what MCPlusBuilder used
to be. The name stuck, and I find it better than MPB.

Instructions are still MCInst, and a bunch of BOLT-specific code still
lives in LLVM, but the staff under Target/* is significantly reduced.

(cherry picked from FBD7300101)


  Commit: 598a346abf305260f0bec9310bbb74054eabb628
      https://github.com/llvm/llvm-project/commit/598a346abf305260f0bec9310bbb74054eabb628
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-03-13 (Tue, 13 Mar 2018)

  Changed paths:
    M bolt/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Fix assertion when setting size of jump table symbol

Summary: This assertion was making sure that when we patched up symbol sizes that we wouldn't modify the size of a symbol that has already had its size set.  The issue here is that private symbols are sometimes composed of multiple objects internally (e.g. jump tables).  In this particular case a jump table started at the same address as the private data blob it was contained in.  Currently, there isn't any good way of differentiating symbols that start at the same address (except possibly using multimaps for certain data structures).  I'm hacking around it by modifying the assertion to ignore jump tables and skip setting the size when it has already been set.  This shouldn't affect any existing optimizations since the only thing that depended on sizes is data reordering and that currently ignores jump tables and private data blobs.

(cherry picked from FBD7269207)


  Commit: faacdf60801b2960c457c83ca6cfdc8deeb9b4ce
      https://github.com/llvm/llvm-project/commit/faacdf60801b2960c457c83ca6cfdc8deeb9b4ce
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-03-16 (Fri, 16 Mar 2018)

  Changed paths:
    M bolt/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Fix assertion when building test binary

Summary:
The binary had some unexpected ovelapping symbols:

.str.34.llvm.2944770977690351622/1 address = 0x48e9ec7, next address =
   0x48e9ed2, size = 21
PG.LC135/1 address = 0x48e9ed2, next address = 0x48e9eef, size = 29

BOLT wasn't expecting this type of overlap when generating HOLE symbols,
so it was asserting.  I've changed the code to deal with this case.

I'll need to change the reordering pass to mark these types of symbols
as unmoveable for now.

(cherry picked from FBD7304195)


  Commit: 3458e92285f965a459b61a061577fc5a9422bb19
      https://github.com/llvm/llvm-project/commit/3458e92285f965a459b61a061577fc5a9422bb19
  Author: spupyrev <spupyrev at fb.com>
  Date:   2018-03-14 (Wed, 14 Mar 2018)

  Changed paths:
    M bolt/BinaryFunctionProfile.cpp

  Log Message:
  -----------
  removing compact-mode

Summary: this is not needed but makes code harder to read; hence, removing

(cherry picked from FBD7257937)


  Commit: 0dea33737a7970083144e85b858448e957334f33
      https://github.com/llvm/llvm-project/commit/0dea33737a7970083144e85b858448e957334f33
  Author: spupyrev <spupyrev at fb.com>
  Date:   2018-03-22 (Thu, 22 Mar 2018)

  Changed paths:
    M bolt/BinaryFunctionProfile.cpp
    M bolt/Passes/BinaryFunctionCallGraph.cpp
    M bolt/Passes/CachePlusReorderAlgorithm.cpp
    M bolt/Passes/HFSortPlus.cpp
    M bolt/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  [BOLT] improvements for CFG construction

Summary:
Some improvements for CFG construction:
- getting rid of fallthrough-inferrence, as this is already
done DataAggregator;
- adjusting block counts for blocks with non-zero outgoing edges
to make sure they're not outlined;
- making sure that all functions (including non-simple ones) are
reordered and placed in the hot section.

The main goal of the diff is to make sure that constructed CFG graphs
exactly correspond to the input profile data.

(cherry picked from FBD7323205)


  Commit: a62f4fda4650f0758ab021ea5cbda0cd0662e385
      https://github.com/llvm/llvm-project/commit/a62f4fda4650f0758ab021ea5cbda0cd0662e385
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-03-19 (Mon, 19 Mar 2018)

  Changed paths:
    M bolt/BinaryContext.cpp
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryFunctionProfile.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/Exceptions.cpp
    A bolt/MCPlus.h
    M bolt/MCPlusBuilder.cpp
    M bolt/MCPlusBuilder.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/DataflowAnalysis.cpp
    M bolt/Passes/DataflowAnalysis.h
    M bolt/Passes/FrameAnalysis.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/Inliner.cpp
    M bolt/Passes/JTFootprintReduction.cpp
    M bolt/Passes/LongJmp.cpp
    M bolt/Passes/RegReAssign.cpp
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/ShrinkWrapping.h
    M bolt/Passes/StackAllocationAnalysis.cpp
    M bolt/Passes/StackPointerTracking.h
    M bolt/Passes/StokeInfo.cpp
    M bolt/ProfileReader.cpp
    M bolt/RewriteInstance.cpp
    M bolt/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][Refactoring] Isolate changes to MC layer

Summary:
Changes that we made to MCInst, MCOperand, MCExpr, etc. are now all
moved into tools/llvm-bolt. That required a change to the way we handle
annotations and any extra operands for MCInst.

Any MCPlus information is now attached via an extra operand of type
MCInst with an opcode ANNOTATION_LABEL. Since this operand is MCInst, we
attach extra info as operands to this instruction. For first-level
annotations use functions to access the information, such as
getConditionalTailCall() or getEHInfo(), etc. For the rest, optional or
second-class annotations, use a general named-annotation interface such
as getAnnotationAs<uint64_t>(Inst, "Count").

I did a test on HHVM binary, and a memory consumption went down a little
bit while the runtime remained the same.

(cherry picked from FBD7405412)


  Commit: 77f35bd0e9baecbe1041087fa445c8795d9cff61
      https://github.com/llvm/llvm-project/commit/77f35bd0e9baecbe1041087fa445c8795d9cff61
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-03-30 (Fri, 30 Mar 2018)

  Changed paths:
    M bolt/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix iterator issue

Summary:
Getting a forward iterator from reverse iterator was implemented
incorrectly. For some reason erase worked on it, but it's clearly wrong
and printing the instruction (before the deletion) results in an error.

(cherry picked from FBD7457457)


  Commit: 0d729f218b34eb743cc6395c43d4f0dcab8d225b
      https://github.com/llvm/llvm-project/commit/0d729f218b34eb743cc6395c43d4f0dcab8d225b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-03-30 (Fri, 30 Mar 2018)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix relocation verification

Summary:
We verify that relocation information matches a value stored in a
binary, i.e. "ExtractedValue == SymbolValue + Addend". However, because
of the size of the relocation, and the fact that an addend is always
of type int64_t, we have to sign-extend the extracted value, and then we
might get mismatch in higher bits in certain scenarios. Hence, we should
only compare values that are truncated to a relocation size.

Discovered while processing hhvm binary with modified compiler flags.

(cherry picked from FBD7462559)


  Commit: 7956da0fe8f125dcc59a05165419a6ea2655315d
      https://github.com/llvm/llvm-project/commit/7956da0fe8f125dcc59a05165419a6ea2655315d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-03-30 (Fri, 30 Mar 2018)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/IndirectCallPromotion.cpp
    M bolt/Passes/Inliner.cpp
    M bolt/Passes/LongJmp.cpp

  Log Message:
  -----------
  [BOLT] Fix CFG in BinaryFunction::eraseInvalidBBs()

Summary:
When we erase invalid/unreachable basic blocks, we have to remove them
from a list of predecessors of regular blocks, otherwise the CFG will be
left in a broken state containing references to removed basic blocks.

(cherry picked from FBD7464292)


  Commit: d8cf08b243bac49285075f7b700272e94b40cfdf
      https://github.com/llvm/llvm-project/commit/d8cf08b243bac49285075f7b700272e94b40cfdf
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-04-04 (Wed, 04 Apr 2018)

  Changed paths:
    M bolt/MCPlusBuilder.h
    M bolt/Passes/AllocCombiner.cpp
    M bolt/Target/AArch64/AArch64MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Use MCPlus::getNumPrimeOperands()

Summary:
Use MCPlus::getNumPrimeOperands() to get the real number of operands
on MCInst. Alternatively, use MCInstrDesc::getNumOperands().

(cherry picked from FBD7507666)


  Commit: 489e51453089e8b5e8d5e2ef16244b84598dec5d
      https://github.com/llvm/llvm-project/commit/489e51453089e8b5e8d5e2ef16244b84598dec5d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-03-29 (Thu, 29 Mar 2018)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/MCPlus.h
    M bolt/MCPlusBuilder.cpp
    M bolt/MCPlusBuilder.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/DataflowAnalysis.h
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/Passes/ShrinkWrapping.h
    M bolt/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Improve annotations format and processing

Summary:
Change the way annotations are stored and processed.

Embed annotation type/index into immediate value stored as an operand.
This limits the effective range of values that could be stored as
annotations to 56 bits, which is still plenty for most integer types
that we use and for pointers on real systems. High 8 bits are reserved
for storing annotation type/index.

Expand the interface for general annotations to include reference to
annotations by index. The main purpose of this interface is to improve
performance of annotations that are used by heavy (>O(N)) algorithms,
such as data flow analysis.

For -frame-opt pass, new memory usage and processing times are slightly
better compared to those before refactoring.

(cherry picked from FBD7492017)


  Commit: 7df6a6d5c6f8c4bbcc34bd36709a03f6e8bb963a
      https://github.com/llvm/llvm-project/commit/7df6a6d5c6f8c4bbcc34bd36709a03f6e8bb963a
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-03-20 (Tue, 20 Mar 2018)

  Changed paths:
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/BinaryPassManager.cpp
    M bolt/MCPlusBuilder.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Passes/BinaryPasses.h
    M bolt/Passes/LongJmp.cpp
    M bolt/RewriteInstance.cpp
    M bolt/Target/AArch64/AArch64MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT-AArch64] Fix AArch64 port - make it work with hhvm

Summary:
This diff has 3 fixes. First fixes the way relocations are read
and interpreted for AArch64, so the references are preserved correctly.
Second, it fixes constant islands to be able to live in the very first
address of a function (which means there is no code, but this function
contains just a constant island).
Third, it fixes function splitting to do not outline entry points for
AArch64. This was done because some functions may load pointers to its
internal basic blocks, issueing a short-range ADR instruction to do so
without its pair ADRP (since the size of the function is supposed to
be small). But when we move this block to a cold region, that is not
the case anymore. Since blocks with a reference are marked as entry
points, we conservatively disable outlining for them in AArch64.

(cherry picked from FBD7505067)


  Commit: 190693059a08913ac43a19df371f52452f32f59a
      https://github.com/llvm/llvm-project/commit/190693059a08913ac43a19df371f52452f32f59a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-04-05 (Thu, 05 Apr 2018)

  Changed paths:
    M bolt/ProfileYAMLMapping.h
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [merge-fdata] Rewrite merge-fdata to use YAML format

Summary:
merge-fdata now operates on .fdata files in YAML format. The previous
format is not supported, which means that non-LBR data could not be
merged and memory data has to be merged with "cat" command.

(cherry picked from FBD7544031)


  Commit: 487877007254709cb5f9587c9e60a9cc273ea037
      https://github.com/llvm/llvm-project/commit/487877007254709cb5f9587c9e60a9cc273ea037
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-04-11 (Wed, 11 Apr 2018)

  Changed paths:
    M bolt/DataAggregator.cpp
    M bolt/DataReader.cpp
    M bolt/DataReader.h

  Log Message:
  -----------
  [BOLT][Cleanup] Remove branch history

Summary:
We are not using branch histories and don't have plans to.
Clean up the code.

(cherry picked from FBD7588644)


  Commit: 8b049d3c7f9382e86f77576b0a6392ef6a8287a4
      https://github.com/llvm/llvm-project/commit/8b049d3c7f9382e86f77576b0a6392ef6a8287a4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-04-09 (Mon, 09 Apr 2018)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/BinaryFunctionProfile.cpp
    M bolt/ProfileReader.cpp
    M bolt/ProfileReader.h
    M bolt/ProfileWriter.cpp
    M bolt/ProfileWriter.h
    M bolt/ProfileYAMLMapping.h
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h
    M bolt/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/merge-fdata/CMakeLists.txt
    M bolt/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT] Support for non-LBR profile in YAML

Summary:
Expanded YAML profile format to support different kinds of profile
including LBR and non-LBR (and memevents in the future).

The profile now starts with a header that includes the profile
description. "profile-flags" field includes either "lbr" or "sample",
but not both at the same time. It could also include "memevent" in
addition to other flags.

For now, the only way to generate non-LBR YAML profile is through
conversion. Once task is done, it should be possible to use
perf2bolt for it.

(cherry picked from FBD7595693)


  Commit: dc12911feaf21107e76a11ee8ee4668816130c22
      https://github.com/llvm/llvm-project/commit/dc12911feaf21107e76a11ee8ee4668816130c22
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-04-09 (Mon, 09 Apr 2018)

  Changed paths:
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Report when operating in relocation mode

Summary:
Since BOLT can use relocations in the binary automatically, it's not
always clear if we are operating in relocation mode or not. This diff
adds "BOLT-INFO" message indicating if the relocation mode in ON.

(cherry picked from FBD7557492)


  Commit: c13cd9084dc2c58a8ea055118a08757762a85c94
      https://github.com/llvm/llvm-project/commit/c13cd9084dc2c58a8ea055118a08757762a85c94
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-04-13 (Fri, 13 Apr 2018)

  Changed paths:
    M bolt/ProfileReader.cpp

  Log Message:
  -----------
  [BOLT] Fix tests

Summary:
During a rebase function hashes changed and new profile
stopped matching functions.

(cherry picked from FBD7618919)


  Commit: 120d26727a2aa8d47a33d30cb32577c25a9430dd
      https://github.com/llvm/llvm-project/commit/120d26727a2aa8d47a33d30cb32577c25a9430dd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-04-13 (Fri, 13 Apr 2018)

  Changed paths:
    M bolt/BinaryBasicBlock.cpp
    M bolt/BinaryBasicBlock.h
    M bolt/BinaryContext.h
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/MCPlusBuilder.h
    M bolt/Passes/BinaryPasses.cpp
    M bolt/RewriteInstance.cpp
    M bolt/RewriteInstance.h
    M bolt/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Restore macro-fusion optimization

Summary:
Restore the optimization with some modifications:
  * Only enabled in relocation mode.
  * Covers instructions other than TEST/CMP.
  * Prints missed macro-fusion opportunities for input.
  * By default enabled for all hot code.
  * Without profile enabled for all code.

The new command-line option:
  -align-macro-fusion - fix instruction alignment for macro-fusion (x86 relocation mode)
      =none   - do not insert alignment no-ops for macro-fusion
      =hot    - only insert alignment no-ops on hot execution paths (default)
      =all    - always align instructions to allow macro-fusion

(cherry picked from FBD7644042)


  Commit: a30fff6e36f3505fddfddb2d8e196b46181efafe
      https://github.com/llvm/llvm-project/commit/a30fff6e36f3505fddfddb2d8e196b46181efafe
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-04-13 (Fri, 13 Apr 2018)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryPassManager.cpp
    M bolt/Passes/BinaryPasses.cpp
    M bolt/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT-AArch64] Fix BOLT build on AArch64

Summary:
Whenever building BOLT in an AArch64 box, we need to make sure
we do not run tests that are excluse for x86. This diff also adds a tag
for expensive tests, so the user can disable them, which is useful when
using a memory-constrained machine to run BOLT tests. It also removes
ifdefs that caused BOLT to behave diferently when running in a non-x86
host. Finally, it changes a case where we depended on updated libstdc++
implementation for insert to make the codebase more friendly with boxes
that do not have the newer version of the lib.

(cherry picked from FBD7625715)


  Commit: db949fc1f5f4a4c8d2647998b7bf1e8cacb4e034
      https://github.com/llvm/llvm-project/commit/db949fc1f5f4a4c8d2647998b7bf1e8cacb4e034
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-04-13 (Fri, 13 Apr 2018)

  Changed paths:
    M bolt/BinaryFunctionProfile.cpp
    M bolt/DataAggregator.cpp
    M bolt/DataAggregator.h
    M bolt/DataReader.cpp
    M bolt/DataReader.h
    M bolt/ProfileReader.cpp
    M bolt/ProfileReader.h
    M bolt/RewriteInstance.cpp

  Log Message:
  -----------
  [PERF2BOLT] Add support for non-LBR aggregation

Summary:
Previously, we depended on the python script perf2bolt.py whenever
operating with non-LBR data.

(cherry picked from FBD7620125)


  Commit: aa91281ac3250fbae424b4166012aecdafeea880
      https://github.com/llvm/llvm-project/commit/aa91281ac3250fbae424b4166012aecdafeea880
  Author: spupyrev <spupyrev at fb.com>
  Date:   2018-03-28 (Wed, 28 Mar 2018)

  Changed paths:
    M bolt/CacheMetrics.cpp
    M bolt/Passes/CachePlusReorderAlgorithm.cpp
    M bolt/Passes/HFSortPlus.cpp

  Log Message:
  -----------
  [BOLT] improving cache metrics

Summary: Modifying parameters of block reordering algorithm that result in better performance. Additionally extending some cache-related metrics

(cherry picked from FBD7578336)


  Commit: d6003e94eb0efa721b6774cc514adb4b3b472ec2
      https://github.com/llvm/llvm-project/commit/d6003e94eb0efa721b6774cc514adb4b3b472ec2
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-04-12 (Thu, 12 Apr 2018)

  Changed paths:
    M bolt/BinaryFunction.cpp
    M bolt/BinaryFunction.h
    M bolt/MCPlus.h
    M bolt/MCPlusBuilder.cpp
    M bolt/MCPlusBuilder.h
    M bolt/Passes/ShrinkWrapping.cpp
    M bolt/RewriteInstance.cpp
    M bolt/Target/AArch64/AArch64MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT-AArch64] Fix -icf, -use-old-text and -update-debug-sections

Summary:
Refactor MCInst comparison code to support target-dependent
functionality. This was necessary because AArch64 uses MCTargetExprs
that only the AArch64 backend knows how to unpack it and compare. Also
fix a bug where a relocation against a constant island would make BOLT
create a fixed reference against a code location in a similar way to
read-only data, so when we asked to -use-old-text, the code would break
for this particular HHVM function
(_ZN5folly2io4zlib18defaultZlibOptionsEv) because the reference now
contains invalid data, since the original .text was overwritten. Finally,
fix a bug with -update-debug-sections on AArch64 where the update
loop wasn't expecting a function with zero basic blocks, which can
happen on AArch64 because some functions contain just a constant
island.

(cherry picked from FBD7679244)


  Commit: caad4bcf3a500cba82f1083c81d74bdd5c8c40b2
      https://github.com/llvm/llvm-project/commit/caad4bcf3a500cba82f1083c81d74bdd5c8c40b2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-04-27 (Fri, 27 Apr 2018)

  Changed paths:
    M bolt/BinaryFunction.h
    M bolt/BinaryFunctionProfile.cpp
    M bolt/DataAggregator.cpp
    M bolt/ProfileReader.cpp
    M bolt/ProfileWriter.cpp

  Log Message:
  -----------
  [BOLT] Fix crash while writing new profile

Summary:
New profile writer was crashing as functions were lacking a profile
flags. Fix it by requiring flags when marking function as profiled.

Generate new profile for clang. The new profile has more coverage and
results in better overall improvement from BOLT. It was generated by
merging multiple runs of:

% perf record -e cycles:u -j any,u -F32000 -- \
    ./clang bf.cpp -O2 -std=c++11 -c -o /tmp/bf.o

(cherry picked from FBD7798580)


  Commit: 9c6f9656166a0336829242b377b2b592addc3e38
      https://github.com/llvm/llvm-project/commit/9c6f9656166a0336829242b377b2b592addc3e38
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-05-04 (Fri, 04 May 2018)

  Changed paths:
    R bolt/BinaryBasicBlock.cpp
    R bolt/BinaryBasicBlock.h
    R bolt/BinaryContext.cpp
    R bolt/BinaryContext.h
    R bolt/BinaryData.cpp
    R bolt/BinaryData.h
    R bolt/BinaryFunction.cpp
    R bolt/BinaryFunction.h
    R bolt/BinaryFunctionProfile.cpp
    R bolt/BinaryLoop.h
    R bolt/BinaryPassManager.cpp
    R bolt/BinaryPassManager.h
    R bolt/BinaryPasses.cpp
    R bolt/BinaryPasses.h
    R bolt/BinarySection.cpp
    R bolt/BinarySection.h
    R bolt/BoltDiff.cpp
    M bolt/CMakeLists.txt
    R bolt/CacheMetrics.cpp
    R bolt/CacheMetrics.h
    R bolt/DWARFRewriter.cpp
    R bolt/DataAggregator.cpp
    R bolt/DataAggregator.h
    R bolt/DataReader.cpp
    R bolt/DataReader.h
    R bolt/DebugData.cpp
    R bolt/DebugData.h
    R bolt/Exceptions.cpp
    R bolt/Exceptions.h
    R bolt/JumpTable.cpp
    R bolt/JumpTable.h
    A bolt/LICENSE.TXT
    R bolt/MCPlus.h
    R bolt/MCPlusBuilder.cpp
    R bolt/MCPlusBuilder.h
    R bolt/Passes/Aligner.cpp
    R bolt/Passes/Aligner.h
    R bolt/Passes/AllocCombiner.cpp
    R bolt/Passes/AllocCombiner.h
    R bolt/Passes/BinaryFunctionCallGraph.cpp
    R bolt/Passes/BinaryFunctionCallGraph.h
    R bolt/Passes/BinaryPasses.cpp
    R bolt/Passes/BinaryPasses.h
    R bolt/Passes/CMakeLists.txt
    R bolt/Passes/CachePlusReorderAlgorithm.cpp
    R bolt/Passes/CallGraph.cpp
    R bolt/Passes/CallGraph.h
    R bolt/Passes/CallGraphWalker.cpp
    R bolt/Passes/CallGraphWalker.h
    R bolt/Passes/DataflowAnalysis.cpp
    R bolt/Passes/DataflowAnalysis.h
    R bolt/Passes/DataflowInfoManager.cpp
    R bolt/Passes/DataflowInfoManager.h
    R bolt/Passes/DominatorAnalysis.h
    R bolt/Passes/FrameAnalysis.cpp
    R bolt/Passes/FrameAnalysis.h
    R bolt/Passes/FrameOptimizer.cpp
    R bolt/Passes/FrameOptimizer.h
    R bolt/Passes/HFSort.cpp
    R bolt/Passes/HFSort.h
    R bolt/Passes/HFSortPlus.cpp
    R bolt/Passes/IndirectCallPromotion.cpp
    R bolt/Passes/IndirectCallPromotion.h
    R bolt/Passes/Inliner.cpp
    R bolt/Passes/Inliner.h
    R bolt/Passes/JTFootprintReduction.cpp
    R bolt/Passes/JTFootprintReduction.h
    R bolt/Passes/LivenessAnalysis.cpp
    R bolt/Passes/LivenessAnalysis.h
    R bolt/Passes/LongJmp.cpp
    R bolt/Passes/LongJmp.h
    R bolt/Passes/PLTCall.cpp
    R bolt/Passes/PLTCall.h
    R bolt/Passes/PettisAndHansen.cpp
    R bolt/Passes/ReachingDefOrUse.h
    R bolt/Passes/ReachingInsns.h
    R bolt/Passes/RegAnalysis.cpp
    R bolt/Passes/RegAnalysis.h
    R bolt/Passes/RegReAssign.cpp
    R bolt/Passes/RegReAssign.h
    R bolt/Passes/ReorderAlgorithm.cpp
    R bolt/Passes/ReorderAlgorithm.h
    R bolt/Passes/ReorderFunctions.cpp
    R bolt/Passes/ReorderFunctions.h
    R bolt/Passes/ReorderUtils.h
    R bolt/Passes/ShrinkWrapping.cpp
    R bolt/Passes/ShrinkWrapping.h
    R bolt/Passes/StackAllocationAnalysis.cpp
    R bolt/Passes/StackAllocationAnalysis.h
    R bolt/Passes/StackAvailableExpressions.cpp
    R bolt/Passes/StackAvailableExpressions.h
    R bolt/Passes/StackPointerTracking.cpp
    R bolt/Passes/StackPointerTracking.h
    R bolt/Passes/StackReachingUses.cpp
    R bolt/Passes/StackReachingUses.h
    R bolt/Passes/StokeInfo.cpp
    R bolt/Passes/StokeInfo.h
    R bolt/ProfileReader.cpp
    R bolt/ProfileReader.h
    R bolt/ProfileWriter.cpp
    R bolt/ProfileWriter.h
    R bolt/ProfileYAMLMapping.h
    A bolt/README.txt
    R bolt/Relocation.cpp
    R bolt/Relocation.h
    R bolt/ReorderAlgorithm.cpp
    R bolt/ReorderAlgorithm.h
    R bolt/RewriteInstance.cpp
    R bolt/RewriteInstance.h
    R bolt/Target/AArch64/AArch64MCPlusBuilder.cpp
    R bolt/Target/AArch64/CMakeLists.txt
    R bolt/Target/CMakeLists.txt
    R bolt/Target/X86/CMakeLists.txt
    R bolt/Target/X86/X86MCPlusBuilder.cpp
    R bolt/llvm-bolt.cpp
    A bolt/llvm.patch
    R bolt/merge-fdata/CMakeLists.txt
    R bolt/merge-fdata/LLVMBuild.txt
    R bolt/merge-fdata/Makefile
    R bolt/merge-fdata/merge-fdata.cpp
    A bolt/src/BinaryBasicBlock.cpp
    A bolt/src/BinaryBasicBlock.h
    A bolt/src/BinaryContext.cpp
    A bolt/src/BinaryContext.h
    A bolt/src/BinaryData.cpp
    A bolt/src/BinaryData.h
    A bolt/src/BinaryFunction.cpp
    A bolt/src/BinaryFunction.h
    A bolt/src/BinaryFunctionProfile.cpp
    A bolt/src/BinaryLoop.h
    A bolt/src/BinaryPassManager.cpp
    A bolt/src/BinaryPassManager.h
    A bolt/src/BinarySection.cpp
    A bolt/src/BinarySection.h
    A bolt/src/BoltDiff.cpp
    A bolt/src/CMakeLists.txt
    A bolt/src/CacheMetrics.cpp
    A bolt/src/CacheMetrics.h
    A bolt/src/DWARFRewriter.cpp
    A bolt/src/DataAggregator.cpp
    A bolt/src/DataAggregator.h
    A bolt/src/DataReader.cpp
    A bolt/src/DataReader.h
    A bolt/src/DebugData.cpp
    A bolt/src/DebugData.h
    A bolt/src/Exceptions.cpp
    A bolt/src/Exceptions.h
    A bolt/src/JumpTable.cpp
    A bolt/src/JumpTable.h
    A bolt/src/MCPlus.h
    A bolt/src/MCPlusBuilder.cpp
    A bolt/src/MCPlusBuilder.h
    A bolt/src/Passes/Aligner.cpp
    A bolt/src/Passes/Aligner.h
    A bolt/src/Passes/AllocCombiner.cpp
    A bolt/src/Passes/AllocCombiner.h
    A bolt/src/Passes/BinaryFunctionCallGraph.cpp
    A bolt/src/Passes/BinaryFunctionCallGraph.h
    A bolt/src/Passes/BinaryPasses.cpp
    A bolt/src/Passes/BinaryPasses.h
    A bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/CachePlusReorderAlgorithm.cpp
    A bolt/src/Passes/CallGraph.cpp
    A bolt/src/Passes/CallGraph.h
    A bolt/src/Passes/CallGraphWalker.cpp
    A bolt/src/Passes/CallGraphWalker.h
    A bolt/src/Passes/DataflowAnalysis.cpp
    A bolt/src/Passes/DataflowAnalysis.h
    A bolt/src/Passes/DataflowInfoManager.cpp
    A bolt/src/Passes/DataflowInfoManager.h
    A bolt/src/Passes/DominatorAnalysis.h
    A bolt/src/Passes/FrameAnalysis.cpp
    A bolt/src/Passes/FrameAnalysis.h
    A bolt/src/Passes/FrameOptimizer.cpp
    A bolt/src/Passes/FrameOptimizer.h
    A bolt/src/Passes/HFSort.cpp
    A bolt/src/Passes/HFSort.h
    A bolt/src/Passes/HFSortPlus.cpp
    A bolt/src/Passes/IndirectCallPromotion.cpp
    A bolt/src/Passes/IndirectCallPromotion.h
    A bolt/src/Passes/Inliner.cpp
    A bolt/src/Passes/Inliner.h
    A bolt/src/Passes/JTFootprintReduction.cpp
    A bolt/src/Passes/JTFootprintReduction.h
    A bolt/src/Passes/LivenessAnalysis.cpp
    A bolt/src/Passes/LivenessAnalysis.h
    A bolt/src/Passes/LongJmp.cpp
    A bolt/src/Passes/LongJmp.h
    A bolt/src/Passes/PLTCall.cpp
    A bolt/src/Passes/PLTCall.h
    A bolt/src/Passes/PettisAndHansen.cpp
    A bolt/src/Passes/ReachingDefOrUse.h
    A bolt/src/Passes/ReachingInsns.h
    A bolt/src/Passes/RegAnalysis.cpp
    A bolt/src/Passes/RegAnalysis.h
    A bolt/src/Passes/RegReAssign.cpp
    A bolt/src/Passes/RegReAssign.h
    A bolt/src/Passes/ReorderAlgorithm.cpp
    A bolt/src/Passes/ReorderAlgorithm.h
    A bolt/src/Passes/ReorderFunctions.cpp
    A bolt/src/Passes/ReorderFunctions.h
    A bolt/src/Passes/ReorderUtils.h
    A bolt/src/Passes/ShrinkWrapping.cpp
    A bolt/src/Passes/ShrinkWrapping.h
    A bolt/src/Passes/StackAllocationAnalysis.cpp
    A bolt/src/Passes/StackAllocationAnalysis.h
    A bolt/src/Passes/StackAvailableExpressions.cpp
    A bolt/src/Passes/StackAvailableExpressions.h
    A bolt/src/Passes/StackPointerTracking.cpp
    A bolt/src/Passes/StackPointerTracking.h
    A bolt/src/Passes/StackReachingUses.cpp
    A bolt/src/Passes/StackReachingUses.h
    A bolt/src/Passes/StokeInfo.cpp
    A bolt/src/Passes/StokeInfo.h
    A bolt/src/ProfileReader.cpp
    A bolt/src/ProfileReader.h
    A bolt/src/ProfileWriter.cpp
    A bolt/src/ProfileWriter.h
    A bolt/src/ProfileYAMLMapping.h
    A bolt/src/Relocation.cpp
    A bolt/src/Relocation.h
    A bolt/src/RewriteInstance.cpp
    A bolt/src/RewriteInstance.h
    A bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    A bolt/src/Target/AArch64/CMakeLists.txt
    A bolt/src/Target/CMakeLists.txt
    A bolt/src/Target/X86/CMakeLists.txt
    A bolt/src/Target/X86/X86MCPlusBuilder.cpp
    A bolt/src/llvm-bolt.cpp
    A bolt/src/merge-fdata/CMakeLists.txt
    A bolt/src/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT] Getting open-source ready

Summary:
BOLT sources are being moved under tools/llvm-bolt/src
and tools/llvm-bolt will contain more files such as LICENSE.txt,
README.txt, etc.

Remove trailing white spaces from our sources.

Create llvm.patch by running

  > git diff f137ed238db11440f03083b1c88b7ffc0f4af65e include lib > \
    tools/llvm-bolt/llvm.patch

README.txt has instructions on checking out sources and applying the
patch.

(cherry picked from FBD7878380)


  Commit: bdf21f7617e4155efbf3df7ce277901ca3825ac9
      https://github.com/llvm/llvm-project/commit/bdf21f7617e4155efbf3df7ce277901ca3825ac9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2017-11-07 (Tue, 07 Nov 2017)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Passes/Aligner.cpp
    M bolt/src/Passes/Aligner.h

  Log Message:
  -----------
  [BOLT] Align basic blocks based on execution count

Summary:
The default is not changing, i.e. we are not aligning code within a
function by default.

New meaning of options for aligning basic blocks:

  -align-blocks
      triggers basic block alignment based on profile

  -preserve-blocks-alignment
      tries to preserve basic block alignment seen on input

Tuning options for "-align-blocks":
  -align-blocks-min-size=<uint>
      blocks smaller than the specified size wouldn't be aligned

  -align-blocks-threshold=<uint>
      align only blocks with frequency larger than containing function
      execution frequency specified in percent. E.g. 1000 means aligning
      blocks that are 10 times more frequently executed than the containing
      function.

(cherry picked from FBD7921980)


  Commit: 729da2da22740428a84ec27839db6c957893cff2
      https://github.com/llvm/llvm-project/commit/729da2da22740428a84ec27839db6c957893cff2
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-04-20 (Fri, 20 Apr 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.cpp
    M bolt/src/BinaryData.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/JumpTable.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/CMakeLists.txt
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/IndirectCallPromotion.h
    A bolt/src/Passes/ReorderData.cpp
    A bolt/src/Passes/ReorderData.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Static data reordering pass.

Summary:
Enable BOLT to reorder data sections in a binary based on memory
profiling data.

This diff adds a new pass to BOLT that can reorder data sections for
better locality based on memory profiling data.  For now, the algorithm
to order data is primitive and just relies on the frequency of loads to
order the contents of a section.  We could probably do a lot better by
looking at what functions use the hot data and grouping together hot
data that is used by a single function (or cluster of functions).
Block ordering might give some hints on how to order the data better as
well.

The new pass has two basic modes: inplace and split (when inplace is
false).  The default is split since inplace hasn't really been tested
much.  When splitting is on, the cold data is copied to a "cold" version
of the section while the hot data is kept in the original section, e.g.
for .rodata, .rodata will contain the hot data and .bolt.org.rodata will
contain the cold bits.  In inplace mode, the section contents are
reordered inplace.  In either mode, all relocations to data within that
section are updated to reflect new data locations.

Things to improve:
- The current algorithm is really dumb and doesn't seem to lead to any
  wins.  It certainly could use some improvement.
- Private symbols can have data that leaks over to an adjacent symbol,
  e.g. a string that has a common suffix can start in one symbol and
  leak over (with the common suffix) into the next.  For now, we punt on
  adjacent private symbols.
- Handle ambiguous relocations better.  Section relocations that point
  to the boundary of two symbols will prevent the adjacent symbols from
  being moved because we can't tell which symbol the relocation is for.
- Handle jump tables.  Right now jump table support must be basic if
  data reordering is enabled.
- Being able to handle TLS.  A good amount of data access in some
  binaries are happening in TLS. It would be worthwhile to be able to
  reorder any TLS sections too.
- Handle sections with writeable data.  This hasn't been tested so
  probably won't work.  We could try to prevent false sharing in
  writeable sections as well.
- A pie in the sky goal would be to use DWARF info to reorder types.

(cherry picked from FBD6792876)


  Commit: e4f39bda51d26078b871ad5a546ee06501e94fd5
      https://github.com/llvm/llvm-project/commit/e4f39bda51d26078b871ad5a546ee06501e94fd5
  Author: spupyrev <spupyrev at fb.com>
  Date:   2018-05-11 (Fri, 11 May 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/CacheMetrics.cpp
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  adjusting cache stats for non-simple functions

Summary:
While working with a binary in non-relocations mode, I realized
some cache metrics are not computed correctly. Hence, this fix.
In addition, logging the number of functions with modified ordering of
basic blocks, which is helpful for analysis.

(cherry picked from FBD7975392)


  Commit: 56b38a14c50ab3a8e7c1549823c5718174925151
      https://github.com/llvm/llvm-project/commit/56b38a14c50ab3a8e7c1549823c5718174925151
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-05-11 (Fri, 11 May 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix dyno-stats for PLT calls

Summary:
To accurately account for PLT optimization, each PLT call should be
counted as an extra indirect call instruction, which in turn is
a load, a call, an indirect call, and instruction entry in dyno stats.

(cherry picked from FBD7978980)


  Commit: 1750fee2ac331261a5fd027eea250f254caf9bbf
      https://github.com/llvm/llvm-project/commit/1750fee2ac331261a5fd027eea250f254caf9bbf
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-05-11 (Fri, 11 May 2018)

  Changed paths:
    M bolt/src/ProfileReader.cpp

  Log Message:
  -----------
  [BOLT] Add option to ignore function hash in profile

Summary:
When we make changes to MCInst opcodes (or get changes from upstream),
a hash value for BinaryFunction changes. As a result, we are unable
to match profile generated by a previous version of BOLT.

Add option `-profile-ignore-hash` to match profile while ignoring
function hash value. With this option we match functions with common
names using the number of basic blocks.

(cherry picked from FBD7983269)


  Commit: 3af3537383fca997ab6a9a8807060ca777542be1
      https://github.com/llvm/llvm-project/commit/3af3537383fca997ab6a9a8807060ca777542be1
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-05-14 (Mon, 14 May 2018)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Properly handle non-standard function refs

Summary:
Application code can reference functions in a non-standard way, e.g.
using arithmetic and bitmask operations on them. One example is if a
program checks if a function is below a certain address or within
a certain address range to perform a low-level optimization or generate
a proper code (JIT).

Instead of relying on a relocation value (symbol+addend), we use only
the symbol value, and then check if the value is inside the function.
If it is, we treat it as a code reference against location within the
function, otherwise we handle it as a non-standard function reference
and issue a warning.

(cherry picked from FBD7996274)


  Commit: 13968f7fa9c7225c018078c32e48cd6c0f71eb98
      https://github.com/llvm/llvm-project/commit/13968f7fa9c7225c018078c32e48cd6c0f71eb98
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-05-17 (Thu, 17 May 2018)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Add option to print functions with bad layout

Summary:
Option `-report-bad-layout=N` prints top N functions with layouts
that have cold blocks placed in the middle of hot blocks. The sorting is
based on execution_count / number_of_basic_blocks formula.

(cherry picked from FBD8051950)


  Commit: 6302e18f9466ce50cb9f6dbb10323821267fe776
      https://github.com/llvm/llvm-project/commit/6302e18f9466ce50cb9f6dbb10323821267fe776
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-05-16 (Wed, 16 May 2018)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [PERF2BOLT] Improve file matching

Summary:
If the input binary for perf2bolt has a build-id and perf data has
recorded build-ids, then try to match them. Adjust the file name if
build-ids match to cover cases where the binary was renamed after data
collection. If there's no matching build-id report an error and exit.

While scanning task events, truncate the name to 15 characters prior to
matching, since that's how names are reported by perf.

(cherry picked from FBD8034436)


  Commit: 929b0908f711457feae6c6b68d9fa5ac82604987
      https://github.com/llvm/llvm-project/commit/929b0908f711457feae6c6b68d9fa5ac82604987
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-05-22 (Tue, 22 May 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/BoltDiff.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/IdenticalCodeFolding.cpp
    A bolt/src/Passes/IdenticalCodeFolding.h

  Log Message:
  -----------
  [BOLT][NFC] Move ICF pass into a separate file

Summary:
Consolidate code used by identical code folding under
Passes/IdenticalCodeFolding.cpp.

(cherry picked from FBD8109916)


  Commit: 42e651224146a12d8531923769187b67496cf0b5
      https://github.com/llvm/llvm-project/commit/42e651224146a12d8531923769187b67496cf0b5
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-04-30 (Mon, 30 Apr 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT-AArch64] Detect linker stubs and address them

Summary:
In AArch64, when the binary gets large, the linker inserts
stubs with 3 instructions: ADRP to load the PC-relative address of
a page; ADD to add the offset of the page; and a branch instruction
to do an indirect jump to the contents of X16 (the linker-reserved
reg). The problem is that the linker does not issue a relocation for
this (since this is not code coming from the assembler), so BOLT has
no idea what is the real target, unless it recognizes these instructions
and extract the target by combining the operands of the instructions
from the stub. This diff does exactly that.

(cherry picked from FBD7882653)


  Commit: b4dbd35d6c183909396611b50bb0c231aaf9548d
      https://github.com/llvm/llvm-project/commit/b4dbd35d6c183909396611b50bb0c231aaf9548d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-05-26 (Sat, 26 May 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Initial support for memcpy() inlininig

Summary:
Add "-inline-memcpy" option to inline calls to memcpy() using
"rep movsb" instruction. The pass is X86-specific.

Calls to _memcpy8 are optimized too using a special return value
(dest+size).

The implementation is very primitive in that it does not track liveness
of %rax after return, and no %rcx substitution. This is going to get
improved if we find the optimization to be useful.

(cherry picked from FBD8211890)


  Commit: 779541283a3ddeac3975f879bbd4a6a2f0655459
      https://github.com/llvm/llvm-project/commit/779541283a3ddeac3975f879bbd4a6a2f0655459
  Author: spupyrev <spupyrev at fb.com>
  Date:   2018-05-17 (Thu, 17 May 2018)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/CachePlusReorderAlgorithm.cpp
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/ReorderAlgorithm.h

  Log Message:
  -----------
  [BOLT] merging cold basic blocks to reduce #jumps

Summary:
This diff introduces a modification of cache+ block ordering algorithm,
which reordered and merges cold blocks in a function with the goal of reducing
the number of (non-fallthrough) jumps, and thus, the code size.

(cherry picked from FBD8044978)


  Commit: 706abb6c9541cb3b18e4093cbfe0e8518c51602d
      https://github.com/llvm/llvm-project/commit/706abb6c9541cb3b18e4093cbfe0e8518c51602d
  Author: Bill Nell <bnell at fb.com>
  Date:   2018-06-06 (Wed, 06 Jun 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.cpp
    M bolt/src/BinaryData.h
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT] Hash anonymous symbol names

Summary:
This diff replaces the addresses in all the {SYMBOLat,HOLEat,DATAat} symbols with hash values based on the data contained in the symbol.  It should make the profiling data for anonymous symbols robust to address changes.

The only small problem with this approach is that the hashed name for padding symbols of the same size collide frequently.  This shouldn't be a big deal since it would be weird if those symbols were hot.

On a test run with hhvm there were 26 collisions (out of ~338k symbols).  Most of the collisions were from small (2,4,8 byte) objects.

(cherry picked from FBD7134261)


  Commit: 232046f9b25e54842dcce4471354d450d80b864f
      https://github.com/llvm/llvm-project/commit/232046f9b25e54842dcce4471354d450d80b864f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-11 (Mon, 11 Jun 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [Bolt] Reduce verbosity while reporting hash collisions

Summary:
Don't report all data objects with hash collisions by default. Only
report the summary, and use -v=1 for providing the full list.

(cherry picked from FBD8372241)


  Commit: 789162276d00c48a0274a826b539a024822819f6
      https://github.com/llvm/llvm-project/commit/789162276d00c48a0274a826b539a024822819f6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-11 (Mon, 11 Jun 2018)

  Changed paths:
    M bolt/README.txt
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DataReader.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/Inliner.h
    M bolt/src/Passes/JTFootprintReduction.h
    M bolt/src/Passes/LongJmp.h
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/ProfileReader.cpp
    M bolt/src/ProfileReader.h
    M bolt/src/ProfileYAMLMapping.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [Bolt][NFC] Change capitalization s/BOLT/Bolt/g

(cherry picked from FBD8373789)


  Commit: a7d025139f377c40b54ce471621ac3d7c2684296
      https://github.com/llvm/llvm-project/commit/a7d025139f377c40b54ce471621ac3d7c2684296
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-14 (Thu, 14 Jun 2018)

  Changed paths:
    M bolt/README.txt
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DataReader.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/Inliner.h
    M bolt/src/Passes/JTFootprintReduction.h
    M bolt/src/Passes/LongJmp.h
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/ProfileReader.cpp
    M bolt/src/ProfileReader.h
    M bolt/src/ProfileYAMLMapping.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  Revert "[Bolt][NFC] Change capitalization s/BOLT/Bolt/g"

Summary:

(cherry picked from FBD8431879)


  Commit: 221107c5fb0684850e76201a3319adf7c122c243
      https://github.com/llvm/llvm-project/commit/221107c5fb0684850e76201a3319adf7c122c243
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-17 (Sun, 17 Jun 2018)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  [BOLT] Update llvm.patch

Summary:

(cherry picked from FBD8475998)


  Commit: 35c09dc4ddbcd9dff21769a3ce74f4c6065dd366
      https://github.com/llvm/llvm-project/commit/35c09dc4ddbcd9dff21769a3ce74f4c6065dd366
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-06-20 (Wed, 20 Jun 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add a user friendly error reporting message

Summary:
In case we fail to disassemble or to build the CFG for a
function, print instructions on bug reporting.

(cherry picked from FBD8549737)


  Commit: 3ab2929b36cc2d3b6b7d859da2e9ab44101ea09e
      https://github.com/llvm/llvm-project/commit/3ab2929b36cc2d3b6b7d859da2e9ab44101ea09e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-20 (Wed, 20 Jun 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix support for PIC jump tables

Summary:
BOLT heuristics failed to work if false PIC jump table entries were
accepted when they were pointing inside a function, but not at
an instruction boundary.

This fix checks if the destination falls at instruction boundary, and
if it does not, it truncates the jump table. This, of course, still does not
guarantee that the entry corresponds to a real destination, and we can
have "false positive" entry(ies). However, it shouldn't affect
correctness of the function, but the CFG may have edges that are never
taken. We may update an incorrect jump table entry, corresponding to an
unrelated data, and for that reason we force moving of jump tables if a
PIC jump table was detected.

(cherry picked from FBD8559588)


  Commit: 1baa2529ea57eea3cd63cbbf9e1d237402d7fa4f
      https://github.com/llvm/llvm-project/commit/1baa2529ea57eea3cd63cbbf9e1d237402d7fa4f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-21 (Thu, 21 Jun 2018)

  Changed paths:
    M bolt/src/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [merge-fdata] Support legacy/non-YAML profile format

Summary: Concatenate profile contents if they are not in YAML format.

(cherry picked from FBD8579955)


  Commit: 8f717dd25ecc0a76581cf0fe014c5a27d2166044
      https://github.com/llvm/llvm-project/commit/8f717dd25ecc0a76581cf0fe014c5a27d2166044
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-06-22 (Fri, 22 Jun 2018)

  Changed paths:
    M bolt/CMakeLists.txt
    A bolt/test/CMakeLists.txt
    A bolt/test/X86/Inputs/srol-bug-input.yaml
    A bolt/test/X86/srol-bug.test
    A bolt/test/lit.cfg.py
    A bolt/test/lit.site.cfg.py.in

  Log Message:
  -----------
  [BOLT] Add initial bolt-only test infra

Summary:
Create folders and setup to make LIT run BOLT-only tests. Add
a test example. This will add a new make/ninja rule "check-bolt" that
the user can invoke to run LIT on this folder.

(cherry picked from FBD8595786)


  Commit: 5b2eab653809d62c9b7120cf60bc21308f7effe6
      https://github.com/llvm/llvm-project/commit/5b2eab653809d62c9b7120cf60bc21308f7effe6
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-06-21 (Thu, 21 Jun 2018)

  Changed paths:
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Fix call to evaluateX86MemOperands

Summary:
There was a call site not providing a displament immediate
value. This assertion is firing in opensource.

(cherry picked from FBD8576033)


  Commit: 72ecd12f2faedceef0b402be8b1a1924412feba8
      https://github.com/llvm/llvm-project/commit/72ecd12f2faedceef0b402be8b1a1924412feba8
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-06-25 (Mon, 25 Jun 2018)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Disable -split-eh in non-relocation mode

Summary:
This option only works in relocation mode. In non-relocation
mode, it generates invalid references that cause MCStreamer to fail.
Disable this flag if the user requested and print a warning.

(cherry picked from FBD8625990)


  Commit: 07353e9590ace8cac1375e89c8c40bd7e2430cf7
      https://github.com/llvm/llvm-project/commit/07353e9590ace8cac1375e89c8c40bd7e2430cf7
  Author: Facebook Github Bot <facebook-github-bot at users.noreply.github.com>
  Date:   2018-06-26 (Tue, 26 Jun 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT][PR] In some cases DB could be nullptr

Summary:
When processing binary with -debug mode in some cases, BD could be nullptr. It will be better to fail later on assert than here with segfault.
Closes https://github.com/facebookincubator/BOLT/pull/18
GitHub Author: Alexander Gryanko <xpahos at gmail.com>

(cherry picked from FBD8650719)


  Commit: 8835f90d1e241d51c6293a44a40ecf2386941b63
      https://github.com/llvm/llvm-project/commit/8835f90d1e241d51c6293a44a40ecf2386941b63
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-06-11 (Mon, 11 Jun 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/CMakeLists.txt
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/JTFootprintReduction.cpp
    M bolt/src/Passes/ReachingDefOrUse.h
    M bolt/src/Passes/RegAnalysis.cpp
    M bolt/src/Passes/RegAnalysis.h
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/Passes/StokeInfo.cpp
    A bolt/src/Passes/ValidateInternalCalls.cpp
    A bolt/src/Passes/ValidateInternalCalls.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [X86] Support a subset of internal calls

Summary:
Add support for functions with internal calls, necessary for
handling Intel MKL library and some code observed in google core dumper
library.

This is not optimizing these functions, but only identifying them,
running analyses to assure we will not break those functions if we move
them, and then "freezing" these functions (marking as not simple so Bolt
will not try to reorder it or touch it in any way).

(cherry picked from FBD8364381)


  Commit: 6802948028b52b24bdadbbb99c1972b3dd4722c4
      https://github.com/llvm/llvm-project/commit/6802948028b52b24bdadbbb99c1972b3dd4722c4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-30 (Sat, 30 Jun 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Allow jump tables with 2 entries

Summary:
GCC 8 can generate jump tables with just 2 entries. Modify our heuristic
to accept it. We still assert that there's more than one entry.

(cherry picked from FBD8709416)


  Commit: edc0cb1121a1d535834059f777f3f1f3a3aaed16
      https://github.com/llvm/llvm-project/commit/edc0cb1121a1d535834059f777f3f1f3a3aaed16
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-29 (Fri, 29 Jun 2018)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  [LLVM] Accept `S` in augmentation strings in CIE

Summary:
Ignore 'S' in augmentation string on input. It just marks a signal
frame. All we have to do is propagate it.

Fixes facebookincubator/BOLT#21

This was already in LLVM trunk rL331738. Update llvm.patch.

(cherry picked from FBD8707222)


  Commit: a6a37995d916964f4b216e3dda967ab491eb0d9a
      https://github.com/llvm/llvm-project/commit/a6a37995d916964f4b216e3dda967ab491eb0d9a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-06-29 (Fri, 29 Jun 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Reject processing of PIE binaries

Summary:
Check if the input binary ELF type. Reject any binary not of
ET_EXEC type, including position-independent executables (PIEs).

Also print the first function containing PIC jump table.

(cherry picked from FBD8707274)


  Commit: 365613b404075a7f4ecb823bb65427eefba7d2c5
      https://github.com/llvm/llvm-project/commit/365613b404075a7f4ecb823bb65427eefba7d2c5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-04 (Wed, 04 Jul 2018)

  Changed paths:
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Fix no-assertions build

Summary:
In release build without assertions MCInst::dump() is undefined and
causes link time failure.

Fixes facebookincubator/BOLT#27.

(cherry picked from FBD8732905)


  Commit: d7b2474f835968cc649bcced27ef86bc3f4c61c4
      https://github.com/llvm/llvm-project/commit/d7b2474f835968cc649bcced27ef86bc3f4c61c4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-05 (Thu, 05 Jul 2018)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  [DebugInfo] Change default value of FDEPointerEncoding

Summary:
If the encoding is not specified in CIE augmentation string, then it
should be DW_EH_PE_absptr instead of DW_EH_PE_omit.

(cherry picked from FBD8740274)


  Commit: b447979b8c35f8e24dc8edc709cffa36b595ea6c
      https://github.com/llvm/llvm-project/commit/b447979b8c35f8e24dc8edc709cffa36b595ea6c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-05 (Thu, 05 Jul 2018)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [BOLT] Fix diagnostics printing in data aggregator

Summary: Print correct part of the string while reporting an error.

(cherry picked from FBD8745329)


  Commit: 64c429da895edf3801e40c85a0a1550e619e95e7
      https://github.com/llvm/llvm-project/commit/64c429da895edf3801e40c85a0a1550e619e95e7
  Author: Puyan Lotfi <plotfi at fb.com>
  Date:   2018-07-06 (Fri, 06 Jul 2018)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [LongJumpPass] X86 enablement. First attempt.

(cherry picked from FBD8753328)


  Commit: 207ac19c638b4bd7c2a9e7936d538835192115a6
      https://github.com/llvm/llvm-project/commit/207ac19c638b4bd7c2a9e7936d538835192115a6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-06 (Fri, 06 Jul 2018)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  Revert "[LongJumpPass] X86 enablement. First attempt."

This reverts commit 010b0f7603fc9fa209c6dc95ce4b9c08e7b70d75.

(cherry picked from FBD28111178)


  Commit: b6c4d8e924d340e778babbbac0abc22643cd76e8
      https://github.com/llvm/llvm-project/commit/b6c4d8e924d340e778babbbac0abc22643cd76e8
  Author: Laith Saed Sakka <lsakka at fb.com>
  Date:   2018-06-07 (Thu, 07 Jun 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/VeneerElimination.cpp
    A bolt/src/Passes/VeneerElimination.h

  Log Message:
  -----------
  -- Adding Veneer elimination pass and Veneer count to dyno stats.

Summary: Create a pass that performs veneers elimination .

(cherry picked from FBD8359299)


  Commit: 544d1577c1d9f6064860b57668232e62a98e8953
      https://github.com/llvm/llvm-project/commit/544d1577c1d9f6064860b57668232e62a98e8953
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-07-03 (Tue, 03 Jul 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    A bolt/test/X86/Inputs/issue20.yaml
    A bolt/test/X86/issue20.test

  Log Message:
  -----------
  Avoid removing BBs referenced by JTs

Summary:
While removing unreachable blocks, we may decide to remove a
block that is listed as a target in a jump table entry. If we do that,
this label will be then undefined and LLVM assembler will crash.
Mitigate this for now by not removing such blocks, as we don't support
removing unnecessary jump tables yet.

Fixes facebookincubator/BOLT#20

(cherry picked from FBD8730269)


  Commit: 12380b8b067251fdebab883ca707133681d6b6a4
      https://github.com/llvm/llvm-project/commit/12380b8b067251fdebab883ca707133681d6b6a4
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-07-03 (Tue, 03 Jul 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    A bolt/test/X86/Inputs/issue26.yaml
    A bolt/test/X86/issue26.test

  Log Message:
  -----------
  Fix assembly after adding entry points

Summary:
When a given function B, located after function A, references
one of A's basic blocks, it registers a new global symbol at the
reference address and update A's Labels vector via
BinaryFunction::addEntryPoint(). However, we don't update A's branch
targets at this point. So we end up with an inconsistent CFG, where the
basic block names are global symbols, but the internal branch operands
are still referencing the old local name of the corresponding blocks
that got promoted to an entry point. This patch fix this by detecting
this situation in addEntryPoint and iterating over all instructions,
looking for references to the old symbol and replacing them to use the
new global symbol (since this is now an entry point).

Fixes facebookincubator/BOLT#26

(cherry picked from FBD8728407)


  Commit: 66e0313d15260c092cafba5f5882b7ea4c706a3e
      https://github.com/llvm/llvm-project/commit/66e0313d15260c092cafba5f5882b7ea4c706a3e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-10 (Tue, 10 Jul 2018)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataReader.cpp

  Log Message:
  -----------
  [perf2bolt] Accept `-` as a valid misprediction symbol

Summary:
As reported in GH-28 `perf` can produce `-` symbol for misprediction bit
if the bit is not supported by the kernel/HW. In this case we can ignore
the bit.

(cherry picked from FBD8786827)


  Commit: 44a36937f878745f59a1bf4c9ee638048a6d72e9
      https://github.com/llvm/llvm-project/commit/44a36937f878745f59a1bf4c9ee638048a6d72e9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-06 (Fri, 06 Jul 2018)

  Changed paths:
    M bolt/llvm.patch
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix llvm-dwarfdump issues

Summary:
llvm-dwarfdump is relying on getRelocatedSection() to return
section_end() for ELF files of types other than relocatable objects.
We've changed the function to return relocatable section for other
types of ELF files. As a result, llvm-dwarfdump started re-processing
relocations for sections that already had relocations applied, e.g. in
executable files, and this resulted in wrong values reported.

As a workaround/solution, we make this function return relocated section
for executable (and any non-relocatable objects) files only if the
section is allocatable.

(cherry picked from FBD8760175)


  Commit: 7aee0adbf9a5ddd62afa425bf14fcd5d1d3f4620
      https://github.com/llvm/llvm-project/commit/7aee0adbf9a5ddd62afa425bf14fcd5d1d3f4620
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-05-31 (Thu, 31 May 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT-AArch64] Create cold symbols on demand

Summary:
Rework the logic we use for managing references to constant
islands. Defer the creation of the cold versions to when we split the
function and will need them.

(cherry picked from FBD8228803)


  Commit: f2f164f47434397d1c2b8aed30e43434178a79d4
      https://github.com/llvm/llvm-project/commit/f2f164f47434397d1c2b8aed30e43434178a79d4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-13 (Fri, 13 Jul 2018)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [perf2bolt] Fix perf build-id matching

Summary:
Recent compiler tool chains can produce build-ids that are less than 40
characters long. Linux perf, however, always outputs 40 characters,
expanding the string with 0's as needed. Fix the matching by only
checking the string prefix.

(cherry picked from FBD8839452)


  Commit: 6e45f5aeec0b26c60f38fcb9a81d4139e09b226f
      https://github.com/llvm/llvm-project/commit/6e45f5aeec0b26c60f38fcb9a81d4139e09b226f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-13 (Fri, 13 Jul 2018)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h

  Log Message:
  -----------
  [perf2bolt] Enforce file matching in perf2bolt

Summary:
If the input binary does not have a build-id and the name does not match
any file names in perf.data, then reject the binary, and issue an error
message suggesting to rename it to one of the listed names from
perf.data.

(cherry picked from FBD8846181)


  Commit: 27f30324478a031c920f964d69db0d6e8e9e6ac3
      https://github.com/llvm/llvm-project/commit/27f30324478a031c920f964d69db0d6e8e9e6ac3
  Author: Laith Saed Sakka <lsakka at fb.com>
  Date:   2018-07-08 (Sun, 08 Jul 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Add initial function injection support

Summary:
This diff have the API needed to inject functions using bolt.
In relocation mode injected functions are emitted between the cold and the hot functions,
In non-reloc mode injected functions are emitted a next text section.

(cherry picked from FBD8715965)


  Commit: ddfcf4f266d218f242b6ea0b714550949adb75ff
      https://github.com/llvm/llvm-project/commit/ddfcf4f266d218f242b6ea0b714550949adb75ff
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-07-17 (Tue, 17 Jul 2018)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    A bolt/test/X86/Inputs/blarge.yaml
    A bolt/test/X86/Inputs/pre-aggregated.txt
    A bolt/test/X86/pre-aggregated-perf.test

  Log Message:
  -----------
  [BOLT] Add parser for pre-aggregated perf data

Summary:
The regular perf2bolt aggregation job is to read perf output directly.
However, if the data is coming from a database instead of perf, one
could write a query to produce a pre-aggregated file. This function
deals with this case.

The pre-aggregated file contains aggregated LBR data, but without binary
knowledge. BOLT will parse it and, using information from the
disassembled binary, augment it with fall-through edge frequency
information. After this step is finished, this data can be either
written to disk to be consumed by BOLT later, or can be used by BOLT
immediately if kept in memory.

File format syntax:
{B|F|f} [<start_id>:]<start_offset> [<end_id>:]<end_offset> <count>
[<mispred_count>]

B - indicates an aggregated branch
F - an aggregated fall-through (trace)
f - an aggregated fall-through with external origin - used to disambiguate
between a return hitting a basic block head and a regular internal
jump to the block

<start_id> - build id of the object containing the start address. We can
skip it for the main binary and use "X" for an unknown object. This will
save some space and facilitate human parsing.

<start_offset> - hex offset from the object base load address (0 for the
main executable unless it's PIE) to the start address.

<end_id>, <end_offset> - same for the end address.

<count> - total aggregated count of the branch or a fall-through.

<mispred_count> - the number of times the branch was mispredicted.
Omitted for fall-throughs.

Example
F 41be50 41be50 3
F 41be90 41be90 4
f 41be90 41be90 7
B 4b1942 39b57f0 3 0
B 4b196f 4b19e0 2 0

(cherry picked from FBD8887182)


  Commit: 631da736b0f2926835d39ee55fc4cdfb079061fb
      https://github.com/llvm/llvm-project/commit/631da736b0f2926835d39ee55fc4cdfb079061fb
  Author: spupyrev <spupyrev at fb.com>
  Date:   2018-05-17 (Thu, 17 May 2018)

  Changed paths:
    M bolt/src/CacheMetrics.cpp
    M bolt/src/Passes/CachePlusReorderAlgorithm.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] further speeding up cache+

Summary:
For large binaries, cache+ algorithm adds a noticeable overhead in
comparison with cache. This modification restricts search space of the
optimization, which makes cache+ as fast as cache for all tested binaries.

There is a tiny (in the order of 0.01%) regression in cache-related metrics,
but this is not noticeable in practice.

(cherry picked from FBD8369968)


  Commit: 49920a8fad09f3cc687b7c77e669cada2cb792e1
      https://github.com/llvm/llvm-project/commit/49920a8fad09f3cc687b7c77e669cada2cb792e1
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-24 (Tue, 24 Jul 2018)

  Changed paths:
    M bolt/src/Relocation.cpp

  Log Message:
  -----------
  [BOLT] Add R_X86_64_PC64 relocation support

(cherry picked from FBD8980691)


  Commit: 771d9765435fa41f6834a19542d3ba0b047445bd
      https://github.com/llvm/llvm-project/commit/771d9765435fa41f6834a19542d3ba0b047445bd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-12 (Thu, 12 Jul 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Passes/ValidateInternalCalls.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][NFC] Minor code refactoring

(cherry picked from FBD8882632)


  Commit: fe9f8219faba269dcc773bfa029b258bc249476d
      https://github.com/llvm/llvm-project/commit/fe9f8219faba269dcc773bfa029b258bc249476d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-30 (Mon, 30 Jul 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryData.cpp
    M bolt/src/BinarySection.h

  Log Message:
  -----------
  [BOLT] Fix TBSS-related issue

Summary:
TLS segment provide a template for initializing thread-local storage
for every new thread. It consists of initialized  and uninitialized
parts. The uninitialized part of TLS, .tbss, is completely meaningless
from a binary analysis perspective. It doesn't take any space in the
file, or in memory. Note that this is different from a regular .bss
section that takes space in memory.

We should not place .tbss into a list of allocatable sections, otherwise
it may cause conflicts with objects contained in the next section.

(cherry picked from FBD9074056)


  Commit: df947861199e20085da3dde4ea287b46fd9441e3
      https://github.com/llvm/llvm-project/commit/df947861199e20085da3dde4ea287b46fd9441e3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-30 (Mon, 30 Jul 2018)

  Changed paths:
    M bolt/src/BinaryData.h
    M bolt/src/BinarySection.h

  Log Message:
  -----------
  [BOLT] Fix range checks

Summary:
containsRange() functions were incorrectly checking for an empty range
at the end of containing object. I.e. [a,b) was reporting true for
containing [b,b).

(cherry picked from FBD9074643)


  Commit: 39f6fcc947bd80f80ca9a2d29ce724e053400774
      https://github.com/llvm/llvm-project/commit/39f6fcc947bd80f80ca9a2d29ce724e053400774
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-07-30 (Mon, 30 Jul 2018)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add support for IFUNC

Summary:
Relocation value verification was failing for IFUNC as the real value
used for relocation wasn't the symbol value, but a corresponding PLT
entry.

Relax the verification and skip any symbols of ST_Other type.

(cherry picked from FBD9123741)


  Commit: 06e1554158a9917e8eb126d92e38f94da296ce30
      https://github.com/llvm/llvm-project/commit/06e1554158a9917e8eb126d92e38f94da296ce30
  Author: Laith Saed Sakka <lsakka at fb.com>
  Date:   2018-07-25 (Wed, 25 Jul 2018)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/RetpolineInsertion.cpp
    A bolt/src/Passes/RetpolineInsertion.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  Retpoline Insertion Pass

Summary:
retpoline insertion implemented for reloc mode,

(cherry picked from FBD8832838)


  Commit: c35dc2a38635414ee7e8d0142df0d9489f235128
      https://github.com/llvm/llvm-project/commit/c35dc2a38635414ee7e8d0142df0d9489f235128
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-06 (Mon, 06 Aug 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Detect and handle fixed indirect branches

Summary:
Sometimes GCC can generate code where one of jump table entries
is being used by an indirect branch with a fixed memory reference,
such as "jmp *(JT+8)". If we don't convert such branches to direct ones
and move jump tables, then the indirect branch will reference the old
table value and will end up at the non-updated destination, possibly
causing a runtime crash.

This fix converts such indirect branches into direct ones.

For now we mark functions containing indirect branches with fixed
destination as non-simple to prevent unreachable code elimination
problem triggered by related dead/unreachable jump table.

(cherry picked from FBD9192363)


  Commit: b2382dc5527dde3b5de3201d83d8f97eafee0ab6
      https://github.com/llvm/llvm-project/commit/b2382dc5527dde3b5de3201d83d8f97eafee0ab6
  Author: Laith Saed Sakka <lsakka at fb.com>
  Date:   2018-08-03 (Fri, 03 Aug 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/PLTCall.cpp
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  retpoline insertion : further updates.

Summary:
Couple of updates:

1) Handle address pattern with segment register.
2) Assume R11 available for PLT calls always.
3) Add CFI state to each BB.
4) early exit getMacroOpFusionPair if Instruction.size() <2.

(cherry picked from FBD9172426)


  Commit: b10d4724c38648b010e1ec98aa051fe4344b3de4
      https://github.com/llvm/llvm-project/commit/b10d4724c38648b010e1ec98aa051fe4344b3de4
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-08-13 (Mon, 13 Aug 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h

  Log Message:
  -----------
  [BOLT] Fix pseudo calculation in BinaryBasicBlock

Summary:
A recent commit broke our tests because it was depending on
getNumNonPseudos() at a very late stage of our optimization pipeline.
The problem was in a instruction deletion member function in
BinaryBasicBlock that was not updating the number of pseudos after
deletion. Fix this.

(cherry picked from FBD9305972)


  Commit: 560c23411a006ba9253de21bf2b382299c6cf860
      https://github.com/llvm/llvm-project/commit/560c23411a006ba9253de21bf2b382299c6cf860
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-14 (Tue, 14 Aug 2018)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h

  Log Message:
  -----------
  [perf2bolt] Use mmap events for PID collection

Summary:
Switch from using `perf script --show-task-events` to
`perf script --show-mmap-events` for associating a binary with PIDs in
perf.data. The output of the former command does not provide enough
information for PIE/.so processing.

(cherry picked from FBD9346586)


  Commit: 87788ca92655a4a6c55f345dbe9769f87b28a2f6
      https://github.com/llvm/llvm-project/commit/87788ca92655a4a6c55f345dbe9769f87b28a2f6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-14 (Tue, 14 Aug 2018)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [perf2bolt] Support profiling of PIEs and .so's

Summary:
Processing profile data for binaries with flexible load address (such as
position-independent executables and shared objects) requires adjusting
binary addresses depending on the base load address.

For every PID the mapping will be more or less unique when executing
with ASLR enabled, thus we have to keep the mapping record for all PIDs
associated with the binary. Then we adjust the addresses based on those
mappings.

(cherry picked from FBD9368566)


  Commit: 88bb14516499c5ffe2326fc209b02fc0c0a5e191
      https://github.com/llvm/llvm-project/commit/88bb14516499c5ffe2326fc209b02fc0c0a5e191
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-16 (Thu, 16 Aug 2018)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/DataAggregator.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Update allocatable relocation sections

Summary:
Position-independent binaries may have runtime relocations of type
R_X86_64_RELATIVE that need an update if they were pointing to one of
the functions that we have relocated.

(cherry picked from FBD9374164)


  Commit: 510a8c4bbe568f457a4689ee224f4f3fd2c902ea
      https://github.com/llvm/llvm-project/commit/510a8c4bbe568f457a4689ee224f4f3fd2c902ea
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-08-14 (Tue, 14 Aug 2018)

  Changed paths:
    M bolt/src/Passes/ShrinkWrapping.cpp

  Log Message:
  -----------
  [BOLT] Fix shrink-wrapping CFI update

Summary:
When updating CFI for a function that was optimized by
shrink-wrapping, if the function had no frame pointers, the CFI update
algorithm was incorrect.

(cherry picked from FBD9328658)


  Commit: 9c4fcafa37ba7f07b6941ee4e0f1986918193f81
      https://github.com/llvm/llvm-project/commit/9c4fcafa37ba7f07b6941ee4e0f1986918193f81
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-08-08 (Wed, 08 Aug 2018)

  Changed paths:
    M bolt/src/ProfileWriter.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Add update-build-id option, on by default

Summary:
The build-id is used by tools to uniquely identify binaries. Update
the output binary build-id with a different number to make it
distinguishable from the input binary. This implementation just flips
the last build-id bit.

(cherry picked from FBD9235336)


  Commit: af1177d99f36f6b1e6ce5d5368319bfb9fbc4bec
      https://github.com/llvm/llvm-project/commit/af1177d99f36f6b1e6ce5d5368319bfb9fbc4bec
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-08-22 (Wed, 22 Aug 2018)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add mattr options to AArch64 target

Summary:
Make the AArch64 subtarget enable all features, so the disassembler
won't choke on extension instructions.

(cherry picked from FBD9477066)


  Commit: a7e0704be671286ba167cca24411835d9b8b2a57
      https://github.com/llvm/llvm-project/commit/a7e0704be671286ba167cca24411835d9b8b2a57
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-08-24 (Fri, 24 Aug 2018)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Reduce AArch64 target feature flags

Summary:
Eliminate some flags that are not recognized and
are currently printing warnings when BOLT runs on AArch64.

(cherry picked from FBD9499971)


  Commit: 2511b09985e774f329a75f12b68cc4f0cdbe5c0a
      https://github.com/llvm/llvm-project/commit/2511b09985e774f329a75f12b68cc4f0cdbe5c0a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-27 (Mon, 27 Aug 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Fix line info for empty CU DIEs

Summary:
In some rare cases a compiler may generate DWARF that contains an empty
CU DIE that references a debug line fragment. That fragment will contain
no file name information, and we fail to register it. Then, as a result,
DW_AT_stmt_list is not updated for the CU. This may cause some
DWARF-processing tools to segfault.

As a solution/workaround, we register "<unknown>" file name for such
debug line tables.

(cherry picked from FBD9526705)


  Commit: 708a55008477590e1022ca9f5ff27a5d19725472
      https://github.com/llvm/llvm-project/commit/708a55008477590e1022ca9f5ff27a5d19725472
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-23 (Thu, 23 Aug 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp

  Log Message:
  -----------
  [BOLT] Fix profile after ICP

Summary:
After optimizing a target of a jump table, ICP was not updating edge
counts corresponding to that target. As a result the edge could be left
hot and negatively influence the code layout.

(cherry picked from FBD9524396)


  Commit: d0a80b08703e631db509533a26e96dd6133fdd92
      https://github.com/llvm/llvm-project/commit/d0a80b08703e631db509533a26e96dd6133fdd92
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-08-28 (Tue, 28 Aug 2018)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Change ForceRelocation behavior

Summary:
Only record address as addend if the target of the relocation
is the pseudo-symbol Zero.

(cherry picked from FBD9551543)


  Commit: 69e6004a4292a98e6a351a5127e1defea3580afd
      https://github.com/llvm/llvm-project/commit/69e6004a4292a98e6a351a5127e1defea3580afd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-30 (Thu, 30 Aug 2018)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [perf2bolt] Fix processing of binaries with names over 15 chars long

Summary:
Do not truncate the binary name for comparison purposes as the binary
name we are getting from "perf script" is no longer truncated.

(cherry picked from FBD9596409)


  Commit: cd19f718b4cbed65e7fb9a342301a09f37acfcd3
      https://github.com/llvm/llvm-project/commit/cd19f718b4cbed65e7fb9a342301a09f37acfcd3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-30 (Thu, 30 Aug 2018)

  Changed paths:
    M bolt/src/BinaryFunctionProfile.cpp

  Log Message:
  -----------
  [BOLT] Merge jump table profile data

Summary:
While running ICF pass we have skipped merging profile data for jump
tables. We were only updating profile in the CFG. Fix that.

(cherry picked from FBD9595523)


  Commit: 41ed5431a01f55a5ddb64229cc61948ffcbf42b9
      https://github.com/llvm/llvm-project/commit/41ed5431a01f55a5ddb64229cc61948ffcbf42b9
  Author: spupyrev <spupyrev at fb.com>
  Date:   2018-08-14 (Tue, 14 Aug 2018)

  Changed paths:
    M bolt/src/Passes/Aligner.cpp

  Log Message:
  -----------
  [BOLT] turning on the compact aligner by default

Summary: Making UseCompactAligner true by default

(cherry picked from FBD9325158)


  Commit: 8026760ac04173e77a86a8059ea0aab47a849d7f
      https://github.com/llvm/llvm-project/commit/8026760ac04173e77a86a8059ea0aab47a849d7f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-08-30 (Thu, 30 Aug 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/IndirectCallPromotion.h

  Log Message:
  -----------
  [BOLT] Fix another issue with profile after ICP

Summary:
For jump tables ICP was using profile from the jump table itself which
doesn't work correct if the jump table is re-used at different code
locations.

(cherry picked from FBD9618774)


  Commit: 53b72d0f2eebc885522524d737e576717b90b87f
      https://github.com/llvm/llvm-project/commit/53b72d0f2eebc885522524d737e576717b90b87f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-09-05 (Wed, 05 Sep 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Ignore symbols from non-allocatable sections

Summary:
While creating BinaryData objects we used to process all symbol table
entries. However, some symbols could belong to non-allocatable sections,
and thus we have to ignore them for the purpose of analyzing in-memory
data.

(cherry picked from FBD9666511)


  Commit: 1387a9d76165382d26b3d8ae6ca3c840e0defb76
      https://github.com/llvm/llvm-project/commit/1387a9d76165382d26b3d8ae6ca3c840e0defb76
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-09-24 (Mon, 24 Sep 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Keep .text section in file when using old text

Summary:
If we reuse text section under `-use-old-text` option, then there's no
need to rename it. Tools, such as perf, seem to not like binaries
without `.text`.

Additionally, check if the code fits into `.text` using the page
alignment, otherwise we were skipping the alignment relying on the user
detecting the warning message. This could have resulted in unexpected
performance drops.

Also add `-no-huge-pages` option to use regular page size for code
alignment purposes (i.e. 4KiB instead of 2MiB).

(cherry picked from FBD10024670)


  Commit: bd0b99c45d1397065f750925f00536bf465bf4fc
      https://github.com/llvm/llvm-project/commit/bd0b99c45d1397065f750925f00536bf465bf4fc
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-09-17 (Mon, 17 Sep 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/LongJmp.h
    M bolt/src/Passes/VeneerElimination.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Change stub-insertion pass for AArch64

Summary:
Previously, we were expanding eligible branches with stubs. After
expansion, we were computing which stubs were unnecessary and removing them,
assuming ranges were shortening as code is removed. The problem with this
approach is that for branches that refer to code that is not managed by
BOLT, the distance to that location can increase and we can end up with an
out-of-range branch.

This rewrites the pass to be simpler, only increasing size and expanding code
with stubs as needed after each iteration, stopping when code stops increasing.
Besides this rewrite, the stub-insertion pass now supports stubs grouping
similar to what the linker does, allowing different functions to share the
same veneer that jumps to a common callee. It also fixes a bug in the previous
implementation that, in very large functions that use TBZ/TBNZ (+-32KB range),
it would mistakenly try to reuse a local stub BB that is out of range.

This includes a change to allow hot functions to be put at the end of the
.text section, closer to the heap, requiring no veneers to jump to JITted
code. And finally it enables eliminate veneers pass by default.

(cherry picked from FBD10023158)


  Commit: ce508b58c6e92dc618a7d40cc1534a0618ffa5a0
      https://github.com/llvm/llvm-project/commit/ce508b58c6e92dc618a7d40cc1534a0618ffa5a0
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-09-21 (Fri, 21 Sep 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Exceptions.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Support relocations without symbols

Summary:
lld may generate relocations without associated symbols. Instead of
rejecting binaries with such relocations, we can re-create the symbol
the relocation is against based on the extracted value.

(cherry picked from FBD10054576)


  Commit: cc2276d3f1f8fc70ec134c20a6d8d9af4ffdc573
      https://github.com/llvm/llvm-project/commit/cc2276d3f1f8fc70ec134c20a6d8d9af4ffdc573
  Author: Igor Sugak <sugak at fb.com>
  Date:   2018-09-17 (Mon, 17 Sep 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [BOLT] fix build with gcc-4.8.5

Summary: These are two minor changes to make it copatible with gcc-4.8.5

(cherry picked from FBD9884971)


  Commit: c3c80822a356b5b126161a35b0a93e174fb9e259
      https://github.com/llvm/llvm-project/commit/c3c80822a356b5b126161a35b0a93e174fb9e259
  Author: Igor Sugak <sugak at fb.com>
  Date:   2018-10-01 (Mon, 01 Oct 2018)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h

  Log Message:
  -----------
  [BOLT] Capitalize i

Summary: as titled

(cherry picked from FBD10136655)


  Commit: b166ccbea800df610668b2562a5867211cac577e
      https://github.com/llvm/llvm-project/commit/b166ccbea800df610668b2562a5867211cac577e
  Author: Facebook Github Bot <facebook-github-bot at users.noreply.github.com>
  Date:   2018-10-04 (Thu, 04 Oct 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/Passes/RegAnalysis.cpp

  Log Message:
  -----------
  [BOLT][PR] Fix compiler warnings in BinaryContext and RegAnalysis

Summary:
This pull request fixes two compiler warnings:

- missing `break;` in a switch-case statement in RegAnalysis.cpp (-Wimplicit-fallthrough warning)
- misleading indentation in BinaryContext.cpp (-Wmisleading-indentation warning)
Pull Request resolved: https://github.com/facebookincubator/BOLT/pull/39
GitHub Author: Andreas Ziegler <andreas.ziegler at fau.de>

(cherry picked from FBD10202092)


  Commit: 74a71c681216b32e7532e881e330b5a39e049257
      https://github.com/llvm/llvm-project/commit/74a71c681216b32e7532e881e330b5a39e049257
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2018-10-11 (Thu, 11 Oct 2018)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Fix bug in analyzeRelocation for GOT entries

Summary:
Special case GOT relocs to ignore addend subtracting
logic in analyzeRelocation, since the addend does not refer to the
target of the instruction being analyzed. Also make the code honor
the comments in the special case about zeroed out ExtractValue but
non-zero addend.
Fix facebookincubator/BOLT#40

(cherry picked from FBD10355019)


  Commit: a76b13d48e4103e43fc0f5b2ed47559a37162d4a
      https://github.com/llvm/llvm-project/commit/a76b13d48e4103e43fc0f5b2ed47559a37162d4a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-10-02 (Tue, 02 Oct 2018)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/ProfileWriter.cpp
    M bolt/src/ProfileYAMLMapping.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [perf2bolt] Pre-aggregate LBR samples

Summary: Pre-aggregating LBR data cuts pef2bolt processing times in half.

(cherry picked from FBD10420286)


  Commit: 30fd960951b8146d93f34fe4467227c4e455a097
      https://github.com/llvm/llvm-project/commit/30fd960951b8146d93f34fe4467227c4e455a097
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-10-22 (Mon, 22 Oct 2018)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Update local symbol count in symbol table

Summary:
Fix sh_info entry for symbol table section to reflect updated number of
local symbols.

(cherry picked from FBD10503216)


  Commit: 40d9fcfdcadbe082bda825d3b0a19ac101aefef5
      https://github.com/llvm/llvm-project/commit/40d9fcfdcadbe082bda825d3b0a19ac101aefef5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-11-12 (Mon, 12 Nov 2018)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Workaround for Clang de-virtualization bug

Summary:
When Clang is boot-strapped with (Thin)LTO, it may produce a code
fragment similar to below:

  .LFT663334 (6 instructions, align : 1)
    Predecessors: .LFT663333
      00000538:   movb    $0x1, %al
      0000053a:   movl    %eax, -0x2c(%rbp)
      0000053d:   movl    $"_ZN5clang6Parser12ConsumeParenEv/1", %ecx
      00000542:   testb   $0x1, %cl
      00000545:   movq    -0x40(%rbp), %r14
      00000549:   je      .Ltmp1071462
    Successors: .Ltmp1071462, .LFT663335

  .LFT663335 (2 instructions, align : 1)
    Predecessors: .LFT663334
      0000054b:   movq    (%r12), %rax
      0000054f:   movq    .Ltmp0(%rax), %rcx
    Successors: .Ltmp1071462

  .Ltmp1071462 (7 instructions, align : 1)
    Predecessors: .LFT663334, .LFT663335
      00000556:   movq    %r12, %rdi
      00000559:   callq   *%rcx
      .......

The code above is making a call by dereferencing a pointer to a member
function. A pointer to a member function could either be a regular
function, or a virtual function. To differentiate between the two, AMD64
ABI (originated from Itanium ABI) uses the last bit of the pointer. The
call instruction sequence varies depending if the function is virtual or
not, and the pointer's last bit is checked. If it's "1" then the value
of the pointer (minus 1) is used as an offset in the object vtable to
get the address of the function, otherwise the pointer is used directly
as a function address.

In this specific case, a de-virtualization is taking place, but it's not
complete. Compiler knows that the member function pointer is actually a
non-virtual function _ZN5clang6Parser12ConsumeParenEv (aka
"clang::Parser::ConsumeParen()"). However, it keeps the (dead) code that
checks the last bit of _ZN5clang6Parser12ConsumeParenEv, and furthermore
keeps the code (unreachable/dead) to make a virtual call while using
(_ZN5clang6Parser12ConsumeParenEv - 1) as an offset into the vtable.
This is obviously wrong, but since the code is unreachable, it will
never affect the runtime correctness.

The value "_ZN5clang6Parser12ConsumeParenEv - 1" falls into a last byte
of a function preceding _ZN5clang6Parser12ConsumeParenEv, and BOLT
creates a label ".Ltmp0" pointing to this last byte that is referenced
in by the instruction sequence above. It just happens that the last byte
is also in the middle of the last instruction, and as a result, BOLT
never emits the label, hence resulting in the error message "Undefined
temporary symbol".

The workaround is to detect non-pc-relative relocations from code
pointing to some (fptr - 1). Note that this is not completely
error-prone, but non-pc-relative references from code into a middle of
a function are quite rare, and chances that in a normal situation they
will point to a byte preceding some function address are virtually zero.

(cherry picked from FBD13030310)


  Commit: e1b8fade7fa6687750114e5cf09dd8d2126a6170
      https://github.com/llvm/llvm-project/commit/e1b8fade7fa6687750114e5cf09dd8d2126a6170
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-11-14 (Wed, 14 Nov 2018)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Add branch priority policy for blocks with 2 successors

Summary:
On x86 the difference between long and short jump instructions could be
either 4 or 3 bytes, depending if it's a conditional jump or not.
For a basic block with 2 jump instructions, if we know that one of
the successors is in a different code region, then we can make it
a target of an unconditional jump instruction. This will save 1 byte
in case the conditional jump happens to be a short one.

(cherry picked from FBD13078139)


  Commit: b0f7fddd3505d5c389d4a637a6e33b7594db6842
      https://github.com/llvm/llvm-project/commit/b0f7fddd3505d5c389d4a637a6e33b7594db6842
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-11-15 (Thu, 15 Nov 2018)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Add method for better function size estimation

Summary:
Add BinaryContext::calculateEmittedSize() that ephemerally emits code
to allow precise estimation of the function size. Relaxation and
macro-op alignment adjustments are taken into account.

(cherry picked from FBD13092139)


  Commit: 067a3850006eb9598a31874df54442d1fd74deac
      https://github.com/llvm/llvm-project/commit/067a3850006eb9598a31874df54442d1fd74deac
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-11-15 (Thu, 15 Nov 2018)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Add thresholds for function splitting

Summary:
Use newly added function size estimation to measure the effectiveness
and guide function splitting. Two new tuning options are added:

  -split-threshold=<uint>
    split function only if its main size is reduced by more than given
    amount of bytes. Default value: 0, i.e. split iff the size is reduced.
    Note that on some architectures the size can increase after splitting.
  -split-align-threshold=<uint>
    when deciding to split a function, apply this alignment while doing
    the size comparison (see -split-threshold). Default value: 2.

(cherry picked from FBD13136352)


  Commit: 2fe0c38d6b3d056dd1a835913129454a4b08ae84
      https://github.com/llvm/llvm-project/commit/2fe0c38d6b3d056dd1a835913129454a4b08ae84
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2018-11-21 (Wed, 21 Nov 2018)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h

  Log Message:
  -----------
  [perf2bolt] Better tracking of process forking

Summary:
Improve tracking of forked processes.

If a process corresponding to the input binary has forked/started
before 'perf record' was initiated, then the full name of the binary
will be recorded in a corresponding MMAP2 event. We've being handling
such cases well so far.

However, if the process was forked after 'perf record' has started, and
execve(2) wasn't called afterwards, then there will be no MMAP2 event
recorded corresponding to the mapping of the main binary (unrelated
MMAP2 events could still be recorded).

To track such cases, we need to parse 'perf script --show-task-events'
command output, and to scan for PERF_RECORD_FORK events, and then add
forked process PIDs to the list associated with the input binary. If
the fork event was followed by an exec event (PERF_RECORD_COMM exec)
of a different binary, then the forked PID should be ignored. If the
exec event was associated with our input binary, then the correct MMAP2
event was recorded and parsed.

To track if the event occurred before or after 'perf record', we parse
event's time. This helps us to differentiate some events. E.g. the exec
event is only registered correctly if it happened after perf recording
has started (otherwise the "exec" part is missing), and thus we only
record forks with non-zero time stamps.

(cherry picked from FBD13250904)


  Commit: c6ce2abb7d71d6ea8703552349d906c9897692b6
      https://github.com/llvm/llvm-project/commit/c6ce2abb7d71d6ea8703552349d906c9897692b6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-01-15 (Tue, 15 Jan 2019)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/Passes/IndirectCallPromotion.h
    M bolt/src/Passes/JTFootprintReduction.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [perf2bolt] Optimize memory usage in perf2bolt

Summary:
While converting perf profile, we only need CFG for functions that were
profiled and can skip building CFG for the rest. This saves us some
processing time and memory.

Breakdown processing of perf.data into two steps. The first
step parses the data, saves it in intermediate format, and marks
functions with the profile. The second step attributes the profile to
functions with CFG. When we disassemble and build CFG for functions in
aggregate-only mode, we skip functions without the profile.

(cherry picked from FBD13706697)


  Commit: af81c7ff803a9f5c47e112cd13eb73feee0e51e6
      https://github.com/llvm/llvm-project/commit/af81c7ff803a9f5c47e112cd13eb73feee0e51e6
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-01-22 (Tue, 22 Jan 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h

  Log Message:
  -----------
  [perf2bolt] Add support for generating autofdo input

Summary:
Autofdo tools support.

(cherry picked from FBD13779026)


  Commit: 365bd1f1c8f4be1c4798709e507c99ae74e07edd
      https://github.com/llvm/llvm-project/commit/365bd1f1c8f4be1c4798709e507c99ae74e07edd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-01-28 (Mon, 28 Jan 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] For non-simple functions always update jump tables in-place

Summary:
For non-simple function we can miss a reference to a jump table or
to an indirect goto table. If we move the jump table, the missed
reference will not get updated, and the corresponding indirect jump
will end up in the old (wrong) location. Updating the original jump
table in-place should take care of the issue.

(cherry picked from FBD13849776)


  Commit: ff6e21290f01bfe7a688102fc8fa92ce07f39947
      https://github.com/llvm/llvm-project/commit/ff6e21290f01bfe7a688102fc8fa92ce07f39947
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-01-31 (Thu, 31 Jan 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/AllocCombiner.cpp
    M bolt/src/Passes/BinaryFunctionCallGraph.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/Inliner.h
    M bolt/src/Passes/JTFootprintReduction.cpp
    M bolt/src/Passes/JTFootprintReduction.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] New inliner implementation

Summary:
Addresses correctness issues related to inlining.
Inlining heuristics are not part of this diff.

(cherry picked from FBD13796888)


  Commit: 0c704eb75a13cdde738c051e6bef5ad1fb724817
      https://github.com/llvm/llvm-project/commit/0c704eb75a13cdde738c051e6bef5ad1fb724817
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-02-05 (Tue, 05 Feb 2019)

  Changed paths:
    M bolt/src/CMakeLists.txt
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/Exceptions.cpp
    M bolt/src/Exceptions.h
    A bolt/src/Heatmap.cpp
    A bolt/src/Heatmap.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLT-HEATMAP] Initial heat map implementation

Summary:
Add heatmap subcommand to produce heatmaps based on perf.data with LBR.
The output is produced in colored ASCII format.

  llvm-bolt heatmap -p perf.data <executable>

    -block-size=<uint> - size of a heat map block in bytes (default 64)
    -line-size=<uint>  - number of entries per line (default 256)
    -max-address=<uint> - maximum address considered valid for heatmap
                          (default 4GB)
    -o=<string>        - heatmap output file (default stdout)

(cherry picked from FBD13969992)


  Commit: c593563d1f963066def0c50fc45b8406ea03a684
      https://github.com/llvm/llvm-project/commit/c593563d1f963066def0c50fc45b8406ea03a684
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-03-12 (Tue, 12 Mar 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  Do not assert on addresses read from processIndirectBranch

Summary: As part of our heuristics to decode an indirect branch, if we
suspect the branch is an indirect tail call, we add its probable target
to the BC::InterproceduralReferences vector to detect functions with
more than one entry point. However, if this probable target is not in an
allocatable section, we were asserting. Remove this assertion and
change the code to conditionally store to InterproceduralReferences
instead. The probable target could be garbage at this point because
of analyzeIndirectBranch failing to identify the load instruction that
has the memory address of the target, so we should tolerate this.

(cherry picked from FBD14432821)


  Commit: a9e64947c5d7813077075bd460439f3b160926fe
      https://github.com/llvm/llvm-project/commit/a9e64947c5d7813077075bd460439f3b160926fe
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-14 (Thu, 14 Mar 2019)

  Changed paths:
    M bolt/src/CMakeLists.txt
    A bolt/src/ExecutableFileMemoryManager.cpp
    A bolt/src/ExecutableFileMemoryManager.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [NFC][BOLT] Move ExecutableFileMemoryManager into its own file

(cherry picked from FBD14474800)


  Commit: 163adbec9fa49542a9b55dc68f1e5923a868383b
      https://github.com/llvm/llvm-project/commit/163adbec9fa49542a9b55dc68f1e5923a868383b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-14 (Thu, 14 Mar 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/Exceptions.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactor allocatable sections rewrite part

Summary:
This refactoring makes it easier to create new code sections and control
code placement. As an example, cold code is being placed into
".text.cold" which is emitted independently from ".text", and the final
address assignment becomes more flexible.

Previously, in non-relocation mode we used to emit temporary section
name into .shstrtab. This resulted in unnecessary bloat of this section.

There was unnecessary padding emitted at the end of text section. After
fixing this, the output binary becomes smaller.

I had to change the way exception handling tables are re-written
as the current infra does not support cross-section label difference.
This means we have to emit absolute landing pad addresses, which might
not work for PIE binaries. I'm going to address this once I investigate
the current exception handling issues in PIEs.

This diff temporarily disables "-hot-functions-at-end" option.

(cherry picked from FBD14475693)


  Commit: 0a55001a0e2ca9d6656005ed87878e39b3303be2
      https://github.com/llvm/llvm-project/commit/0a55001a0e2ca9d6656005ed87878e39b3303be2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-14 (Thu, 14 Mar 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Fix -hot-functions-at-end option

Summary: Make "-hot-functions-at-end" option work again.

(cherry picked from FBD14476242)


  Commit: 61ea19edf83461b489063053cc4d37b1e37c5ca8
      https://github.com/llvm/llvm-project/commit/61ea19edf83461b489063053cc4d37b1e37c5ca8
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-15 (Fri, 15 Mar 2019)

  Changed paths:
    M bolt/src/Passes/ReorderFunctions.cpp
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/Passes/RetpolineInsertion.h

  Log Message:
  -----------
  [BOLT][NFC] Fix compilation warnings

Summary: Get rid of warnings while building with Clang.

(cherry picked from FBD14495620)


  Commit: 17cd2034f3db3c08f8247940d874b0b6ee75cf96
      https://github.com/llvm/llvm-project/commit/17cd2034f3db3c08f8247940d874b0b6ee75cf96
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-18 (Mon, 18 Mar 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Fix debug line info emission

Summary:
GDB does not like if the first entry in the line info table after
end_sequence entry is not marked with is_stmt. If this happens, it will
not print the correct line number information for such address. Note
that everything works fine starting with the first address marked
with is_stmt.

This could happen if the first instruction in the cold section wasn't
marked with is_stmt.

The fix is to always emit debug line info for the first instruction
in any function fragment with is_stmt flag.

(cherry picked from FBD14516629)


  Commit: 6bcb3389dd7d61f8655b6556d8d9ed47e8c79198
      https://github.com/llvm/llvm-project/commit/6bcb3389dd7d61f8655b6556d8d9ed47e8c79198
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-15 (Fri, 15 Mar 2019)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Place hot text mover functions into a separate section

Summary:
Create a separate pass for assigning functions to sections. Detect
functions originating from special sections (by default .stub and
.mover) and place them into ".text.mover" if "-hot-text" options is
specified.

Cold functions are isolated from hot functions even when no function
re-ordering is specified.

(cherry picked from FBD14512628)


  Commit: b8d3dc40ea069c070e7d534341e159eb7ae13681
      https://github.com/llvm/llvm-project/commit/b8d3dc40ea069c070e7d534341e159eb7ae13681
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-19 (Tue, 19 Mar 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Use local binding for cold fragment symbols

Summary:
We used to use existing symbol binding while duplicating and renaming
cold fragment symbols. As a result, some of those were emitted with
global binding. This confuses gdb, and it starts treating those symbols
as additional entry points.

The fix is to always emit such symbols with a local binding. This also
means that we have to sort static symbol table before emission to make
sure local symbols precede all others.

(cherry picked from FBD14529265)


  Commit: 69faf6137243af4f60bdfd6057844bf1fff5e415
      https://github.com/llvm/llvm-project/commit/69faf6137243af4f60bdfd6057844bf1fff5e415
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-20 (Wed, 20 Mar 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Fix section lookup while deleting symbols

Summary:
While removing redundant local symbols, we used new section index to
lookup the corresponding section in the old section table. As a result,
we used to either not remove the correct symbols, or remove the wrong
ones.

(cherry picked from FBD14552047)


  Commit: d1b76f2ac2fe793b7a6566dfe0077044c0f0445f
      https://github.com/llvm/llvm-project/commit/d1b76f2ac2fe793b7a6566dfe0077044c0f0445f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-21 (Thu, 21 Mar 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Allocate enough space past __hot_end for huge pages

Summary:
While using "-hot-text" option, we might not get enough cold text to
fill up the last huge page, and we can get data allocated on this page
producing undesirable effects. To prevent this from happening, always
make sure to allocate enough space past __hot_end.

(cherry picked from FBD14575100)


  Commit: 297d1a4e1a7516d7fd7d0ae4fa0cd284ccf8193a
      https://github.com/llvm/llvm-project/commit/297d1a4e1a7516d7fd7d0ae4fa0cd284ccf8193a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-27 (Wed, 27 Mar 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Do not write jump table section headers

Summary:
In non-relocation mode we were accidentally emitting section headers for
every single jump table. This happened with default
`-jump-tables=basic`.

(cherry picked from FBD14653282)


  Commit: 8894853f42b8d869fa3746e0f96460f9470697e9
      https://github.com/llvm/llvm-project/commit/8894853f42b8d869fa3746e0f96460f9470697e9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-03-29 (Fri, 29 Mar 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][DWARF] Dedup .debug_abbrev section patches

Summary:
When we patch .debug_abbrev we issue many duplicate patches. Instead of
storing these patches as a vector, use a hash map. This saves some
processing time and memory.

(cherry picked from FBD14691292)


  Commit: 7fd487066f6f0fa28c012182af513fcf415f6bb5
      https://github.com/llvm/llvm-project/commit/7fd487066f6f0fa28c012182af513fcf415f6bb5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-03 (Wed, 03 Apr 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/BinaryPassManager.h
    M bolt/src/BoltDiff.cpp
    M bolt/src/DWARFRewriter.cpp
    A bolt/src/DWARFRewriter.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DebugData.h
    M bolt/src/Passes/Aligner.cpp
    M bolt/src/Passes/Aligner.h
    M bolt/src/Passes/AllocCombiner.cpp
    M bolt/src/Passes/AllocCombiner.h
    M bolt/src/Passes/BinaryFunctionCallGraph.cpp
    M bolt/src/Passes/BinaryFunctionCallGraph.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/FrameAnalysis.h
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/FrameOptimizer.h
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/IdenticalCodeFolding.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/IndirectCallPromotion.h
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/Inliner.h
    M bolt/src/Passes/JTFootprintReduction.cpp
    M bolt/src/Passes/JTFootprintReduction.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/LongJmp.h
    M bolt/src/Passes/PLTCall.cpp
    M bolt/src/Passes/PLTCall.h
    M bolt/src/Passes/RegAnalysis.h
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/Passes/RegReAssign.h
    M bolt/src/Passes/ReorderData.cpp
    M bolt/src/Passes/ReorderData.h
    M bolt/src/Passes/ReorderFunctions.cpp
    M bolt/src/Passes/ReorderFunctions.h
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/Passes/RetpolineInsertion.h
    M bolt/src/Passes/StokeInfo.cpp
    M bolt/src/Passes/StokeInfo.h
    M bolt/src/Passes/ValidateInternalCalls.cpp
    M bolt/src/Passes/ValidateInternalCalls.h
    M bolt/src/Passes/VeneerElimination.cpp
    M bolt/src/Passes/VeneerElimination.h
    M bolt/src/ProfileWriter.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Move BinaryFunctions into a BinaryContext and more

Summary:
A long due refactoring that makes interfaces cleaner and less awkward.
Mainly makes the future work way easier.

(cherry picked from FBD14766284)


  Commit: c8a927696cf4e39a813be4c42fe5b48bfbddcc76
      https://github.com/llvm/llvm-project/commit/c8a927696cf4e39a813be4c42fe5b48bfbddcc76
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-03 (Wed, 03 Apr 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Detect internal references into a middle of instruction

Summary:
Some instructions in assembly-written functions could reference 8-byte
constants from another instructions using 4-byte offsets, presumably to
save a couple of bytes.

Detect such cases, and skip processing such functions until we teach
BOLT how to handle references into a middle of instruction.

(cherry picked from FBD14768212)


  Commit: 624a0e810d843818c9c45a74fcdf98c8ffa69ea9
      https://github.com/llvm/llvm-project/commit/624a0e810d843818c9c45a74fcdf98c8ffa69ea9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-01 (Mon, 01 Apr 2019)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [DWARF][BOLT] Convert DW_AT_(low|high)_pc to DW_AT_ranges only if necessary

Summary:
While updating DWARF, we used to convert address ranges for functions
into DW_AT_ranges format, even if the ranges were not split and still
had a simple [low, high) form. We had to do this because functions with
contiguous ranges could be sharing an abbrev with non-contiguous range
function, and we had to convert the abbrev.

It turns out, that the excessive usage of DW_AT_ranges may lead to
internal core dumps in gdb in the presence of .gdb_index.
I still don't know the root cause of it, but reducing the number
DW_AT_ranges used by DW_TAG_subprogram DIEs does alleviate the
issue.

We can keep a simple range for DIEs that are guaranteed not to
share an abbrev with any non-contiguous function. Hence we have to
postpone the update of function ranges until we've seen all DIEs.
Note that DIEs from different compilation units could share the same
abbrev, and hence we have to process DIEs from all compilation units.

(cherry picked from FBD14814043)


  Commit: 90996eb54b907d2b431d9e83bcb2401069cd3a49
      https://github.com/llvm/llvm-project/commit/90996eb54b907d2b431d9e83bcb2401069cd3a49
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-04-05 (Fri, 05 Apr 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h

  Log Message:
  -----------
  [PERF2BOLT] Print a better message if perf.data lacks LBR

Summary:
If processing the perf.data in LBR mode but the data was
collected without -j, currently we confusingly report all samples
to mismatch the input binary, even though the samples match but
lack LBR info. Change perf2bolt to detect this scenario and print
a helpful message instructing the user to collect data with LBR.

(cherry picked from FBD14817732)


  Commit: 7d89b113d86ac0517734f6e438ab3037a6c07d18
      https://github.com/llvm/llvm-project/commit/7d89b113d86ac0517734f6e438ab3037a6c07d18
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-09 (Tue, 09 Apr 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT][NFC] Indentation fix

(cherry picked from FBD14856700)


  Commit: a8e05d067d4ecc7e1ed434f8f05b4a3c49e4440a
      https://github.com/llvm/llvm-project/commit/a8e05d067d4ecc7e1ed434f8f05b4a3c49e4440a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-09 (Tue, 09 Apr 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/Exceptions.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Add interface to extract values from static addresses

(cherry picked from FBD14858028)


  Commit: 88375d311e0c7fb4393e06213ac969511881dabd
      https://github.com/llvm/llvm-project/commit/88375d311e0c7fb4393e06213ac969511881dabd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-09 (Tue, 09 Apr 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Sort basic block successors for printing

Summary:
For easier analysis of the hottest targets of jump tables it helps to
have basic block successors sorted based on the taken frequency.

(cherry picked from FBD14856640)


  Commit: 315ae74de39a5b9ead5b13aa61860945f6ca1e72
      https://github.com/llvm/llvm-project/commit/315ae74de39a5b9ead5b13aa61860945f6ca1e72
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-09 (Tue, 09 Apr 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Include <numeric> for std::iota

Summary: Some compilers require <numeric> header.

(cherry picked from FBD14868132)


  Commit: e50e89be9e596bdfa844f4f81aa3762b118a6feb
      https://github.com/llvm/llvm-project/commit/e50e89be9e596bdfa844f4f81aa3762b118a6feb
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-11 (Thu, 11 Apr 2019)

  Changed paths:
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Handle R_X86_64_converted_reloc_bit

Summary:
In binutils 2.30 a bfd linker accidentally started modifying some
relocations on output under `-q/--emit-relocs` by turning on
R_X86_64_converted_reloc_bit. As a result, BOLT ignored such
relocations and failed to correctly update the binary.

This diff filters out R_X86_64_converted_reloc_bit from the relocation
type.

(cherry picked from FBD14907832)


  Commit: 8f982685183ae7679d718ddf24c78028b2395aa0
      https://github.com/llvm/llvm-project/commit/8f982685183ae7679d718ddf24c78028b2395aa0
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-15 (Mon, 15 Apr 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Reduce warnings for non-simple functions

Summary:
If a function was already marked as non-simple, there's no reason to
issue a warning that it has a reference in the middle of an
instruction. Besides, sometimes there wouldn't be instructions
disassembled at a given entry, and the warning would be incorrect.

(cherry picked from FBD14938227)


  Commit: 27dcec97171795fb2e15327cccba7fce0a426285
      https://github.com/llvm/llvm-project/commit/27dcec97171795fb2e15327cccba7fce0a426285
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-15 (Mon, 15 Apr 2019)

  Changed paths:
    M bolt/src/DataReader.cpp

  Log Message:
  -----------
  [BOLT] Abort processing if the profile has no valid data

Summary:
It's possible to pass a profile in invalid format to BOLT, and we
silently ignore it. This could cause a regression as such scenario can
go undetected. We should abort processing if no valid data was seen in
the profile and issue a warning if it was partially invalid.

(cherry picked from FBD14941211)


  Commit: 22ba3dc8166f0eea150d03bf7eb18b813cfac4e6
      https://github.com/llvm/llvm-project/commit/22ba3dc8166f0eea150d03bf7eb18b813cfac4e6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-16 (Tue, 16 Apr 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add another section to the list of hot text movers

Summary:

(cherry picked from FBD14954472)


  Commit: 31fc56b313cb4281a10e7cb55979c9c611732b44
      https://github.com/llvm/llvm-project/commit/31fc56b313cb4281a10e7cb55979c9c611732b44
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-04-16 (Tue, 16 Apr 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix adjustFunctionBoundaries w.r.t. entry points

Summary:
Don't consider symbols in another section when processing
additional entry points for a function.

(cherry picked from FBD14962853)


  Commit: ffae5e73f3fbbd43570ae32ceae63b07e838fcb8
      https://github.com/llvm/llvm-project/commit/ffae5e73f3fbbd43570ae32ceae63b07e838fcb8
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-15 (Mon, 15 Apr 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [BOLT] Fix an issue with std:errc

Summary:
On some platforms
`llvm::make_error_code(std::errc::no_such_process) == std::errc::no_such_process`
evaluates to false.

(cherry picked from FBD14944405)


  Commit: 99ef4c90c160be962c9d2e60a4429f8f169f86e3
      https://github.com/llvm/llvm-project/commit/99ef4c90c160be962c9d2e60a4429f8f169f86e3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-16 (Tue, 16 Apr 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Basic support for split functions

Summary:
This adds very basic and limited support for split functions.
In non-relocation mode, split functions are ignored, while their debug
info is properly updated. No support in the relocation mode yet.

Split functions consist of a main body and one or more fragments.
For fragments, the main part is called their parent. Any fragment
could only be entered via its parent or another fragment.

The short-term goal is to correctly update debug information for split
functions, while the long-term goal is to have a complete support
including full optimization. Note that if we don't detect split
bodies, we would have to add multiple entry points via tail calls,
which we would rather avoid.

Parent functions and fragments are represented by a `BinaryFunction`
and are marked accordingly. For now they are marked as non-simple, and
thus only supported in non-relocation mode. Once we start building a
CFG, it should be a common graph (i.e. the one that includes all
fragments) in the parent function.

The function discovery is unchanged, except for the detection of
`\.cold\.` pattern in the function name, which automatically marks the
function as a fragment of another function.

Because of the local function name ambiguity, we cannot rely on the
function name to establish child fragment and parent relationship.
Instead we rely on disassembly processing.

`BinaryContext::getBinaryFunctionContainingAddress()` now returns a
parent function if an address from its fragment is passed.

There's no jump table support at the moment. Jump tables can have
source and destinations in both fragment and parent.

Parent functions that enter their fragments via C++ exception handling
mechanism are not yet supported.

(cherry picked from FBD14970569)


  Commit: 433f3e3e02afd7e1120ea30418927d8b41e345f8
      https://github.com/llvm/llvm-project/commit/433f3e3e02afd7e1120ea30418927d8b41e345f8
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-17 (Wed, 17 Apr 2019)

  Changed paths:
    M bolt/src/Exceptions.cpp

  Log Message:
  -----------
  [BOLT] Process CFIs for functions with FDE size mismatch

Summary:
If a function size indicated in FDE is different from the one in the
symbol table, we can keep processing the function as we are using the
max size for internal purposes. Typically this happens for
assembly-written functions with padding at the end. This padding is not
included in FDE, but it is in the symbol table.

(cherry picked from FBD14987653)


  Commit: 3b422eafd027e2b665ad4fa5b2343437bc9a6f9d
      https://github.com/llvm/llvm-project/commit/3b422eafd027e2b665ad4fa5b2343437bc9a6f9d
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-04-17 (Wed, 17 Apr 2019)

  Changed paths:
    M bolt/src/Passes/DominatorAnalysis.h
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Passes/ShrinkWrapping.h

  Log Message:
  -----------
  [BOLT] Fix non-determinism in shrink wrapping

Summary:
Iterating over SmallPtrSet is non-deterministic. Change it to
SmallSetVector. Similarly, do not sort a vector of ProgramPoint when
computing the dominance frontier, as ProgramPoint uses the pointer value
to determine order. Use a SmallSetVector there too to avoid duplicates
instead of sorting + uniqueing.

(cherry picked from FBD14992085)


  Commit: d9f1bd42fd06f14d0532e7974e2d33bae8140e2f
      https://github.com/llvm/llvm-project/commit/d9f1bd42fd06f14d0532e7974e2d33bae8140e2f
  Author: Brian Gesiak <modocache at gmail.com>
  Date:   2019-04-22 (Mon, 22 Apr 2019)

  Changed paths:
    M bolt/src/Target/CMakeLists.txt

  Log Message:
  -----------
  [cmake] Only build enabled targets

Summary:
When attempting to build llvm-bolt with `-DLLVM_ENABLE_TARGETS="X86"`, I
encountered an error:

```
CMake Error at cmake/modules/AddLLVM.cmake:559 (add_dependencies):
  The dependency target "AArch64CommonTableGen" of target
  "LLVMBOLTTargetAArch64" does not exist.
Call Stack (most recent call first):
  cmake/modules/AddLLVM.cmake:607 (llvm_add_library)
  tools/llvm-bolt/src/Target/AArch64/CMakeLists.txt:1 (add_llvm_library)
```

The issue is that the `llvm-bolt/src/Target/AArch64` subdirectory is
added by CMake unconditionally. The LLVM project, on the other hand,
only adds the subdirectories that are enabled, by using a `foreach` loop
over `LLVM_TARGETS_TO_BUILD`. Copying that same loop, from
`llvm/lib/Target/CMakeLists.txt`, to this project avoids the error.

(cherry picked from FBD15030236)


  Commit: eba1a67730f856b06e75a2603eca035049c1caa4
      https://github.com/llvm/llvm-project/commit/eba1a67730f856b06e75a2603eca035049c1caa4
  Author: Brian Gesiak <modocache at gmail.com>
  Date:   2019-04-22 (Mon, 22 Apr 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/Passes/Aligner.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/CachePlusReorderAlgorithm.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/ProfileReader.cpp

  Log Message:
  -----------
  Fix casting issues on macOS

Summary:
`size_t` is platform-dependent, and on macOS it is defined as
`unsigned long long`. This is not the same type as is used in many calls
to templated functions that expect the same type. As a result, on macOS,
calls to `std::max` fail because a template function that takes
`uint64_t, unsigned long long` cannot be found.

To work around the issue:

* Specify explicit `std::max` and `std::min` functions where necessary,
  to work around the compiler trying (and failing) to find a suitable
  instantiation.
* For lambda return types, specify an explicit return type where necessary.
* For `operator ==()` calls, use an explicit cast where necessary.

(cherry picked from FBD15030283)


  Commit: 4e4d39c21cb612f20cc65572db71c5bcc2a32145
      https://github.com/llvm/llvm-project/commit/4e4d39c21cb612f20cc65572db71c5bcc2a32145
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-04-18 (Thu, 18 Apr 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Update symbols for secondary entry points

Summary:
Update the output ELF symbol table for symbols representing
secondary entry points for functions. Previously, those were left
unchanged in the symtab.

(cherry picked from FBD15010517)


  Commit: 91b2de3c23c14f1df9dd8db9404dd00f8a9bd64a
      https://github.com/llvm/llvm-project/commit/91b2de3c23c14f1df9dd8db9404dd00f8a9bd64a
  Author: Brian Gesiak <modocache at gmail.com>
  Date:   2019-04-24 (Wed, 24 Apr 2019)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  [BOLT] Minimize BOLT's diff with LLVM by removing trivial changes (NFC)

Summary: BOLT works as a series of patches rebased onto upstream LLVM at revision `f137ed238db`. Some of these patches introduce unnecessary whitespace changes or includes. Remove these to minimize the diff with upstream LLVM.

(cherry picked from FBD15064122)


  Commit: 492e4a515ea0d4bbf2c703ae9f8416797277059d
      https://github.com/llvm/llvm-project/commit/492e4a515ea0d4bbf2c703ae9f8416797277059d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-25 (Thu, 25 Apr 2019)

  Changed paths:
    M bolt/src/Passes/ReorderFunctions.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Automatically enable -hot-text

Summary:
Enable -hot-text by default if reordering functions.

Also fail immediately if function reordering is specified on the command
line in non-relocation mode.

(cherry picked from FBD15095178)


  Commit: 5717b0c427d3ae2c928c1d46beea496d71ceaa37
      https://github.com/llvm/llvm-project/commit/5717b0c427d3ae2c928c1d46beea496d71ceaa37
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-25 (Thu, 25 Apr 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [perf2bolt] Fix print report for pre-aggregated profile

Summary:
For pre-aggregated profile, we were using the number of records in the
profile for `NumTraces` ignoring the counts per record. As a result,
the reported percentage of mismatched traces was bogus.

(cherry picked from FBD15093123)


  Commit: caa0fafa18e4e6a468e9ee585e4d714c1f6cb0b3
      https://github.com/llvm/llvm-project/commit/caa0fafa18e4e6a468e9ee585e4d714c1f6cb0b3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-26 (Fri, 26 Apr 2019)

  Changed paths:
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix profile reading in non-reloc mode

Summary:
In non-relocation mode we may execute multiple re-write passes either
because we need to split large functions or update debug information for
large functions (in this context large functions are functions that do
not fit into the original function boundaries after optimizations).

When we execute another pass, we reset RewriteInstance and run most of
the steps such as disassembly and profile matching for the 2nd or 3rd
time. However, when we match a profile, we check `Used` flag, and don't
use the profile for the 2nd time. Since we didn't reset the flag while
resetting the rest of the states, we ignored profile for all functions.
Resetting the flag in-between rewrite passes solves the problem.

(cherry picked from FBD15110959)


  Commit: 21ee0e98c716423a837e7c131e317ef4cca6a88b
      https://github.com/llvm/llvm-project/commit/21ee0e98c716423a837e7c131e317ef4cca6a88b
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-04-26 (Fri, 26 Apr 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix symboltable update bug

Summary:
Commit "Update symbols for secondary entry points" introduced
a bug by using getBinaryFunctionContainingAddress() instead of
getBinaryFunctionAtAddress() regarding ICF'd functions. Only the latter
would fetch the correct BinaryFunction object for addresses of functions
that were ICF'd. As a result of this bug, the dynamic symbol table was
not updated for function symbols that were folded by ICF.

(cherry picked from FBD15112941)


  Commit: 2b1523362eb03ac407b995af24e7e2f46f076ba1
      https://github.com/llvm/llvm-project/commit/2b1523362eb03ac407b995af24e7e2f46f076ba1
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-26 (Fri, 26 Apr 2019)

  Changed paths:
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Strip debug sections by default

Summary:
We used to ignore debug sections by default, but we kept them in the
binary which led to invalid debug information in the output. It's better
to strip debug info and print a warning to the user.

Note: we are not updating debug info by default due to high memory
requirements for large applications.

(cherry picked from FBD15128947)


  Commit: f1dfd38dece6f1fd56a2c5d995bc3b41b7db6dc6
      https://github.com/llvm/llvm-project/commit/f1dfd38dece6f1fd56a2c5d995bc3b41b7db6dc6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-29 (Mon, 29 Apr 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/CMakeLists.txt
    A bolt/src/DynoStats.cpp
    A bolt/src/DynoStats.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h

  Log Message:
  -----------
  [BOLT][NFC] Move DynoStats out of BinaryFunction

Summary: Move DynoStats into separate source files.

(cherry picked from FBD15138883)


  Commit: 310b32fbe57852506e7b9fd9409c0b08f0ffc20c
      https://github.com/llvm/llvm-project/commit/310b32fbe57852506e7b9fd9409c0b08f0ffc20c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-30 (Tue, 30 Apr 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Limit jump table size by containing object

Summary:
While checking for a size of a jump table, we've used containing
section as a boundary. This worked for most cases as typically jump
tables are not marked with symbol table entries. However, the compiler
may generate objects for indirect goto's.

(cherry picked from FBD15158905)


  Commit: 4b55967d9e99ed9425218b6d8a8bab5c2fc51682
      https://github.com/llvm/llvm-project/commit/4b55967d9e99ed9425218b6d8a8bab5c2fc51682
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-04-30 (Tue, 30 Apr 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [perf2bot] Pass `-f` flag to perf

Summary:
perf tool requires the input data to be owned by the current user or
root, otherwise it rejects the input. Use `-f` option to override this
behavior.

(cherry picked from FBD15160678)


  Commit: fee61231ef2cbb1afdae6e3fb73570bace964275
      https://github.com/llvm/llvm-project/commit/fee61231ef2cbb1afdae6e3fb73570bace964275
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-05-02 (Thu, 02 May 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/JumpTable.cpp
    M bolt/src/JumpTable.h

  Log Message:
  -----------
  [BOLT] Move JumpTable management to BinaryContext

Summary:
Make BinaryContext responsible for creation and management of
JumpTables. This will be used for detection and resolution of jump table
conflicts across functions.

(cherry picked from FBD15196017)


  Commit: f1fde4415459573e59effe4b33854d46b8090556
      https://github.com/llvm/llvm-project/commit/f1fde4415459573e59effe4b33854d46b8090556
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-05-02 (Thu, 02 May 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/IndirectCallPromotion.h

  Log Message:
  -----------
  [BOLT] Improve ICP activation policy and hot jt processing

Summary:
Previously, ICP worked with a budget of N targets to convert to
direct calls. As long as the frequency of up to N of the hottest targets
surpassed a given fraction (threshold) of the total frequency, say, 90%,
then the optimization would convert a number of targets (up to N) to
direct calls. Otherwise, it would completely abort processing this call
site. The intent was to convert a given fraction of the indirect call
site frequency to use direct calls instead, but this ends up being a
"all or nothing" strategy.

In this patch we change this to operate with the same strategy seem in
LLVM's ICP, with two thresholds. The idea is that the hottest target of
an indirect call site will be compared against these two thresholds: one
checks its frequency relative to the total frequency of the original
indirect call site, and the other checks its frequency relative to the
remaining, unconverted targets (excluding the hottest targets that were
already converted to direct calls). The remaining threshold is typically
set higher than the total threshold. This allows us more control over
ICP.

I expose two pairs of knobs, one for jump tables and another for
indirect calls.

To improve the promotion of hot jump table indices when we have memory
profile, I also fix a bug that could cause us to promote extra indices
besides the hottest ones as seen in the memory profile. When we have the
memory profile, I reapply the dual threshold checks to the memory
profile which specifies exactly which indices are hot. I then update N,
the number of targets to be promoted, based on this new information, and
update frequency information.

To allow us to work with smaller profiles, I also created an option in
perf2bolt to filter out memory samples outside the statically allocated
area of the binary (heap/stack). This option is on by default.

(cherry picked from FBD15187832)


  Commit: 4755825447d4b6920afebf405d2c9fe2cb4ffa3f
      https://github.com/llvm/llvm-project/commit/4755825447d4b6920afebf405d2c9fe2cb4ffa3f
  Author: Laith Saed Sakka <lsakka at fb.com>
  Date:   2019-05-15 (Wed, 15 May 2019)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  Parse statically defined tracepoint markers from .note.stapsdt section

Summary:
    Parse statically defined tracepoints(SDT) markers from the ELF file, and store them.
    Add an option to print SDTs (-print-sdt).
    Add test case for parsing and printing SDTs.

(cherry picked from FBD15366712)


  Commit: ca659e4336badb4bc324d9d64e17355563a34c13
      https://github.com/llvm/llvm-project/commit/ca659e4336badb4bc324d9d64e17355563a34c13
  Author: Laith Saed Sakka <lsakka at fb.com>
  Date:   2019-05-16 (Thu, 16 May 2019)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Preserve nops that are SDT markers in binaries and disable SDT conflicting optimizations

Summary:
SDT markers that appears as nops in the assembly, are preserved and not eliminated.
Functions with SDT markers are also flagged. Inlining and folding are disabled for
functions that have SDT markers.

(cherry picked from FBD15379799)


  Commit: d047df12c5fc22feb025f055e4a7f745c96f5efa
      https://github.com/llvm/llvm-project/commit/d047df12c5fc22feb025f055e4a7f745c96f5efa
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-05-20 (Mon, 20 May 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Add an option to specialize memcpy() for 1 byte copy

Summary:
Add an option:

  -memcpy1-spec=func1,func2:cs1,func3:cs1:cs2,...

to specialize calls to memcpy() in listed functions (the name could be
supplied in regex) for size 1. The optimization will dynamically check
if the size argument equals to 1 and execute a one byte copy, otherwise
it will call memcpy() as usual. Specific call sites could be indicated
after ":" using their numeric count from the start of the function.

(cherry picked from FBD15428936)


  Commit: be344c8de7ca8529454fcf9c61b78ce1ce0f3307
      https://github.com/llvm/llvm-project/commit/be344c8de7ca8529454fcf9c61b78ce1ce0f3307
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-05-22 (Wed, 22 May 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Refactor handling of interproc refs

Summary:
Move handling of interprocedural references to BinaryContext.

Post-process indirect branches immediately after the CFG is built.

This is almost NFC. Since indirect branches are now post-processed
before the profile data is processed it interferes with the way the
profile data in YAML format is handled.

(cherry picked from FBD15456003)


  Commit: f57d3c00fcb32859c632057d6a4b4c3807165658
      https://github.com/llvm/llvm-project/commit/f57d3c00fcb32859c632057d6a4b4c3807165658
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-05-22 (Wed, 22 May 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Better verification of jump tables

Summary:
Run analyzeIndirectBranch() using basic block boundaries instead of
running ad-hoc validation of the jump table assumptions.

(cherry picked from FBD15465034)


  Commit: e5b1d9cd8c8a78b7db0063c5be7a051387d49421
      https://github.com/llvm/llvm-project/commit/e5b1d9cd8c8a78b7db0063c5be7a051387d49421
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-05-23 (Thu, 23 May 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryData.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinarySection.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/Inliner.h
    M bolt/src/Passes/ValidateInternalCalls.cpp

  Log Message:
  -----------
  [BOLT][NFC] Fix white space

(cherry picked from FBD15485688)


  Commit: c8038da36e2c2ebc95578d32d9a86e780114b2de
      https://github.com/llvm/llvm-project/commit/c8038da36e2c2ebc95578d32d9a86e780114b2de
  Author: Laith Sakka <laith.s.sakka at gmail.com>
  Date:   2019-05-22 (Wed, 22 May 2019)

  Changed paths:
    M bolt/src/Passes/FrameAnalysis.cpp

  Log Message:
  -----------
  Minor-fix: remove duplicate definition of SPT optimization timer
Summary:

(cherry picked from FBD28111560)


  Commit: 9ef9a7b1be107fc910e559b3aef3755a3b7221af
      https://github.com/llvm/llvm-project/commit/9ef9a7b1be107fc910e559b3aef3755a3b7221af
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-05-29 (Wed, 29 May 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Use regex matching for function names passed on command line

Summary:
Options such as `-print-only`, `-skip-funcs`, etc. now take regular
expressions. Internally, the option is converted to '^funcname$' form
prior to regex matching. This ensures that names without special
symbols will match exactly, i.e. "foo" will not match "foo123".

(cherry picked from FBD15551930)


  Commit: 3df2c9ea1f09de82f8455a429ce0c1adbad9304e
      https://github.com/llvm/llvm-project/commit/3df2c9ea1f09de82f8455a429ce0c1adbad9304e
  Author: Laith Sakka <laith.s.sakka at gmail.com>
  Date:   2019-05-17 (Fri, 17 May 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinarySection.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Update SDT locations after bolt reordering

Summary: Update SDT locations in .note section to match the new location after bolt reorder the code.

(cherry picked from FBD15427779)


  Commit: 21f4303bfd01dbe684dfbaf00e469298f2c465ce
      https://github.com/llvm/llvm-project/commit/21f4303bfd01dbe684dfbaf00e469298f2c465ce
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-04-12 (Fri, 12 Apr 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    A bolt/src/BoltAddressTranslation.cpp
    A bolt/src/BoltAddressTranslation.h
    M bolt/src/CMakeLists.txt
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/MCPlus.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/ProfileWriter.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  Support data collection in bolted binaries

Summary:
Similarly to how the compiler relies on DWARF to map samples, so
it is possible to collect profile data in binaries optimized by PGO
techniques and retrofit data to be used in a representation of the program
that was not optimized by PGO, this diff implements an option in BOLT to
encode a table in the output binary that allows us to map data collected
in optimized binaries back to the address space used in the input binary
(where the profile is useful, since we do not support running BOLT on a
binary already optimized by BOLT). The goal is to offer an option to
support BOLT in scenarios where it is not easy to run a special deployment of
the binary with a version that was not optimized by BOLT just for data
collection.

This feature is enabled with the -enable-bat flag. BAT stands for BOLT
Address Translation, which refers to the process of mapping output to
input addresses.

(cherry picked from FBD15531860)


  Commit: d3c1821f5fcb2a43e46a1e931756dce6502cda7e
      https://github.com/llvm/llvm-project/commit/d3c1821f5fcb2a43e46a1e931756dce6502cda7e
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-06-05 (Wed, 05 Jun 2019)

  Changed paths:
    M bolt/CMakeLists.txt
    M bolt/src/DataReader.cpp
    M bolt/src/ProfileWriter.cpp

  Log Message:
  -----------
  Compile Bolt using std 14.

Summary:
Compile Bolt using std 14.
We want that to be able to use some threading the locking tools that do not exists in std 11.

(cherry picked from FBD15671736)


  Commit: fac6a89c237f2d8ce70c37e78bce90a2e37dacbe
      https://github.com/llvm/llvm-project/commit/fac6a89c237f2d8ce70c37e78bce90a2e37dacbe
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-06-04 (Tue, 04 Jun 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Better handling of address references

Summary:
We used to handle PC-relative address references differently from direct
address references. As a result, some cases, such as escaped function
label address, were not handled when dealing with absolute (non-PIC)
code. This diff moves processing of an address reference into
BinaryContext::handleAddressRef() which is called for both PIC and
non-PIC code.

(cherry picked from FBD15643535)


  Commit: 9df5063c0e164374cbf668262d9e1e7f774b36f5
      https://github.com/llvm/llvm-project/commit/9df5063c0e164374cbf668262d9e1e7f774b36f5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-06-06 (Thu, 06 Jun 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [perf2bolt] Option to use event PC with LBR stack

Summary:
Add an option to get extra profile trace using the recorded event PC.
The trace goes from the latest LBR record destination to the event PC.

(cherry picked from FBD15711804)


  Commit: 66cf16208fa754a2754050de283f59e7d72063fc
      https://github.com/llvm/llvm-project/commit/66cf16208fa754a2754050de283f59e7d72063fc
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-06-06 (Thu, 06 Jun 2019)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/FrameAnalysis.h

  Log Message:
  -----------
  Use singleton instances for SPT (stack pointer tracking) in FrameAnalysis.

Summary:
During frame analysis, the functions do not change, and stack pointer tracking
does not need to be performed more than one time.

The current implementation performs the SPT analysis multiple times per
function during the frame analysis, we ca eliminate such computation redundancy.

On HHVM with -frame-opts=hot, this save around a minute which is 40% of the
frame optimization runtime. (129s to 76s).
fdata should be passed for a reasonable evaluation (we need the call graph).

However, this comes at a memory cost, around 2G to the peak when only -frame-opt=hot only is used but,
When all the usual flags are passed, the effect is to the peak is only 200K (measured from one test).

Update:
When jemalloc is used the base became way better and the following runtime are observed:

[jemalloc]
hhvm  85 -->  72.
clang  27 --> 23.

[malloc]
hhvm 129 -->  76.
clang  34   --> 27.

(cherry picked from FBD15707003)


  Commit: 9e2ad3f5939159dad4bc0da36c9c51a25fc0cd09
      https://github.com/llvm/llvm-project/commit/9e2ad3f5939159dad4bc0da36c9c51a25fc0cd09
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-06-12 (Wed, 12 Jun 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Delay populating jump tables

Summary:
During the initial disassembly pass, only identify jump tables
without populating the contents. Later, after all functions have been
disassembled, we have a better idea of jump table boundaries and can do
a better job of populating their entries.

As a result, we no longer have embedded jump tables (i.e. a jump table
that is parter of another jump table). If we ever need to keep
sequential jump tables inseparable during the output, we can always
add such functionality later.

Fixes facebookincubator/BOLT#56.

(cherry picked from FBD15800427)


  Commit: 9894de00940b02b23f600b22df78c6fcd38296f5
      https://github.com/llvm/llvm-project/commit/9894de00940b02b23f600b22df78c6fcd38296f5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-06-13 (Thu, 13 Jun 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Check instruction boundaries while populating jump tables

Summary:
Now that we populate jump tables after all functions are disassembled,
we can check for instruction boundaries corresponding to jump table
entries. No need to delegate this task to postProcessJumpTables().

(cherry picked from FBD15814762)


  Commit: 1ec091e6f56c4e738773503984ddee54c9f4d51c
      https://github.com/llvm/llvm-project/commit/1ec091e6f56c4e738773503984ddee54c9f4d51c
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-05-31 (Fri, 31 May 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  Parallelize ICF Pass

Summary:
ICF consumes 10-15% of bolt runtime, for HHVM that is around 45 seconds.
this diff perform some parallelization for the pass to make it faster.
A 60% reduction in the ICF runtime  is measured on the parallel version for HHVM.

(cherry picked from FBD15589515)


  Commit: bda13b7dd8c36f17b2b2bf1ff9c183755749bc62
      https://github.com/llvm/llvm-project/commit/bda13b7dd8c36f17b2b2bf1ff9c183755749bc62
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-06-10 (Mon, 10 Jun 2019)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h

  Log Message:
  -----------
  [BOLT] Add option to print profile bias stats

Summary:
Profile bias may happen depending on the hardware counter used
to trigger LBR sampling, on the hardware implementation and as an
intrinsic characteristic of relying on LBRs. Since we infer fall-through
execution and these non-taken branches take zero hardware resources to
be represented, LBR-based profile likely overrepresents paths with fall
throughs and underrepresents paths with many taken branches. This patch
adds an option to print statistics about profile bias so we can better
understand these biases.

The goal is to analyze differences in the sum of the frequency of all
incoming edges in a basic block versus the sum of all outgoing. In an
ideally sampled profile, these differences should be close to zero. With
this option, the user gets the mean of these differences in flow as a
percentage of the input flow. For example, if this number is 15%, it
means, on average, a block observed 15% more or less flow going out of
it in comparison with the flow going in. We also print the standard
deviation so we can have an idea of how spread apart are different
measurements of flow differences. If variance is low, it means the
average bias is happening across all blocks, which is compatible with
using LBRs. If the variance is high, it means some blocks in the profile
have a much higher bias than others, which is compatible with using a
biased event such as cycles to sample LBRs because it overrepresents
paths that end in an expensive instruction.

(cherry picked from FBD15790517)


  Commit: db02a1a142fbf23086aacf25340fa616600ddc4e
      https://github.com/llvm/llvm-project/commit/db02a1a142fbf23086aacf25340fa616600ddc4e
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-06-24 (Mon, 24 Jun 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Ignore empty funcs in relocation mode

Summary:
Make BOLT ignore empty functions (those containing no instructions,
despite having some space allocated to it filled with zeroes).

(cherry picked from FBD15981683)


  Commit: 0d23cbaa5268c0d3761beeeb9d04e4c539d6ec5b
      https://github.com/llvm/llvm-project/commit/0d23cbaa5268c0d3761beeeb9d04e4c539d6ec5b
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-06-19 (Wed, 19 Jun 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/CMakeLists.txt
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/IndirectCallPromotion.h
    A bolt/src/Passes/Instrumentation.cpp
    A bolt/src/Passes/Instrumentation.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Initial experimental instrumentation pass

Summary:
An instrumentation pass that modifies the input binary to
generate a profile after execution finishes. It modifies branches to
increment counters stored in the process memory and injects a new
function that dumps this data to an fdata file, readable by BOLT.

This instrumentation is experimental and currently uses a naive
approach where every branch is instrumented. This is not ideal for
runtime performance, but should be good enough for us to
evaluate/debug LBR profile quality against instrumentation.

Does not support instrumenting indirect calls yet, only direct
calls, direct branches and indirect local branches.

(cherry picked from FBD15998096)


  Commit: 459add2827d4dc98563f8368ec414dc8779e5ab5
      https://github.com/llvm/llvm-project/commit/459add2827d4dc98563f8368ec414dc8779e5ab5
  Author: Wenlei He <wenlei at fb.com>
  Date:   2019-06-26 (Wed, 26 Jun 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Force non-relocation mode for heatmap generation

Summary: BOLT operates in relocation mode by default when .reloc is in the binary. This changes disables relocation mode for heatmap generation so we can use that for more cases. There's a small separate change that ignores zero-sized symbol in zero-sized code section during function discovery.

(cherry picked from FBD16009610)


  Commit: 06e7a1e0595d4f5a2a2b467c11b6419231c1af5f
      https://github.com/llvm/llvm-project/commit/06e7a1e0595d4f5a2a2b467c11b6419231c1af5f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-06-27 (Thu, 27 Jun 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Ignore false function references

Summary:
A relocation can have an addend that makes it look as the relocated
value is in a different section from the symbol being relocated.
E.g., a relocation against a variable in .rodata could have a negative
offset that will make it look like it is against a symbol in .text
(a section that typically precedes .rodata).

Unless the relocation is against a section symbol, we know
exactly the symbol that is being relocated and there is no issue.
However, when the linker leaves only a section relocation (i.e. a
relocation against a section symbol when a temporary original symbol
gets deleted), we have to guess the relocated symbol, and can falsely
detect a function reference in the case described above.

The fix is to keep a section relocation if the corresponding
relocated value falls into a different section, and to detect and
ignore false function reference.

(cherry picked from FBD16030791)


  Commit: e89ad0db4baf9774eb3f35661207cbcde6be0251
      https://github.com/llvm/llvm-project/commit/e89ad0db4baf9774eb3f35661207cbcde6be0251
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-06-28 (Fri, 28 Jun 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/DynoStats.cpp
    M bolt/src/DynoStats.h
    M bolt/src/JumpTable.cpp
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/IdenticalCodeFolding.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Introduce strict relocation mode

Summary:
In strict relocation mode we rely on relocations to represent all
possible entry points into a function. Most of the code generated by
tested compilers (gcc and clang) will result in relocations against
any internal labels for jump tables and for computed goto tables.

In situations where we cannot properly reconstruct a jump table, or when
we cannot determine a table that guides an indirect jump, e.g. when
multiple computed goto tables are used, we conservatively assume that
the indirect jump can end up at any possible basic block referenced by
relocations.

In strict mode, simple functions may include the aforementioned
instructions with unknown control flow with a conservative list of
destinations added to the containing basic block. This allows us to
expand coverage of simple functions and to enable code reordering
optimizations for more functions.

The strict mode is recommended when BOLT is used with a well-formed
code generated by a compiler.

To use the strict mode, add "-strict" on the command line.

Another effect of this diff, is that with relocations, we will always
replace the immediate operand of an instruction with a symbol if the
relocation exists against this operand.

Also this diff fixes issues with Clang compiled with -fpic.

(cherry picked from FBD15872849)


  Commit: 078ece16911ce4430e48b108218259a31eb428ef
      https://github.com/llvm/llvm-project/commit/078ece16911ce4430e48b108218259a31eb428ef
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-06-28 (Fri, 28 Jun 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix out-of-bounds entry points

Summary:
Check that a symbol address is less than the next function
address before considering it for a secondary entry.

(cherry picked from FBD16056468)


  Commit: 4e90fc1e3b9b9f8f218d500ca48ee43669eef7ce
      https://github.com/llvm/llvm-project/commit/4e90fc1e3b9b9f8f218d500ca48ee43669eef7ce
  Author: Wenlei He <aktoon at gmail.com>
  Date:   2019-07-02 (Tue, 02 Jul 2019)

  Changed paths:
    M bolt/src/Passes/IndirectCallPromotion.cpp

  Log Message:
  -----------
  [BOLT] Prioritize Jump Table ICP target by frequency and indice count

Summary: We select the top hot targets for indirect call promotion. But since we only have frequency for targets, not for actual jump table indices, we have to merge indices that share the same actual target. In order to do that we sort targets by pointer of target symbol before merging, which introduces instability. Later we stable sort merged targets by frequency. Due to the instability of sorting pointers, and depending on how many indices each merged target has, we could end up with unstable ICP. This commit changes the 2nd pass sorting to prioritize targets with fewer indices, and higher mispredicts, in addition to higher frequency. It improves stability of ICP, and also exposes more ICP because targets with fewer indices has better chance of getting promoted.

(cherry picked from FBD16099701)


  Commit: 86b529bd543a73d57c82e90965915fe05a643997
      https://github.com/llvm/llvm-project/commit/86b529bd543a73d57c82e90965915fe05a643997
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-06-14 (Fri, 14 Jun 2019)

  Changed paths:
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/FrameAnalysis.h
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/StackPointerTracking.cpp
    M bolt/src/Passes/StackPointerTracking.h

  Log Message:
  -----------
  run SPT in parallel, and split annotation allocator

Summary:
This diff includes two main changes:
1) When creating an annotation, a dedicated annotation allocator can be used, instead of the default allocator. This allows some annotation to be deallocated  right after the end of their usage completely. Furthermore, having the ability to use dedicated allocators allows running SPT in parallel where each task uses a different allocator.

2) SPT is parallelized.

(cherry picked from FBD15913492)


  Commit: 00c252f6d80ac5af5a81011d92e2c095a75eeb9f
      https://github.com/llvm/llvm-project/commit/00c252f6d80ac5af5a81011d92e2c095a75eeb9f
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-06-19 (Wed, 19 Jun 2019)

  Changed paths:
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/FrameAnalysis.h

  Log Message:
  -----------
  Clean SPTMap in frame anaylsis in parallel

Summary:
This diff parallelize the STPClean() function reducing its runtime from 5 seconds to 0.4 on HHVM,
Making the runtime for the frame optimizer goes down to 33 seconds on HHVM.

(cherry picked from FBD15914371)


  Commit: f10d1fe0f3ef7ac92904441f4b683905ce006f96
      https://github.com/llvm/llvm-project/commit/f10d1fe0f3ef7ac92904441f4b683905ce006f96
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-02 (Tue, 02 Jul 2019)

  Changed paths:
    M bolt/src/Passes/FrameAnalysis.cpp

  Log Message:
  -----------
  Run cleanAnnotations within frame analysis in parallel

Summary: This diff parallelize the function FrameAnalysis::cleanAnnotations()

(cherry picked from FBD16096711)


  Commit: 3cfc76cdbfef54b821f8fb4507d95c51bc196986
      https://github.com/llvm/llvm-project/commit/3cfc76cdbfef54b821f8fb4507d95c51bc196986
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-03 (Wed, 03 Jul 2019)

  Changed paths:
    M bolt/src/CMakeLists.txt
    A bolt/src/ParallelUtilities.cpp
    A bolt/src/ParallelUtilities.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  Create a general interface to implement parallel tasks easily and apply it to run EliminateUnreachableBlocks in parallel.

Summary:
Each time we run some work in parallel over the list of functions in bolt, we manage a thread pool, task scheduling and perform some work to manage the granularity of the tasks based on the type of the work we do.

In this task, I am creating an interface where all those details are abstracted out, the user provides the function that will run on each  function, and some policy parameters that setup the scheduling and granularity configurations.

This will make it easier to implement parallel tasks, and eliminate redundant coding efforts.

(cherry picked from FBD16116077)


  Commit: 8880969ced9c36553e60811e5bf7413c08a448cf
      https://github.com/llvm/llvm-project/commit/8880969ced9c36553e60811e5bf7413c08a448cf
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-07-10 (Wed, 10 Jul 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Restrict creation of jump tables

Summary:
Heuristic that creates a jump table for every memory access,
including those we do not match against a pattern in an indirect jump,
is too permissive and has false positives. Guard this logic under
strict mode until we figure out a better strategy.

(cherry picked from FBD16192205)


  Commit: 1169f1fdd8434f0608010c920d40bbc6b0e88174
      https://github.com/llvm/llvm-project/commit/1169f1fdd8434f0608010c920d40bbc6b0e88174
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-07-02 (Tue, 02 Jul 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/JumpTable.cpp
    M bolt/src/JumpTable.h
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Support duplicating jump tables

Summary:
If two indirect branches use the same jump table, we need to
detect this and duplicate dump tables so we can modify this CFG
correctly. This is necessary for instrumentation and shrink wrapping.
For the latter, we only detect this and bail, fixing this old known
issue with shrink wrapping.

Other minor changes to support better instrumentation: add an option
to instrument only hot functions, add LOCK prefix to instrumentation
increment instruction, speed up splitting critical edges by avoiding
calling recomputeLandingPads() unnecessarily.

(cherry picked from FBD16101312)


  Commit: 9977b03fea5c9438feb63e1205e67375e796cbe5
      https://github.com/llvm/llvm-project/commit/9977b03fea5c9438feb63e1205e67375e796cbe5
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-08 (Mon, 08 Jul 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/ParallelUtilities.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/CachePlusReorderAlgorithm.cpp
    M bolt/src/Passes/ReorderAlgorithm.cpp
    M bolt/src/Passes/ReorderAlgorithm.h

  Log Message:
  -----------
  Run reorder blocks in parallel

Summary:
This diff change reorderBasicBlocks pass to run in parallel,
it does so by adding locks to the fix branches function,
and creating temporary MCCodeEmitters when estimating basic block code size.

(cherry picked from FBD16161149)


  Commit: 98539b0966e18e2b4640adcb204dc5e8d945bfa9
      https://github.com/llvm/llvm-project/commit/98539b0966e18e2b4640adcb204dc5e8d945bfa9
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-09 (Tue, 09 Jul 2019)

  Changed paths:
    M bolt/src/Passes/Aligner.cpp
    M bolt/src/Passes/Aligner.h

  Log Message:
  -----------
  run aligner pass in parallel

Summary: this diff parallelize the aligner pass

(cherry picked from FBD16176327)


  Commit: f4ab6e69248a798fda8cc73bd61d7ba7a46cdd79
      https://github.com/llvm/llvm-project/commit/f4ab6e69248a798fda8cc73bd61d7ba7a46cdd79
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-10 (Wed, 10 Jul 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Exceptions.cpp
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  run finalize functions in parallel
Summary:

(cherry picked from FBD16188733)


  Commit: 7d428354181b5b0dc190f4259fadb2c480778617
      https://github.com/llvm/llvm-project/commit/7d428354181b5b0dc190f4259fadb2c480778617
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-12 (Fri, 12 Jul 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/ParallelUtilities.cpp
    M bolt/src/ParallelUtilities.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  Run buildCFG in disassembly in parallel

Summary:
This diff  parallelize the construction of call graph during disassembly.
The diff includes a change to  parallel-utilities where another interface
is added, that support running tasks on binaryFunctions that involves
adding instruction annotations. This pattern is common in different places,
e.g. frame optimizations. And such, pattern justify creating an interface,
that abstract out all the messy details.

(cherry picked from FBD16232809)


  Commit: fde5a2b470c15aa4ab0d3aee1439ef4d06199c42
      https://github.com/llvm/llvm-project/commit/fde5a2b470c15aa4ab0d3aee1439ef4d06199c42
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-02 (Tue, 02 Jul 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/DataflowInfoManager.cpp
    M bolt/src/Passes/DataflowInfoManager.h
    M bolt/src/Passes/DominatorAnalysis.h
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/FrameOptimizer.h
    M bolt/src/Passes/LivenessAnalysis.h
    M bolt/src/Passes/ReachingDefOrUse.h
    M bolt/src/Passes/ReachingInsns.h
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Passes/ShrinkWrapping.h
    M bolt/src/Passes/StackAllocationAnalysis.h
    M bolt/src/Passes/StackAvailableExpressions.h
    M bolt/src/Passes/StackPointerTracking.h
    M bolt/src/Passes/StackReachingUses.h
    M bolt/src/Passes/ValidateInternalCalls.cpp

  Log Message:
  -----------
  Run shrink wrapping in parallel

Summary:
Shrink wrapping is an expensive part of frame optimizations if
performed on all functions. This diff makes it run in parallel,
reducing wall time.

(cherry picked from FBD16092651)


  Commit: 2c9c6b164b23cdceb5ba99e8f1bc2a360731eb53
      https://github.com/llvm/llvm-project/commit/2c9c6b164b23cdceb5ba99e8f1bc2a360731eb53
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-07-22 (Mon, 22 Jul 2019)

  Changed paths:
    M bolt/src/DynoStats.cpp

  Log Message:
  -----------
  [BOLT] Fix issue printing CTCs without annotations

Summary:
After stripping annotations, conditional tail calls no longer can be
identified by their corresponding tag. We can check the number of basic
block successors instead.

Fixes facebookincubator/BOLT#58.

(cherry picked from FBD16444718)


  Commit: 86800abc8135e7860be46239d598f0a76132ce48
      https://github.com/llvm/llvm-project/commit/86800abc8135e7860be46239d598f0a76132ce48
  Author: Facebook Github Bot <facebook-github-bot at users.noreply.github.com>
  Date:   2019-07-24 (Wed, 24 Jul 2019)

  Changed paths:
    M bolt/src/CMakeLists.txt
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][PR] Target compilation based on LLVM CMake configuration

Summary:

Minimalist implementation of target configurable compilation.

Fixes https://github.com/facebookincubator/BOLT/issues/59
Pull Request resolved: https://github.com/facebookincubator/BOLT/pull/60
GitHub Author: Pierre RAMOIN <pierre.ramoin at amadeus.com>

(cherry picked from FBD16461879)


  Commit: b50500893ddb6870e37a90792acc5b1ed8b22bb1
      https://github.com/llvm/llvm-project/commit/b50500893ddb6870e37a90792acc5b1ed8b22bb1
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-17 (Wed, 17 Jul 2019)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  Lock-based parallelization for updateDebugInfo

Summary:
BOLT spends a decent amount of time creating patches to update
debug information when -update-debug-sections is passed.
In updateDebugInfo patches are created to update .debug_info
and .debug_abbrev sections while .debug_loc and .debug_ranges
contents are populated. This this diff uses a lock-based approach to
parallelize  updateDebugInfo functions and reduces the runtime of the
function by around 30%.

(cherry picked from FBD16352261)


  Commit: 744a2417dd64e8c4ecc74e343c8894b0d43b944a
      https://github.com/llvm/llvm-project/commit/744a2417dd64e8c4ecc74e343c8894b0d43b944a
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-17 (Wed, 17 Jul 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  Run findSubprograms in preprocessDebugInfo in parallel

Summary:
While reading debug info the function findSubprograms
runs on each compilation unit. This diff parallelize that loop
reducing its runtime duration by 70%.

(cherry picked from FBD16362867)


  Commit: 98fdba2cc765f4182859aea81caf796c8c2373fa
      https://github.com/llvm/llvm-project/commit/98fdba2cc765f4182859aea81caf796c8c2373fa
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-07-24 (Wed, 24 Jul 2019)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/Exceptions.cpp
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/ReorderAlgorithm.cpp
    M bolt/src/Passes/ShrinkWrapping.h
    M bolt/src/Passes/StackPointerTracking.h
    M bolt/src/RewriteInstance.h
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLT][NFC] Fix white space

(cherry picked from FBD16473918)


  Commit: 672287504716894b46c36bd187d64ccc97a07d6a
      https://github.com/llvm/llvm-project/commit/672287504716894b46c36bd187d64ccc97a07d6a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-07-24 (Wed, 24 Jul 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix processing PLT without relocs

Summary:
Some binaries may not have a relocation section corresponding to PLT.
Handle them properly.

(cherry picked from FBD16477841)


  Commit: a9b9aa1e025cae00ea5ee382910913d6e3316e90
      https://github.com/llvm/llvm-project/commit/a9b9aa1e025cae00ea5ee382910913d6e3316e90
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-07-23 (Tue, 23 Jul 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Add code padding verification

Summary:
In non-relocation mode, we allow data objects to be embedded in the
code. Such objects could be unmarked, and could occupy an area between
functions, the area which is considered to be code padding.

When we disassemble code, we detect references into the padding area
and adjust it, so that it is not overwritten during the code emission.
We assume the reference to be pointing to the beginning of the object.

However, assembly-written functions may reference the middle of an
object and use negative offsets to reference data fields. Thus,
conservatively, we reduce the possibly-overwritten padding area to
a minimum if the object reference was detected.

Since we also allow functions with unknown code in non-relocation mode,
it is possible that we miss references to some objects in code.
To cover such cases, we need to verify the padding area before we
allow to overwrite it.

(cherry picked from FBD16477787)


  Commit: 6443c46b9dbfc5d7e10c6e29e2d8d4298bf91b4d
      https://github.com/llvm/llvm-project/commit/6443c46b9dbfc5d7e10c6e29e2d8d4298bf91b4d
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-23 (Tue, 23 Jul 2019)

  Changed paths:
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/ReorderUtils.h

  Log Message:
  -----------
  Run hfsort+ in parallel

Summary:
hfsort+ performs an expensive analysis to determine the
new order of the functions. 99% of the time during hfsort+
is spent in the function runPassTwo. This diff runs the body
of the hot loop in runPassTwo in parallel speeding up the
total runtime of reorder-functions pass by up to 4x

(cherry picked from FBD16450780)


  Commit: 1bce256e677c0b0842632621513ad09d644077e2
      https://github.com/llvm/llvm-project/commit/1bce256e677c0b0842632621513ad09d644077e2
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-25 (Thu, 25 Jul 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Fix race condition in buildCFG

Summary:
switch to sequential execution when print-all is passed.
Since the function getDynoStats have an unsafe access
to the annotation allocators.

(cherry picked from FBD16503502)


  Commit: 79ff4ec1cb174a21f8425a65f4f1c35d8de56889
      https://github.com/llvm/llvm-project/commit/79ff4ec1cb174a21f8425a65f4f1c35d8de56889
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-06-11 (Tue, 11 Jun 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [perf2bolt] Enforce strict mode for perf2bolt

Summary:
In strict relocation mode, we get better function coverage. However, if
the profile used for optimization was converted using non-strict mode,
then it wouldn't match functions exclusive to strict mode. Hence,
we have to enforce strict relocation mode for profile conversion, so it
can be used for either mode.

I'm also adding parallel profile pre-processing unless `--no-threads` is
specified. This masks the runtime overhead of function disassembly on
multi-core machines.

(cherry picked from FBD16587855)


  Commit: 8d5854ef092753f20a4f531e386f503d5d111515
      https://github.com/llvm/llvm-project/commit/8d5854ef092753f20a4f531e386f503d5d111515
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-07-31 (Wed, 31 Jul 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Add option to verify instruction encoder/decoder

Summary:
Add option `-check-encoding` to verify if the input to LLVM disassembler
matches the output of the assembler. When set, the verification runs on
every instruction in processed functions.

I'm not enabling the option by default as it could be quite noisy on x86
where instruction encoding is ambiguous and can include redundant
prefixes.

(cherry picked from FBD16595415)


  Commit: 5084534699d4a56882ef1e08ab29c4e1c4fc2d25
      https://github.com/llvm/llvm-project/commit/5084534699d4a56882ef1e08ab29c4e1c4fc2d25
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-24 (Wed, 24 Jul 2019)

  Changed paths:
    M bolt/src/Passes/IdenticalCodeFolding.cpp

  Log Message:
  -----------
  Rewrite ICF using parallel utilities

Summary: Rewrite ICF using parallel utilities

(cherry picked from FBD16472975)


  Commit: cc8415406c7bdbfda012ba0977cf848e5f03d027
      https://github.com/llvm/llvm-project/commit/cc8415406c7bdbfda012ba0977cf848e5f03d027
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-25 (Thu, 25 Jul 2019)

  Changed paths:
    M bolt/src/Passes/FrameAnalysis.cpp

  Log Message:
  -----------
  Rewrite frame analysis using parallel utilities

Summary: Rewrite frame analysis using parallel utilities

(cherry picked from FBD16499130)


  Commit: c1564a10263c6a2354b93b7ecaa4b6a67176013c
      https://github.com/llvm/llvm-project/commit/c1564a10263c6a2354b93b7ecaa4b6a67176013c
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-07-30 (Tue, 30 Jul 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Add test for parallel mode

Summary:
Add a flag that disable writing botl-info section
and add a test that run bolt with two modes parallel
and sequential and assert that the resulting binaries
are the same.

(cherry picked from FBD16575440)


  Commit: f77cccf6811cbfa9ba00f9984d21a7bf50240e77
      https://github.com/llvm/llvm-project/commit/f77cccf6811cbfa9ba00f9984d21a7bf50240e77
  Author: laith sakka <laith.s.sakka at gmail.com>
  Date:   2019-08-05 (Mon, 05 Aug 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Rename option

(cherry picked from FBD16655093)


  Commit: 62aa74f8369f4ca213115819639052b7f5b4cb2e
      https://github.com/llvm/llvm-project/commit/62aa74f8369f4ca213115819639052b7f5b4cb2e
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-07-24 (Wed, 24 Jul 2019)

  Changed paths:
    M bolt/CMakeLists.txt
    A bolt/runtime/CMakeLists.txt
    A bolt/runtime/instr.cpp
    M bolt/src/CMakeLists.txt
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/ExecutableFileMemoryManager.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLT] Support instrumentation via runtime library

Summary:
To allow the development of future instrumentation work, this
patch adds support in BOLT for linking arbitrary libraries into the
binary processed by BOLT. We use orc relocation handling mechanism for
that. With this support, this patch also moves code programatically
generated in X86 assembly language by X86MCPlusBuilder to C code written
in a new library called bolt_rt. Change CMake to support this library as
an external project in the same way as clang does with compiler_rt. This
library is installed in the lib/ folder relative to BOLT root
installation and by default instrumentation will look for the library
at that location to finish processing the binary with instrumentation.

(cherry picked from FBD16572013)


  Commit: 821480d27f3916ac83ff9e182fbff4183837e0ed
      https://github.com/llvm/llvm-project/commit/821480d27f3916ac83ff9e182fbff4183837e0ed
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-08-02 (Fri, 02 Aug 2019)

  Changed paths:
    M bolt/runtime/instr.cpp
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Encode instrumentation tables in file

Summary:
Avoid directly allocating string and description tables in
binary's static data region, since they are not needed during runtime
except when writing the profile at exit. Change the runtime library to
open the tables on disk and read only when necessary.

(cherry picked from FBD16626030)


  Commit: bf030f336ab1c54a94ce743146e09403fa3c8d32
      https://github.com/llvm/llvm-project/commit/bf030f336ab1c54a94ce743146e09403fa3c8d32
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-08-19 (Mon, 19 Aug 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix misleading output

Summary:
BOLT prints "spawning thread to pre-process profile" message even when
it is not running in the aggregation mode. Fix that.

(cherry picked from FBD16908596)


  Commit: f588d7a6ea3dd491172f855f0bc0db183cfb26bd
      https://github.com/llvm/llvm-project/commit/f588d7a6ea3dd491172f855f0bc0db183cfb26bd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-08-19 (Mon, 19 Aug 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/JumpTable.cpp
    M bolt/src/JumpTable.h

  Log Message:
  -----------
  [BOLT] Tighter control of jump table detection

Summary:
We were too permissive by allowing more jump tables during the
preliminary scan of memory. This allowed for jump tables to be
falsely detected. And since we didn't have a way to backtrack
the jump table creation, we had to assert.

This diff refactors the code that analyzes jump table contents.
Preliminary and final passes share the same code. The only difference
should be the detection of instruction boundaries that are available
during the final pass.

This should affect strict relocation mode only.

(cherry picked from FBD16923335)


  Commit: 243507db990d300577d940b6e49fdd74fa28932a
      https://github.com/llvm/llvm-project/commit/243507db990d300577d940b6e49fdd74fa28932a
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-08-23 (Fri, 23 Aug 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [BOLT] Fix aggregator w.r.t. split functions

Summary:
We should not rely on split function detection while aggregating
data, but only look up the original function names in the symbol table.
Split function detection should be done by BOLT and not perf2bolt while
writing the profile. Then, BOLT, when reading it, will take care of
combining functions if necessary.

This caused a bug in bolted data collection where samples in cold parts
of a function were being falsely attributed to the hot part of a function
instead of being attributed to the cold part, causing incorrect translation of
addresses.

(cherry picked from FBD16993065)


  Commit: 1f6564f1176c6e05ed7a76a92306197112f8f231
      https://github.com/llvm/llvm-project/commit/1f6564f1176c6e05ed7a76a92306197112f8f231
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-08-26 (Mon, 26 Aug 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Support .plt.got section

Summary:
We decode the regular .plt section and we are able to perform
optimizations on it with -plt=hot or -plt=all, however, .plt.got
sections are not decoded by BOLT. This patch teaches BOLT how to read
them. They are created by the bfd linker whenever there is no need for
the dynamic linker to lazy-bind the symbol (when they are eagerly
resolved at binary load time). These entries are 8-byte sized instead of
16-byte sized like the regular PLT, and contain a single indirect call
instruction with 7 bytes and a nop.

(cherry picked from FBD17060515)


  Commit: 52786928ff66ea59e4b84c0c88593d65557d77a1
      https://github.com/llvm/llvm-project/commit/52786928ff66ea59e4b84c0c88593d65557d77a1
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-08-29 (Thu, 29 Aug 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix perf2bolt race in BAT mode

Summary:
We start a thread to preprocess the profile while the main
thread continues to disassemble the input binary. We should not
disassemble it in BAT mode, however, the test to check whether we have
BAT in the input binary depends on the preprocessing thread, so there
is a race where we may start disassembling functions just because the
preprocessing thread didn't conclude we are in BAT mode. Fix this and
make the main thread check for BAT without depending on the
preprocessing thread.

(cherry picked from FBD17124370)


  Commit: cc4b2fb61425ed3c8656041b5c2ec7d26cc7f0d1
      https://github.com/llvm/llvm-project/commit/cc4b2fb61425ed3c8656041b5c2ec7d26cc7f0d1
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-08-07 (Wed, 07 Aug 2019)

  Changed paths:
    M bolt/runtime/CMakeLists.txt
    M bolt/runtime/instr.cpp
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Efficient edge profiling in instrumented mode

Summary:
Change our edge profiling technique when using instrumentation
to do not instrument every edge. Instead, build the spanning tree
for the CFG and omit instrumentation for edges in the spanning tree.
Infer the edge count for these edges when writing the profile during
run time. The inference works with a bottom-up traversal of the spanning
tree and establishes the value of the edge connecting to the parent based
on a simple flow equation involving output and input edges, where the
only unknown variable is the parent edge.

This requires some engineering in the runtime lib to support dynamic
allocation for building these graphs at runtime.

(cherry picked from FBD17062773)


  Commit: 8cd1ba599b7c8f116723ec7e66170523edf4a93f
      https://github.com/llvm/llvm-project/commit/8cd1ba599b7c8f116723ec7e66170523edf4a93f
  Author: Wenlei He <aktoon at gmail.com>
  Date:   2019-09-03 (Tue, 03 Sep 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h

  Log Message:
  -----------
  [BOLT] Ignore LBR from kernel interrupts

Summary: This change adds a switch (`ignore-interrupt-lbr`) to ignores LBR from perf input that is result of kernel interrupts. These asynchronous flow of user/kernel transition will make BOLT think that profile is stale, thus bailout optimization for functions. Ideally, user mode filter need to be set for `perf record` so we don't have asynchronous LBRs. However these are identifiable as kernel address space is known, so we can ignore any LBRs that come from or go into kernel addresses during aggregation. This is under a switch and off by default in case we need to BOLT kernel module.

(cherry picked from FBD17170107)


  Commit: 615a318b604d7088955cc5e75cf4ef55bdbe5b4e
      https://github.com/llvm/llvm-project/commit/615a318b604d7088955cc5e75cf4ef55bdbe5b4e
  Author: Wenlei He <aktoon at gmail.com>
  Date:   2019-09-03 (Tue, 03 Sep 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Filter perf samples by PID

Summary: `perf2bolt` accepts executable name, and the tool will find all the PIDs associated with that executable. When different versions of an executable are running at the same time, name alone may not be sufficient as we will get samples from different versions of the binary aggregated together. The resulting fdata may look stale to BOLT, which makes BOLT bailout optimization for functions. This change adds a `-pid` switch that lets user specify process ID in addition to executable name so BOLT can target a specific process.

(cherry picked from FBD17178898)


  Commit: e9c6c73bb8755b5a59865b6fe716bdfa96fa6066
      https://github.com/llvm/llvm-project/commit/e9c6c73bb8755b5a59865b6fe716bdfa96fa6066
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-09-11 (Wed, 11 Sep 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/SplitFunctions.cpp
    A bolt/src/Passes/SplitFunctions.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][non-reloc] Change function splitting in non-relocation mode

Summary:
This diff applies to non-relocation mode mostly. In this mode, we are
limited by original function boundaries, i.e. if a function becomes
larger after optimizations (e.g. because of the newly introduced
branches) then we might not be able to write the optimized version,
unless we split the function. At the same time, we do not benefit from
function splitting as we do in the relocation mode since we are not
moving functions/fragments, and the hot code does not become more
compact.

For the reasons described above, we used to execute multiple re-write
attempts to optimize the binary and we would only split functions that
were too large to fit into their original space.

After the first attempt, we would know functions that did not fit
into their original space. Then we would re-run all our passes again
feeding back the function information and forcefully splitting
such functions. Some functions still wouldn't fit even after the
splitting (mostly because of the branch relaxation for conditional tail
calls that does not happen in non-relocation mode). Yet we have emitted
debug info as if they were successfully overwritten. That's why we had
one more stage to write the functions again, marking failed-to-emit
functions non-simple. Sadly, there was a bug in the way 2nd and 3rd
attempts interacted, and we were not splitting the functions correctly
and as a result we were emitting less optimized code.

One of the reasons we had the multi-pass rewrite scheme in place, was
that we did not have an ability to precisely estimate the code size
before the actual code emission. Recently, BinaryContext obtained such
functionality, and now we can use it instead of relying on the
multi-pass rewrite. This eliminates redundant work of re-running
the same function passes multiple times.

Because function splitting runs before a number of optimization passes
that run on post-CFG state (those rely on the splitting pass), we
cannot estimate the non-split code size with 100% accuracy. However,
it is good enough for over 99% of the cases to extract most of the
performance gains for the binary.

As a result of eliminating the multi-pass rewrite, the processing time
in non-relocation mode with `-split-functions=2` is greatly reduced.
With debug info update, it is less than half of what it used to be.

New semantics for `-split-functions=<n>`:

  -split-functions - split functions into hot and cold regions
    =0 -   do not split any function
    =1 -   in non-relocation mode only split functions too large to fit
           into original code space
    =2 -   same as 1 (backwards compatibility)
    =3 -   split all functions

(cherry picked from FBD17362607)


  Commit: c8232201165d52cddd5256449f906c3e9dcda092
      https://github.com/llvm/llvm-project/commit/c8232201165d52cddd5256449f906c3e9dcda092
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-09-17 (Tue, 17 Sep 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Better check for compiler de-virtualization bug

Summary:
The existing check for compiler de-virtualization bug was not working
when the relocation reference did not fall on a function boundary.
As a result, we were falsely detecting "unmarked object in code".

When running the check, the address could be arbitrary, except it
shouldn't match any existing function. Additionally, check that there's
a proper reference to the de-virtualized callee to avoid false
positives.

(cherry picked from FBD17433887)


  Commit: 5e6d246b9cee36b39c02e22fd8b478b55534bd73
      https://github.com/llvm/llvm-project/commit/5e6d246b9cee36b39c02e22fd8b478b55534bd73
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-09-18 (Wed, 18 Sep 2019)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Reword message for macro-op fusion optimization

Summary:
With the word "missed", the previous message about opportunities for
macro-op fusion optimization could be misleading.

(cherry picked from FBD17464603)


  Commit: ba31344fa92f5489fce276853d1be5235b639884
      https://github.com/llvm/llvm-project/commit/ba31344fa92f5489fce276853d1be5235b639884
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-09-20 (Fri, 20 Sep 2019)

  Changed paths:
    M bolt/runtime/CMakeLists.txt
    A bolt/runtime/config.h.in
    M bolt/runtime/instr.cpp
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix build for Mac

Summary:
Change our CMake config for the standalone runtime instrumentation
library to check for the elf.h header before using it, so the build
doesn't break on systems lacking it. Also fix a SmallPtrSet usage where
its elements are not really pointers, but uint64_t, breaking the build
in Apple's Clang.

(cherry picked from FBD17505759)


  Commit: c9f4bbdc22beb6e159d6ac5220c2c61f0ade7684
      https://github.com/llvm/llvm-project/commit/c9f4bbdc22beb6e159d6ac5220c2c61f0ade7684
  Author: Mark Santaniello <marksan at fb.com>
  Date:   2019-09-26 (Thu, 26 Sep 2019)

  Changed paths:
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [llvm-bolt] Bugfix jemalloc sized deallocation segfault

Summary:
C++14 "sized deallocation" introduces a 2-argument `delete` where the new 2nd argument is the original allocated size.  It's useful for allocators like jemalloc to be "reminded" of the original allocation size, else they incur the cost of an address to size lookup.  Jemalloc has provided this for a while as `sdallocx`, and recently it got wired up to the new 2-arg `delete`.

Here I introduce typedefs for the SmallVectors so the "16" is consistent, which seems to fix the issue.

(cherry picked from FBD17618981)


  Commit: 13948f376d5c066649bbe18703264d6f327ff81f
      https://github.com/llvm/llvm-project/commit/13948f376d5c066649bbe18703264d6f327ff81f
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-10-04 (Fri, 04 Oct 2019)

  Changed paths:
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Do not emit BAT for non-simple in nonreloc

Summary: Doing so cause corrupt entries to be emitted.

(cherry picked from FBD17774505)


  Commit: 8c6ea8540a3341ff63be0f91cae802ff15a1cd2a
      https://github.com/llvm/llvm-project/commit/8c6ea8540a3341ff63be0f91cae802ff15a1cd2a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-10-08 (Tue, 08 Oct 2019)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Improve object discovery runtime

Summary:

(cherry picked from FBD17872824)


  Commit: d87f95065a2f55094e49060bee8c1320d5d4bc90
      https://github.com/llvm/llvm-project/commit/d87f95065a2f55094e49060bee8c1320d5d4bc90
  Author: Xin-Xin Wang <xinxinw at fb.com>
  Date:   2019-10-14 (Mon, 14 Oct 2019)

  Changed paths:
    M bolt/test/CMakeLists.txt

  Log Message:
  -----------
  [BOLT] Add missing CMake test dependencies

Summary:
I noticed when setting up a new repository for bolt that bolt tests
would fail unexpectedly when running `ninja check-bolt` and
`ninja check-llvm`. This turns out to be because dependencies for bolt
binaries were not specified in the CMake configuration so they were not
built before running the tests. This diff adds the dependencies to the
CMake configuration for check-bolt and check-llvm so that bolt binaries
are built before running tests.

(cherry picked from FBD17919505)


  Commit: 698a4684ac8160ff41ecd02fd8a3a49115ea9463
      https://github.com/llvm/llvm-project/commit/698a4684ac8160ff41ecd02fd8a3a49115ea9463
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-10-11 (Fri, 11 Oct 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT] Fix merge-fdata and heatmap in BAT

Summary:
merge-fdata for legacy format was simply appending all input
strings to output, but the real format supports some header strings
that can't be simply concatanated to output. Check for the header
string used by BAT before merging fdata to avoid creating an output
file with invalid lines (header in the middle of the fdata file).

For heatmap, avoid reading BAT tables, since they won't be used.

(cherry picked from FBD17943131)


  Commit: 103b0a77cc46e769cfcd86784306e0126002eecf
      https://github.com/llvm/llvm-project/commit/103b0a77cc46e769cfcd86784306e0126002eecf
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-10-14 (Mon, 14 Oct 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Fix non-determinism while reading debug info

Summary:
When reading debug info in parallel, CUs for functions were populated in
parallel and the order was non-deterministic. We used the first CU from
the non-deterministically-ordered list to set the line number resulting
in different outputs.

The fix is to sort the list after it's been created and before assigning
the line table unit.

(cherry picked from FBD17946889)


  Commit: b807641e2a8a48e343653f54c950cf78940ce670
      https://github.com/llvm/llvm-project/commit/b807641e2a8a48e343653f54c950cf78940ce670
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-10-17 (Thu, 17 Oct 2019)

  Changed paths:
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h

  Log Message:
  -----------
  [BOLT] Fix stale functions when using BAT

Summary:
If collecting data in Intel Skylake machines, we may face a
bug where LBR0 or LBR1 may be duplicated w.r.t. the next entry. This
makes perf2bolt interpret it as an invalid trace, which ordinarily we
discard during aggregation. However, in BAT, since we do not disassemble
the binary where the collection happened but rely only on the
translation table, it is not possible to detect bad traces and discard
them. This gets to the fdata file, and this invalid trace ends up
invalidating the profile for the whole function (by being treated as
stale by BOLT).

In this patch, we detect Skylake by looking for LBRs with 32 entries,
and discard the first 2 entries to avoid running into this problem.

It also fixes an issue with collision in the translation map by
prioritizing the last basic block when more than one share the same
output address.

(cherry picked from FBD17996791)


  Commit: 12aca4005c723ebd15046357f9faf0e3dec32666
      https://github.com/llvm/llvm-project/commit/12aca4005c723ebd15046357f9faf0e3dec32666
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-10-20 (Sun, 20 Oct 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Ignore __builtin_unreachable destination

Summary:
For functions with unknown control flow, do not populate TakenBranches
with an entry pointing to the end of the function.

(cherry picked from FBD18034019)


  Commit: 8fb6512a238476162acea7c51c409c25e80e0472
      https://github.com/llvm/llvm-project/commit/8fb6512a238476162acea7c51c409c25e80e0472
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-10-21 (Mon, 21 Oct 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT][Docs] Instructions for linking with jemalloc/tcmalloc

(cherry picked from FBD18050722)


  Commit: a3295715e4ef43e92f8381fc407eee43b6116324
      https://github.com/llvm/llvm-project/commit/a3295715e4ef43e92f8381fc407eee43b6116324
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-10-28 (Mon, 28 Oct 2019)

  Changed paths:
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp

  Log Message:
  -----------
  [AArch64] Recognize one extra br idiom

Summary:
We do not support optimizing functions with jump tables in
AArch64, but we do need to detect them. This idiom is slightly different
from the ones we've seen before. It encode jump table entries as
relative to the jump table itself instead of relative to the indirect
branch (BR) instruction.

(cherry picked from FBD18191100)


  Commit: ed8be23e73f266944faa2f81e818afb556553b3f
      https://github.com/llvm/llvm-project/commit/ed8be23e73f266944faa2f81e818afb556553b3f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-10-28 (Mon, 28 Oct 2019)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  [BOLT][llvm] Reduce memory used by MCInst

Summary:
BOLT creates MCInst for every instruction from the input. For large
binaries, this means we are creating tens if not hundreds of millions of
instructions. If the number of operands for average instruction is much
less than 8, we benefit from changing the type of Operands from
SmallVector<MCOperand, 8> to SmallVector<MCOperand, 2>. That seems
to be the optimal type for X86-64 on average.

The size of MCInst goes down from 176 to 80 which often reduces BOLT
memory consumption by gigabytes.

(cherry picked from FBD18218924)


  Commit: 1ed3ac17ffcec73c63f12d35b9b4267b8ef6931d
      https://github.com/llvm/llvm-project/commit/1ed3ac17ffcec73c63f12d35b9b4267b8ef6931d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-10-29 (Tue, 29 Oct 2019)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Fix section offsets after debug stripping

Summary:
Be default, we strip debug sections from the binary. Even though we did
not write the sections, we allocated space for them in the output binary
by mistake.

(cherry picked from FBD18218708)


  Commit: a1388308f0a0a96d0635538f1bc1f40adf15d54d
      https://github.com/llvm/llvm-project/commit/a1388308f0a0a96d0635538f1bc1f40adf15d54d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-01 (Fri, 01 Nov 2019)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Use NameResolver class for local symbols

Summary: NameResolver class is used to assign unique names to local symbols.

(cherry picked from FBD18277131)


  Commit: 98e63610b19c3251dbae3e7d05ec66fc9274035d
      https://github.com/llvm/llvm-project/commit/98e63610b19c3251dbae3e7d05ec66fc9274035d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-01 (Fri, 01 Nov 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Create OffsetTranslationTable for basic blocks

Summary:
Use BinaryBasicBlock::OffsetTranslationTable for BAT. This removes
dependency on instructions after the code emission.

(cherry picked from FBD18283965)


  Commit: f2b257bec8926dfced11973a711ccb80b5f3e58a
      https://github.com/llvm/llvm-project/commit/f2b257bec8926dfced11973a711ccb80b5f3e58a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-03 (Sun, 03 Nov 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinarySection.h
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Update SDTs based on translation tables

Summary:
We've used to emit special annotations to update SDT markers. However,
we can just use "Offset" annotations for the same purpose. Unlike BAT,
we have to generate "reverse" address translation tables.
This approach eliminates reliance on instructions after code emission.

(cherry picked from FBD18318660)


  Commit: d5ddb320ef5bd0aa93bd7c7fc9b179e278fe8319
      https://github.com/llvm/llvm-project/commit/d5ddb320ef5bd0aa93bd7c7fc9b179e278fe8319
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-10-31 (Thu, 31 Oct 2019)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Free memory for CFG after emission

Summary:
Once we emit function code, we no longer need CFG for next phases
that use basic blocks for address-translation and symbol update
purposes. We free memory used by CFG and instructions. The freed
memory gets reused by later phases resulting in overall memory usage
reduction.

We can probably improve memory consumption even further by replacing
BinaryBasicBlocks with more compact data structures.

(cherry picked from FBD18408954)


  Commit: 72b52edcbb2881bed66d30b974461e7d80c8e489
      https://github.com/llvm/llvm-project/commit/72b52edcbb2881bed66d30b974461e7d80c8e489
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-08 (Fri, 08 Nov 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Free more memory in BinaryFunction::releaseCFG()

Summary:
Free more lists in BinaryFunction::releaseCFG().

Release BinaryFunction::Relocations after disassembly.

Do not populate BinaryFunction::MoveRelocations as we are not using them
currently.

Also remove PCRelativeRelocationOffsets that weren't used.

(cherry picked from FBD18413256)


  Commit: 6796b7216b539034b5376e316c2bb117b85861b5
      https://github.com/llvm/llvm-project/commit/6796b7216b539034b5376e316c2bb117b85861b5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-10 (Sun, 10 Nov 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/JumpTable.cpp

  Log Message:
  -----------
  [BOLT] Fix jump table analysis for non-simple functions

Summary:
When we disassemble functions, we add discovered jump tables to a global
container in BinaryContext. Later, we analyze and verify all jump
tables. However, analysis for non-simple functions might fail for numerous
reasons, e.g. there would be no instruction at a destination. Since we
are not overwriting non-simple functions, it is not a critical error.
Thus, we can safely skip jump table analysis for non-simple functions.

(cherry picked from FBD18422997)


  Commit: 95a1c7f5537a22359a119ef88d02d71ab50d228f
      https://github.com/llvm/llvm-project/commit/95a1c7f5537a22359a119ef88d02d71ab50d228f
  Author: spupyrev <spupyrev at fb.com>
  Date:   2019-10-31 (Thu, 31 Oct 2019)

  Changed paths:
    M bolt/src/CacheMetrics.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/ReorderAlgorithm.cpp
    M bolt/src/Passes/ReorderAlgorithm.h
    M bolt/src/Passes/ReorderUtils.h

  Log Message:
  -----------
  speeding up ext-tsp

Summary:
Speeding up cache+/ext-tsp block reordering algorithm.
On a high-level, the speedup is achieved by:
- precomputing and memorizing all jumps between a pair of chains
(instead of extracting them on every merge iteration);
- using a cache of size O(|E|) instead of O(|V|^2) as in previous version.

The final output is identical to previous one subject to a new deterministic
comparison of double values.

(cherry picked from FBD18380870)


  Commit: 3b1b9916dde9ddaecc77e5a9c58e3430d1ed75e3
      https://github.com/llvm/llvm-project/commit/3b1b9916dde9ddaecc77e5a9c58e3430d1ed75e3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-19 (Tue, 19 Nov 2019)

  Changed paths:
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][NFC] Refactor data section emission code

Summary: RewriteInstance::emitDataSection() -> BinarySection::emitAsData()

(cherry picked from FBD18623050)


  Commit: b07e870d785fcebc2e6cc00f46fb4765abd8fa7d
      https://github.com/llvm/llvm-project/commit/b07e870d785fcebc2e6cc00f46fb4765abd8fa7d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-20 (Wed, 20 Nov 2019)

  Changed paths:
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add BinarySection::flushPendingRelocations()

(cherry picked from FBD18623527)


  Commit: 658f270417c78c894dd1f4dc344dbd50f0d6a914
      https://github.com/llvm/llvm-project/commit/658f270417c78c894dd1f4dc344dbd50f0d6a914
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-19 (Tue, 19 Nov 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Refactor data PC relocations in BinaryContext

Summary:
We only use locations of PC relocations and ignore the rest of the data.
There's no need to store type and value.

(cherry picked from FBD18623280)


  Commit: a09659fd54183adf1065369fb2c2ae291290c7c3
      https://github.com/llvm/llvm-project/commit/a09659fd54183adf1065369fb2c2ae291290c7c3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-18 (Mon, 18 Nov 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Refactor markAmbiguousRelocations()

Summary:
Refactor markAmbiguousRelocations() code and move it to BinaryContext.

Also remove a redundant check.

(cherry picked from FBD18623815)


  Commit: 7350d40404babc3737bdc552c9524b6cc2249407
      https://github.com/llvm/llvm-project/commit/7350d40404babc3737bdc552c9524b6cc2249407
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-11 (Mon, 11 Nov 2019)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][NFC] Refactor BinaryFunction::addEntryPoint()

Summary:
There is no need to support existing functionality of adding entry
points after the CFG is built as the function is only called in empty or
disassembled state. Previously we used to run disassemble+buildCFG per
function, but now these phases are decoupled.

Also, remove a couple of redundant checks.

(cherry picked from FBD18622822)


  Commit: 3cc4fc267b35b300ea86331a48d1be5ff417a37d
      https://github.com/llvm/llvm-project/commit/3cc4fc267b35b300ea86331a48d1be5ff417a37d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-22 (Fri, 22 Nov 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Proper support for -trap-avx512 option

Summary:
If -trap-avx512 option is not set, verify that we correctly encode
AVX-512 instructions and treat them as ordinary instructions.

(cherry picked from FBD18666427)


  Commit: 4bcc53a408b6a74661bd5f00414a9037bf2be3ea
      https://github.com/llvm/llvm-project/commit/4bcc53a408b6a74661bd5f00414a9037bf2be3ea
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-11-26 (Tue, 26 Nov 2019)

  Changed paths:
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Passes/ShrinkWrapping.h

  Log Message:
  -----------
  [BOLT] Fix shrink wrapping empty BB issue

Summary:
When combining icp=calls and shrink wrapping, the former may
generate empty BBs that are going to trigger a bug in shrink wraping
restore placement strategy. The restore is wrongly pushed to the BB
successor instead of being added to the current block. Add a pass to
go over the CFG to fix empty blocks by adding a temporary NOP
instruction that is going to be deleted later. Empty BBs are not
supported by one of the analysis done at this pass.

(cherry picked from FBD18717994)


  Commit: 28f91871b3726828522be79488acaf223dcb41ad
      https://github.com/llvm/llvm-project/commit/28f91871b3726828522be79488acaf223dcb41ad
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-11-14 (Thu, 14 Nov 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [PERF2BOLT/BOLT] Improve support for .so

Summary:
Avoid asserting on inputs that are shared libraries with
R_X86_64_64 static relocs and RELATIVE dynamic relocations matching
those. Our relocation checking mechanism would expect the result of
the static relocation to be encoded in the binary, but the linker
instead puts it as an addend in the RELATIVE dyn reloc.

Also fix aggregation for .so if the executable segment is not the
first one in the binary.

(cherry picked from FBD18651868)


  Commit: 8e2d3f7c3066a5d04fb53d86598a02631bfa4dad
      https://github.com/llvm/llvm-project/commit/8e2d3f7c3066a5d04fb53d86598a02631bfa4dad
  Author: Xin-Xin Wang <xinxinw at fb.com>
  Date:   2019-10-23 (Wed, 23 Oct 2019)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT] Fix invalid abbrev error when reading debug_info section with readelf

Summary:
This fixes a bug which causes the debug_info and debug_loc sections to be unreadable by readelf/objdump.

Basically, we're using 12 bytes of a ULEB128 value to fill in space, but readelf can't read more than 9 bytes of ULEB128. Thus, we replace that value with a string of 'a' instead.

(cherry picked from FBD18097728)


  Commit: 112c4251f58510f8fb4e62092706ad5c92dff95a
      https://github.com/llvm/llvm-project/commit/112c4251f58510f8fb4e62092706ad5c92dff95a
  Author: Xin-Xin Wang <xinxinw at fb.com>
  Date:   2019-10-25 (Fri, 25 Oct 2019)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT] Separate DebugRangesSectionsWriter into Ranges and ARanges

Summary: The `.debug_aranges` section is already deterministic and is logically separate from the `.debug_ranges` section so separate them into separate classes so that it will be easier to make DebugRangesSectionsWriter deterministic

(cherry picked from FBD18153057)


  Commit: 6f93d53bf51e6f0f9f9683da5964baed58e2fffa
      https://github.com/llvm/llvm-project/commit/6f93d53bf51e6f0f9f9683da5964baed58e2fffa
  Author: Xin-Xin Wang <xinxinw at fb.com>
  Date:   2019-10-25 (Fri, 25 Oct 2019)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT] Remove test for impossible debug ranges condition

Summary:
The condition `DebugRangesOffset == -1U` can never happen since DebugRangesOffset has type `uint64_t` and the value always comes from `RangesSectionWriter->addRanges` which gets its value from `DebugRangesSectionWriter.SectionOffset` which has type `uint32_t`. The condition seems to be left over from a time where something was using `-1` as an error value.

I'm removing that check so I can use `-1` as a tag to refer to the empty range that will be at the beginning of the ranges section.

(cherry picked from FBD18153119)


  Commit: e5d1334ad5f4ed0c163b41163bb371be0e4e570c
      https://github.com/llvm/llvm-project/commit/e5d1334ad5f4ed0c163b41163bb371be0e4e570c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-12-05 (Thu, 05 Dec 2019)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [perf2bolt] Ignore mmap events unrelated to execution

Summary:
Some processes can mmap the main binary for the purpose of
introspection. We should ignore such mmap events for fixed-address
binaries. For PIC binaries, we record the mapping and do the address
filtering later for all sample events.

(cherry picked from FBD18844314)


  Commit: bdb60857e83b02046f0f7682b1d3d4fec4be6bec
      https://github.com/llvm/llvm-project/commit/bdb60857e83b02046f0f7682b1d3d4fec4be6bec
  Author: Xin-Xin Wang <xinxinw at fb.com>
  Date:   2019-10-25 (Fri, 25 Oct 2019)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT] Make .debug_loc update deterministic

Summary:
Change the single DebugLocWriter to one for each compilation unit. Then, each thread can write to its own DebugLocWriter and we can combine the data in a deterministic order once the threads are done.

The only catch is that each thread would need the offset of the location lists it adds, so we make a list of pending location list patches and compute the final offsets at the end.

(cherry picked from FBD18153069)


  Commit: e46d52de5b1c7c0861131218ba51c457eeca275f
      https://github.com/llvm/llvm-project/commit/e46d52de5b1c7c0861131218ba51c457eeca275f
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-12-13 (Fri, 13 Dec 2019)

  Changed paths:
    M bolt/src/Passes/IndirectCallPromotion.cpp

  Log Message:
  -----------
  [BOLT] Fix non-determinism in ICP with threads

Summary:
-icp-top-callsites selects candidates for optimization until a
threshold is met. Currently, this parameter is set to 99% of calls by
default. The order of functions evaluated changes in parallel mode,
thus the functions that may be included to satisfy 99% of all calls may
change, leading to different optimization decisions when running in
parallel versus sequential.

Fix this by enabling optimizations for all branches with the same
frequency once we reach our budget instead of cutting off immediatelly
after our budget is satisfied. In that way, order of functions has no
impact on which functions are optimized.

(cherry picked from FBD18902239)


  Commit: 16a497c627d93910423c767eb5a9ced6ccd62e0e
      https://github.com/llvm/llvm-project/commit/16a497c627d93910423c767eb5a9ced6ccd62e0e
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-12-13 (Fri, 13 Dec 2019)

  Changed paths:
    M bolt/runtime/CMakeLists.txt
    M bolt/runtime/instr.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BoltDiff.cpp
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/Passes/ReorderAlgorithm.cpp
    M bolt/src/Passes/SplitFunctions.cpp
    M bolt/src/Passes/SplitFunctions.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Support full instrumentation

Summary:
Add full instrumentation support (branches, direct and
indirect calls). Add output statistics to show how many hot bytes
were split from cold ones in functions. Add -cold-threshold option
to allow splitting warm code (non-zero count). Add option in
bolt-diff to report missing functions in profile 2.

In instrumentation, fini hooks are fixed to run proper finalization
code after program finishes. Hooks for startup are added to setup
the runtime structures that needs initilization, such as indirect call
hash tables.

Add support for automatically dumping profile data every N seconds by
forking a watcher process during runtime.

(cherry picked from FBD17644396)


  Commit: d414acfbb6eb4f551b466fe0ab852f5878d1e5e8
      https://github.com/llvm/llvm-project/commit/d414acfbb6eb4f551b466fe0ab852f5878d1e5e8
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-12-17 (Tue, 17 Dec 2019)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/ExecutableFileMemoryManager.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [perf2bolt] Better mmap event matching

Summary:
When perf tool reports a mapping address of a binary, it is not always
the address of the first loadable segment we were checking against.
As a result, perf2botl was not working properly for binaries where the
first segment was not executable.

The fix is to check if the address reported by mmap event matches any
of the loadable segments. Note that the segment alignment has to be
applied to get real loadable address of the segment.

Fixes facebookincubator/BOLT#65

(cherry picked from FBD19146419)


  Commit: 9aa276d34978af0682321a64f136b81a10ea00ce
      https://github.com/llvm/llvm-project/commit/9aa276d34978af0682321a64f136b81a10ea00ce
  Author: Xin-Xin Wang <xinxinw at fb.com>
  Date:   2019-10-25 (Fri, 25 Oct 2019)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT] Make .debug_loc update deterministic

Summary:
Change the single DebugLocWriter to one for each compilation unit. Then, each thread can write to its own DebugLocWriter and we can combine the data in a deterministic order once the threads are done.

The only catch is that each thread would need the offset of the location lists it adds, so we make a list of pending location list patches and compute the final offsets at the end.

(cherry picked from FBD18153069)


  Commit: de284bc510b8d6d8a7ebb122f3ac6373bfbad093
      https://github.com/llvm/llvm-project/commit/de284bc510b8d6d8a7ebb122f3ac6373bfbad093
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-12-18 (Wed, 18 Dec 2019)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/LongJmp.cpp

  Log Message:
  -----------
  [BOLT] Fix symbol table entries for secondary entries

Summary:
Commit "Support full instrumentation" changed the map
SymbolToFunction in BinaryContext to map secondary entries of functions
too. This introduced unexpected behavior in our symbol table rewriting
logic, which caused it to mistakenly write them with the address of the
original function. Fix the behavior of getBinaryFunctionAtAddress to
correct this. Also fix other users of SymbolToFunction to ensure they
are not accidentally using secondary entries when they shouldn't.

(cherry picked from FBD19168319)


  Commit: 8c7f524afb38ebe4a84978cc429567cab61fca91
      https://github.com/llvm/llvm-project/commit/8c7f524afb38ebe4a84978cc429567cab61fca91
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-01-02 (Thu, 02 Jan 2020)

  Changed paths:
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [BOLT] Fix build of the runtime on OSX

Summary: Fix the compilation error on OSX

(cherry picked from FBD19269806)


  Commit: 088e3c032ac75b2dc5931cdf33138e38066bb18a
      https://github.com/llvm/llvm-project/commit/088e3c032ac75b2dc5931cdf33138e38066bb18a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-01-06 (Mon, 06 Jan 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/ProfileWriter.cpp

  Log Message:
  -----------
  [BOLT] Improve handling of secondary function entry points

Summary:
"Fix symbol table entries for secondary entries" diff broke the inliner.

Fix the breakage and make the discovery of secondary entry points more
accurate.

Add ability to BinaryContext::getFunctionForSymbol() to return an entry
point discriminator and use it instead of calling getEntryForSymbol()
and isSecondaryEntry(). This is the preferred way since
getFunctionForSymbol() is thread-safe.

(cherry picked from FBD19295983)


  Commit: 45b27d7b44aa78e7e24a79027f83b410216aa357
      https://github.com/llvm/llvm-project/commit/45b27d7b44aa78e7e24a79027f83b410216aa357
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-01-10 (Fri, 10 Jan 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.cpp
    M bolt/src/BinaryData.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/JumpTable.cpp
    M bolt/src/JumpTable.h

  Log Message:
  -----------
  [BOLT] Get rid of Names in BinaryData

Summary:
For BinaryData, we used to maintain a vector of StringRef names and also
a vector of pointers to MCSymbol's associated with the data. There was
an unnecessary duplication of information and an associated overhead of
keeping it in sync. Fix it by removing Names and using Symbols wherever
Names were used.

Also merge two variants of registerNameAtAddress() and remove
unreachable/dead code in the process.

(cherry picked from FBD19359123)


  Commit: 0283271f29dc460acd4beb31ad0786e41f767cbd
      https://github.com/llvm/llvm-project/commit/0283271f29dc460acd4beb31ad0786e41f767cbd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-01-13 (Mon, 13 Jan 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Do no report error on mismatched instruction encoding

Summary:
When the validation of instruction encoding fails but we are able to
continue processing the binary, do no report an error. Report encoding
format only under `-v=1`.

(cherry picked from FBD19376531)


  Commit: 961d3d02d8943070b5f2fc0f0358f04f18709396
      https://github.com/llvm/llvm-project/commit/961d3d02d8943070b5f2fc0f0358f04f18709396
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-01-14 (Tue, 14 Jan 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Move postProcessEntryPoints after disassembly

Summary:
Call postProcessEntryPoints only after all functions have been
disassembled and all interprocedural references have been processed,
when all possible entry points have been accounted for. This makes our
detection of bad entries more robust as it does not depend on the order
of the functions any more.

(cherry picked from FBD19404767)


  Commit: 7a59783d7a0564b35c4966358d60624882fea88b
      https://github.com/llvm/llvm-project/commit/7a59783d7a0564b35c4966358d60624882fea88b
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-01-15 (Wed, 15 Jan 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Move createBinaryContext to BinaryContext

Summary:
1. Move createBinaryContext to BinaryContext.
1. Add support for nonlinux triples in createBinaryContext.
2. Remove unnecessary std::move in DWARFRewriter.cpp.

(cherry picked from FBD19421314)


  Commit: ac697b7d3a3b68fa68f2035b2e0f2fddb6aeaf3e
      https://github.com/llvm/llvm-project/commit/ac697b7d3a3b68fa68f2035b2e0f2fddb6aeaf3e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-01-13 (Mon, 13 Jan 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BoltDiff.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/ReorderFunctions.cpp
    M bolt/src/Passes/VeneerElimination.cpp
    M bolt/src/ProfileReader.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Replace list of Names with Symbols for BinaryFunction

Summary:
BinaryFunction used to have a list of Names associated with its main
entry point. However, the function is primarily identified by its
corresponding symbol or symbols, and these symbols are available as we
are creating them for a corresponding BinaryData object.

There's also no reason to emit symbols for alternative function names
(aliases), so change the code to only emit needed symbols.

When we emit a cold fragment for a function, only emit one cold symbol
for the fragment instead of one per every main entry symbol/name.

When we match a symbol to an entry point in the function, with this
change we can first go through the list of main entry symbols (now that
they are available).

(cherry picked from FBD19426709)


  Commit: d57513e4ab8d7e674279b11c904d84e7d1d2421d
      https://github.com/llvm/llvm-project/commit/d57513e4ab8d7e674279b11c904d84e7d1d2421d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-01-08 (Wed, 08 Jan 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Fix symbol table issue with ICF

Summary: Not all symbol table entries were updated after ICF.

(cherry picked from FBD19319685)


  Commit: 0080d74506fbf675b852acd909c9379a29473ce7
      https://github.com/llvm/llvm-project/commit/0080d74506fbf675b852acd909c9379a29473ce7
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-01-28 (Tue, 28 Jan 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix issue with strict and builtin_unreachable

Summary:
In strict mode, a jump table with targets generated by
builtin_unreachable (located at the very end of the function) was
asserting when being recreated by postProcessIndirectBranches. Fix
this.

(cherry picked from FBD19614981)


  Commit: 41de03b8e900ee96f748e19779ba83faded95d81
      https://github.com/llvm/llvm-project/commit/41de03b8e900ee96f748e19779ba83faded95d81
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-02-07 (Fri, 07 Feb 2020)

  Changed paths:
    M bolt/src/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  [BOLT] Fix section names under `-generate-link-sections`

Summary:
Use proper function while printing modified function name to file.

(cherry picked from FBD19791847)


  Commit: c3c4b15a2e1cf4ba545e9b4b8021449461eae0e5
      https://github.com/llvm/llvm-project/commit/c3c4b15a2e1cf4ba545e9b4b8021449461eae0e5
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-02-10 (Mon, 10 Feb 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Remove BinaryContext::getFunctionData

Summary:
In this diff we refactor the code around getting the original binary encoding of function's body.
The main changes are: remove BinaryContext::getFunctionData, remove the parameter of the method BinaryFunction::disassemble, introduce BinaryFunction::getData.

(cherry picked from FBD19824368)


  Commit: d5b8fc8fbed53407b27c80be4144b85bcff66c44
      https://github.com/llvm/llvm-project/commit/d5b8fc8fbed53407b27c80be4144b85bcff66c44
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-02-11 (Tue, 11 Feb 2020)

  Changed paths:
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h

  Log Message:
  -----------
  [BOLT] Make the methods isText/isData more robust

Summary: Make the methods isText/isData work for MachO.

(cherry picked from FBD19849460)


  Commit: c82e7fd1cc260585000bbd2745471c8159bda981
      https://github.com/llvm/llvm-project/commit/c82e7fd1cc260585000bbd2745471c8159bda981
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-02-10 (Mon, 10 Feb 2020)

  Changed paths:
    M bolt/llvm.patch
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Decoder cache friendly alignment wrt Intel JCC Erratum

Summary:
This diff ports reviews.llvm.org/D70157 to our LLVM tree, which
makes the integrated assembler able to align X86 control-flow changing
instructions in a way to reduce the performance impact of the ucode
update on Intel processors that implement the JCC erratum mitigation.

See white paper "Mitigations for Jump Conditional Code Erratum" by Intel
published November 2019.

To port this patch, I changed classifySecondInstInMacroFusion to analyze
instruction opcodes directly instead of analyzing the CondCond operand
(in more recent versions of LLVM, all conditional branches share the
same opcode, but with a different conditional operand). I also pulled to
our tree Alignment.h as a dependency, and the macroop analyzing helpers.

x86-align-branch-boundary and -x86-align-branch are the two flags that
control nop insertion to avoid disabling the decoder cache, following
the original patch. In BOLT, I added the flag
x86-align-branch-boundary-hot-only to request the alignment to only be
applied to hot code, which is turned on by default. The reason is
because such alignment  is expensive to perform on large modules, but if
we limit it to hot code, the relaxation pass runtime becomes tolerable.

(cherry picked from FBD19828850)


  Commit: 58a129a602b110f838c82400e74b74cbc891209b
      https://github.com/llvm/llvm-project/commit/58a129a602b110f838c82400e74b74cbc891209b
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2019-12-03 (Tue, 03 Dec 2019)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp

  Log Message:
  -----------
  [BOLT] Move peepholes pass after sctc

Summary:
There are two peephole subpasses, remove-double-jumps and
remove-useless-conditional-branches, that operates by reading branches
directly, which makes them tricky to run before fix-branches. In the
case of remove-double-jumps, it will even lead to suboptimal code if
the patched branch was going to be removed by fix-branches when the
target is the fall-through. If the final target is a tail call, it will
lead to a broken CFG in the worst case. Fix this by moving these passes
after SCTC, which already produces CFGs with conditional tail calls.

(cherry picked from FBD18795592)


  Commit: 36cf37c4c134ab25b1b9cda01a4535d347814cb2
      https://github.com/llvm/llvm-project/commit/36cf37c4c134ab25b1b9cda01a4535d347814cb2
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-01-30 (Thu, 30 Jan 2020)

  Changed paths:
    M bolt/src/BinarySection.h
    M bolt/src/CMakeLists.txt
    A bolt/src/MachORewriteInstance.cpp
    A bolt/src/MachORewriteInstance.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    A bolt/src/Utils.cpp
    A bolt/src/Utils.h
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLT] Add initial bits for parsing MachO files

Summary: Start adding initial bits for MachO, this diff contains some small preparations for finding functions inside a MachO binary, this will be done in the next diff. The concept of a section in the MachO world is quite different from ELF, nevertheless, for functions for now it more or less fits into the current picture (in BOLT), but things will diverge more significantly a bit later.

(cherry picked from FBD19648161)


  Commit: 754b6569f6f636e63e532ea06083f2b846f8f25f
      https://github.com/llvm/llvm-project/commit/754b6569f6f636e63e532ea06083f2b846f8f25f
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-02-17 (Mon, 17 Feb 2020)

  Changed paths:
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Add missing std::move

Summary: Add missing std::move in the method BinaryFunction::addAlternativeName

(cherry picked from FBD19944661)


  Commit: 16630f5c580e1a0b2e22e066c8cbf7630f35f064
      https://github.com/llvm/llvm-project/commit/16630f5c580e1a0b2e22e066c8cbf7630f35f064
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-02-17 (Mon, 17 Feb 2020)

  Changed paths:
    A bolt/src/NameResolver.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Factor out NameResolver from RewriteInstance

Summary: Factor out the helper class NameResolver from the class RewriteInstance.

(cherry picked from FBD19943916)


  Commit: 9711286858a938c781f3bdf961b63765b6326597
      https://github.com/llvm/llvm-project/commit/9711286858a938c781f3bdf961b63765b6326597
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-02-18 (Tue, 18 Feb 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinarySection.h
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Get rid of BinarySection::IsLocal

Summary: The flag is no longer used/needed.

(cherry picked from FBD19951571)


  Commit: a9d85413acc774f1754a73b6c78c242b478c9613
      https://github.com/llvm/llvm-project/commit/a9d85413acc774f1754a73b6c78c242b478c9613
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-02-19 (Wed, 19 Feb 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Emit long nops by default

Summary:
Change our X86 target to use long nops by default. In general,
BOLT does not put nops into the instruction stream that is going to be
executed, since it doesn't align basic blocks, only functions. Since we
rebased BOLT, our relationship with MCAssembler changed because it
stopped using multibyte nops and we never needed to revisit that. But it
makes a difference if we want to mitigate perf issues with the Intel
JCC erratum, since the nops inserted are going to be decoded and
executed. To make MCAssembler emit long nops again, we need to explictly
set mattr (Features) of the X86 target.

(cherry picked from FBD19987277)


  Commit: 5b64bf212879d19fe54bab9afa5fc95190b84eec
      https://github.com/llvm/llvm-project/commit/5b64bf212879d19fe54bab9afa5fc95190b84eec
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-02-11 (Tue, 11 Feb 2020)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Disassemble functions from a MachO binary

Summary: Add first bits to disassemble functions from a MachO binary.

(cherry picked from FBD19900493)


  Commit: 4ad5048393c10dafbf1cdde5d9e80bc5f5ba359f
      https://github.com/llvm/llvm-project/commit/4ad5048393c10dafbf1cdde5d9e80bc5f5ba359f
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-02-17 (Mon, 17 Feb 2020)

  Changed paths:
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add first bits to build CFG

Summary: Add first bits to build CFG.

(cherry picked from FBD19943472)


  Commit: 76aa1c26aa3a1ed0167db9c0f28d6361b6e58bfa
      https://github.com/llvm/llvm-project/commit/76aa1c26aa3a1ed0167db9c0f28d6361b6e58bfa
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-02-17 (Mon, 17 Feb 2020)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h

  Log Message:
  -----------
  [BOLT] Enable reversing the order of basic blocks

Summary: Enable reversing the order of basic blocks.

(cherry picked from FBD19943692)


  Commit: be43f89c4f372582cb0a92334fc3ecea9af2f761
      https://github.com/llvm/llvm-project/commit/be43f89c4f372582cb0a92334fc3ecea9af2f761
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-02-23 (Sun, 23 Feb 2020)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  [BOLT][llvm] Update llvm.patch

Summary:

(cherry picked from FBD20063562)


  Commit: 01b7c902426838834f7bbd4c2e0c7fa50c33777b
      https://github.com/llvm/llvm-project/commit/01b7c902426838834f7bbd4c2e0c7fa50c33777b
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-02-23 (Sun, 23 Feb 2020)

  Changed paths:
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Add missing override

Summary: Add missing override in X86MCPlusBuilder.cpp.

(cherry picked from FBD20064222)


  Commit: 3b45212e84ad074296e0bc521cd4623ae71bc87c
      https://github.com/llvm/llvm-project/commit/3b45212e84ad074296e0bc521cd4623ae71bc87c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-02-24 (Mon, 24 Feb 2020)

  Changed paths:
    M bolt/llvm.patch
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/ExecutableFileMemoryManager.h

  Log Message:
  -----------
  [BOLT] Delete ExecutableFileMemoryManager::registerNoteSection()

Summary: The interface is no longer in use.

(cherry picked from FBD20070558)


  Commit: 495761dc70456e91753c218e0e9e5b8f19464e80
      https://github.com/llvm/llvm-project/commit/495761dc70456e91753c218e0e9e5b8f19464e80
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-02-24 (Mon, 24 Feb 2020)

  Changed paths:
    M bolt/src/BinarySection.h

  Log Message:
  -----------
  [BOLT][NFC] Remove unused BinarySection member functions

(cherry picked from FBD20087243)


  Commit: 2df4e7b99ed556870e28c410afb4c6832658bc34
      https://github.com/llvm/llvm-project/commit/2df4e7b99ed556870e28c410afb4c6832658bc34
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-02-24 (Mon, 24 Feb 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][NFC] Minor refactoring of RewriteInstance

(cherry picked from FBD20087424)


  Commit: 340da8f294e521f2438fb60b297f286d350cf9ff
      https://github.com/llvm/llvm-project/commit/340da8f294e521f2438fb60b297f286d350cf9ff
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-02-18 (Tue, 18 Feb 2020)

  Changed paths:
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/ShrinkWrapping.cpp
    A bolt/test/X86/shrinkwrapping-pushpop.s
    A bolt/test/link_fdata.sh
    M bolt/test/lit.cfg.py
    M bolt/test/lit.site.cfg.py.in

  Log Message:
  -----------
  [BOLT] Fix shrink wrapping to check pops

Summary:
Shrink wrapping has a mode where it will directly move push
pop pairs, instead of replacing them with stores/loads. This is an
ambitious mode that is triggered sometimes, but whenever matching with
a push, it would operate with the assumption that the restoring
instruction was a pop, not a load, otherwise it would assert. Fix this
assertion to bail nicely back to non-pushpop mode (use regular store and
load instructions).

(cherry picked from FBD20085905)


  Commit: d89bb53afa934433080128799800cb304d669b77
      https://github.com/llvm/llvm-project/commit/d89bb53afa934433080128799800cb304d669b77
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-02-24 (Mon, 24 Feb 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][NFC] Factor out relocation processing

(cherry picked from FBD20087297)


  Commit: b0cbb601655ed1fceeb3119e456f7ca49083bed7
      https://github.com/llvm/llvm-project/commit/b0cbb601655ed1fceeb3119e456f7ca49083bed7
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-03-03 (Tue, 03 Mar 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Fix begin decrementing

Summary: Fix begin decrementing.

(cherry picked from FBD20232474)


  Commit: c7e012e145fd7a307eb524eecc91e2218d8e2dc5
      https://github.com/llvm/llvm-project/commit/c7e012e145fd7a307eb524eecc91e2218d8e2dc5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-03-03 (Tue, 03 Mar 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h

  Log Message:
  -----------
  [BOLT][NFC] Get rid of BestFit parameter

Summary: The parameter is no longer used.

(cherry picked from FBD20236516)


  Commit: cb9c991dcbe44bec28c75ad512a843b32de58740
      https://github.com/llvm/llvm-project/commit/cb9c991dcbe44bec28c75ad512a843b32de58740
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-03-03 (Tue, 03 Mar 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Remove allow-section-relocations option

Summary: The option is not used. Remove all related code.

(cherry picked from FBD20237859)


  Commit: 842a25f785ccd1c47237951582eb29e24a617e83
      https://github.com/llvm/llvm-project/commit/842a25f785ccd1c47237951582eb29e24a617e83
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-03-02 (Mon, 02 Mar 2020)

  Changed paths:
    M bolt/src/MachORewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Mark functions containing data as non-simple

Summary: Temporarily mark functions containing data as non-simple.

(cherry picked from FBD20213279)


  Commit: e3654fc27485ab17ff7381f9d0bcca9478504c28
      https://github.com/llvm/llvm-project/commit/e3654fc27485ab17ff7381f9d0bcca9478504c28
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-03-04 (Wed, 04 Mar 2020)

  Changed paths:
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h

  Log Message:
  -----------
  [BOLT] Uniquify names of local symbols

Summary:
1. Uniquify names of local symbols.
2. Handle aliases.

(cherry picked from FBD20270196)


  Commit: af553124d3306fd47479f74a952437278aa98cb2
      https://github.com/llvm/llvm-project/commit/af553124d3306fd47479f74a952437278aa98cb2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-03-07 (Sat, 07 Mar 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Refactor emission of original .eh_frame

Summary:
There is no need to treat the emission of the original `.eh_frame`
section as a special case.

(cherry picked from FBD20323360)


  Commit: 74a2777c548453bad287a347e924051722f6e785
      https://github.com/llvm/llvm-project/commit/74a2777c548453bad287a347e924051722f6e785
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-03-08 (Sun, 08 Mar 2020)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactor ELF parts of instrumentation code

Summary:
This is a prerequisite for larger emitter refactoring.

Since .dynamic is read unconditionally, add an error message if the
section is missing, or the size of the section is zero.

(cherry picked from FBD20331735)


  Commit: 1f3e351a9c7702af9b072ec5aa95b4d29c6fa0e5
      https://github.com/llvm/llvm-project/commit/1f3e351a9c7702af9b072ec5aa95b4d29c6fa0e5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-03-06 (Fri, 06 Mar 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    A bolt/src/BinaryEmitter.cpp
    A bolt/src/BinaryEmitter.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/CMakeLists.txt
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/Exceptions.cpp
    M bolt/src/JumpTable.cpp
    M bolt/src/JumpTable.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactor code and data emission code

Summary:
Consolidate code and data emission code in ELF-independent
BinaryEmitter. The high-level interface includes only two
functions emitBinaryContext() and emitFunctionBody() used
by RewriteInstance and BinaryContext respectively.

(cherry picked from FBD20332901)


  Commit: a07f1a26e78ae96ce57338f166be129713ee14f7
      https://github.com/llvm/llvm-project/commit/a07f1a26e78ae96ce57338f166be129713ee14f7
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-03-11 (Wed, 11 Mar 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactor section prefixes

(cherry picked from FBD20400886)


  Commit: bbbf679b426e8dba6c5969b8d24a5b9103d609ce
      https://github.com/llvm/llvm-project/commit/bbbf679b426e8dba6c5969b8d24a5b9103d609ce
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-02-26 (Wed, 26 Feb 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactor ELF symbol table rewriting code

Summary:
Make ELF symbol table rewriting code more structured. While at it,
remove symbols from non-allocatable sections.

(cherry picked from FBD20243386)


  Commit: 58b0d9e7b0faeee35973685bfd3e6fcc76b9d74f
      https://github.com/llvm/llvm-project/commit/58b0d9e7b0faeee35973685bfd3e6fcc76b9d74f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-03-24 (Tue, 24 Mar 2020)

  Changed paths:
    M bolt/llvm.patch
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Add support for base address in DWARF location lists

Summary:
The version of LLVM that we are based on lacks the support for base
address in DWARF location lists. Add the missing pieces.

(cherry picked from FBD20640784)


  Commit: b08d82d91be176046192905bd8c0f4c8d03d096e
      https://github.com/llvm/llvm-project/commit/b08d82d91be176046192905bd8c0f4c8d03d096e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-03-30 (Mon, 30 Mar 2020)

  Changed paths:
    M bolt/src/Passes/IdenticalCodeFolding.cpp

  Log Message:
  -----------
  [BOLT] Verify exceptions action table equivalence in ICF

Summary:
Some functions may have exactly the same code and exception handlers.
However, their action tables could be different leading to mismatching
semantics. We should verify their equivalence while running ICF.

(cherry picked from FBD20889035)


  Commit: abda7dc6a7226e1dcd1b581919b34c39fd9efb46
      https://github.com/llvm/llvm-project/commit/abda7dc6a7226e1dcd1b581919b34c39fd9efb46
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-04 (Sat, 04 Apr 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix ICF non-determinism in non-relocation mode

Summary:
ICF may fold functions in arbitrary order when running multi-threaded.
This is fine in relocation mode as we end up with just one function
holding all function symbols.

However, in non-relocation mode we keep all function bodies, and if we
keep merging profiles in non-deterministic order, we end up with
functions with non deterministic profiles. The fix for non-relocation
mode is to not merge profiles as the factual new profile could be
different from the merged one since both function instances are
potentially callable.

Additionally, emit extra symbols for ICF functions in non-relocation
mode to make it possible to track the folding.

(cherry picked from FBD20889866)


  Commit: ee0371ad97c383bf676d6a04c1c0a6fae907c4da
      https://github.com/llvm/llvm-project/commit/ee0371ad97c383bf676d6a04c1c0a6fae907c4da
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BoltDiff.cpp
    M bolt/src/DebugData.h
    M bolt/src/JumpTable.cpp
    M bolt/src/JumpTable.h
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/ProfileReader.cpp
    M bolt/src/ProfileWriter.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Speedup ICF by better function hashing

Summary:
Too many hash collisions may cause ICF to run slowly.

We used to hash BinaryFunction only looking at instruction opcodes,
ignoring instruction operands. With many almost identical functions,
such approach may lead to long ICF processing time. By including
operands into the hash, we reduce the number of collisions and
improve the runtime often by a factor of 2 or more.

(cherry picked from FBD20888957)


  Commit: 401fa5b493fc21fe3f56f502befe7b5532b06df6
      https://github.com/llvm/llvm-project/commit/401fa5b493fc21fe3f56f502befe7b5532b06df6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-07 (Tue, 07 Apr 2020)

  Changed paths:
    M bolt/src/Passes/IdenticalCodeFolding.cpp

  Log Message:
  -----------
  [BOLT] Further speedup ICF

Summary:
Further speedup ICF by applying stricter rules for congruent functions.
While checking symbolic operands in congruent functions, consider
operands congruent only if they are equal or reference functions
with identical hashes, i.e. potentially foldable functions.
Note that jump table operands are handled as a special case.

(cherry picked from FBD20912054)


  Commit: 6dbd15bc019e04f88e464a839aafd7b3ee329820
      https://github.com/llvm/llvm-project/commit/6dbd15bc019e04f88e464a839aafd7b3ee329820
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-04-06 (Mon, 06 Apr 2020)

  Changed paths:
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    A bolt/test/X86/instrumentation-ind-calls.s

  Log Message:
  -----------
  [BOLT-X86] Fix instrumentation issue with indirect calls

Summary:
Indirect calls that use RSP to compute the target address would
break in instrumentation mode because we were adding instructions that
changed the stack pointer. Fix this.

(cherry picked from FBD20883791)


  Commit: 1be7a82540978998a17eb7fc78d5f8abf5e6fd93
      https://github.com/llvm/llvm-project/commit/1be7a82540978998a17eb7fc78d5f8abf5e6fd93
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2019-11-11 (Mon, 11 Nov 2019)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  [BOLT] Speedup RTDyld external symbol resolution

Summary:
RuntimeDyldImpl::resolveExternalSymbols() some time ago used to call
getSymbolAddress() while in the second loop. That call could have
modified the contents of ExternalSymbolRelocations that the loop was
iterating over. Thus the code was written in a way that erased the
processed entry on every loop iteration and reset the map
iterator. With large number of entries in ExternalSymbolRelocations the
loop code becomes a performance bottleneck.

Since getSymbolAddress() is no longer used, the
ExternalSymbolRelocations could be iterated in a straightforward way and
the map cleared before the function exit.

(cherry picked from FBD21057058)


  Commit: 606532bdf19fbf31893a5486a4803858d5dec11d
      https://github.com/llvm/llvm-project/commit/606532bdf19fbf31893a5486a4803858d5dec11d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-16 (Thu, 16 Apr 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/Relocation.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix .eh_frame update with ICF in non-relocation mode

Summary:
In a rare case, we may fold a function and fail to emit it in
non-relocation mode due to a function size increase. At the same time,
the function that the original function was folded into could have been
successfully emitted, e.g. because it was split in the presence of a
profile information.

Later, because the function was not emitted, we have to use its original
.eh_frame entry in the preserved .eh_frame section. However, that entry
is no longer referencing the original function, but the function that
the original was folded into. This happens since the original symbol gets
emitted at the other function location. As a result, .eh_frame entry for
the folded function is missing.

To prevent incorrect update of the original .eh_frame, create
relocations against absolute values. This guarantees preservation of the
section contents while updating pc-relative references.

(cherry picked from FBD21061130)


  Commit: 10245b5c5bbee78b3c7005985ce68b7301ae1cbd
      https://github.com/llvm/llvm-project/commit/10245b5c5bbee78b3c7005985ce68b7301ae1cbd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-16 (Thu, 16 Apr 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Emit ICF symbols for large functions

Summary:
In non-relocation mode, make sure we emit extra symbols for a folded
function even if the function was not overwritten due to its large
size.

(cherry picked from FBD21080467)


  Commit: 23edb3ed9ce769d09d80d25cd1dab89a194f7dd9
      https://github.com/llvm/llvm-project/commit/23edb3ed9ce769d09d80d25cd1dab89a194f7dd9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-19 (Sun, 19 Apr 2020)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Option to control .text alignment

Summary:
Add option `-align-text=<n>` to control .text alignment within a
segment. Set to page size by default.

(cherry picked from FBD21120063)


  Commit: 33e0b2aa5806d7bced47c625915fd1144a5569c5
      https://github.com/llvm/llvm-project/commit/33e0b2aa5806d7bced47c625915fd1144a5569c5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-19 (Sun, 19 Apr 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Do not emit old .eh_frame in relocation mode

Summary:
In relocation mode, there is no use for old .eh_frame section. Moreover,
it can interfere with new EH frames via .eh_frame_hdr when the original
.text is reused.

(cherry picked from FBD21120070)


  Commit: 0ea98d1f0b4594d0a856364cdf454a32cad5f29e
      https://github.com/llvm/llvm-project/commit/0ea98d1f0b4594d0a856364cdf454a32cad5f29e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-22 (Wed, 22 Apr 2020)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Option to fail if invalid profile detected

Summary:
Add an option to fail processing of the input binary if the profile
is not accurate:

  -stale-threshold=<uint>
    - maximum percentage of stale functions to tolerate (default: 100)

Default (100) means never to fail.

A function profile is considered stale if any branch in its profile
has invalid source or destination.

Use `-stale-threshold=0` to fail if any staleness is detected in the
profile.

(cherry picked from FBD21189036)


  Commit: fbca177a83e4220531dee99d3ab2699fb9ccd67d
      https://github.com/llvm/llvm-project/commit/fbca177a83e4220531dee99d3ab2699fb9ccd67d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-23 (Thu, 23 Apr 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Speedup PLT processing

Summary:
With larger PLT sizes, linear PLT symbol name lookup becomes a
bottleneck.

(cherry picked from FBD21223695)


  Commit: ac1af09e82893e10a72dc7d05f04688dbcaedb74
      https://github.com/llvm/llvm-project/commit/ac1af09e82893e10a72dc7d05f04688dbcaedb74
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-24 (Fri, 24 Apr 2020)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT][NFC] Change wording while reporting functions stats

Summary:

(cherry picked from FBD21242167)


  Commit: 5296b6d12ac06fd3ad7b2f97e96baeb4a5a824f4
      https://github.com/llvm/llvm-project/commit/5296b6d12ac06fd3ad7b2f97e96baeb4a5a824f4
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-19 (Sun, 19 Apr 2020)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/ProfileReader.cpp
    M bolt/test/X86/issue26.test

  Log Message:
  -----------
  [BOLT] Change symbol handling for secondary function entries

Summary:
Some functions could be called at an address inside their function body.
Typically, these functions are written in assembly as C/C++ does not
have a multi-entry function concept. The addresses inside a function
body that could be referenced from outside are called secondary entry
points.

In BOLT we support processing functions with secondary/multiple entry
points. We used to mark basic blocks representing those entry points
with a special flag. There was only one problem - each basic block has
exactly one MCSymbol associated with it, and for the most efficient
processing we prefer that symbol to be local/temporary. However, in
certain scenarios, e.g. when running in non-relocation mode, we need
the entry symbol to be global/non-temporary.

We could create global symbols for secondary points ahead of time when
the entry point is marked in the symbol table. But not all such entries
are properly marked. This means that potentially we could discover an
entry point only after disassembling the code that references it, and
it could happen after a local label was already created at the same
location together with all its references. Replacing the local symbol
and updating the references turned out to be an error-prone process.

This diff takes a different approach. All basic blocks are created with
permanently local symbols. Whenever there's a need to add a secondary
entry point, we create an extra global symbol or use an existing one
at that location. Containing BinaryFunction maps a local symbol of a
basic block to the global symbol representing a secondary entry point.
This way we can tell if the basic block is a secondary entry point,
and we emit both symbols for all secondary entry points. Since secondary
entry points are quite rare, the overhead of this approach is minimal.

Note that the same location could be referenced via local symbol from
inside a function and via global entry point symbol from outside.
This is true for both primary and secondary entry points.

(cherry picked from FBD21150193)


  Commit: ac36e17a73c7c5dce7a557bf9c786b231f250726
      https://github.com/llvm/llvm-project/commit/ac36e17a73c7c5dce7a557bf9c786b231f250726
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-27 (Mon, 27 Apr 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][BFC] Refactor code for adding secondary function entries

Summary:
In non-relocation mode, the code for marking a function non-simple was
decoupled from the code that added new entry points.  Fix that.

(cherry picked from FBD21264247)


  Commit: b62a1774af28ef1a4abc228616b14d5140c89f15
      https://github.com/llvm/llvm-project/commit/b62a1774af28ef1a4abc228616b14d5140c89f15
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-04-26 (Sun, 26 Apr 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Cover PIC jump table reference in non-strict mode

Summary:
In non-strict relocation mode it was possible to miss a jump table
reference leading to incorrect code.

(cherry picked from FBD21251467)


  Commit: 4e69764c659f6b54f24d2388cf6f3dbfe084a06f
      https://github.com/llvm/llvm-project/commit/4e69764c659f6b54f24d2388cf6f3dbfe084a06f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-05-01 (Fri, 01 May 2020)

  Changed paths:
    M bolt/src/DynoStats.cpp

  Log Message:
  -----------
  [BOLT] Fix dyno stats after ICF in non-reloc mode

Summary:
The commit that fixed ICF determinism in non-relocation mode disabled
profile merging for functions. Dyno stats output needs to be updated to
reflect the lack of merge.

(cherry picked from FBD21366046)


  Commit: 04c5d4fcab08b285c97b084d282dc70a597d0d53
      https://github.com/llvm/llvm-project/commit/04c5d4fcab08b285c97b084d282dc70a597d0d53
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-05-03 (Sun, 03 May 2020)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/AllocCombiner.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/JTFootprintReduction.cpp
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/Passes/ReorderFunctions.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Introduce isIgnored() function attribute

Summary:
Whenever a function is not meant for processing, e.g. when the user
requests to optimize only a subset of functions, mark the function as
ignored. Use this attribute instead of opts::shouldProcess().

(cherry picked from FBD21374806)


  Commit: 924d0bdb08a387fa1c306a78e229a65db078d02c
      https://github.com/llvm/llvm-project/commit/924d0bdb08a387fa1c306a78e229a65db078d02c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-05-03 (Sun, 03 May 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Introduce lite processing mode without relocations

Summary:
When optimizing a binary without relocations, we can skip processing
functions without profile (cold functions). By skipping processing of
cold functions, we reduce the processing time and memory. We call
such mode a lite mode, and it is enabled by default.

Some processing is still done for functions without profile even in lite
mode. scanExternalRefs() function is used to detect secondary entry
points to functions that are not marked in the symbol table.

Note that the no-relocation requirement is a temporary limitation
of the lite mode.

(cherry picked from FBD21366567)


  Commit: 7b61bdf8ea975c0e916e068e03b873475fb154a7
      https://github.com/llvm/llvm-project/commit/7b61bdf8ea975c0e916e068e03b873475fb154a7
  Author: Xun Li <xun at fb.com>
  Date:   2020-05-04 (Mon, 04 May 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Check runtime lib format within archiver

Summary: We only support linking ELF runtime library right now. If the library is an archiver, we check that each individual library inside the archiver is an ELF library.

(cherry picked from FBD21388672)


  Commit: 96c4168ddc5291a6bab4fd60620db2b04f892af1
      https://github.com/llvm/llvm-project/commit/96c4168ddc5291a6bab4fd60620db2b04f892af1
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-05-06 (Wed, 06 May 2020)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [BOLT] Ignore kernel interrupts by default

(cherry picked from FBD21431563)


  Commit: 689447bf10860f6c22ec72a43d5bc5d91b85329d
      https://github.com/llvm/llvm-project/commit/689447bf10860f6c22ec72a43d5bc5d91b85329d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-05-05 (Tue, 05 May 2020)

  Changed paths:
    M bolt/llvm.patch
    M bolt/src/BinaryEmitter.cpp

  Log Message:
  -----------
  [BOLT] Change .debug_line emission for non-simple functions

Summary:
We use a special routine to emit line info for functions that we do not
overwrite. The resulting DWARF was not quite efficient as we were
advancing addresses using a larger than needed opcodes. Since there were
only a few functions that we didn't emit/overwrite, it was not a big
issue.

However, in lite mode the majority of functions are not overwritten and
as a result, the inefficiency in debug line encoding got exposed and
binaries were getting larger than expected .debug_line sections.

Fix it by using more conventional line table opcodes for address
advancing.

(cherry picked from FBD21423074)


  Commit: f91d121eee5f78fc0e2a2f94f06d5a438f10b80f
      https://github.com/llvm/llvm-project/commit/f91d121eee5f78fc0e2a2f94f06d5a438f10b80f
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-05-06 (Wed, 06 May 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add option to tag version

Summary:
Add a dummy option in BOLT to allow us to write any string in
the bolt info section. This is accomplished since we record the complete
argv vector. This string used to tag this binary with any ID that can
later be associated with a specific BOLT invocation.

(cherry picked from FBD21441902)


  Commit: cce49b95225605f466f7ac8f0afe76a622f1e091
      https://github.com/llvm/llvm-project/commit/cce49b95225605f466f7ac8f0afe76a622f1e091
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-05-14 (Thu, 14 May 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/Passes/BinaryFunctionCallGraph.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/ProfileReader.cpp
    M bolt/src/ProfileWriter.cpp

  Log Message:
  -----------
  [BOLT] Remove StringRef from IndirectCallProfile

Summary:
IndirectCallProfile was holding to a StringRef from a profile reader
providing an implicit dependency on the reader.

(cherry picked from FBD21587101)


  Commit: 872917118270fd1a5c46a0866acc6cbff47fca40
      https://github.com/llvm/llvm-project/commit/872917118270fd1a5c46a0866acc6cbff47fca40
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-05-07 (Thu, 07 May 2020)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.cpp
    M bolt/src/BinaryData.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/BoltAddressTranslation.h
    M bolt/src/CMakeLists.txt
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/ReorderData.cpp
    M bolt/src/Passes/ReorderData.h
    M bolt/src/Passes/StackPointerTracking.cpp
    A bolt/src/ProfileReaderBase.cpp
    A bolt/src/ProfileReaderBase.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    A bolt/src/YAMLProfileReader.cpp
    A bolt/src/YAMLProfileReader.h
    A bolt/src/YAMLProfileWriter.cpp
    A bolt/src/YAMLProfileWriter.h
    M bolt/src/llvm-bolt.cpp
    M bolt/src/merge-fdata/CMakeLists.txt

  Log Message:
  -----------
  [BOLT] Refactor profile-handling code

Summary:
This diff handles several issues related to profile reading and
handling:
  * Unifies interface used by 3 profile readers in ProfileReaderBase.
  * Adds automatic detection of the profile file contents.
  * Removes reader-specific fields from BinaryFunction and BinaryData.
    All the information is stored in instruction annotations.
  * Removes implicit memory dependencies in annotations on profile
    reader instance.
  * Adds lite mode support to YAML reader.
  * Moves profile reading code out of BinaryFunction.

(cherry picked from FBD21601411)


  Commit: 8a680745dd58692be0871155c0a5599190707946
      https://github.com/llvm/llvm-project/commit/8a680745dd58692be0871155c0a5599190707946
  Author: Xun Li <xun at fb.com>
  Date:   2020-05-21 (Thu, 21 May 2020)

  Changed paths:
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Remove const call to take_front

Summary:
take_front() is a const member of StringRef. Calling it does nothing.
This suggests that this line of code is useless, deleting it.
But it's good to double check, what was the original intention here?

(cherry picked from FBD21697637)


  Commit: 2b65b3aa6b0897d1eb97cdf4c51b0ff94a40d5f1
      https://github.com/llvm/llvm-project/commit/2b65b3aa6b0897d1eb97cdf4c51b0ff94a40d5f1
  Author: Xun Li <xun at fb.com>
  Date:   2020-05-21 (Thu, 21 May 2020)

  Changed paths:
    M bolt/src/Passes/ReorderAlgorithm.cpp

  Log Message:
  -----------
  Use shuffle instead of random_shuffle

Summary: random_shuffle is deprecated in C++14.

(cherry picked from FBD21698180)


  Commit: cd067ae1e8e0614a19b806dc1a3370fb2edd33d0
      https://github.com/llvm/llvm-project/commit/cd067ae1e8e0614a19b806dc1a3370fb2edd33d0
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-05-26 (Tue, 26 May 2020)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinarySection.cpp
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    A bolt/src/NameShortener.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Emit functions on MachO

Summary: Start emitting  functions (for MachO input binaries).

(cherry picked from FBD21721586)


  Commit: 00892a5fd0fe1c3a8f58071abd8ca166856bf1b8
      https://github.com/llvm/llvm-project/commit/00892a5fd0fe1c3a8f58071abd8ca166856bf1b8
  Author: Xun Li <xun at fb.com>
  Date:   2020-05-21 (Thu, 21 May 2020)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/CMakeLists.txt
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    A bolt/src/Passes/InstrumentationSummary.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    A bolt/src/RuntimeLibs/CMakeLists.txt
    A bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    A bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h
    A bolt/src/RuntimeLibs/RuntimeLibrary.cpp
    A bolt/src/RuntimeLibs/RuntimeLibrary.h

  Log Message:
  -----------
  Refactor runtime library

Summary:
As we are adding more types of runtime libraries, it would be better to move the runtime library out of RewriteInstance so that it could grow separately. This also requires splitting the current implementation of Instrumentation.cpp to two separate pieces, one as normal Pass, one as the runtime library. The Instrumentation Pass would pass over the generated data to the runtime library, which will use to emit binary and perform linking.

This patch does the following:
1. Turn Instrumentation class into an optimization pass. Register the pass in the pass manager instead of in RewriteInstance.
2. Split all the data that are generated by Instrumentation that's needed by runtime library into a separate data structure called InstrumentationSummary. At the creation of Instrumentation pass, we create an instance of such data structure, which will be moved over to the runtime at the end of the pass.
3. Added a runtime library member to BinaryContext. Set the member at the end of Instrumentation pass.
4. In BinaryEmitter, make BinaryContext to also emit runtime library binary.
5. Created a base class RuntimeLibrary, that defines the interface of a runtime library, along with a few common helper functions.
6. Created InstrumentationRuntimeLibrary which inherits from RuntimeLibrary, that does all the work (mostly copied over) for emit and linking.
7. Added a new directory called RuntimeLibs, and put all the runtime library related files into it.

(cherry picked from FBD21694762)


  Commit: 9bd71615290d9b499d3d1ff8bab29758bfee9002
      https://github.com/llvm/llvm-project/commit/9bd71615290d9b499d3d1ff8bab29758bfee9002
  Author: Xun Li <xun at fb.com>
  Date:   2020-05-02 (Sat, 02 May 2020)

  Changed paths:
    M bolt/runtime/CMakeLists.txt
    A bolt/runtime/common.h
    A bolt/runtime/hugify.cpp
    M bolt/runtime/instr.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/RuntimeLibs/CMakeLists.txt
    A bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp
    A bolt/src/RuntimeLibs/HugifyRuntimeLibrary.h
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h
    M bolt/src/RuntimeLibs/RuntimeLibrary.h

  Log Message:
  -----------
  Adding automatic huge page support

Summary:
This patch enables automated hugify for Bolt.
When running Bolt against a binary with -hugify specified, Bolt will inject a call to a runtime library function at the entry of the binary. The runtime library calls madvise to map the hot code region into a 2M huge page. We support both new kernel with THP support and old kernels. For kernels with THP support we simply make a madvise call, while for old kernels, we first copy the code out, remap the memory with huge page, and then copy the code back.
With this change, we no longer need to manually call into hugify_self and precompile it with --hot-text. Instead, we could simply combine --hugify option with existing optimizations, and at runtime it will automatically move hot code into 2M pages.

Some details around the changes made:
1. Add an command line option to support --hugify. --hugify will automatically turn on --hot-text to get the proper hot code symbols. However, running with both --hugify and --hot-text is not allowed, since --hot-text is used on binaries that has precompiled call to hugify_self, which contradicts with the purpose of --hugify.
2. Moved the common utility functions out of instr.cpp to common.h, which will also be used by hugify.cpp. Added a few new system calls definitions.
3. Added a new class that inherits RuntimeLibrary, and implemented the necessary emit and link logic for hugify.
4. Added a simple test for hugify.

(cherry picked from FBD21384529)


  Commit: 2d524fd5e22f2faea123566ac1b21b7e0a5d0b53
      https://github.com/llvm/llvm-project/commit/2d524fd5e22f2faea123566ac1b21b7e0a5d0b53
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-09 (Tue, 09 Jun 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Update section index for symbols from unemitted functions

Summary:
Under some conditions, e.g. while running in lite mode or when a
function is non-simple, BOLT may decide not to emit function code and
hence there's no need to update the symbol. However, since we change
section table, the corresponding section index may need an update.

Also, update section index for ICF symbols.

(cherry picked from FBD21970017)


  Commit: 48b71ad219c1894e52f8bcb86a118c1ec1c12466
      https://github.com/llvm/llvm-project/commit/48b71ad219c1894e52f8bcb86a118c1ec1c12466
  Author: takh <takh at fb.com>
  Date:   2020-06-10 (Wed, 10 Jun 2020)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/Heatmap.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  Generate heatmap for linux kernel

Summary:
This diff handles several challenges related to heatmap generation for Linux kernel (vmlinux elf file):
- If the input binary elf file contains the section `__ksymtab`, this diff assumes that this is the linux kernel `vmlinux` file and enables an extra flag `LinuxKernelMode`
- In `LinuxKernelMode`, we only support heat map generation right now, therefore it ensures that current BOLT mode is heat map generation. Otherwise, it exits with error.
- For some Linux symbol and section combinations, BOLT may not be able to find section for symbol (specially symbols that specifies the end of some section). For such cases, we show an warning message without exiting which was the previous behavior.
- Linux kernel elf file does not contain dynamic section, therefore, we don't exit when no dynamic section is found for linux kernel binary.
- Current `ParseMMap` logic does not work with linux kernel. MMap entries for linux kernel uses `PERF_RECORD_MMAP` format instead of typical `PERF_RECORD_MMAP2` format. Since linux kernel address mapping is absolute (same as specified in the ELF file), we avoid calling `ParseMMap` in linux kernel mode.
- Linux kernel entries are registered with PID -1, therefore `BinaryMMapInfo` lookup is not required for linux kernel entries. Similarly, `adjustLBR` is also not required.
- Default max address in linux kernel mode is highest unsigned 64-bit integer instead of current 4GBs.
- Added another new parameter for heatmap, `MinAddress`, in case of Linux kernel mode which is `KernelBaseAddress`, otherwise, it is 0. While registering Heatmap sample counts from LBR entries, any address lower than this `MinAddress` is ignored.
- `IgnoreInterruptLBR` is disabled in linux kernel mode to ensure that kernel entries are processed

Currently, linux kernel heat map also include heat map for Linux kernel modules that are not part of vmlinux elf file. This is intentional to identify other potential optimization opportunities. If reviewers think, those modules should be omitted, I will disable those modules based on highest end address of a vmlinux elf section.

(cherry picked from FBD21992765)


  Commit: 7950e1e5bb603ba302515ab84022ffbcc2c9d4e8
      https://github.com/llvm/llvm-project/commit/7950e1e5bb603ba302515ab84022ffbcc2c9d4e8
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-06-15 (Mon, 15 Jun 2020)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  Provide a redundant declaration of KernelBaseAddr

Summary: Adjust the code to make it buildable with clang-10.

(cherry picked from FBD22055933)


  Commit: 0823882d47b8c21c22be36526d059c19a615fda4
      https://github.com/llvm/llvm-project/commit/0823882d47b8c21c22be36526d059c19a615fda4
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-06-12 (Fri, 12 Jun 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h

  Log Message:
  -----------
  Link functions on MachO

Summary: Add first bits for linking functions on MachO.

(cherry picked from FBD21991721)


  Commit: e22378d20aa289e297298eb65d348b5f33c5da3d
      https://github.com/llvm/llvm-project/commit/e22378d20aa289e297298eb65d348b5f33c5da3d
  Author: Xun Li <xun at fb.com>
  Date:   2020-06-16 (Tue, 16 Jun 2020)

  Changed paths:
    M bolt/src/RuntimeLibs/RuntimeLibrary.cpp

  Log Message:
  -----------
  Be more flexible when locating runtime libs

Summary:
In some cases we install bolt binary into one level deeper in bin/, such as bin/install/, we need to go back one more level to find lib directory.

(cherry picked from FBD22070974)


  Commit: 0ce0bce9e72e6983712a1c593d36eda7cad3d12a
      https://github.com/llvm/llvm-project/commit/0ce0bce9e72e6983712a1c593d36eda7cad3d12a
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-15 (Mon, 15 Jun 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/PatchEntries.cpp
    A bolt/src/Passes/PatchEntries.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    M bolt/src/Utils.h

  Log Message:
  -----------
  [BOLT] Support for lite mode with relocations

Summary:
Add '-lite' support for relocations for improved processing time,
memory consumption, and more resilient processing of binaries with
embedded assembly code.

In lite relocation mode, BOLT will skip full processing of functions
without a profile. It will run scanExternalRefs() on such functions
to discover external references and to create internal relocations
to update references to optimized functions.

Note that we could have relied on the compiler/linker to provide
relocations for function references. However, there's no assurance
that all such references are reported. E.g., the compiler can resolve
inter-procedural references internally, leaving no relocations
for the linker.

The scan process takes about <10 seconds per 100MB of code on modern
hardware. It's a reasonable overhead to live with considering the
flexibility it provides.

If BOLT fails to scan or disassemble a function, .e.g., due to a data
object embedded in code, or an unsupported instruction, it enables a
patching mode to guarantee that the failed function will call
optimized/moved versions of functions. The patching happens at original
function entry points.

'-skip=<func1,func2,...>' option now can be used to skip processing of
arbitrary functions in the relocation mode.

With '-use-old-text' or '-strict' we require all functions to be
processed. As such, it is incompatible with '-lite' option,
and '-skip' option will only disable optimizations of listed
functions, not their disassembly and emission.

(cherry picked from FBD22040717)


  Commit: e7c34642269d82107af190581e072c25b3d0a606
      https://github.com/llvm/llvm-project/commit/e7c34642269d82107af190581e072c25b3d0a606
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-18 (Thu, 18 Jun 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Disable trapping on AVX-512 by default

Summary:

(cherry picked from FBD22118562)


  Commit: db4642d0a68a0dbf053d351b0f2550f6c1b938a8
      https://github.com/llvm/llvm-project/commit/db4642d0a68a0dbf053d351b0f2550f6c1b938a8
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-18 (Thu, 18 Jun 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Support -hot-text in lite mode

Summary: Update special symbol references in functions that are not emitted.

(cherry picked from FBD22120995)


  Commit: 15fffe282400a8aea43746f4bc4a466a89c7b0ea
      https://github.com/llvm/llvm-project/commit/15fffe282400a8aea43746f4bc4a466a89c7b0ea
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-18 (Thu, 18 Jun 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fix memory error

Summary: Fix for double-free I've introduced earlier.

(cherry picked from FBD22132595)


  Commit: 8374e8e3fedcdc16555d05d53438448e7ffe240f
      https://github.com/llvm/llvm-project/commit/8374e8e3fedcdc16555d05d53438448e7ffe240f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-22 (Mon, 22 Jun 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Properly register symbols at secondary entry points

Summary:
We may end up with a secondary entry symbol set to zero if there was no
symbol in the input file at the entry point address, and if we skipped
the function emission, e.g. if it was ignored. In that case, the symbol
should be properly initialized with a proper address.

(cherry picked from FBD22169167)


  Commit: 0403adde327da928015640d1c9d9da4b348119ff
      https://github.com/llvm/llvm-project/commit/0403adde327da928015640d1c9d9da4b348119ff
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-22 (Mon, 22 Jun 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Fixes for scanExternalRefs()

Summary:
In my previous commit, I've accidentally reverted the condition while
evaluating a branch target.

Also, do not emit instruction for relocation purposes in
scanExternalRefs() if there was no TargetSymbol set and we have not
produced new relocations.

(cherry picked from FBD22169317)


  Commit: efce443e0da6cc75c5776ac786d82986de2e27c3
      https://github.com/llvm/llvm-project/commit/efce443e0da6cc75c5776ac786d82986de2e27c3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-22 (Mon, 22 Jun 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Create entry points for internal refs from external code

Summary:
If we detect an internal function reference from code outside of the
function, then create an entry point at that location.

(cherry picked from FBD22169337)


  Commit: 12b7987d4fc309771275049675557e474d673937
      https://github.com/llvm/llvm-project/commit/12b7987d4fc309771275049675557e474d673937
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-22 (Mon, 22 Jun 2020)

  Changed paths:
    M bolt/src/Passes/ValidateInternalCalls.cpp

  Log Message:
  -----------
  [BOLT] Ignore functions that failed validation

Summary:
If a function failed internal calls validation, we can ignore it and
keep processing the binary.

(cherry picked from FBD22169381)


  Commit: ae296ea66582f9986a7489d50d8a590ec67f9ba8
      https://github.com/llvm/llvm-project/commit/ae296ea66582f9986a7489d50d8a590ec67f9ba8
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-22 (Mon, 22 Jun 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Allow to overwrite -use-old-text option

(cherry picked from FBD22169409)


  Commit: 4946b881a82516df6640694b2936cc2a77181cb6
      https://github.com/llvm/llvm-project/commit/4946b881a82516df6640694b2936cc2a77181cb6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-22 (Mon, 22 Jun 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Fix getNewValueForSymbol()

Summary:
getNewValueForSymbol() uses orc::RTDyldObjectLinkingLayer::findSymbol()
to resolve symbol values. The latter will always return JITSymbol,
even if there was no symbol defined. The address for the undefined
symbol will be zero, but some symbols could legally be resolved to zero
too.

We need to distinguish between real zero-valued symbols and symbols that
were not emitted and are not visible by orc::RTDyldObjectLinkingLayer.
If zero address is returned by ORC, check for a binary data with the
same name and use its address for the symbol resolution.

(cherry picked from FBD22175269)


  Commit: 13baf47a3cdc867918273fa4bf616512f0bf0560
      https://github.com/llvm/llvm-project/commit/13baf47a3cdc867918273fa4bf616512f0bf0560
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-22 (Mon, 22 Jun 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Passes/PatchEntries.cpp

  Log Message:
  -----------
  [BOLT] Add '-force-patch' to forcefully patch old entries

Summary:
The option is useful for debugging.

Also, print personality function when dumping a function.

(cherry picked from FBD22169482)


  Commit: 4aaa8892ddbe16887cab58270914695e09ee07de
      https://github.com/llvm/llvm-project/commit/4aaa8892ddbe16887cab58270914695e09ee07de
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-23 (Tue, 23 Jun 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Ignore duplicate relocations

Summary:
lld linker may emit static relocations against addresses that also have
dynamic relocations associated with them. When this happens, BOLT fails
to validate the extracted value at the address.

Read dynamic relocations in the binary and ignore static relocations at
addresses that have a duplicate dynamic relocation.

(cherry picked from FBD22192345)


  Commit: 94230a2c074a44e4bde09046b8bc499cba2d5982
      https://github.com/llvm/llvm-project/commit/94230a2c074a44e4bde09046b8bc499cba2d5982
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-25 (Thu, 25 Jun 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [perf2bolt] Relax rules for aggregation in strict mode

Summary:
While aggregating perf.data events, even in strict mode, there is no
need to process all functions since we are not generating an output
binary. However, it's still important to convert data for as many
functions as possible, even for ones with unknown internal control flow.

(cherry picked from FBD22248390)


  Commit: 250ca4082ece099b81822d27095695790b034026
      https://github.com/llvm/llvm-project/commit/250ca4082ece099b81822d27095695790b034026
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-26 (Fri, 26 Jun 2020)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/ExecutableFileMemoryManager.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Add static binary support

Summary:
Accept binaries without dynamic section/segment as a valid input.

Modify the check for invalid debug info "executables" that are result of
running "objcopy --only-keep-debug". Instead of checking for an empty
dynamic segment, check that ".text" is mapped into a valid segment.

Move SegmentMapInfo inside BinaryContext.

Fixes facebookincubator/BOLT#91

Temporarily removing issue*.test tests that use yaml2obj and operate on
fake binaries.

(cherry picked from FBD22271481)


  Commit: ffaba22476f0a0be96a7eec729f5a8ef1cfbb019
      https://github.com/llvm/llvm-project/commit/ffaba22476f0a0be96a7eec729f5a8ef1cfbb019
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-24 (Wed, 24 Jun 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Do not emit duplicate org symbols

Summary:
When adding symbols for patched functions, we may end up emitting
multiple symbols per function if the function has multiple names (e.g.
after identical code folding by the linker).

(cherry picked from FBD22294112)


  Commit: 41cb6b68ed0791be2d7ff6cd484e76e838a4a1aa
      https://github.com/llvm/llvm-project/commit/41cb6b68ed0791be2d7ff6cd484e76e838a4a1aa
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-06-24 (Wed, 24 Jun 2020)

  Changed paths:
    M bolt/test/X86/pre-aggregated-perf.test

  Log Message:
  -----------
  Update X86/pre-aggregated-perf.test

Summary:
Add REQUIRED statement.

(cherry picked from FBD22290759)


  Commit: 26ad0bd9519e60c9d84182b4a2a7fb9f10ed5dd6
      https://github.com/llvm/llvm-project/commit/26ad0bd9519e60c9d84182b4a2a7fb9f10ed5dd6
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-06-30 (Tue, 30 Jun 2020)

  Changed paths:
    A bolt/test/X86/issue20.s
    A bolt/test/X86/issue26.s
    M bolt/test/X86/pre-aggregated-perf.test

  Log Message:
  -----------
  [TESTS] Re-add issue20/issue26 tests

Summary:
Re-add tests removed because they used to depend on yaml2obj.
Rewrite them with an assembler (llvm-mc) and use the system linker to
produce a valid ELF as input to BOLT.

(cherry picked from FBD22323449)


  Commit: e233dec4676dc3fdbbedfd7e599482a257301a0b
      https://github.com/llvm/llvm-project/commit/e233dec4676dc3fdbbedfd7e599482a257301a0b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-06-30 (Tue, 30 Jun 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Skip R_X86_64_PLT32 relocation verification

Summary:
R_X86_64_PLT32 relocations recorded by the linker may point to the PLT
section instead of being resolved to the symbol reported by the
relocation. Sometimes they could point to the symbol too. Disable
internal verification for this type of relocation.

Include a fix for symbol address calculation when it is based on the
extracted value. The truncation to the relocation size is needed if
the results overflows.

(cherry picked from FBD22317952)


  Commit: 84eae1a413a97f8dcc412cecf907016cb2ff7918
      https://github.com/llvm/llvm-project/commit/84eae1a413a97f8dcc412cecf907016cb2ff7918
  Author: Xun Li <xun at fb.com>
  Date:   2020-07-02 (Thu, 02 Jul 2020)

  Changed paths:
    M bolt/runtime/hugify.cpp
    M bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/RuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/RuntimeLibrary.h

  Log Message:
  -----------
  [Bolt] Improve coding style for runtime lib related code

Summary:
Reading through the LLVM coding standard again, realized a few places where I didn't follow the standard when coding. Addressing them:
1. prefer static functions over functions in unnamed namespace.
2. #include as little as possible in headers
3. Have vtable anchors.

(cherry picked from FBD22353046)


  Commit: a9fac6a89fac8a9e7bce834ab5c7aafd531034a5
      https://github.com/llvm/llvm-project/commit/a9fac6a89fac8a9e7bce834ab5c7aafd531034a5
  Author: takh <takh at fb.com>
  Date:   2020-06-18 (Thu, 18 Jun 2020)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/Heatmap.cpp
    M bolt/src/Heatmap.h

  Log Message:
  -----------
  Support for CDF distribution of heatmap buckets

Summary: This diff adds the support for generating CDF distributions of heatmap buckets.

(cherry picked from FBD22128291)


  Commit: 3e795c8a5f32e96d9a6ac44e2c8712e75aa8d6d0
      https://github.com/llvm/llvm-project/commit/3e795c8a5f32e96d9a6ac44e2c8712e75aa8d6d0
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-07-06 (Mon, 06 Jul 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinarySection.h

  Log Message:
  -----------
  [BOLT] Ignore addresses from non-allocatable sections

Summary:
We've accidentally registered TBSS section address with a BinaryContext
resulting in addresses being attributed to it when
getSectionForAddress() was called.

(cherry picked from FBD22369323)


  Commit: f40ffa0dc8b98df7351229405b837056fac6cb20
      https://github.com/llvm/llvm-project/commit/f40ffa0dc8b98df7351229405b837056fac6cb20
  Author: Tanvir Ahmed Khan <takh at fb.com>
  Date:   2020-07-06 (Mon, 06 Jul 2020)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  Report stale sample count and percentage

Summary: This diff adds extra reporting of total number of stale branch samples for the binary.

(cherry picked from FBD22304965)


  Commit: 181327d7633ff8a49c30baedd844e160d861f8f6
      https://github.com/llvm/llvm-project/commit/181327d7633ff8a49c30baedd844e160d861f8f6
  Author: Angélica Moreira <angelicaam at fb.com>
  Date:   2020-07-07 (Tue, 07 Jul 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    A bolt/src/Passes/BranchPredictionInfo.cpp
    A bolt/src/Passes/BranchPredictionInfo.h
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/FeatureMiner.cpp
    A bolt/src/Passes/FeatureMiner.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLT] Add the FeatureMiner pass to extract Calder's features.

(cherry picked from FBD19844247)


  Commit: 170f73ac9e1c208e508ebc3c9c426db80085be12
      https://github.com/llvm/llvm-project/commit/170f73ac9e1c208e508ebc3c9c426db80085be12
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-07-15 (Wed, 15 Jul 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    A bolt/test/X86/fix-branches-jrcxz.s

  Log Message:
  -----------
  [BOLT] Fix fix-branches in presence of JRCXZ and friends

Summary:
Do not fail/assert when trying to reorder blocks that terminate
with JRCXZ/JECXZ/LOOP instructions. We cannot invert the condition of
these instructions, so just treat them accordingly in fixBranches().

(cherry picked from FBD22487107)


  Commit: 6c8fc28892c71a89ba5e7f2b07287adf771be1a2
      https://github.com/llvm/llvm-project/commit/6c8fc28892c71a89ba5e7f2b07287adf771be1a2
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-07-16 (Thu, 16 Jul 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/CMakeLists.txt
    M bolt/src/RewriteInstance.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  Revert "[BOLT] Add the FeatureMiner pass to extract Calder's features."

This reverts commit 2476f46af02ccce04e9ed456462dd098460e4e1f.

Reviewed By: maks

(cherry picked from FBD28111787)


  Commit: 937244b4f248e368fca3c2ea2c8de0f5aafc6408
      https://github.com/llvm/llvm-project/commit/937244b4f248e368fca3c2ea2c8de0f5aafc6408
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-07-17 (Fri, 17 Jul 2020)

  Changed paths:
    M bolt/src/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  [BOLT] Allow to specify -reorder-functions option multiple times

Summary: Need to be able to override the option.

(cherry picked from FBD22583585)


  Commit: f7d4bed9d1bf68f11bbb4ab2e0f5fc4a79413ef7
      https://github.com/llvm/llvm-project/commit/f7d4bed9d1bf68f11bbb4ab2e0f5fc4a79413ef7
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-07-17 (Fri, 17 Jul 2020)

  Changed paths:
    M bolt/src/Passes/Instrumentation.cpp

  Log Message:
  -----------
  Extracted sequence insertion function into helper function

Summary: Factored out common code from multiple places into a helper function

(cherry picked from FBD22606101)


  Commit: 6b89a9cb444afb9e115c287c02200036b0a258a6
      https://github.com/llvm/llvm-project/commit/6b89a9cb444afb9e115c287c02200036b0a258a6
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-07-17 (Fri, 17 Jul 2020)

  Changed paths:
    M bolt/src/Passes/Instrumentation.cpp

  Log Message:
  -----------
  Handle intra-function call in instrumentOneTarget

Summary: Added handling of intra-function calls (internal control transfer by call instruction) to instrumentOneTarget

(cherry picked from FBD22606033)


  Commit: ed029462816e4bae5bdf1f0897889feae34d55ed
      https://github.com/llvm/llvm-project/commit/ed029462816e4bae5bdf1f0897889feae34d55ed
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-07-24 (Fri, 24 Jul 2020)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp
    A bolt/test/X86/Inputs/user_func_order.txt
    A bolt/test/X86/user-func-reorder.c

  Log Message:
  -----------
  [BOLT] Fix hot_end symbol update with user function order

Summary:
If no profile data is provided, but only a user-provided order
file for functions, fix the placement of the __hot_end symbol.

(cherry picked from FBD22713265)


  Commit: c6799a689df719ca7ceee53774691bf6ac839157
      https://github.com/llvm/llvm-project/commit/c6799a689df719ca7ceee53774691bf6ac839157
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-07-27 (Mon, 27 Jul 2020)

  Changed paths:
    M bolt/runtime/common.h
    M bolt/runtime/hugify.cpp
    M bolt/runtime/instr.cpp
    M bolt/test/X86/user-func-reorder.c

  Log Message:
  -----------
  [BOLT] Fix stack alignment for runtime lib

Summary:
Right now, the SAVE_ALL sequence executed upon entry of both
of our runtime libs (hugify and instrumentation) will cause the stack to
not be aligned at a 16B boundary because it saves 15 8-byte regs. Change
the code sequence to adjust for that. The compiler may generate code
that assumes the stack is aligned by using movaps instructions, which
will crash.

(cherry picked from FBD22744307)


  Commit: 8f7cb54ae5a75cb72e25e3e0bb3e7d0f3d99b8c1
      https://github.com/llvm/llvm-project/commit/8f7cb54ae5a75cb72e25e3e0bb3e7d0f3d99b8c1
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-07-27 (Mon, 27 Jul 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/SplitFunctions.cpp
    M bolt/src/Passes/SplitFunctions.h

  Log Message:
  -----------
  Added execution count threshold option

Summary:
Added execution count threshold option (execution-count-threshold) controlling the optimizations that are sensitive to the accuracy of the profiling data:
- BB reordering
- function splitting
- frame opts
- shrink wrapping
- indirect call promotion

(cherry picked from FBD22682171)


  Commit: 8f2a96286605f7dbb29374e437f572ee093caa2d
      https://github.com/llvm/llvm-project/commit/8f2a96286605f7dbb29374e437f572ee093caa2d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-08-04 (Tue, 04 Aug 2020)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [perf2bolt] Fix for SKL bug workaround

Summary:
Some LBR traces contain less than 16/32 entries. When the first trace is
less than the standard length, we fail to enable SKL bug workaround with
BAT mode enabled. The result is a bad profile from perf2bolt. The fix
is to check the length of every trace, not just the first one.

Issue facebookincubator/BOLT#94

(cherry picked from FBD22917971)


  Commit: 0033a7612d546ce38fe2f350ffa8b601386944bb
      https://github.com/llvm/llvm-project/commit/0033a7612d546ce38fe2f350ffa8b601386944bb
  Author: takh <takh at fb.com>
  Date:   2020-08-04 (Tue, 04 Aug 2020)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  Linux kernel marker to update special sections

Summary: This diff adds SDT marker like LK marker to update special lk sections

(cherry picked from FBD22932157)


  Commit: 6547813d1fb6509bbca56c423e8707b3fd7894fd
      https://github.com/llvm/llvm-project/commit/6547813d1fb6509bbca56c423e8707b3fd7894fd
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-08-06 (Thu, 06 Aug 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Print when we are operating in lite mode

Summary:

(cherry picked from FBD22968343)


  Commit: 8b989765f63cc416a36e88a36720473a2e5904d2
      https://github.com/llvm/llvm-project/commit/8b989765f63cc416a36e88a36720473a2e5904d2
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-07-21 (Tue, 21 Jul 2020)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  Add first bits to support emitting more than 255 sections on MachO

Summary:
Add first bits to support emitting more than 255 sections.
Update llvm.patch to include the changes in MachOObjectFile.cpp.

(cherry picked from FBD22655053)


  Commit: aaf49b095f58ff95cfeec5add70556fb21bff3c8
      https://github.com/llvm/llvm-project/commit/aaf49b095f58ff95cfeec5add70556fb21bff3c8
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-08-12 (Wed, 12 Aug 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [perf2bolt] Issue error when writing YAML for BOLTed input

Summary:
When the input file is processed by BOLT, we cannot save profile in YAML
format as it requires CFG representation of functions.

(cherry picked from FBD22941794)


  Commit: 9bc4a8db18bb44ef091635044e446e8c2f4bec4a
      https://github.com/llvm/llvm-project/commit/9bc4a8db18bb44ef091635044e446e8c2f4bec4a
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-08-18 (Tue, 18 Aug 2020)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  Fix BAT cold-to-hot mappings

Summary:
Right now, if activity is recorded in cold parts, we write to
the .fdata file the ".cold" name instead of the correct name of the
function. Fix this.

(cherry picked from FBD23148705)


  Commit: 8c4ba8f16550ff7a8d69f64b1e07746dcef7d511
      https://github.com/llvm/llvm-project/commit/8c4ba8f16550ff7a8d69f64b1e07746dcef7d511
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-08-20 (Thu, 20 Aug 2020)

  Changed paths:
    M bolt/src/Passes/ShrinkWrapping.cpp
    A bolt/test/X86/shrinkwrapping-critedge.s

  Log Message:
  -----------
  Bugfix for splitting critical edges in shrink wrapping

Summary:
Fix issue with splitting critical edges originating at
the same BB in ShrinkWrapping::splitFrontierCritEdges.

Splitting of critical edges originating at the same FromBB
wasn't handled correctly as the Frontier at index corresponding
to FromBB was overwritten with basic blocks created for
multiple DestinationBBs.

(cherry picked from FBD23232398)


  Commit: 62469b503671162a01f3c7343c804228e1759279
      https://github.com/llvm/llvm-project/commit/62469b503671162a01f3c7343c804228e1759279
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-09-14 (Mon, 14 Sep 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Do no map sections with zero address

Summary:
Sections that do not originate from the input binary will have an
input address set to zero and thus do not have to be mapped.

Mapping such sections caused a build time regression in non-relocation
mode.

(cherry picked from FBD23670334)


  Commit: a82cff0f52a87db225f63336c2f2e472e62a69db
      https://github.com/llvm/llvm-project/commit/a82cff0f52a87db225f63336c2f2e472e62a69db
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-09-14 (Mon, 14 Sep 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  [BOLT] Eliminate "shallow" function lookup

Summary:
Whenever we search for a function based on its address in the input
binary, we now always return a corresponding fragment for split
functions. If the user needs an access to the main fragment, they can
call getTopmostFragment().

(cherry picked from FBD23670311)


  Commit: a10f799290e6ec789fa32d0d396c3b59ddf2d002
      https://github.com/llvm/llvm-project/commit/a10f799290e6ec789fa32d0d396c3b59ddf2d002
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-09-15 (Tue, 15 Sep 2020)

  Changed paths:
    M bolt/src/BinarySection.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][Linux] Initial support for special Linux Kernel sections

Summary:
Enable initial support for reading and patching special Linux kernel sections.

Author: Tanvir Ahmed Khan <takh at fb.com>

GitHub Author: takhandipu

(cherry picked from FBD22998869)


  Commit: 0601ae643859016ea57777a52a528fed9dd3936f
      https://github.com/llvm/llvm-project/commit/0601ae643859016ea57777a52a528fed9dd3936f
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-09-24 (Thu, 24 Sep 2020)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h

  Log Message:
  -----------
  Set InputFileOffset for MachO sections

Summary: Set InputFileOffset for MachO sections.

(cherry picked from FBD23903542)


  Commit: d1ec11b28f4dc4a4e50f2b2f51133b3450272396
      https://github.com/llvm/llvm-project/commit/d1ec11b28f4dc4a4e50f2b2f51133b3450272396
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-09-29 (Tue, 29 Sep 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  postProcessEntryPoints: return after setIgnored and setSimple are set

Summary:
This patch fixes the assertion failure during instrumentation.

The assertion is raised by `getInstructionAtOffset` , which expects `CurrentState` to be either `Disassembled` or `CFG`.

The function is called from `postProcessEntryPoints`, which goes over Labels and performs a series of checks. The checks call BinaryFunction methods `setSimple(false)` or `setIgnored()`.
However, if `setIgnored` is invoked, it resets the state to `Empty`. Thus subsequent call to `getInstructionAtOffset` will fail.

(cherry picked from FBD24005197)


  Commit: 2808c800e8c2fe85d32ccd4190e82e2ab43b1867
      https://github.com/llvm/llvm-project/commit/2808c800e8c2fe85d32ccd4190e82e2ab43b1867
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-09-30 (Wed, 30 Sep 2020)

  Changed paths:
    M bolt/src/MachORewriteInstance.cpp

  Log Message:
  -----------
  Read the entry point address on MachO

Summary: Read the entry point address on MachO

(cherry picked from FBD24039370)


  Commit: d7fb998637a28108d657dc7e2722ad318ace3701
      https://github.com/llvm/llvm-project/commit/d7fb998637a28108d657dc7e2722ad318ace3701
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M bolt/src/Relocation.cpp
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp
    A bolt/test/X86/section_reloc_with_addend.s

  Log Message:
  -----------
  [BOLT] Fix sign issue when validating X86 relocations

Summary:
In analyzeRelocations, we extract the result of the relocation
from binary code to recreate the target of it in a few special cases.
For R_X86_64_32S relocations, however, we were neglecting the
possibility of the encoded value in the instruction to be negative.

(cherry picked from FBD24096347)


  Commit: 71e185f2dac683bdd973c17532da2390ab86bddc
      https://github.com/llvm/llvm-project/commit/71e185f2dac683bdd973c17532da2390ab86bddc
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-10-05 (Mon, 05 Oct 2020)

  Changed paths:
    M bolt/llvm.patch
    M bolt/src/MachORewriteInstance.cpp

  Log Message:
  -----------
  Add -check-overlapping-elements option

Summary:
This diff adds a command line option to disable the check of overlapping elements in Mach-O parsing. This check in its current form is prohibitively expensive for large binaries.
A long-term fix would be to reimplement the check in a more efficient manner (and contribute it to the upstream).

(cherry picked from FBD24109468)


  Commit: 59c21b42dacf783cb05fd5de12b2e06fd7810628
      https://github.com/llvm/llvm-project/commit/59c21b42dacf783cb05fd5de12b2e06fd7810628
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-10-06 (Tue, 06 Oct 2020)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  Precompute symbol section indices on MachO

Summary: Precompute symbol section indices on Mach-O.

(cherry picked from FBD24133810)


  Commit: 35632d4828c0677461d1d881963224c1e61f2640
      https://github.com/llvm/llvm-project/commit/35632d4828c0677461d1d881963224c1e61f2640
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-10-07 (Wed, 07 Oct 2020)

  Changed paths:
    M bolt/src/Relocation.cpp
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Refactor relocations class impl per arch, NFC

Summary:
Do not mix relocation codes from different archs. Even though
they do not intersect at the moment, this could easily introduce bugs
once new relocations are supported (for example, ILP32 for AArch64).

(cherry picked from FBD24169425)


  Commit: 0376abe252a1240a1c9f3d950c1e6a252bf06f19
      https://github.com/llvm/llvm-project/commit/0376abe252a1240a1c9f3d950c1e6a252bf06f19
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-10-07 (Wed, 07 Oct 2020)

  Changed paths:
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  Add ToolPath field to MachORewriteInstance

Summary: Add ToolPath field to MachORewriteInstance. This will enable us to locate the runtime library relative to the tool's location.

(cherry picked from FBD24183448)


  Commit: 0465d952cc9f52adbb014de62cfbccc795e64416
      https://github.com/llvm/llvm-project/commit/0465d952cc9f52adbb014de62cfbccc795e64416
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-09 (Fri, 09 Oct 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/NameResolver.h
    M bolt/src/Passes/PatchEntries.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Refactor PatchEntries pass

Summary:
Use injected functions with fixed addresses to patch original function
entries.

(cherry picked from FBD24133890)


  Commit: 843309c07575e888f1180e3e696cd15a6911ed1e
      https://github.com/llvm/llvm-project/commit/843309c07575e888f1180e3e696cd15a6911ed1e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-09 (Fri, 09 Oct 2020)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/PatchEntries.cpp

  Log Message:
  -----------
  [BOLT] Disable PatchEntries in non-relocation mode on ELF

Summary:
At the moment we are not using PatchEntries pass in non-relocation mode
on ELF. However, we will use it on MachO.

(cherry picked from FBD24235271)


  Commit: 7f1fd807622c0dba1f41abed630e1b906923c776
      https://github.com/llvm/llvm-project/commit/7f1fd807622c0dba1f41abed630e1b906923c776
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-10-02 (Fri, 02 Oct 2020)

  Changed paths:
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/Passes/PatchEntries.cpp

  Log Message:
  -----------
  Add support for emitting code into a new segment on MachO

Summary: Add support for emitting code into a new segment on MachO (in the instrumentation mode).

(cherry picked from FBD24097547)


  Commit: c27e25405629cf9202f5df0e82960e6ade17f0f8
      https://github.com/llvm/llvm-project/commit/c27e25405629cf9202f5df0e82960e6ade17f0f8
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Change label name for cold fragments

Summary:
Append ".cold.0" suffix to the original part of the name, such that
"foo/1" becomes "foo.cold.0/1" instead of "foo/1.cold.0".

(cherry picked from FBD24246112)


  Commit: 528da5d7955b582f7b349dec9563d622257dae31
      https://github.com/llvm/llvm-project/commit/528da5d7955b582f7b349dec9563d622257dae31
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M bolt/llvm.patch

  Log Message:
  -----------
  Fix handling of _end symbol on MachO

Summary: _end is "defined" but its address doesn't belong to any section. This diff adds special handling for this symbol.

(cherry picked from FBD24249120)


  Commit: 247b4181a306aff348c1d2d8c3847280866a7f32
      https://github.com/llvm/llvm-project/commit/247b4181a306aff348c1d2d8c3847280866a7f32
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp

  Log Message:
  -----------
  [BOLT] Emit symbol size for functions

Summary:
On targets that support it, emit size of the emitted function symbol.

At the moment there's no use for the size except that it is visible in a
temporary .o file symbol table.

(cherry picked from FBD24246177)


  Commit: 473a6199ab0bf89fc0f6e6ae2797b43d032d12ed
      https://github.com/llvm/llvm-project/commit/473a6199ab0bf89fc0f6e6ae2797b43d032d12ed
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  Add first bits to support emitting instrumented code on MachO

Summary:
Add first bits to support emitting instrumented code on MachO.
This diff enables us to instrument branches / emit counters.

(cherry picked from FBD24255164)


  Commit: 9f15b9f3c21ecfaf70a491ecc6d35187be6ed112
      https://github.com/llvm/llvm-project/commit/9f15b9f3c21ecfaf70a491ecc6d35187be6ed112
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp

  Log Message:
  -----------
  [BOLT] Fix debug line info in lite relocation mode

Summary: Emit line info for functions that were not emitted in relocation mode.

(cherry picked from FBD24267650)


  Commit: 53bd88c7fe2bb80d6a98831e858d8d6dbfe00d40
      https://github.com/llvm/llvm-project/commit/53bd88c7fe2bb80d6a98831e858d8d6dbfe00d40
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-12 (Mon, 12 Oct 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Refactor reading of debug line info

Summary:
Match BinaryFunction to a DWARFUnit based on the unit's address ranges
skipping the parsing of DIEs.

(cherry picked from FBD24269325)


  Commit: 0b6df06e0434f5ae380989b16c35026af890bf63
      https://github.com/llvm/llvm-project/commit/0b6df06e0434f5ae380989b16c35026af890bf63
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-10-14 (Wed, 14 Oct 2020)

  Changed paths:
    M bolt/src/Passes/ShrinkWrapping.cpp
    A bolt/test/X86/shrinkwrapping-lock.s

  Log Message:
  -----------
  [BOLT] In shrinkwrap, do not split prefix/instr

Summary:
When placing restore instructions in the shrink wrapping pass,
we typically put them right before the last instruction of a block at
the dominance frontier. If this instruction happened to have a prefix,
because the MC lib separates prefix into separate MCInsts, we would
accidentally put a load between a prefix and another instruction. Fix
this.

(cherry picked from FBD24295324)


  Commit: bbd9d610fe62f1049ebbd810863ad2a345cc9f7e
      https://github.com/llvm/llvm-project/commit/bbd9d610fe62f1049ebbd810863ad2a345cc9f7e
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M bolt/runtime/CMakeLists.txt
    M bolt/runtime/common.h
    M bolt/runtime/hugify.cpp
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  Add first bits to cross-compile the runtime for OSX

Summary: Add first bits to cross-compile the runtime for OSX.

(cherry picked from FBD24330977)


  Commit: f15532c2aa48e937b84943d9feda2aaa66fe7b48
      https://github.com/llvm/llvm-project/commit/f15532c2aa48e937b84943d9feda2aaa66fe7b48
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-16 (Fri, 16 Oct 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT][DWARF] Streamline processing of DWARF unit DIEs

Summary:
Do not store processed DWARF DIEs, but instead process them while
reading one at a time.

Reduces memory consumption when updating debug info by 10%-25%.

(cherry picked from FBD24327029)


  Commit: 6133d2598b1be578bd0313995d0a7fd77fa6b9ba
      https://github.com/llvm/llvm-project/commit/6133d2598b1be578bd0313995d0a7fd77fa6b9ba
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M bolt/src/Passes/Instrumentation.cpp

  Log Message:
  -----------
  Inject a hook into the entry point on MachO

Summary:
This diff is a preparation for loading the runtime on MachO.
The proposed schema is the following:

1/  Function "bolt_instr_setup" is placed into the predefined section "setup" (in the final setting this function will be coming from the instrumentation runtime but we still will be placing it into this section).

2/ In the instrumentation pass we create a symbol "bolt_instr_setup" and inject the corresponding call into the beginning of the function representing the entry point of the binary.

(cherry picked from FBD24329530)


  Commit: e4396c41da02b5af0926d63c260af129fd8f3641
      https://github.com/llvm/llvm-project/commit/e4396c41da02b5af0926d63c260af129fd8f3641
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-10-17 (Sat, 17 Oct 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    A bolt/test/X86/hot_end_symbol.s

  Log Message:
  -----------
  [BOLT] Ignore __hot_start, __hot_end from input

Summary:
When -hot-text is on, do not read __hot_start and __hot_end
from input (inserted by a linker script with the intent of ordering
functions). This can confuse BOLT into creating a function with this
name depending on which address the symbol lands and we will assert
when trying to emit our own __hot_start/__hot_end with symbol
redefinition.

(cherry picked from FBD24366636)


  Commit: d6d88399fce41d95df51d62c1e735fe274cb3f6c
      https://github.com/llvm/llvm-project/commit/d6d88399fce41d95df51d62c1e735fe274cb3f6c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-17 (Sat, 17 Oct 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Enable lite mode by default with relocations

Summary:
When optimizing input with relocations, make it faster and less
memory-hungry with lite mode.

(cherry picked from FBD24374241)


  Commit: d91add0bfe52a520de90e7ae098312cc2cc5d9ac
      https://github.com/llvm/llvm-project/commit/d91add0bfe52a520de90e7ae098312cc2cc5d9ac
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-21 (Wed, 21 Oct 2020)

  Changed paths:
    M bolt/src/Passes/PatchEntries.cpp
    M bolt/src/Passes/PatchEntries.h

  Log Message:
  -----------
  [BOLT] Fix PatchEntries pass

Summary:
While refactoring the pass, I removed the important transactional
property of the patching process. Restore it.

(cherry picked from FBD24440214)


  Commit: 5f2f96c4c9580110b8f6e7227d7df8b60a298f93
      https://github.com/llvm/llvm-project/commit/5f2f96c4c9580110b8f6e7227d7df8b60a298f93
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-10-21 (Wed, 21 Oct 2020)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Add pass number to dot dump filename

Summary:
Change .dot dumps filename format from
  <function>-<passname>.dot
to
  <function>-<passidx>_<passname>.dot
This change helps navigate dumps by making the pass order explicit.
Example:
  execute_stack_op.cold.6-1(*2)-00_build-cfg.dot
  execute_stack_op.cold.6-1(*2)-01_validate-internal-calls.dot
  execute_stack_op.cold.6-1(*2)-02_strip-rep-ret.dot
  ...

(cherry picked from FBD24452903)


  Commit: 6b185cccf464ecdb2b5b88ff9e98a57f39009c4d
      https://github.com/llvm/llvm-project/commit/6b185cccf464ecdb2b5b88ff9e98a57f39009c4d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-10-22 (Thu, 22 Oct 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Always keep dynamic symbols defined

Summary:
Some symbols in .dynsym will be erroneously marked as belonging to a
non-allocatable section that BOLT can remove. In that case, keep the
original invalid index for such symbols instead of setting the UNDEF
index.

(cherry picked from FBD24488677)


  Commit: eb12d719ac3abcc83e494735ed281b2a690e3166
      https://github.com/llvm/llvm-project/commit/eb12d719ac3abcc83e494735ed281b2a690e3166
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-10-30 (Fri, 30 Oct 2020)

  Changed paths:
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Fix no-asserts build

Summary: Only use dump() method under DEBUG() macro.

(cherry picked from FBD24666481)


  Commit: 3e78082c1b611ed0ccacce5c106c647ac875235f
      https://github.com/llvm/llvm-project/commit/3e78082c1b611ed0ccacce5c106c647ac875235f
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-10-30 (Fri, 30 Oct 2020)

  Changed paths:
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [DOCS] Add instrumentation instructions to README

Summary: Add basic instructions on how to instrument a binary.

(cherry picked from FBD24660183)


  Commit: 37921b489a6971ac6a5d16f8ba93b1624b65741d
      https://github.com/llvm/llvm-project/commit/37921b489a6971ac6a5d16f8ba93b1624b65741d
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-10-30 (Fri, 30 Oct 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/CallGraph.cpp

  Log Message:
  -----------
  [BOLT] Please sanitizers

Summary:
In BinaryContext, we had StringRef holding a reference to
an r-value std::string. This triggers clang's address sanitizer
warnings. In MCPlusBuilder we had a left shift overflowing a type,
which is undefined behavior. Similarly, in CallGraph, we had a hash
function shifting a negative value, which is also UB. The last two
triggers the UB sanitizer.

(cherry picked from FBD24661045)


  Commit: c1bb4dcb2b87d33d3b5ea0024788b76030dacaee
      https://github.com/llvm/llvm-project/commit/c1bb4dcb2b87d33d3b5ea0024788b76030dacaee
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-11-03 (Tue, 03 Nov 2020)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Remove threaded EliminateUnreachableBlock version

Summary:
EliminateUnreachableBlocks has a data race because it depends
on BinaryContext::computeCodeSize. computeCodeSize supports independent
Emitters, enabling a lock-free execution. Unfortunately, that is almost
as expensive as the lock. Removing the boilerplate code for
parallellization of this pass turned out to be the best alternative: no
races and slightly better execution time for HHVM.

(cherry picked from FBD24716250)


  Commit: 4f4239cebadc5b146437d0eee31ee755851c0447
      https://github.com/llvm/llvm-project/commit/4f4239cebadc5b146437d0eee31ee755851c0447
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-11-04 (Wed, 04 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Exceptions.cpp
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix C++ exceptions for shared objects

Summary:
Fix several issues to make C++ exceptions work in shared objects:
  * Set MCObjectFileInfo PIC type based on the input binary type.
  * Support indirect (DW_EH_PE_indirect) encoding while writing
    exception Type Table.
  * Use different LPStart value and landing pad encoding for .so's.
  * Disable splitting of exception-handling code for .so's because of
    the new encoding.

(cherry picked from FBD24698765)


  Commit: 58460460d9a7e2cdb0739e3cc91adf632fd1b8cb
      https://github.com/llvm/llvm-project/commit/58460460d9a7e2cdb0739e3cc91adf632fd1b8cb
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2020-11-04 (Wed, 04 Nov 2020)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][PR] Handle TLS relocations on AArch64

Summary:
Some of the TLS relocatios like R_AARCH64_TLSDESC_ADR_PAGE21 must be
handled by bolt and should not be skipped by the removed condition. Some
of the TLS relocations like R_AARCH64_TLS_TPREL64 could really be skipped
here, but AFAIU this condition was added as part of BOLT its self optimization, so
to prevent future problems here my suggestion is not to add another condition
like "isTLS(RType) && isTLSRelocatable(RType)", but just remove it since
absense of this condition should not broke any other TLS relocation.
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Pull Request resolved: https://github.com/facebookincubator/BOLT/pull/103
GitHub Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>

(cherry picked from FBD24745928)


  Commit: 54522877105e8af8b1382cb0c009064df8167b4e
      https://github.com/llvm/llvm-project/commit/54522877105e8af8b1382cb0c009064df8167b4e
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-06 (Fri, 06 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h

  Log Message:
  -----------
  Extract BinaryContext::registerFragment

Summary: registerFragment to be reused in adding fragments reachable only through jump tables.

(cherry picked from FBD24656651)


  Commit: dc48354f71cf86f2f0de80c81628f28616dfd30b
      https://github.com/llvm/llvm-project/commit/dc48354f71cf86f2f0de80c81628f28616dfd30b
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-06 (Fri, 06 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    A bolt/test/X86/interprocedural_ref_entry_point.s
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  processInterproceduralReferences: record references to cold fragments as entry points

Summary:
For interprocedural references to fragments, record them as
fragment entry points. Not registering these entry points leads to
UCE removing the blocks and "Undefined temporary symbol"
assertion.

(cherry picked from FBD24511281)


  Commit: 2b09d672ce89c01109cf2d3774436d353e5e668d
      https://github.com/llvm/llvm-project/commit/2b09d672ce89c01109cf2d3774436d353e5e668d
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-06 (Fri, 06 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryFunction.h
    A bolt/test/X86/split_func_jump_table_fragment.s
    A bolt/test/X86/split_func_jump_table_fragment_noparent.s

  Log Message:
  -----------
  Conservatively handle jump tables in split functions

Summary:
- Allow jump table entries to point to locations inside the function and its fragments.
Reasoning behind this is that jump table identification has the logic of stopping at entry which belongs to a function different from the one originally referencing jump table. This assumption is invalid for jump tables with entries pointing to both parent function and cold fragments, leading to "unclaimed PC-relative relocations" assertion.

- Add fragment identification heuristic based on function name regex and contiguous jump table entries.
Currently, parent-to-fragment relationship is set up based on interprocedural references – direct references from the parent function. These references don't include references through jump table.
Additionally, some fragments are only reachable through jump table. In that case, in order to fully consume jump table, add parent-to-fragment relationship during `analyzeJumpTable` using the following heuristics:
  1. Fragment is identified as such based on name (contains `.cold.` part), but
  2. Parent function is not set – no direct interprocedural references to that fragment, and
  3. Fragment has the name of the form <parent>.cold(.\d+)

* For split functions with jump table entries spanning parent and fragments, mark parent and all fragments as ignored.

(cherry picked from FBD24456904)


  Commit: f86a78a4e756a2b342551622cc2fc4460eb798fa
      https://github.com/llvm/llvm-project/commit/f86a78a4e756a2b342551622cc2fc4460eb798fa
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-06 (Fri, 06 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  Lost in rebase: call registerFragment with a reference to TargetBF

Summary: Fixes broken build due to a lost dereferencing

(cherry picked from FBD24799948)


  Commit: c36b71686ca9cc09f2cbeb99de5b3219517f47a0
      https://github.com/llvm/llvm-project/commit/c36b71686ca9cc09f2cbeb99de5b3219517f47a0
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-09 (Mon, 09 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Improve cold fragment name matching

Summary:
Fix cold fragment name matching regex by replacing existing
regexes `.*\.cold\..*` and  `.*\.cold`
and combining them into `.*\.cold(\.\d)?`,
applied to restored name (with BOLT-added suffixes stripped)

This allows matching names like "execute_stack_op.cold/1", which
previously weren't recognized.

(cherry picked from FBD24804880)


  Commit: e54d3897991ee7d1ad9bd33056cef9b657c3e1ab
      https://github.com/llvm/llvm-project/commit/e54d3897991ee7d1ad9bd33056cef9b657c3e1ab
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-10 (Tue, 10 Nov 2020)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/DynoStats.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    A bolt/test/X86/bb_with_two_tail_calls.s

  Log Message:
  -----------
  [BOLT] Disable DynoStats printing after SCTC

Summary:
Introduce new BinaryFunction flag `IsCanonicalCFG`, which gets
unset by SCTC pass. Make DynoStats collection conditional on this
new flag.
SCTC leaves CFG in a state where branch counters of BBs with tail
calls/conditional tail calls are not available (except via annotations,
which get stripped by `lower-annotations`). Without branch
counters, DynoStats are invalid.

(cherry picked from FBD24558050)


  Commit: c0cb55053604875d351d99726dcb585e887a8e49
      https://github.com/llvm/llvm-project/commit/c0cb55053604875d351d99726dcb585e887a8e49
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-10 (Tue, 10 Nov 2020)

  Changed paths:
    M bolt/test/X86/shrinkwrapping-critedge.s

  Log Message:
  -----------
  Minimize X86/shrinkwrapping-critedge test case

Summary: Minimized test case while preserving the CFG subgraph with an issue

(cherry picked from FBD24871063)


  Commit: 157129b751eed09d7de05e3840daf760bd9adbd1
      https://github.com/llvm/llvm-project/commit/157129b751eed09d7de05e3840daf760bd9adbd1
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-12 (Thu, 12 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT] Debug logging in analyzeJumpTable

Summary:
Added debug logging in/around `analyzeJumpTable`:
- Dump jump table entries as they are being processed:
```BOLT-DEBUG: analyzeJumpTable in read_encoded_value_with_base/2(*2)
  * Checking 0x428ff40 -> OK: real entry
  * Checking 0x428ff44 -> OK: real entry
  * Checking 0x428ff48 -> OK: real entry
  * Checking 0x428ff4c -> OK: real entry
  * Checking 0x428ff50 -> OK: real entry
  * Checking 0x428ff54 -> OK: address in split fragment
  * Checking 0x428ff58 -> OK: address in split fragment
  * Checking 0x428ff5c -> OK: address in split fragment
  * Checking 0x428ff60 -> OK: address in split fragment
  * Checking 0x428ff64 -> OK: real entry
  * Checking 0x428ff68 -> OK: real entry
  * Checking 0x428ff6c -> OK: real entry
  * Checking 0x428ff70 -> OK: real entry
BOLT-DEBUG: analyzeJumpTable in classify_object_over_fdes/1(*2)
  * Checking 0x428ff74 -> OK: real entry
  ...
```
- Dump skipped functions:
```
Skipping _ZNK6icu_676number4impl12RoundingImpl5applyERNS1_15DecimalQuantityER10UErrorCode.part.2/1(*2) family
Ignoring _ZNK6icu_676number4impl12RoundingImpl5applyERNS1_15DecimalQuantityER10UErrorCode.part.2/1(*2)
Ignoring _ZNK6icu_676number4impl12RoundingImpl5applyERNS1_15DecimalQuantityER10UErrorCode.part.2.cold.3/1(*2)
Skipping _ZNK6icu_676number4impl12RoundingImpl5applyERNS1_15DecimalQuantityER10UErrorCode family
Ignoring _ZNK6icu_676number4impl12RoundingImpl5applyERNS1_15DecimalQuantityER10UErrorCode
Ignoring _ZNK6icu_676number4impl12RoundingImpl5applyERNS1_15DecimalQuantityER10UErrorCode.cold.4/1(*2)
```
- Dump values of unclaimed PC-relative relocations in data.

(cherry picked from FBD24898172)


  Commit: e8234b3b989e5dcc670550fda514384dcaf09fad
      https://github.com/llvm/llvm-project/commit/e8234b3b989e5dcc670550fda514384dcaf09fad
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-12 (Thu, 12 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Add invalid offset for a JT entry pointing to a fragment

Summary:
In a jump table identification, register an invalid offset for jump table
entries pointing to function fragments.
These invalid offsets have no effect other than padding the jump
table size, calculated as `max(OffsetEntries, Entries)`.
Correct jump table size is required in strict mode (enabled by default
in aggregation mode by `perf2bolt`) in accounting of all PC-relative
relocations in data.
Functions containing these jump tables with invalid offsets are
marked to be ignored immediately afterwards in
`populateJumpTables`.

(cherry picked from FBD24897464)


  Commit: 6401af89c730c1a558e8a8e2e39b6129e3206236
      https://github.com/llvm/llvm-project/commit/6401af89c730c1a558e8a8e2e39b6129e3206236
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-12 (Thu, 12 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    A bolt/test/X86/split_func_jump_table_fragment_reverse.s

  Log Message:
  -----------
  [BOLT] Support jump tables in split fragments with entries pointing back to parent functions

Summary:
Support jump tables belonging to split fragments with entries
pointing back to parent functions.
While skipping such families of functions, make sure to use the
topmost fragment to ignore its fragments.

(cherry picked from FBD24907438)


  Commit: 1e9b733008023d80052b3d616148ca9cc8d382f0
      https://github.com/llvm/llvm-project/commit/1e9b733008023d80052b3d616148ca9cc8d382f0
  Author: Sergey Pupyrev <spupyrev at fb.com>
  Date:   2020-11-14 (Sat, 14 Nov 2020)

  Changed paths:
    M bolt/src/Passes/CallGraph.h
    M bolt/src/Passes/HFSort.cpp
    M bolt/src/Passes/HFSort.h
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/ReorderFunctions.cpp

  Log Message:
  -----------
  a new version of hfsort+

Summary:
A faster and better version of function reordering:
- fixed a bug when some computed probabilities were negative;
- changed an O(n^2) loop to a priority queue to find a candidate of chains to merge

(cherry picked from FBD24571208)


  Commit: 7eaf63a118d6db42473aa74e9ee6ba4e3657043c
      https://github.com/llvm/llvm-project/commit/7eaf63a118d6db42473aa74e9ee6ba4e3657043c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2020-11-16 (Mon, 16 Nov 2020)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp

  Log Message:
  -----------
  [BOLT] Fix data race while running split functions pass

Summary:
In BinaryContext::calculateEmittedSize(), after the temporary code
emission, we have to perform a cleanup and mark all symbols used
during the emission as undefined and unregistered (so that we can emit
them again later). The cleanup is happening even for symbols that were
referenced and not defined by emitted code.

If all emitted symbols are local, there is no risk that one thread will
define a symbol while some other thread will undefine it in its cleanup
code. Such behavior is expected as local symbols can only be referenced
within the containing function and each function is processed in one
thread. However, secondary entry points have associated global symbols
and if we emit them, then it is possible for a thread to undefine
a symbol while the other thread had defined it and was in the process of
emitting the fragment with it. In such case, a data race may happen and
the thread that contains the definition of the symbol may define it
twice causing a redefinition error.

To avoid the data race, we skip the emission of secondary entry global
symbols when emitting code used only for the size estimation.

(cherry picked from FBD24986007)


  Commit: 1cf23e5ee8bfdea7f8418d81c060174f20b357c5
      https://github.com/llvm/llvm-project/commit/1cf23e5ee8bfdea7f8418d81c060174f20b357c5
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-11-17 (Tue, 17 Nov 2020)

  Changed paths:
    M bolt/runtime/CMakeLists.txt
    M bolt/runtime/common.h
    M bolt/runtime/instr.cpp
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  Link the instrumentation runtime on OSX

Summary: Link the instrumentation runtime on OSX.

(cherry picked from FBD24390019)


  Commit: f9d00d418b3e095bf0b551f7c88cd2fd0a41d4aa
      https://github.com/llvm/llvm-project/commit/f9d00d418b3e095bf0b551f7c88cd2fd0a41d4aa
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-11-17 (Tue, 17 Nov 2020)

  Changed paths:
    M bolt/src/Passes/ShrinkWrapping.cpp
    A bolt/test/X86/shrinkwrapping-insertcfi.s

  Log Message:
  -----------
  [BOLT] Handle insertion of updated CFI at the first basic block

Summary:
Fix corner case of insertion of updated CFI with unset `PrevBB`.
Handle it in the same way as inserting past hot-cold split point.

(cherry picked from FBD24943911)


  Commit: 1b258b890849c8a218fc632236283980a646054a
      https://github.com/llvm/llvm-project/commit/1b258b890849c8a218fc632236283980a646054a
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-11-19 (Thu, 19 Nov 2020)

  Changed paths:
    M bolt/runtime/common.h

  Log Message:
  -----------
  Refactor syscall wrappers for OSX

Summary: Refactor syscall wrappers for OSX.

(cherry picked from FBD25084642)


  Commit: e067f2adf4e42b30f8c03fae5158da9ca3b0c6af
      https://github.com/llvm/llvm-project/commit/e067f2adf4e42b30f8c03fae5158da9ca3b0c6af
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2020-11-19 (Thu, 19 Nov 2020)

  Changed paths:
    M bolt/runtime/instr.cpp
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/Passes/Instrumentation.cpp

  Log Message:
  -----------
  Inject instrumentation's global dtor on MachO

Summary:
This diff is a preparation for dumping the profile generated by BOLT's instrumenation on MachO.

1/  Function "bolt_instr_fini" is placed into the predefined section "__fini"

2/ In the instrumentation pass we create a symbol "bolt_instr_fini" and
replace the last global destructor with it.

This is a temporary solution, in the future we need to register bolt_instr_fini in addition to the existing destructors without dropping the last one.

(cherry picked from FBD25071864)


  Commit: d2f68039bc427d865055ead0f4a70f988b1e9d68
      https://github.com/llvm/llvm-project/commit/d2f68039bc427d865055ead0f4a70f988b1e9d68
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-12-03 (Thu, 03 Dec 2020)

  Changed paths:
    M bolt/src/Passes/FrameAnalysis.cpp
    A bolt/test/X86/shrinkwrapping-alignment.s

  Log Message:
  -----------
  [BOLT] Fix shrinkwrapping bug when changing frame alignment

Summary:
This fixes a bug with shrink wrapping when trying to move
push-pops in a function where we are not allowed to modify the
stack layout for alignment reasons. In this bug, we failed to
propagate alignment requirement upwards in the call graph from
function A to B when: (1) there is a cycle in the call graph and
(2) the distance from A to B is greater than 1 in the call graph
and (3) there is a node in the path from A to B, not including
A or B, that does not access parameters in the stack.

(cherry picked from FBD25315977)


  Commit: e0261a22ce2193e8bb1cdc4c364a84e54a1bd20d
      https://github.com/llvm/llvm-project/commit/e0261a22ce2193e8bb1cdc4c364a84e54a1bd20d
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-12-09 (Wed, 09 Dec 2020)

  Changed paths:
    M bolt/test/X86/shrinkwrapping-critedge.s

  Log Message:
  -----------
  [TEST] Remove dependency on debug output

Summary:
Test mistakenly used -debug output, which makes it fail on
no-asserts build.

(cherry picked from FBD25399449)


  Commit: e3898d5969ad47b26c09c9d7221fc8491f00b9a3
      https://github.com/llvm/llvm-project/commit/e3898d5969ad47b26c09c9d7221fc8491f00b9a3
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2020-12-30 (Wed, 30 Dec 2020)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/YAMLProfileReader.cpp

  Log Message:
  -----------
  [BOLT] Add threshold options for lite mode

Summary:
Add options for trading processing speed for binary performance.

  -lite-threshold-pct=<uint>
    Threshold (in percent) for selecting functions to process in lite
    mode. Higher threshold means fewer functions to process.
    E.g threshold of 90 means only top 10 percent of functions with
    profile will be processed.

  -lite-threshold-count=<uint>
    Similar to '-lite-threshold-pct' but specify threshold using
    absolute function call count. I.e. limit processing to functions
    executed at least the specified number of times.

  -no-scan
    Do not scan cold functions for external references (may result in
    slower binary).

(cherry picked from FBD24739092)


  Commit: 0de92b83460575df6b7e6750a50d8d3a5ce98b1a
      https://github.com/llvm/llvm-project/commit/0de92b83460575df6b7e6750a50d8d3a5ce98b1a
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-01-11 (Mon, 11 Jan 2021)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [PERF2BOLT] Relax segment matching requirements

Summary:
When looking at perf.data's available binaries and their
respective mmap'ed segments, match them with the input binary by
looking at both aligned and non-aligned addresses. If we suppose
the alignment is the mmap'ed page size, we may miss some cases and
perf2bolt will refuse to proceed because it failed to match the
input binary with a process recorded in perf.data.

(cherry picked from FBD25732673)


  Commit: a86cd533b3a8a1f8e7e19d71b74e2c0a2780fffc
      https://github.com/llvm/llvm-project/commit/a86cd533b3a8a1f8e7e19d71b74e2c0a2780fffc
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-01-19 (Tue, 19 Jan 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Fix missing newlines in debug prints

(cherry picked from FBD25966797)


  Commit: faaefff618cab6cc89357c8d28fc13973a191a16
      https://github.com/llvm/llvm-project/commit/faaefff618cab6cc89357c8d28fc13973a191a16
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2021-01-20 (Wed, 20 Jan 2021)

  Changed paths:
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [BOLT] Fix operator new signature

Summary:
Use size_t for the first parameter of operator new.
https://en.cppreference.com/w/cpp/memory/new/operator_new

(cherry picked from FBD25750921)


  Commit: d6e60c5becfd70de0df7b4b229b7c5d84c37c4bf
      https://github.com/llvm/llvm-project/commit/d6e60c5becfd70de0df7b4b229b7c5d84c37c4bf
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2021-01-20 (Wed, 20 Jan 2021)

  Changed paths:
    M bolt/runtime/CMakeLists.txt
    M bolt/runtime/common.h

  Log Message:
  -----------
  [BOLT] Enable intToStr for MacOS

Summary: Enable intToStr et al. in the runtime library for MacOS.

(cherry picked from FBD25745358)


  Commit: fea6b4e4691e17a0996e3561bc7c3a8e4f762af5
      https://github.com/llvm/llvm-project/commit/fea6b4e4691e17a0996e3561bc7c3a8e4f762af5
  Author: Sergey Pupyrev <spupyrev at fb.com>
  Date:   2021-01-27 (Wed, 27 Jan 2021)

  Changed paths:
    M bolt/src/CacheMetrics.cpp
    M bolt/src/Passes/ExtTSPReorderAlgorithm.cpp

  Log Message:
  -----------
  an updated version of ExtTSP

Summary:
a few minor updates in block reordering:
- some refactoring to improve readability;
- optimized chain splitting strategy to improve quality of layout and performance of the algorithm.

(cherry picked from FBD25126220)


  Commit: 6a84124e1d192acafd85b7cc00cbb97310c7c1ec
      https://github.com/llvm/llvm-project/commit/6a84124e1d192acafd85b7cc00cbb97310c7c1ec
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

  Changed paths:
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  [BOLT] Add support for __literal16 section on MachO

Summary:
1. Add support for __literal16 section in the instrumentation runtime library for MacOS.
2. Fix emitting __counters section.

(cherry picked from FBD25746342)


  Commit: 3b876cc3e776712bee39a8337871109f9e206096
      https://github.com/llvm/llvm-project/commit/3b876cc3e776712bee39a8337871109f9e206096
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

  Changed paths:
    M bolt/runtime/common.h
    M bolt/runtime/instr.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Add support for dumping counters on MacOS

Summary: Add support for dumping counters on MacOS

(cherry picked from FBD25750516)


  Commit: a0dd5b05dcf700b32ba5f370d74aede6d61c46a2
      https://github.com/llvm/llvm-project/commit/a0dd5b05dcf700b32ba5f370d74aede6d61c46a2
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2021-01-28 (Thu, 28 Jan 2021)

  Changed paths:
    M bolt/runtime/common.h
    M bolt/runtime/instr.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Add support for dumping profile on MacOS

Summary: Add support for dumping profile on MacOS.

(cherry picked from FBD25751363)


  Commit: 0a8aaf56bb58ba9b7d561dda02a27a292f517954
      https://github.com/llvm/llvm-project/commit/0a8aaf56bb58ba9b7d561dda02a27a292f517954
  Author: Alexander Shaposhnikov <alexshap at fb.com>
  Date:   2021-01-29 (Fri, 29 Jan 2021)

  Changed paths:
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [BOLT] Add support for reading profile on Mach-O

Summary: Add support for reading profile on Mach-O.

(cherry picked from FBD25777049)


  Commit: 1c5d3a056c4abfe1022f67e1e366765d769782fa
      https://github.com/llvm/llvm-project/commit/1c5d3a056c4abfe1022f67e1e366765d769782fa
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2020-12-01 (Tue, 01 Dec 2020)

  Changed paths:
    M bolt/LICENSE.TXT
    R bolt/LLVMBuild.txt
    M bolt/README.md
    R bolt/README.txt
    A bolt/docs/Heatmap.png
    A bolt/docs/Heatmaps.md
    A bolt/docs/OptimizingClang.md
    A bolt/docs/RuntimeLibrary.md
    R bolt/llvm.patch
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/CacheMetrics.cpp
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataReader.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/DynoStats.cpp
    M bolt/src/Exceptions.cpp
    M bolt/src/Exceptions.h
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/ExecutableFileMemoryManager.h
    M bolt/src/Heatmap.cpp
    M bolt/src/JumpTable.cpp
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/ParallelUtilities.cpp
    M bolt/src/ParallelUtilities.h
    M bolt/src/Passes/Aligner.cpp
    M bolt/src/Passes/AllocCombiner.cpp
    M bolt/src/Passes/BinaryFunctionCallGraph.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    R bolt/src/Passes/BranchPredictionInfo.cpp
    R bolt/src/Passes/BranchPredictionInfo.h
    M bolt/src/Passes/CMakeLists.txt
    R bolt/src/Passes/CachePlusReorderAlgorithm.cpp
    M bolt/src/Passes/DataflowAnalysis.cpp
    M bolt/src/Passes/ExtTSPReorderAlgorithm.cpp
    R bolt/src/Passes/FeatureMiner.cpp
    R bolt/src/Passes/FeatureMiner.h
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/HFSort.cpp
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/Passes/InstrumentationSummary.h
    M bolt/src/Passes/JTFootprintReduction.cpp
    M bolt/src/Passes/LongJmp.cpp
    A bolt/src/Passes/MCF.cpp
    A bolt/src/Passes/MCF.h
    M bolt/src/Passes/PLTCall.cpp
    M bolt/src/Passes/PatchEntries.cpp
    M bolt/src/Passes/PettisAndHansen.cpp
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/Passes/ReorderAlgorithm.cpp
    M bolt/src/Passes/ReorderData.cpp
    M bolt/src/Passes/ReorderFunctions.cpp
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Passes/SplitFunctions.cpp
    M bolt/src/Passes/StackAllocationAnalysis.cpp
    M bolt/src/Passes/StackAvailableExpressions.cpp
    M bolt/src/Passes/StackReachingUses.cpp
    M bolt/src/Passes/StokeInfo.cpp
    M bolt/src/Passes/ValidateInternalCalls.cpp
    M bolt/src/Passes/VeneerElimination.cpp
    R bolt/src/ProfileReader.cpp
    R bolt/src/ProfileReader.h
    R bolt/src/ProfileWriter.cpp
    R bolt/src/ProfileWriter.h
    M bolt/src/Relocation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/RuntimeLibs/CMakeLists.txt
    M bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/HugifyRuntimeLibrary.h
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h
    M bolt/src/RuntimeLibs/RuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/RuntimeLibrary.h
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/AArch64/CMakeLists.txt
    M bolt/src/Target/X86/CMakeLists.txt
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    M bolt/src/Utils.cpp
    M bolt/src/Utils.h
    M bolt/src/YAMLProfileReader.cpp
    M bolt/src/YAMLProfileWriter.cpp
    M bolt/src/llvm-bolt.cpp
    M bolt/test/CMakeLists.txt
    M bolt/test/X86/Inputs/blarge.yaml
    M bolt/test/X86/Inputs/issue20.yaml
    M bolt/test/X86/Inputs/issue26.yaml
    M bolt/test/X86/Inputs/srol-bug-input.yaml
    M bolt/test/X86/pre-aggregated-perf.test
    M bolt/test/X86/shrinkwrapping-insertcfi.s
    M bolt/test/lit.cfg.py
    M bolt/test/lit.site.cfg.py.in

  Log Message:
  -----------
  Rebase: Merge BOLT codebase in monorepo

Summary:
This commit is the first step in rebasing all of BOLT
history in the LLVM monorepo. It also solves trivial build issues
by updating BOLT codebase to use current LLVM. There is still work
left in rebasing some BOLT features and in making sure everything
is working as intended.

History has been rewritten to put BOLT in the /bolt folder, as
opposed to /tools/llvm-bolt.

(cherry picked from FBD33289252)


  Commit: 16521f1f7906c99337caa5369b39fb8d5d04aeb8
      https://github.com/llvm/llvm-project/commit/16521f1f7906c99337caa5369b39fb8d5d04aeb8
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-03-15 (Mon, 15 Mar 2021)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.cpp
    M bolt/src/BinaryData.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryEmitter.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/BinaryLoop.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/BinaryPassManager.h
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/BoltAddressTranslation.h
    M bolt/src/BoltDiff.cpp
    M bolt/src/CacheMetrics.cpp
    M bolt/src/CacheMetrics.h
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DataReader.cpp
    M bolt/src/DataReader.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/DynoStats.cpp
    M bolt/src/DynoStats.h
    M bolt/src/Exceptions.cpp
    M bolt/src/Exceptions.h
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/ExecutableFileMemoryManager.h
    M bolt/src/Heatmap.cpp
    M bolt/src/Heatmap.h
    M bolt/src/JumpTable.cpp
    M bolt/src/JumpTable.h
    M bolt/src/MCPlus.h
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/NameResolver.h
    M bolt/src/NameShortener.h
    M bolt/src/ParallelUtilities.cpp
    M bolt/src/ParallelUtilities.h
    M bolt/src/Passes/Aligner.cpp
    M bolt/src/Passes/Aligner.h
    M bolt/src/Passes/AllocCombiner.cpp
    M bolt/src/Passes/AllocCombiner.h
    M bolt/src/Passes/BinaryFunctionCallGraph.cpp
    M bolt/src/Passes/BinaryFunctionCallGraph.h
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/CallGraph.cpp
    M bolt/src/Passes/CallGraph.h
    M bolt/src/Passes/CallGraphWalker.cpp
    M bolt/src/Passes/CallGraphWalker.h
    M bolt/src/Passes/DataflowAnalysis.cpp
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/DataflowInfoManager.cpp
    M bolt/src/Passes/DataflowInfoManager.h
    M bolt/src/Passes/DominatorAnalysis.h
    M bolt/src/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/FrameAnalysis.h
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/FrameOptimizer.h
    M bolt/src/Passes/HFSort.cpp
    M bolt/src/Passes/HFSort.h
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/IdenticalCodeFolding.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/IndirectCallPromotion.h
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/Inliner.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/Passes/InstrumentationSummary.h
    M bolt/src/Passes/JTFootprintReduction.cpp
    M bolt/src/Passes/JTFootprintReduction.h
    M bolt/src/Passes/LivenessAnalysis.cpp
    M bolt/src/Passes/LivenessAnalysis.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/LongJmp.h
    M bolt/src/Passes/MCF.cpp
    M bolt/src/Passes/MCF.h
    M bolt/src/Passes/PLTCall.cpp
    M bolt/src/Passes/PLTCall.h
    M bolt/src/Passes/PatchEntries.cpp
    M bolt/src/Passes/PatchEntries.h
    M bolt/src/Passes/PettisAndHansen.cpp
    M bolt/src/Passes/ReachingDefOrUse.h
    M bolt/src/Passes/ReachingInsns.h
    M bolt/src/Passes/RegAnalysis.cpp
    M bolt/src/Passes/RegAnalysis.h
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/Passes/RegReAssign.h
    M bolt/src/Passes/ReorderAlgorithm.cpp
    M bolt/src/Passes/ReorderAlgorithm.h
    M bolt/src/Passes/ReorderData.cpp
    M bolt/src/Passes/ReorderData.h
    M bolt/src/Passes/ReorderFunctions.cpp
    M bolt/src/Passes/ReorderFunctions.h
    M bolt/src/Passes/ReorderUtils.h
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/Passes/RetpolineInsertion.h
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Passes/ShrinkWrapping.h
    M bolt/src/Passes/SplitFunctions.cpp
    M bolt/src/Passes/SplitFunctions.h
    M bolt/src/Passes/StackAllocationAnalysis.cpp
    M bolt/src/Passes/StackAllocationAnalysis.h
    M bolt/src/Passes/StackAvailableExpressions.cpp
    M bolt/src/Passes/StackAvailableExpressions.h
    M bolt/src/Passes/StackPointerTracking.cpp
    M bolt/src/Passes/StackPointerTracking.h
    M bolt/src/Passes/StackReachingUses.cpp
    M bolt/src/Passes/StackReachingUses.h
    M bolt/src/Passes/StokeInfo.cpp
    M bolt/src/Passes/StokeInfo.h
    M bolt/src/Passes/ValidateInternalCalls.cpp
    M bolt/src/Passes/ValidateInternalCalls.h
    M bolt/src/Passes/VeneerElimination.cpp
    M bolt/src/Passes/VeneerElimination.h
    M bolt/src/ProfileReaderBase.cpp
    M bolt/src/ProfileReaderBase.h
    M bolt/src/ProfileYAMLMapping.h
    M bolt/src/Relocation.cpp
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/HugifyRuntimeLibrary.h
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h
    M bolt/src/RuntimeLibs/RuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/RuntimeLibrary.h
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    M bolt/src/Utils.cpp
    M bolt/src/Utils.h
    M bolt/src/YAMLProfileReader.cpp
    M bolt/src/YAMLProfileReader.h
    M bolt/src/YAMLProfileWriter.cpp
    M bolt/src/YAMLProfileWriter.h
    M bolt/src/llvm-bolt.cpp
    M bolt/src/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT] Update license headers

Summary: Update license and fix headers for some files.

(cherry picked from FBD28112041)


  Commit: 0ec91a25df0534931267394611e4af83aa981c8e
      https://github.com/llvm/llvm-project/commit/0ec91a25df0534931267394611e4af83aa981c8e
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-02-17 (Wed, 17 Feb 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    A bolt/test/X86/Inputs/file1.s
    A bolt/test/X86/Inputs/file2.s
    A bolt/test/X86/Inputs/main.s
    A bolt/test/X86/debugTypesBug.s
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  Update DW_AT_stmt_list for .debug_types

Summary:
There is no real link between CU and TU, so relying on fact
that address are the same, and we are updating all of them.

(cherry picked from FBD28112114)


  Commit: da752c9c5c20f11cf85a293a25c6bd4727d431e0
      https://github.com/llvm/llvm-project/commit/da752c9c5c20f11cf85a293a25c6bd4727d431e0
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-03-17 (Wed, 17 Mar 2021)

  Changed paths:
    M bolt/README.md
    M bolt/runtime/hugify.cpp
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  Fix license for a few remaining files

Summary: As titled.

(cherry picked from FBD28112137)


  Commit: 06959eedcfe351d14cec7b0bfcbc1b3f81d808dc
      https://github.com/llvm/llvm-project/commit/06959eedcfe351d14cec7b0bfcbc1b3f81d808dc
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-03-17 (Wed, 17 Mar 2021)

  Changed paths:
    M bolt/test/X86/debugTypesBug.s

  Log Message:
  -----------
  Fix up test for Update DW_AT_stmt_list for .debug_types

Summary: As titled.

(cherry picked from FBD28112186)


  Commit: ec9751eef5b701eb2bdaaa7986fe1e8a16d6a77d
      https://github.com/llvm/llvm-project/commit/ec9751eef5b701eb2bdaaa7986fe1e8a16d6a77d
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-02-17 (Wed, 17 Feb 2021)

  Changed paths:
    M bolt/src/Relocation.cpp
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][PR] readDynamicRelocations: Skip NONE relocations

Summary:
NONE relocations should not be processed during dynamic relocations read process
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Pull Request resolved: https://github.com/facebookincubator/BOLT/pull/118
GitHub Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>

(cherry picked from FBD26489881)


  Commit: 225a8d7f2c013aa2b1cb00a96878c671a19d512b
      https://github.com/llvm/llvm-project/commit/225a8d7f2c013aa2b1cb00a96878c671a19d512b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-03-04 (Thu, 04 Mar 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Ignore TBSS section at layout time

Summary:
TBSS section is a "virtual" section that does not take memory or file
space. Ignore it completely while adjusting section sizes.

(cherry picked from FBD26824484)


  Commit: 76d346ca14d412560c464310cdb23931ffed0eed
      https://github.com/llvm/llvm-project/commit/76d346ca14d412560c464310cdb23931ffed0eed
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-03-09 (Tue, 09 Mar 2021)

  Changed paths:
    M bolt/runtime/common.h
    M bolt/runtime/instr.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  [BOLT][PR] Instrumentation: Introduce -no-counters-clear and -wait-forks options

Summary:
This PR introduces 2 new instrumentation options:
1. instrumentation-no-counters-clear: Discussed at https://github.com/facebookincubator/BOLT/issues/121
2. instrumentation-wait-forks: Since the instrumentation counters are mapped as MAP_SHARED it will be nice to add ability to wait until all forks of the parent process will die using tracking of process group.
The last patch is just emitBinary code refactor.
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Pull Request resolved: https://github.com/facebookincubator/BOLT/pull/125
GitHub Author: Vladislav Khmelevskyi <Vladislav.Khmelevskyi at huawei.com>

(cherry picked from FBD26919011)


  Commit: b11c826889d90e78d9fe15ffd8a5dbc990660f8f
      https://github.com/llvm/llvm-project/commit/b11c826889d90e78d9fe15ffd8a5dbc990660f8f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-03-15 (Mon, 15 Mar 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    A bolt/test/X86/zero-sized-object.s

  Log Message:
  -----------
  [BOLT] Fix false references to zero-sized objects

Summary:
Whenever BOLT encounters a data reference in code, it tries to convert
it into <Object+Offset> form. The primary reason behind this approach is
to support read-only data-reordering optimization. However, with the
current level of the linker and compiler support we don't have enough
information to always correctly restore the original <Object+Offset>.
E.g. with zero-sized symbols we have to speculate that the actual size
of the underlying object extends to the next symbol. Most of the time,
there will be an object pointed by a zero-sized symbol and even
if we are guessing incorrectly, there will be no harm in creating
references of such form.

The problem happens when there's no object corresponding to the original
symbol and the next object is an (unmarked) jump table:

  A:                   # <- zero-sized object
  .LJUMP_TABLE:
    .long <entry1>
    .long <entry2>
    ....
  .LB:
    .long 21
  .LC:
    .long 42

The jump table will be moved and all references past it (up to the next
named object) will be incorrectly updated.

We should not speculate about the size of A in a case like that and
treat all discovered data objects (and thus references) independently.

(cherry picked from FBD27005660)


  Commit: b3c34d568adcf5fe45a14f7dfd0149448a888255
      https://github.com/llvm/llvm-project/commit/b3c34d568adcf5fe45a14f7dfd0149448a888255
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-03-15 (Mon, 15 Mar 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h
    A bolt/test/X86/instrumentation-dup-jts.s

  Log Message:
  -----------
  [BOLT] Fix instrumentation bug in duplicated JTs

Summary:
Fix a bug with instrumentation when trying to instrument
functions that share a jump table with multiple indirect
jumps. Usually, each indirect jump that uses a JT will have its own
copy of it. When this does not happen, we need to duplicate the jump
table safely, so we can split the edges correctly (each copy of the
jump table may have different split edges). For this to happen, we
need to correctly match the sequence of instructions that perform the
indirect jump to identify the base address of the jump table and patch
it to point to the new cloned JT. It was reported to us a case in
which the compiler generated suboptimal code to do an indirect jump
which our matcher failed to identify.

Fixes facebookincubator/BOLT#126

(cherry picked from FBD27065579)


  Commit: e7169be93fafdc6197c2f07725714d718b469277
      https://github.com/llvm/llvm-project/commit/e7169be93fafdc6197c2f07725714d718b469277
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-03-23 (Tue, 23 Mar 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    A bolt/test/X86/false-jump-table.s

  Log Message:
  -----------
  [BOLT] Do not assert on jump table heuristic failure

Summary:
During the initial indirect jump analysis, we used to assert that the
discovered jump table type matched the pattern of the corresponding
instruction sequence. E.g., for PIC jump table memory we expected the
PIC jump table instruction sequence. The assertions were too
conservative, as in the case of a mismatch we can mark the indirect jump
as having an unknown control flow. That should be sufficient to either
skip the function processing or rely on relocation information for
possible recovery of the control flow.

(cherry picked from FBD27255816)


  Commit: 081e39aa150aaf581f992e9af628ade85e626a02
      https://github.com/llvm/llvm-project/commit/081e39aa150aaf581f992e9af628ade85e626a02
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-03-29 (Mon, 29 Mar 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    A bolt/test/X86/no-output.test

  Log Message:
  -----------
  Rebase: [cherry-pick] [BOLT] Add option to skip writing an output file

Summary:
The user may wish to run BOLT for printing statistics only
(i.e. to check that the profile is valid). Add an option to run BOLT
without writing any output file, similar to a dry run. This option
is triggered by supplying -o with "/dev/null".

(cherry picked from FBD29568632)


  Commit: f1bfb18ceb66b12bd7dcc760d9d10123d506d0e3
      https://github.com/llvm/llvm-project/commit/f1bfb18ceb66b12bd7dcc760d9d10123d506d0e3
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-03-18 (Thu, 18 Mar 2021)

  Changed paths:
    M bolt/src/BinarySection.h
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Refactor SectionPatchers map to a Patcher in BinarySection

Summary:
Refactor SectionPatches to avoid the use of extra map and a cast
from StringRef to std::string.

cherry-picked from FBD26756560

(cherry picked from FBD27490641)


  Commit: 35732d954b5b189094fd0a2864f66d9ca1bd5bb2
      https://github.com/llvm/llvm-project/commit/35732d954b5b189094fd0a2864f66d9ca1bd5bb2
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-04-06 (Tue, 06 Apr 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT] Remove cantFail in getAddressRanges calls

Summary:
We may have a CU with empty ranges, so accept errors coming
from DWARFDie::getAddressRanges(). This happens when using tools that
selectively strip debuginfo from the binary.

(cherry picked from FBD27602731)


  Commit: dc2673a03958d621fe3af4e1dfc7a0f794d5766b
      https://github.com/llvm/llvm-project/commit/dc2673a03958d621fe3af4e1dfc7a0f794d5766b
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-04-07 (Wed, 07 Apr 2021)

  Changed paths:
    M bolt/src/RuntimeLibs/RuntimeLibrary.cpp

  Log Message:
  -----------
  [BOLT] Fix value invalidation bug in runtimelib

Summary:
We can't use a fragment of the old LibPath as an input
to create a new one.

(cherry picked from FBD27642728)


  Commit: c7306cc21987ff9e68b9629b6673b152ed0f0049
      https://github.com/llvm/llvm-project/commit/c7306cc21987ff9e68b9629b6673b152ed0f0049
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-04-08 (Thu, 08 Apr 2021)

  Changed paths:
    M bolt/runtime/instr.cpp
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.cpp
    M bolt/src/BinaryData.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/BoltAddressTranslation.h
    M bolt/src/BoltDiff.cpp
    M bolt/src/CacheMetrics.cpp
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataReader.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/DynoStats.cpp
    M bolt/src/DynoStats.h
    M bolt/src/Exceptions.cpp
    M bolt/src/ExecutableFileMemoryManager.cpp
    M bolt/src/Heatmap.cpp
    M bolt/src/JumpTable.cpp
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/NameResolver.h
    M bolt/src/ParallelUtilities.cpp
    M bolt/src/Passes/Aligner.cpp
    M bolt/src/Passes/AllocCombiner.cpp
    M bolt/src/Passes/BinaryFunctionCallGraph.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/CallGraph.cpp
    M bolt/src/Passes/CallGraph.h
    M bolt/src/Passes/CallGraphWalker.cpp
    M bolt/src/Passes/DataflowAnalysis.cpp
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/DataflowInfoManager.cpp
    M bolt/src/Passes/DominatorAnalysis.h
    M bolt/src/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/HFSort.cpp
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/InstrumentationSummary.h
    M bolt/src/Passes/JTFootprintReduction.cpp
    M bolt/src/Passes/LivenessAnalysis.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/LongJmp.h
    M bolt/src/Passes/MCF.cpp
    M bolt/src/Passes/PLTCall.cpp
    M bolt/src/Passes/PatchEntries.cpp
    M bolt/src/Passes/PettisAndHansen.cpp
    M bolt/src/Passes/ReachingDefOrUse.h
    M bolt/src/Passes/ReachingInsns.h
    M bolt/src/Passes/RegAnalysis.cpp
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/Passes/ReorderAlgorithm.cpp
    M bolt/src/Passes/ReorderData.cpp
    M bolt/src/Passes/ReorderFunctions.cpp
    M bolt/src/Passes/ReorderUtils.h
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Passes/ShrinkWrapping.h
    M bolt/src/Passes/SplitFunctions.cpp
    M bolt/src/Passes/StackAllocationAnalysis.cpp
    M bolt/src/Passes/StackAvailableExpressions.cpp
    M bolt/src/Passes/StackPointerTracking.h
    M bolt/src/Passes/StackReachingUses.cpp
    M bolt/src/Passes/StokeInfo.cpp
    M bolt/src/Passes/StokeInfo.h
    M bolt/src/Passes/ValidateInternalCalls.cpp
    M bolt/src/Passes/ValidateInternalCalls.h
    M bolt/src/Passes/VeneerElimination.cpp
    M bolt/src/Relocation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/RuntimeLibrary.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    M bolt/src/YAMLProfileReader.cpp
    M bolt/src/YAMLProfileWriter.cpp
    M bolt/src/llvm-bolt.cpp
    M bolt/src/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  Rebase: [BOLT][NFC] Expand auto types

Summary:
Expanded auto types across BOLT semi-automatically with the aid
of clangd LSP

(cherry picked from FBD33289309)


  Commit: f84f451a54a483a51ac70f2d80e6c766ef2eb0f7
      https://github.com/llvm/llvm-project/commit/f84f451a54a483a51ac70f2d80e6c766ef2eb0f7
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-04-17 (Sat, 17 Apr 2021)

  Changed paths:
    M bolt/src/Passes/LivenessAnalysis.h
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Use const reference for MCInstrDesc

Summary:
Addressing comments from the review for "Expand auto types".
Use const reference in MCPlusBuilder for MCInstrDesc where the copy
is not necessary.

(cherry picked from FBD27844344)


  Commit: 3355936e145c623ab5bd6afe4b70b6ccbcd9bcbf
      https://github.com/llvm/llvm-project/commit/3355936e145c623ab5bd6afe4b70b6ccbcd9bcbf
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-04-21 (Wed, 21 Apr 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][NFC] Remove RewriteInstance::EHFrame

(cherry picked from FBD27915725)


  Commit: f8fa3e97d5b3c5add9be7b983c92791391473695
      https://github.com/llvm/llvm-project/commit/f8fa3e97d5b3c5add9be7b983c92791391473695
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-04-21 (Wed, 21 Apr 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Remove -dump-eh-frame option

Summary: The option duplicates functionality of "llvm-dwarfdump -eh-frame".

(cherry picked from FBD27917505)


  Commit: bd86c06c1b326c9ef4abf1aefbbf9939522a6219
      https://github.com/llvm/llvm-project/commit/bd86c06c1b326c9ef4abf1aefbbf9939522a6219
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-04-21 (Wed, 21 Apr 2021)

  Changed paths:
    M bolt/src/Exceptions.h

  Log Message:
  -----------
  [BOLT][NFC] Remove CFIReaderWriter::fdes()

(cherry picked from FBD27918126)


  Commit: 52391820757ecdd59d74e141fff360662affe68f
      https://github.com/llvm/llvm-project/commit/52391820757ecdd59d74e141fff360662affe68f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-04-30 (Fri, 30 Apr 2021)

  Changed paths:
    M bolt/src/DataAggregator.cpp

  Log Message:
  -----------
  [perf2bolt] Further relax segment matching

Summary:
Previously, we used p_align value of the code segment to predict the
mapping of the segment at runtime. However, at times the reported
value is not aligned and at other times the actual aligned value will
be different because of the different page size used.
All we know is that the page size used at runtime should not exceed
p_align value. Adjust our segment address matching accordingly.

(cherry picked from FBD28133066)


  Commit: eb99a6665c6e21d70bf230e09b6507b8fb69c2fc
      https://github.com/llvm/llvm-project/commit/eb99a6665c6e21d70bf230e09b6507b8fb69c2fc
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-04-30 (Fri, 30 Apr 2021)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryEmitter.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryFunctionProfile.cpp
    M bolt/src/BinaryPassManager.h
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/BoltAddressTranslation.h
    M bolt/src/BoltDiff.cpp
    M bolt/src/CacheMetrics.cpp
    M bolt/src/CacheMetrics.h
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataAggregator.h
    M bolt/src/DataReader.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/DynoStats.cpp
    M bolt/src/DynoStats.h
    M bolt/src/Exceptions.cpp
    M bolt/src/Exceptions.h
    M bolt/src/ExecutableFileMemoryManager.h
    M bolt/src/Heatmap.h
    M bolt/src/JumpTable.cpp
    M bolt/src/JumpTable.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/MachORewriteInstance.h
    M bolt/src/ParallelUtilities.cpp
    M bolt/src/ParallelUtilities.h
    M bolt/src/Passes/AllocCombiner.h
    M bolt/src/Passes/BinaryFunctionCallGraph.h
    M bolt/src/Passes/BinaryPasses.h
    M bolt/src/Passes/CallGraph.h
    M bolt/src/Passes/CallGraphWalker.cpp
    M bolt/src/Passes/CallGraphWalker.h
    M bolt/src/Passes/DataflowAnalysis.h
    M bolt/src/Passes/DataflowInfoManager.h
    M bolt/src/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/FrameAnalysis.h
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/FrameOptimizer.h
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/IdenticalCodeFolding.h
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/Inliner.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/Passes/JTFootprintReduction.cpp
    M bolt/src/Passes/JTFootprintReduction.h
    M bolt/src/Passes/LivenessAnalysis.h
    M bolt/src/Passes/MCF.cpp
    M bolt/src/Passes/PLTCall.h
    M bolt/src/Passes/PatchEntries.h
    M bolt/src/Passes/RegAnalysis.cpp
    M bolt/src/Passes/RegAnalysis.h
    M bolt/src/Passes/RegReAssign.cpp
    M bolt/src/Passes/ReorderAlgorithm.cpp
    M bolt/src/Passes/ReorderAlgorithm.h
    M bolt/src/Passes/ReorderData.cpp
    M bolt/src/Passes/ReorderData.h
    M bolt/src/Passes/ReorderFunctions.h
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/Passes/RetpolineInsertion.h
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Passes/ShrinkWrapping.h
    M bolt/src/Passes/SplitFunctions.cpp
    M bolt/src/Passes/SplitFunctions.h
    M bolt/src/Passes/StackAllocationAnalysis.cpp
    M bolt/src/Passes/StackAllocationAnalysis.h
    M bolt/src/Passes/StackAvailableExpressions.cpp
    M bolt/src/Passes/StackAvailableExpressions.h
    M bolt/src/Passes/StackPointerTracking.cpp
    M bolt/src/Passes/StackPointerTracking.h
    M bolt/src/Passes/StackReachingUses.h
    M bolt/src/Passes/StokeInfo.cpp
    M bolt/src/Passes/StokeInfo.h
    M bolt/src/Passes/ValidateInternalCalls.cpp
    M bolt/src/Passes/VeneerElimination.h
    M bolt/src/ProfileReaderBase.cpp
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    M bolt/src/YAMLProfileReader.h
    M bolt/src/YAMLProfileWriter.cpp
    M bolt/src/YAMLProfileWriter.h
    M bolt/src/llvm-bolt.cpp
    M bolt/src/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  Rebase: [BOLT][NFC] Remove unneeded includes with include-what-you-use

Summary:
Ran iwyu multiple times, manually picked header remove lines.
Reached fixed point wrt removal: iwyu doesn't automatically remove
any more headers or forward declarations.

(cherry picked from FBD29569221)


  Commit: 94653797f38f2472008ad9aed89101785e484983
      https://github.com/llvm/llvm-project/commit/94653797f38f2472008ad9aed89101785e484983
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-05-04 (Tue, 04 May 2021)

  Changed paths:
    M bolt/test/CMakeLists.txt
    M bolt/test/X86/bb_with_two_tail_calls.s
    M bolt/test/X86/fix-branches-jrcxz.s
    M bolt/test/X86/hot_end_symbol.s
    M bolt/test/X86/no-output.test
    M bolt/test/X86/section_reloc_with_addend.s
    M bolt/test/X86/shrinkwrapping-alignment.s
    M bolt/test/X86/shrinkwrapping-critedge.s
    M bolt/test/X86/shrinkwrapping-insertcfi.s
    M bolt/test/X86/shrinkwrapping-lock.s
    M bolt/test/X86/shrinkwrapping-pushpop.s
    M bolt/test/X86/split_func_jump_table_fragment.s
    M bolt/test/X86/split_func_jump_table_fragment_noparent.s
    M bolt/test/X86/split_func_jump_table_fragment_reverse.s
    M bolt/test/X86/user-func-reorder.c
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  Rebase: [BOLT][NFC] Avoid binutils in tests

Summary:
Replace binutils tools with llvm tools

(cherry picked from FBD29575630)


  Commit: 9a884543f167717cb46cf4e6e92d9e0ef521bddd
      https://github.com/llvm/llvm-project/commit/9a884543f167717cb46cf4e6e92d9e0ef521bddd
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-05-07 (Fri, 07 May 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BoltAddressTranslation.cpp
    M bolt/src/CacheMetrics.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/Passes/BinaryFunctionCallGraph.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/src/Passes/FrameOptimizer.cpp
    M bolt/src/Passes/HFSortPlus.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/ReorderData.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Avoid unnecessary copies with push_back

Summary: Small refactoring inspired by clang-tidy modernize-use-emplace

(cherry picked from FBD28307493)


  Commit: ce84e9607a41b3c3b6f3c23cf6463fd7524a3653
      https://github.com/llvm/llvm-project/commit/ce84e9607a41b3c3b6f3c23cf6463fd7524a3653
  Author: Alexey Moksyakov <aleksey.moksyakov at huawei.com>
  Date:   2021-04-23 (Fri, 23 Apr 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    A bolt/test/X86/bug-reorder-bb-jrcxz.s
    M bolt/test/X86/fix-branches-jrcxz.s

  Log Message:
  -----------
  [PR] Fix bb reordering optimization

Summary:
Reorder-blocks optimization pass doesn't take into account that
available offset for legacy Jcc instructions (for example,
JRCXZ - operand 8 bits) has to be less than 255 bytes.
It's rare case and to exclude such functions with unsupported
instructions from optimization passes added extra checking

Alexey Moksyakov
Advanced Software Technology Lab, Huawei

(cherry picked from FBD28264117)


  Commit: de298c08fd878efdd230eae6f150489dbeb39ea8
      https://github.com/llvm/llvm-project/commit/de298c08fd878efdd230eae6f150489dbeb39ea8
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-05-11 (Tue, 11 May 2021)

  Changed paths:
    M bolt/test/X86/bb_with_two_tail_calls.s
    M bolt/test/X86/debugTypesBug.s
    M bolt/test/X86/false-jump-table.s
    M bolt/test/X86/fix-branches-jrcxz.s
    M bolt/test/X86/hot_end_symbol.s
    M bolt/test/X86/instrumentation-dup-jts.s
    M bolt/test/X86/instrumentation-ind-calls.s
    M bolt/test/X86/interprocedural_ref_entry_point.s
    M bolt/test/X86/issue20.s
    M bolt/test/X86/issue26.s
    M bolt/test/X86/section_reloc_with_addend.s
    M bolt/test/X86/shrinkwrapping-alignment.s
    M bolt/test/X86/shrinkwrapping-critedge.s
    M bolt/test/X86/shrinkwrapping-insertcfi.s
    M bolt/test/X86/shrinkwrapping-lock.s
    M bolt/test/X86/shrinkwrapping-pushpop.s
    M bolt/test/X86/split_func_jump_table_fragment.s
    M bolt/test/X86/split_func_jump_table_fragment_noparent.s
    M bolt/test/X86/split_func_jump_table_fragment_reverse.s
    M bolt/test/X86/user-func-reorder.c
    M bolt/test/X86/zero-sized-object.s
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  [PR] Fix tests build with -no-pie option

Summary:
Since gcc/ld could produce and expect PIE files we need to pass -no-pie option to avoid linking errors for tests.
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD28360045)


  Commit: b728bfc70a8d4fd65ad99688aa327ad6e5b92815
      https://github.com/llvm/llvm-project/commit/b728bfc70a8d4fd65ad99688aa327ad6e5b92815
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-05-11 (Tue, 11 May 2021)

  Changed paths:
    M bolt/src/Passes/CallGraph.h

  Log Message:
  -----------
  [PR] Add missing includes

Summary:
Adds missing headers removed by IWYU.
NB: this caused build breakage on ubuntu-latest

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD28368185)


  Commit: fe37f1870e2896184cb99836ae47b43b91af4381
      https://github.com/llvm/llvm-project/commit/fe37f1870e2896184cb99836ae47b43b91af4381
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-05-13 (Thu, 13 May 2021)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BoltDiff.cpp
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataReader.cpp
    M bolt/src/Exceptions.cpp
    M bolt/src/Heatmap.cpp
    M bolt/src/JumpTable.cpp
    M bolt/src/Passes/Aligner.cpp
    M bolt/src/Passes/AllocCombiner.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/CallGraphWalker.cpp
    M bolt/src/Passes/FrameAnalysis.cpp
    M bolt/src/Passes/IdenticalCodeFolding.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/Inliner.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/MCF.cpp
    M bolt/src/Passes/ReorderData.cpp
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/Passes/ValidateInternalCalls.cpp
    M bolt/src/Relocation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    M bolt/src/YAMLProfileReader.cpp
    M bolt/src/YAMLProfileWriter.cpp
    M bolt/src/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT][NFC] Follow LLVM variable initialization style

(cherry picked from FBD28417604)


  Commit: 500edf26c95ee9eb938ed235180bc44acf525b21
      https://github.com/llvm/llvm-project/commit/500edf26c95ee9eb938ed235180bc44acf525b21
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-05-10 (Mon, 10 May 2021)

  Changed paths:
    M bolt/src/Passes/DataflowAnalysis.h

  Log Message:
  -----------
  [BOLT][NFC] Address warning about ProgramPoint implicit copy constructor

Summary:
Explicit assignment operator can be replaced with an implicit one.
Remove it to allow an implicit copy constructor:
```
bolt/src/Passes/DataflowAnalysis.h:74:8: warning: definition of
implicit copy constructor for 'ProgramPoint' is deprecated because it
has a user-declared copy assignment operator [-Wdeprecated-copy]
  void operator=(const ProgramPoint &PP) {
       ^
bolt/src/Passes/DataflowAnalysis.h:62:14: note: in implicit copy
constructor for 'llvm::bolt::ProgramPoint' first required here
      return ProgramPoint(&*Last);
```

(cherry picked from FBD28335138)


  Commit: 81c59d9a54ed8c83ef439cbb63644db0d5c908cd
      https://github.com/llvm/llvm-project/commit/81c59d9a54ed8c83ef439cbb63644db0d5c908cd
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-05-12 (Wed, 12 May 2021)

  Changed paths:
    M bolt/src/BinarySection.cpp
    M bolt/src/BinarySection.h
    M bolt/src/Relocation.h

  Log Message:
  -----------
  [BOLT][NFC] Change interface for searching relocations

(cherry picked from FBD28406629)


  Commit: ba6fdb8113108ed017e046b307b0c7c7d4527465
      https://github.com/llvm/llvm-project/commit/ba6fdb8113108ed017e046b307b0c7c7d4527465
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-05-12 (Wed, 12 May 2021)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinarySection.h
    M bolt/src/JumpTable.cpp

  Log Message:
  -----------
  [BOLT] Preserve original jump table relocations

Summary:
Remove relocations against internal function labels, e.g. jump table
relocations, only when overwriting them.

While reading an input file with relocations, we create internal
relocations against code references (we skip PIC relocations).
Later, when we discover jump tables, we remove corresponding relocations
with the assumption that original relocations will either be ignored or
replaced by new relocations. However, it is possible to miss some
references to the jump table, in which case the original entries will
not be ignored. While such situation is abnormal, it is still a
better/safer approach to preserve relocations if we are not replacing
them with new ones.

(cherry picked from FBD28406628)


  Commit: 99d7f90635020b7c149068783846f6ffd8c32523
      https://github.com/llvm/llvm-project/commit/99d7f90635020b7c149068783846f6ffd8c32523
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-05-13 (Thu, 13 May 2021)

  Changed paths:
    M bolt/test/CMakeLists.txt

  Log Message:
  -----------
  [BOLT][NFC][TEST] Added llvm-dwarfdump and llvm-mc to BOLT_TEST_DEPS

(cherry picked from FBD28427352)


  Commit: 12e9fec69742e2cc487313118abfd284dce49f0f
      https://github.com/llvm/llvm-project/commit/12e9fec69742e2cc487313118abfd284dce49f0f
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-04-01 (Thu, 01 Apr 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryData.h
    M bolt/src/BinaryFunction.cpp
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/MachORewriteInstance.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    A bolt/test/X86/Inputs/debug-fission-script.txt
    A bolt/test/X86/Inputs/debug-fission-simple.s
    A bolt/test/X86/debug-fission-single.s

  Log Message:
  -----------
  Rebase: [BOLT] DebugFission Support

Summary:
Implemented support for Debug Fission.
For the most part it doesn't impact Monolithic execution path.
One area that was changed is the DW_AT_low_pc/DW_AT_high_pc conversion. Before it was to DW_AT_ranges/DW_AT_low_pc, now DW_AT_low_pc is kept in same place.
Another more visible impact is in Skeleton CU the DW_AT_low_pc is replaced with DW_AT_ranges_base if it's not originally present and bolt converted ranges conversion inside the dwo units.

Output of this are multiple .dwo files with updated debug information.

(cherry picked from FBD29569788)


  Commit: 79807d99fe9665b104fb62064f530a78783340aa
      https://github.com/llvm/llvm-project/commit/79807d99fe9665b104fb62064f530a78783340aa
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-05-11 (Tue, 11 May 2021)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/BinaryPasses.cpp
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/LoopInversionPass.cpp
    A bolt/src/Passes/LoopInversionPass.h
    A bolt/test/X86/loop-inversion-pass.s
    M bolt/test/link_fdata.sh

  Log Message:
  -----------
  [PR] Introduce loop inversion pass

Summary:
This patch introduces LoopInversionPass. Its main purpose is to ensure
that the loop layout is optimal depending on the profile information. So
if profile information shows that the loop is used, the unconditional
jump instruction must be executed only once and vice-versa. Please take
a look to the pass header file and test for more details.

Also change link_fdata script a bit, to be able to change FDATA prefix,
like FileCheck does.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

PR facebookincubator/BOLT#153

(cherry picked from FBD28391811)


  Commit: 5a6c379f5b9456a13b17e6c6f5c39dc92016763f
      https://github.com/llvm/llvm-project/commit/5a6c379f5b9456a13b17e6c6f5c39dc92016763f
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-05-14 (Fri, 14 May 2021)

  Changed paths:
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Emit paddings to preserve data alignment

Summary:
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

facebookincubator/BOLT#156

(cherry picked from FBD28521843)


  Commit: a26370389a3ed3898f451f8f6ff83c61a2e9bf11
      https://github.com/llvm/llvm-project/commit/a26370389a3ed3898f451f8f6ff83c61a2e9bf11
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-05-26 (Wed, 26 May 2021)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][NFC] Disable ProcessAllSections in RuntimeDyld

Summary:
FBD55943 changed the way ProcessAllSections works in RuntimeDyld. After
the change, all sections, including symbol table, section table, etc.
are loaded into memory whenever ProcessAllSections is enabled.

In BOLT we rely on RuntimeDyld for processing sections with relocations.
These include most allocatable sections and additionally .debug_line.
The latter is skipped by RuntimeDyld without ProcessAllSections flag.
If we enable ProcessAllSections, we will have to deal with allocating
memory for more sections than we need (see above) and later to filter
them out.

The alternative is to mark all sections that we actually plan to use as
"required for execution" (using RuntimeDyld terminology). For
.debug_line section on ELF it means adding SHF_ALLOC flag. On MachO,
RuntimeDyld currently treats all sections as required.

(cherry picked from FBD28729398)


  Commit: 1c06193d0f4f04fd191ad982fc59752aebc28763
      https://github.com/llvm/llvm-project/commit/1c06193d0f4f04fd191ad982fc59752aebc28763
  Author: James Luo <jamesluox at fb.com>
  Date:   2021-06-02 (Wed, 02 Jun 2021)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/JumpTable.cpp
    M bolt/src/Passes/IdenticalCodeFolding.cpp

  Log Message:
  -----------
  [BOLT] Resolve JumpTable namespace issue in pseudo probe decoder migration

Summary: This diff fixes the JumpTable namespace conflicts during the migration of pseudo probe decoder.

(cherry picked from FBD28859927)


  Commit: 65d227c03557b231b76941593eebac2aa6c9dbb3
      https://github.com/llvm/llvm-project/commit/65d227c03557b231b76941593eebac2aa6c9dbb3
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-02 (Wed, 02 Jun 2021)

  Changed paths:
    M bolt/test/X86/split_func_jump_table_fragment.s

  Log Message:
  -----------
  [BOLT][TEST] Fix test case to conform to analyzePICJumpTable pattern matching

Summary:
Make sure that jump table is properly recognized in
`split_func_jump_table_fragment.s`.

(cherry picked from FBD28839976)


  Commit: 7bccf8d25d6f003c4124acd652927c14a5b92756
      https://github.com/llvm/llvm-project/commit/7bccf8d25d6f003c4124acd652927c14a5b92756
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-06-04 (Fri, 04 Jun 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    A bolt/test/X86/Inputs/inline-foo.c
    A bolt/test/X86/Inputs/inline-main.c
    A bolt/test/X86/inline-debug-info.test
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  [BOLT][NFC] Fix debug info printouts for inlined functions

Summary:
While printing debug info for instructions, we should use line tables
from the corresponding DWARF CU which could be different from the
containing function CU in case of inlined instructions.

(cherry picked from FBD28908324)


  Commit: 2da5b12a3dcf9a1bd3e0737cee623694ac81ee1b
      https://github.com/llvm/llvm-project/commit/2da5b12a3dcf9a1bd3e0737cee623694ac81ee1b
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-02 (Wed, 02 Jun 2021)

  Changed paths:
    M bolt/runtime/common.h
    M bolt/runtime/hugify.cpp

  Log Message:
  -----------
  [BOLT] Hugify: check for THP support via sysfs

Summary:
Remove dependence on kernel version check, query sysfs directly
instead.

(cherry picked from FBD28858208)


  Commit: 226d1c3b0bbd534574fa5e104d58cace6eebc262
      https://github.com/llvm/llvm-project/commit/226d1c3b0bbd534574fa5e104d58cace6eebc262
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-06-09 (Wed, 09 Jun 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp

  Log Message:
  -----------
  [BOLT] Change how DF DWO logging is handled

Summary: Changing assert to a warning when DWO debug information can't be retrieved. Usually due to invalid path.

(cherry picked from FBD29005217)


  Commit: 8a919593c7848f3b7121fa0c03b383d889e88117
      https://github.com/llvm/llvm-project/commit/8a919593c7848f3b7121fa0c03b383d889e88117
  Author: James Luo <jamesluox at fb.com>
  Date:   2021-06-11 (Fri, 11 Jun 2021)

  Changed paths:
    M bolt/src/BinaryContext.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][CSSPGO] Pseudo probe decoding

Summary:
Make bolt decode pseudo probe section in binary

For more detail of pseudo probe, check https://reviews.llvm.org/D86490.

(cherry picked from FBD28856316)


  Commit: f7f0a571d7e180167edb6b2be05d18224f3baa38
      https://github.com/llvm/llvm-project/commit/f7f0a571d7e180167edb6b2be05d18224f3baa38
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-02 (Wed, 02 Jun 2021)

  Changed paths:
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT][NFC] Suppress addList override warning

Summary:
Suppresses the warning
```
src/DebugData.h:338:20: warning: 'addList' overrides a member function but is not marked 'override' [-Wsuggest-override]
```

(cherry picked from FBD28858201)


  Commit: 1efadeedf26ac2b6dff511a1379e478483bdd9c5
      https://github.com/llvm/llvm-project/commit/1efadeedf26ac2b6dff511a1379e478483bdd9c5
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-06-13 (Sun, 13 Jun 2021)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT] Fix rodata load simplification pass

Summary:
If the target address has a runtime relocation against it, do not
perform the load simplification.

(cherry picked from FBD29091939)


  Commit: 2cf9008a60a7d29e643fe13fa3c9e45171c76170
      https://github.com/llvm/llvm-project/commit/2cf9008a60a7d29e643fe13fa3c9e45171c76170
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-06-04 (Fri, 04 Jun 2021)

  Changed paths:
    M bolt/runtime/common.h

  Log Message:
  -----------
  [PR] Instrumentation: Disable signals on mutex lock

Summary:
When indirect call is instrmented it locks SimpleHashTable's mutex on get() call.
If while locked we we receive a signal and signal handler also will call
indirect function we will end up with deadlock.

PR facebookincubator/BOLT#167

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD28909921)


  Commit: a8b9319536274230550f05ed08565029f0f01a1d
      https://github.com/llvm/llvm-project/commit/a8b9319536274230550f05ed08565029f0f01a1d
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-06-02 (Wed, 02 Jun 2021)

  Changed paths:
    M bolt/src/Relocation.cpp
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [PR] Patch allocatable relocations for AArch64

Summary: PR facebookincubator/BOLT#166

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD28910060)


  Commit: e485a9830b69161475a7f36d1c16b8c9609388cf
      https://github.com/llvm/llvm-project/commit/e485a9830b69161475a7f36d1c16b8c9609388cf
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-06-16 (Wed, 16 Jun 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  Rebase: [BOLT][DebugFission] Fix reading support for DWP

Summary:
Dived more in to DWARF APIs and llvm-symbolizer this is a more streamline way of doing it, and address base gets set properly.
Writing out dwo files with dwp input will be separate patch.

(cherry picked from FBD31361529)


  Commit: ba915af1cd7d78db7a62a78e6d452ee8445d0ae7
      https://github.com/llvm/llvm-project/commit/ba915af1cd7d78db7a62a78e6d452ee8445d0ae7
  Author: Sameeran joshi <joshisameeran17 at gmail.com>
  Date:   2021-06-08 (Tue, 08 Jun 2021)

  Changed paths:
    M bolt/src/llvm-bolt.cpp

  Log Message:
  -----------
  [PR][BOLT] Print revision in perf2bolt and bolt-diff modes"

Summary:
Fix issue facebookincubator/BOLT#160
PR facebookincubator/BOLT#172

(cherry picked from FBD29139522)


  Commit: bbbd159ccb1cf3d5a5580e84736f406ee005ca53
      https://github.com/llvm/llvm-project/commit/bbbd159ccb1cf3d5a5580e84736f406ee005ca53
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-06-18 (Fri, 18 Jun 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    A bolt/test/X86/Inputs/icf-jump-tables.c
    A bolt/test/X86/icf-jump-tables.test

  Log Message:
  -----------
  [BOLT] Fix undefined symbol warnings/errors

Summary:
When we fold a function in relocation mode, make sure to clear its state
to avoid emitting relocations against undefined symbols.

(cherry picked from FBD29245320)


  Commit: be0da0fac27b2f3bf5a604876db0b9cbe01ecc07
      https://github.com/llvm/llvm-project/commit/be0da0fac27b2f3bf5a604876db0b9cbe01ecc07
  Author: Joey Thaman <jthaman at fb.com>
  Date:   2021-06-21 (Mon, 21 Jun 2021)

  Changed paths:
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  Throw an error in instrument for dynamic libs

Summary:
In InstrumentatonRuntimeLibrary, throw an error

if the program uses dynamic libraries

(cherry picked from FBD29265147)


  Commit: f46af9e9bc1c67fb5df95fc5a8b5ad72b59c5c3d
      https://github.com/llvm/llvm-project/commit/f46af9e9bc1c67fb5df95fc5a8b5ad72b59c5c3d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-06-23 (Wed, 23 Jun 2021)

  Changed paths:
    M bolt/test/X86/icf-jump-tables.test

  Log Message:
  -----------
  [BOLT][TESTS] Fix ICF test case

Summary:
Host compiler may generate duplicate functions and as a result BOLT can
fold more than 1 function.

(cherry picked from FBD29347302)


  Commit: da276d73c7353cf2dc382e6e302e6560da50476a
      https://github.com/llvm/llvm-project/commit/da276d73c7353cf2dc382e6e302e6560da50476a
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-24 (Thu, 24 Jun 2021)

  Changed paths:
    M bolt/src/BinarySection.cpp

  Log Message:
  -----------
  [BOLT] Handle R_X86_64_64 in flushPendingRelocations

Summary:
Handle R_X86_64_64 the same way as R_X86_64_32;
`getSizeForType` takes care of the size:

```x86_64 ABI relocation types
Name        Value Field  Calculation
R_X86_64_64 1     word64 S + A
R_X86_64_32 10    word32 S + A
```

(cherry picked from FBD29370417)


  Commit: 521a61b0560a686ddb15e20957ed5592b333f5f7
      https://github.com/llvm/llvm-project/commit/521a61b0560a686ddb15e20957ed5592b333f5f7
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-16 (Wed, 16 Jun 2021)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/StokeInfo.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Use MCPlusBuilder::isPseudo

Summary: Consistently use this interface across BOLT codebase

(cherry picked from FBD29171718)


  Commit: dea6c247d93754e5909ceea7e4169d550b552045
      https://github.com/llvm/llvm-project/commit/dea6c247d93754e5909ceea7e4169d550b552045
  Author: James Luo <jamesluox at fb.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][CSSPGO] Relate decoded pseudo probe basic blocks

Summary:
Assign decoded pseudo probe to correlated output block

Pseudo probes can then be encoded to a proper address

(cherry picked from FBD29211688)


  Commit: b964e852d569e4c6fbd82c2a09b61fdb3c7a743b
      https://github.com/llvm/llvm-project/commit/b964e852d569e4c6fbd82c2a09b61fdb3c7a743b
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-17 (Thu, 17 Jun 2021)

  Changed paths:
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Readability improvements in X86,Aarch64 MCPlusBuilder

Summary: Minor refactorings in target specific MCPlusBuilders to improve readability

(cherry picked from FBD29309701)


  Commit: ef1b1e7184f7c012302a28a2aa6ed56419d21746
      https://github.com/llvm/llvm-project/commit/ef1b1e7184f7c012302a28a2aa6ed56419d21746
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-17 (Thu, 17 Jun 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT][NFC] Refactor handlePCRelOperand

Summary: Move error logging to handlePCRelOperand, reduce code duplication

(cherry picked from FBD29309702)


  Commit: 38c58879928d5a67f35db49e40e9a686954e5df3
      https://github.com/llvm/llvm-project/commit/38c58879928d5a67f35db49e40e9a686954e5df3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-06-22 (Tue, 22 Jun 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][NFC] Always process runtime relocations

Summary:
Dynamic relocations applied at runtime should be processed even in
non-relocation mode.

(cherry picked from FBD29311906)


  Commit: 8f7a400629d21aa61a319e54a84da91baaa905ff
      https://github.com/llvm/llvm-project/commit/8f7a400629d21aa61a319e54a84da91baaa905ff
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT][NFC] Delete MoveRelocations entirely

Summary: MoveRelocations are unused. Remove interfaces and emission part.

(cherry picked from FBD29468409)


  Commit: 8f751bc0581fb9b63fecd3b883b0d1098c9aa354
      https://github.com/llvm/llvm-project/commit/8f751bc0581fb9b63fecd3b883b0d1098c9aa354
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT][NFC] Un-inline adding external references out of disassemble loop

Summary:
Move the code that handles true external references (non-unreachable)
out of a for-loop in `BinaryFunction::disassemble`.

(cherry picked from FBD29411345)


  Commit: c7c0803b5961dde5280f05899fe58203fc120438
      https://github.com/llvm/llvm-project/commit/c7c0803b5961dde5280f05899fe58203fc120438
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT][NFC] Un-inline indirect branch handling out of disassemble loop

Summary:
Move the `processIndirectBranch` switch statement out of a for-loop
in `BinaryFunction::disassemble`

(cherry picked from FBD29411346)


  Commit: a07d24cc4bd14ede648f8dd8616135fd8566b421
      https://github.com/llvm/llvm-project/commit/a07d24cc4bd14ede648f8dd8616135fd8566b421
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT][NFC] Un-inline checking AArch64 linker veneers out of disassemble loop

Summary:
Move the AArch64 `matchLinkerVeneer` check out of a for-loop
in `BinaryFunction::disassemble`

(cherry picked from FBD29411348)


  Commit: 3e5ce1f2821448d9e0a4352e4e90bad7c46d2019
      https://github.com/llvm/llvm-project/commit/3e5ce1f2821448d9e0a4352e4e90bad7c46d2019
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-06-30 (Wed, 30 Jun 2021)

  Changed paths:
    M bolt/test/X86/Inputs/blarge.yaml
    M bolt/test/X86/Inputs/issue20.yaml
    M bolt/test/X86/Inputs/issue26.yaml
    M bolt/test/X86/Inputs/srol-bug-input.yaml

  Log Message:
  -----------
  [BOLT][TESTS] Remove dynamic relocations from YAML tests

Summary:
Our YAML objects contain references to dynamic relocations via .dynamic,
but there are no corresponding relocation sections. Change .dynamic
contents to specify no dynamic relocations.

(cherry picked from FBD29502108)


  Commit: f7499c671191253b8f9c96b04c6dd9cb5642d0ee
      https://github.com/llvm/llvm-project/commit/f7499c671191253b8f9c96b04c6dd9cb5642d0ee
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-06-18 (Fri, 18 Jun 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Fix writing out dwo with DWP as input

Summary:
The code for writing out dwo files wasn't handling case where DWP is an input.
Because all the sections are part of the same binary.

One note with current implementation. .debug-str.dwo will have strings for all the dwo objects.
This is because llvm-dwp de-duplicates strings and combines them in to one section. It then re-writes .debug-str-offsets.dwo to point to new .debug-str.dwo section.

(cherry picked from FBD29244835)


  Commit: 1de0746790d0fc32b774b0cf2c3fc3bcb9d43ac2
      https://github.com/llvm/llvm-project/commit/1de0746790d0fc32b774b0cf2c3fc3bcb9d43ac2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-06-30 (Wed, 30 Jun 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT] Read all dynamic relocations and refactor code

Summary:
Add code to read more dynamic relocations (DT_JMPREL) and enforce strict
checks that corresponding sections sizes match .dynamic entry
description.

(cherry picked from FBD29502109)


  Commit: 4c12afc1f459a9e7d16e2893240bf51d2c193bb3
      https://github.com/llvm/llvm-project/commit/4c12afc1f459a9e7d16e2893240bf51d2c193bb3
  Author: Joey Thaman <jthaman at fb.com>
  Date:   2021-06-29 (Tue, 29 Jun 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/ParallelUtilities.cpp
    M bolt/src/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/src/Passes/IndirectCallPromotion.cpp
    M bolt/src/Passes/ShrinkWrapping.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][NFC] Resolved all clang-12 warnings for bolt

Summary:
clang-12 now compiles bolt without warnings.
Some warnings were fixed if possible while others were suppressed by
doing (void)variable for unused variable warnings or moving code inside
assert statements of LLVM_DEBUG blocks.

(cherry picked from FBD29469054)


  Commit: c9f5f47b518ccaf2d230cf1aa6d34611a2ab58ba
      https://github.com/llvm/llvm-project/commit/c9f5f47b518ccaf2d230cf1aa6d34611a2ab58ba
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-06-30 (Wed, 30 Jun 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    A bolt/test/X86/Inputs/plt-sec.yaml
    A bolt/test/X86/plt-sec.test

  Log Message:
  -----------
  [BOLT] Add support for .plt.sec and refactor PLT-reading code

Summary:
A binary can contain multiple PLT sections with different name and
attributes (such as an entry size). Extend the support to .plt.sec and
refactor the code to make future extensions simpler.

(cherry picked from FBD29502107)


  Commit: 60b15062e16a37fb94365c90289cbe3d19e3f270
      https://github.com/llvm/llvm-project/commit/60b15062e16a37fb94365c90289cbe3d19e3f270
  Author: Zino Benaissa <zinob at fb.com>
  Date:   2021-05-24 (Mon, 24 May 2021)

  Changed paths:
    M bolt/src/DynoStats.cpp
    M bolt/src/DynoStats.h
    M bolt/src/Passes/BinaryPasses.h

  Log Message:
  -----------
  [BOLT] Dump dynamic execution per instruction opcode

Summary:
We extended DynoStats to dump the histogram per instruction opcode. By
default the dump is turned off. Use '-print-dyno-opcode-stats' to enable
the dump.

BOLT also dumps for each instruction opcode the maximum execution count and
corresponding function name and basic block offsets where the instruction
occurs. Below is a sample of the dump:

                   Opcode,    Execution Count,      Max Exec Count, Function Name:Offset
                  SHR8rCL,                232,                 232, _ZNK5folly14AsyncSSLSocket4goodEv:53
                VPADDDYrr,              13956,                 388, chacha20_encrypt_bytes.part.0/3:736
               PMOVSXBWrr,                  4,                   2, ares_expand_name/1:264
                VMOVAPSmr,               1082,                  43, chacha20_encrypt_bytes.part.0/3:2864
                VPSHUFBrr,               9540,                1667, chacha20_encrypt_bytes.part.0/3:4416
            VPUNPCKLDQYrr,               1102,                 188, jsimd_ycc_rgb_convert_avx2/1:125
          VPBROADCASTQYrm,                 39,                  39, chacha20_encrypt_bytes.part.0/3:400
               PMOVSXWDrr,                  8,                   2, ares_expand_name/1:264
                   VPORrr,                817,                 129, jsimd_idct_islow_avx2/1:41
                  PSLLDri,            8690752,               65644, blockmix_salsa8_xor/1:1424

(cherry picked from FBD28859624)


  Commit: 2f466605595f70a440b44a5aba4c4310a0cc28a3
      https://github.com/llvm/llvm-project/commit/2f466605595f70a440b44a5aba4c4310a0cc28a3
  Author: Joey Thaman <jthaman at fb.com>
  Date:   2021-07-01 (Thu, 01 Jul 2021)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/TailDuplication.cpp
    A bolt/src/Passes/TailDuplication.h
    A bolt/test/X86/tail-duplication-pass.s

  Log Message:
  -----------
  [BOLT] Tail duplication analysis pass

Summary:
Created a binary pass that records how many
times tail duplication would be used and how many cache
misses it would theoretically stop

(cherry picked from FBD29619858)


  Commit: 3e55dea4dd1e3530f9e2d19033e8f5e0d65cda0a
      https://github.com/llvm/llvm-project/commit/3e55dea4dd1e3530f9e2d19033e8f5e0d65cda0a
  Author: James Luo <jamesluox at fb.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [BOLT][CSSPGO] Encode pseudo probe section to binary

Summary:
Update .pseudo_probe section in input binary

DFS inline tree and emit pseudo probes with updated addresses

(cherry picked from FBD29522142)


  Commit: 0df7bf7b8b8443fd2c235fa3909068ddf58e5415
      https://github.com/llvm/llvm-project/commit/0df7bf7b8b8443fd2c235fa3909068ddf58e5415
  Author: James Luo <jamesluox at fb.com>
  Date:   2021-07-16 (Fri, 16 Jul 2021)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][CSSPGO] Handle indirect call promotion in Pseudo Probe Integration

Summary:
Match new direct call generated during ICP to correct pseudo probe

New call is matched to the probes of original call instruction.

(cherry picked from FBD29591662)


  Commit: 68be8caf3f276c231f0583089723d1ae8d7b7fc3
      https://github.com/llvm/llvm-project/commit/68be8caf3f276c231f0583089723d1ae8d7b7fc3
  Author: Vasily Leonenko <vasily.leonenko at huawei.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  RewriteInstance: account .stab and .stabstr as debug sections

Summary:
.stab and .stabstr are special sections containing debugging
information and strings associated with the debugging information.
This commit adds them to the list of debugging sections, so
these sections can be removed for output binary.

Vasily Leonenko,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD29746153)


  Commit: a7e2a8f9468630fdf4773467395fb34564e7ae7a
      https://github.com/llvm/llvm-project/commit/a7e2a8f9468630fdf4773467395fb34564e7ae7a
  Author: Joey Thaman <jthaman at fb.com>
  Date:   2021-07-16 (Fri, 16 Jul 2021)

  Changed paths:
    M bolt/src/BinaryBasicBlock.cpp
    M bolt/src/BinaryBasicBlock.h
    M bolt/src/Passes/TailDuplication.cpp
    M bolt/src/Passes/TailDuplication.h
    A bolt/test/X86/tail-duplication-complex.s
    M bolt/test/X86/tail-duplication-pass.s

  Log Message:
  -----------
  [BOLT] Tail Duplication active pass

Summary:
Amended the Tail Duplication
analysis pass to do the tail duplication in question

(cherry picked from FBD29833794)


  Commit: c33f08e7df51e0160924c7b441859aa7eac5802e
      https://github.com/llvm/llvm-project/commit/c33f08e7df51e0160924c7b441859aa7eac5802e
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-07-28 (Wed, 28 Jul 2021)

  Changed paths:
    M bolt/README.md

  Log Message:
  -----------
  [BOLT] Update build instructions in README

Summary: Remove llvm.patch from build instructions.

(cherry picked from FBD29973395)


  Commit: 89a2e16037700f7f0f505190576f16fa47a5e669
      https://github.com/llvm/llvm-project/commit/89a2e16037700f7f0f505190576f16fa47a5e669
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-07-14 (Wed, 14 Jul 2021)

  Changed paths:
    M bolt/src/MCPlusBuilder.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    A bolt/test/X86/Inputs/plt-got-sec.yaml
    A bolt/test/X86/Inputs/plt-sec-8-byte.yaml
    A bolt/test/X86/plt-sec-8-byte.test
    M bolt/test/X86/plt-sec.test

  Log Message:
  -----------
  [BOLT] Support PLT sections with variable entry sizes

Summary:
The linker can generate 8- or 16-byte entries in .plt.got and .plt.sec
sections. On X86, the main differentiator is the presence of endbr64
instruction at the beginning of the entry. Detect the instruction and
adjust the size accordingly.

(cherry picked from FBD29847639)


  Commit: 60b10a8eade65114c7e6600675a11beed6f94091
      https://github.com/llvm/llvm-project/commit/60b10a8eade65114c7e6600675a11beed6f94091
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-07-29 (Thu, 29 Jul 2021)

  Changed paths:
    M bolt/src/MCPlus.h
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Unify isTailCall interface across X86 and AArch64

Summary:
Move the common code into MCPlusBuilder.h.
Use group 1 `kTailCall` MCAnnotation instead of dynamically allocated
annotation.
This diff reduces the processing time overhead to 1.5% vs using
TAILJMP opcode.

(cherry picked from FBD30055585)


  Commit: ad79d51778e37293502b7a8246fa387092771969
      https://github.com/llvm/llvm-project/commit/ad79d51778e37293502b7a8246fa387092771969
  Author: Vasily Leonenko <vasily.leonenko at huawei.com>
  Date:   2021-06-19 (Sat, 19 Jun 2021)

  Changed paths:
    M bolt/runtime/CMakeLists.txt
    M bolt/runtime/instr.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Generate and use _start and _fini trampolines

Summary:
This commit implements new method for _start & _fini functions hooking
which allows to use relative jumps for future PIE & .so library support.
Instead of using absolute address of _start & _fini functions known on
linking stage - we'll use dynamically created trampoline functions and
use corresponding symbols in instrumentation runtime library.

As we would like to use instrumentation for dynamically loaded binaries
(with PIE & .so), thus we need to compile instrumentation library with
"-fPIC" flag to support relative address resolution for functions and
data.

For shared libraries we need to handle initialization of instrumentation
library case by using DT_INIT section entry point.

Also this commit adds detection if the binary is executable or shared
library based on existence of PT_INTERP header. In case of shared
library we save information about real library init function address
for further usage for instrumentation library init trampoline function
creation and also update DT_INIT to point instrumentation library init
function.

Functions called from init/fini functions should be called with forced
stack alignment to avoid issues with instructions which relies on it.
E.g. optimized string operations.

Vasily Leonenko,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092316)


  Commit: 6665c628eab66e1c407adb71c6044ecc323e0344
      https://github.com/llvm/llvm-project/commit/6665c628eab66e1c407adb71c6044ecc323e0344
  Author: Elvina Yakubova <elvina.yakubova at huawei.com>
  Date:   2021-01-18 (Mon, 18 Jan 2021)

  Changed paths:
    M bolt/runtime/common.h

  Log Message:
  -----------
  [PR] Instrumentation: Add readlink and getdents support

Summary:
This commit adds support for getting directory entries and
reading value of a symbolic link in instrumentation runtime library

Elvina Yakubova,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092362)


  Commit: 2ffd6e2b430e00206ce60174f03f32ff6da6f051
      https://github.com/llvm/llvm-project/commit/2ffd6e2b430e00206ce60174f03f32ff6da6f051
  Author: Elvina Yakubova <elvina.yakubova at huawei.com>
  Date:   2021-01-19 (Tue, 19 Jan 2021)

  Changed paths:
    M bolt/runtime/common.h
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Add support for opening libs based on links /proc/self/map_files

Summary:
This commit adds support for opening libs based on links
/proc/self/map_files.  For this we're getting current virtual address
and searching the lib in the directory with such address range. After
that, we're getting full path to the binary by using readlink
function. Direct read from link in /proc/self/map_files entries is not
possible because of lack of permissions.

Elvina Yakubova,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092422)


  Commit: 9b39a823ea21a4e1b6cda45c6e9d77ca5f8e8d20
      https://github.com/llvm/llvm-project/commit/9b39a823ea21a4e1b6cda45c6e9d77ca5f8e8d20
  Author: Vasily Leonenko <vasily.leonenko at huawei.com>
  Date:   2021-06-21 (Mon, 21 Jun 2021)

  Changed paths:
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Initial support for static executables

Summary:
This commit introduces static binaries instrumentation
support.  Note that current implementation does not support profile
output on the instrumented binary finalization. So it requires to use
-instrumentation-sleep-time=N (N>0) option usage.  Note: There is
unhandled case with static PIE executable which might have dynamic
header.

Vasily Leonenko,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092471)


  Commit: 361f3b5576c4e90e1f1cb7572d2d3923a1670b4b
      https://github.com/llvm/llvm-project/commit/361f3b5576c4e90e1f1cb7572d2d3923a1670b4b
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-06-23 (Wed, 23 Jun 2021)

  Changed paths:
    M bolt/runtime/instr.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Passes/Instrumentation.h
    M bolt/src/Passes/InstrumentationSummary.h
    M bolt/src/Passes/RetpolineInsertion.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Fix runtime handlers for PIE files

Summary:
This commit fixes runtime instrumentation handlers for PIE
binaries case.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092522)


  Commit: 285ac26d169b18d51fe53511b2b41757fb25c1c4
      https://github.com/llvm/llvm-project/commit/285ac26d169b18d51fe53511b2b41757fb25c1c4
  Author: Vasily Leonenko <vasily.leonenko at huawei.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M bolt/README.md
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  [PR] README: remove note about experimental status of instrumentation

Summary:
Vasily Leonenko,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092666)


  Commit: 519cbbaa9a4e766772015cfe309fd4c6e524d96f
      https://github.com/llvm/llvm-project/commit/519cbbaa9a4e766772015cfe309fd4c6e524d96f
  Author: Vasily Leonenko <vasily.leonenko at huawei.com>
  Date:   2021-07-30 (Fri, 30 Jul 2021)

  Changed paths:
    M bolt/runtime/instr.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Introduce instrumentation-binpath argument

Summary:
This commit introduces -instrumentation-binpath argument used
to point instuqmented binary in runtime in case if /proc/self/map_files
path is not accessible due to access restriction issues.

Vasily Leonenko
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092681)


  Commit: 553f28e9217d168476148eb13e7e53bdc84883d1
      https://github.com/llvm/llvm-project/commit/553f28e9217d168476148eb13e7e53bdc84883d1
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-07-31 (Sat, 31 Jul 2021)

  Changed paths:
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Fix start and fini trampoline pointers

Summary:
The trampolines are no loger pointers to the functions.  For
propper name resolving by bolt use extern "C" for all external symbols
in instr.cpp

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092698)


  Commit: af58da4ef3fbd766b2c44cfdbdb859a21022d10a
      https://github.com/llvm/llvm-project/commit/af58da4ef3fbd766b2c44cfdbdb859a21022d10a
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-07-22 (Thu, 22 Jul 2021)

  Changed paths:
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Avoid generating GOT table in instrumentation library

Summary:
To avoid RELATIVE relocations avoid using of GOT table
by using hidden visibility for all symbols in library.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092712)


  Commit: 900914d3c66bbe573964876d30b5be4029e0f4ee
      https://github.com/llvm/llvm-project/commit/900914d3c66bbe573964876d30b5be4029e0f4ee
  Author: Vasily Leonenko <vasily.leonenko at huawei.com>
  Date:   2021-06-19 (Sat, 19 Jun 2021)

  Changed paths:
    A bolt/test/X86/instrumentation-pie.c
    A bolt/test/X86/instrumentation-shlib.c

  Log Message:
  -----------
  [PR] Tests: add instrumentation tests for PIE exec & shared libs

Summary:
This commit adds dummy tests for checking instrumentation
support for PIE executables and shared libraries.

Vasily Leonenko,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30092729)


  Commit: d217e2f338a0c025f6e16ae13e34a48e0800657e
      https://github.com/llvm/llvm-project/commit/d217e2f338a0c025f6e16ae13e34a48e0800657e
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-06-29 (Tue, 29 Jun 2021)

  Changed paths:
    M bolt/src/CMakeLists.txt
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/test/X86/debug-fission-single.s

  Log Message:
  -----------
  Rebase: [BOLT] DWP output support

Summary:
Added support for writing out DWP file. Works with regular dwo as input or DWP as input.

(cherry picked from FBD31361619)


  Commit: faee814fb9457649d55e592be77af22d59d82d3f
      https://github.com/llvm/llvm-project/commit/faee814fb9457649d55e592be77af22d59d82d3f
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-08-16 (Mon, 16 Aug 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/test/X86/debug-fission-single.s

  Log Message:
  -----------
  Fix NFC tests

Summary:
Our NFC tests are failing on debug-fission-single.s. Fix the test
to be compliant with our checking script.

(cherry picked from FBD30352415)


  Commit: 8459c14c688a7ce3e09942873faa06db3bfe0f3d
      https://github.com/llvm/llvm-project/commit/8459c14c688a7ce3e09942873faa06db3bfe0f3d
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-08-11 (Wed, 11 Aug 2021)

  Changed paths:
    M bolt/src/Relocation.cpp

  Log Message:
  -----------
  [PR] Fix AARCH64 ADR* relocations

Summary:
The ADRP instructions has 21 bits to store page offsets + 12 lowest bits
are zero, that give us a total of 33 bits (32 bits for address + 1 sign
bit, to address +- 4GB).

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30283044)


  Commit: b64de0756985ce27169f5c78741900eac3e7a302
      https://github.com/llvm/llvm-project/commit/b64de0756985ce27169f5c78741900eac3e7a302
  Author: Amir Ayupov <aaupov at users.noreply.github.com>
  Date:   2021-08-12 (Thu, 12 Aug 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][NFC][PR] Removed unused singletonSet

Summary:
Remove unused code introduced a while ago (2016), with its use removed
since then.

PR facebookincubator/BOLT#198

Author: Amir Aupov <aaupov at fb.com>

(cherry picked from FBD30376537)


  Commit: 2a5790b670a928a07f5dedab41298dbb803d001b
      https://github.com/llvm/llvm-project/commit/2a5790b670a928a07f5dedab41298dbb803d001b
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-06-29 (Tue, 29 Jun 2021)

  Changed paths:
    M bolt/src/DataAggregator.cpp
    M bolt/src/DataReader.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/Utils.cpp
    M bolt/src/Utils.h
    M bolt/test/CMakeLists.txt
    A bolt/test/X86/Inputs/fdata-escape-chars-syms.txt
    A bolt/test/X86/Inputs/fdata-escape-chars.txt
    A bolt/test/X86/fdata-escape-chars.ll
    M bolt/test/link_fdata.sh
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  [PR] Fdata: Escape whitespaces in symbol names

Summary:
This patch is part of preparation for golang support. The golang symbols
might have spaces in the name (for example "type..eq.[10]interface {}").
Since fdata uses spaces as a field separator such names brakes the fdata
format, so we need to escape whitespaces and backslashes in symbol names
using the backslash character.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD29999491)


  Commit: ef6186c822f3323eedbaa5b75e177e5a31557409
      https://github.com/llvm/llvm-project/commit/ef6186c822f3323eedbaa5b75e177e5a31557409
  Author: Joey Thaman <jthaman at fb.com>
  Date:   2021-08-10 (Tue, 10 Aug 2021)

  Changed paths:
    M bolt/src/MCPlusBuilder.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/TailDuplication.cpp
    M bolt/src/Passes/TailDuplication.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    A bolt/test/X86/tail-duplication-constant-prop.s

  Log Message:
  -----------
  [BOLT] Added Constant and Copy Propagation to tail duplicated blocks

Summary:
Added a function in TailDuplication
that will do Constant and Copy Propagation for blocks that
we duplicated as a part of tail duplication.  Added supporting
functions to MCPlusBuilder to find src registers and replace
registers

(cherry picked from FBD30231907)


  Commit: a1036e42dab5b7556d797049eef9cefb4dbc3da4
      https://github.com/llvm/llvm-project/commit/a1036e42dab5b7556d797049eef9cefb4dbc3da4
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-08-22 (Sun, 22 Aug 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [PR] Print relocations warning if failed to process

Summary:
Currently most of the warnings are printed only in debug mode. Since
relocations are very important for binary correct work I suggest to
print number of failed to process relocations to pay extra attention in
case some problems with them were met

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30500629)


  Commit: c040431fe6d5e49f5c090f0e14c74888380d3c9e
      https://github.com/llvm/llvm-project/commit/c040431fe6d5e49f5c090f0e14c74888380d3c9e
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-08-20 (Fri, 20 Aug 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/MCPlusBuilder.h
    A bolt/src/Passes/ADRRelaxationPass.cpp
    A bolt/src/Passes/ADRRelaxationPass.h
    M bolt/src/Passes/CMakeLists.txt
    M bolt/src/Relocation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    A bolt/test/AArch64/adrrelaxationpass.s
    A bolt/test/AArch64/lit.local.cfg
    A bolt/test/X86/lit.local.cfg

  Log Message:
  -----------
  [PR] AArch64: Fix ADR instruction handling

Summary:
There are 2 problems found when handling ADR instruction:
1. When extracting value from the ADR instruction we need to do
it another way, then we do it for ADRP instruction.
2. When creating target expression the VariantKind should be other for
ADR instruction.

And we introduces R_AARCH64_ADR_PREL_LO21,
R_AARCH64_TLSDESC_ADR_PREL21 and R_AARCH64_ADR_PREL_PG_HI21_NC
relocations support.

Also this patch introduces AdrPass, which will replace non-local
pointing ADR instructions with ADRP + ADD instructions sequence due to
small offset range of ADR instruction, so after BOLT magic there are no
guarantees that ADR instruction will still be in the range of
just +- 1MB from its target. The instruction replacement needs
relocations to be avalailable, so we won't remove "IsFromCode"
relocations after disassembly from BF anymore. Also we need original
offset of ADR instruction to be available so we add offset annotation
for these instructions.

The last thing this patch adds is ARM testing directory, which will be
used only on ARM testing servers. The common tests (non-assembler tests
which are platform-independent) might be moved from the X86 directory to
the parent one in the future, so such tests could be tested on both X86
and ARM machines.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30497379)


  Commit: 3e8af67a95dea242d8495b287744e8278de29e7c
      https://github.com/llvm/llvm-project/commit/3e8af67a95dea242d8495b287744e8278de29e7c
  Author: Joey Thaman <jthaman at fb.com>
  Date:   2021-08-17 (Tue, 17 Aug 2021)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/CMakeLists.txt
    A bolt/src/Passes/ThreeWayBranch.cpp
    A bolt/src/Passes/ThreeWayBranch.h
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp
    A bolt/test/X86/three-way-branch-pass.s

  Log Message:
  -----------
  [BOLT] Optimize the three way branch

Summary:
Three way branches commonly appear
in HHVM. They have one test and then two jumps.  The
jump's destinations are not currently optimized.
This pass attempts to optimize which is the first branch.

(cherry picked from FBD30460441)


  Commit: 23fc454f68bc9914f999934bc5c7d9d858671919
      https://github.com/llvm/llvm-project/commit/23fc454f68bc9914f999934bc5c7d9d858671919
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-08-27 (Fri, 27 Aug 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT] Refactor to use new APIs for getting offset of attribute

Summary: Changing to use the new APIs for getting offset of attribute from .debug_info. They were split in to multiple ones so that Offset can be gotten seperatly.

(cherry picked from FBD30616705)


  Commit: 856299594c6794bc44dd6de02b49148b21566bdf
      https://github.com/llvm/llvm-project/commit/856299594c6794bc44dd6de02b49148b21566bdf
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-09-06 (Mon, 06 Sep 2021)

  Changed paths:
    M bolt/src/Passes/ReorderAlgorithm.cpp

  Log Message:
  -----------
  [PR] ReorderAlgorithm.cpp: Fix iterator types

Summary:
The clang 12 doesn't want to build this place due to unrelated
types of iterator element and std vector.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30821177)


  Commit: e2480fcc984f079e0b7c82a57a4b9bc98ab082ea
      https://github.com/llvm/llvm-project/commit/e2480fcc984f079e0b7c82a57a4b9bc98ab082ea
  Author: Vasily Leonenko <vasily.leonenko at huawei.com>
  Date:   2021-08-27 (Fri, 27 Aug 2021)

  Changed paths:
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  [PR] LIT: add checking if maxIndividualTestTime is availabe on the platform

Summary:
This commit adds checking if maxIndividualTestTime is availabe on
the platform. If available - it sets per test timeout to 60sec and
declares lit-max-individual-test-time feature for further checking
by particular test cases.
Based on https://reviews.llvm.org/D64251 implementation.

Vasily Leonenko,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30821986)


  Commit: 9aa134dc2d4cac699f8059a1233f76308dbea540
      https://github.com/llvm/llvm-project/commit/9aa134dc2d4cac699f8059a1233f76308dbea540
  Author: Vasily Leonenko <vasily.leonenko at huawei.com>
  Date:   2021-08-08 (Sun, 08 Aug 2021)

  Changed paths:
    M bolt/runtime/common.h
    M bolt/runtime/instr.cpp
    M bolt/src/Passes/Instrumentation.cpp
    M bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    A bolt/test/X86/instrumentation-indirect.c

  Log Message:
  -----------
  [PR] Instrumentation: use TryLock for SimpleHashTable getter

Summary:
This commit introduces TryLock usage for SimpleHashTable getter to
avoid deadlock and relax syscalls usage which causes significant
overhead in runtime.
The old behavior left under -conservative-instrumentation option passed
to instrumentation library.
Also, this commit includes a corresponding test case: instrumentation of
executable which performs indirect calls from common code and signal
handler.

Note: in case if TryLock was failed to acquire the lock - this indirect
call will not be accounted in the resulting profile.

Vasily Leonenko,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD30821949)


  Commit: 7b779f819f4a7dee487efc86df53d4e9c7b58182
      https://github.com/llvm/llvm-project/commit/7b779f819f4a7dee487efc86df53d4e9c7b58182
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-09-10 (Fri, 10 Sep 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp
    A bolt/test/X86/interp-overwrite-bug.s

  Log Message:
  -----------
  [BOLT] Fix binary corruption in non-reloc mode

Summary:
We have a problem where we will emit sections that we are not supposed
to emit (with no output offset assigned). This will make us write at
file offset 0 and corrupt the first sections in the binary (usually
.interp section will be corrupted and bash will refuse to run the
binary).

This only happens in non-reloc mode when using JTS_BASIC and when we
do not emit a function that has a jump table (if it gets too large).

Using -update-debug-sections will trigger the pass
check-large-functions, which will mark large funcs as non-simple
and will hide this bug.

(cherry picked from FBD30882012)


  Commit: 47ce9b39e410ef38b0145025439635fcb05dc481
      https://github.com/llvm/llvm-project/commit/47ce9b39e410ef38b0145025439635fcb05dc481
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-09-15 (Wed, 15 Sep 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] [NFC] Cleanup old code in mapCodeSections

Summary:
In "Add initial function injection support", Laith added this
code because injected functions would use the original text section as
the section to emit their code to. Now, what happens is that functions
are mapped to either their own section in non-reloc mode, or mapped to
a particular section in the pass reassign sections. So this section does
not need to have an output address anymore and this code is obsolete.

(cherry picked from FBD30980450)


  Commit: 1ca3a8b824d68903e3e6791c60b1f59852aeae76
      https://github.com/llvm/llvm-project/commit/1ca3a8b824d68903e3e6791c60b1f59852aeae76
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-09-20 (Mon, 20 Sep 2021)

  Changed paths:
    M bolt/src/BinaryFunction.cpp
    M bolt/src/DynoStats.h

  Log Message:
  -----------
  [NFC] Fix warnings when building with clang

Summary:
Fix switch-cases that don't handle all MCCFIInstruction
enumeration types. Fix range-loop iterator forced copy.

(cherry picked from FBD31068505)


  Commit: 48fbeb1a46f53f3e45b023fc6894896b81877733
      https://github.com/llvm/llvm-project/commit/48fbeb1a46f53f3e45b023fc6894896b81877733
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-21 (Tue, 21 Sep 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/test/X86/debug-fission-single.s

  Log Message:
  -----------
  [BOLT] Fix warnings from LLVM DWARF reading library

Summary:
LLVM started printing warnings when DWARFDebugInfoEntry::extractFast()
is invoked trying to read a DIE past the current unit limits. This
results in verbose warnings from BOLT which are harmless but confusing
to the user. Check the boundaries before calling the API above.

(cherry picked from FBD31097271)


  Commit: 542c03c3a3d1f53c8bb8514123d19f1288cca6be
      https://github.com/llvm/llvm-project/commit/542c03c3a3d1f53c8bb8514123d19f1288cca6be
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-09-02 (Thu, 02 Sep 2021)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/Relocation.cpp
    M bolt/src/RewriteInstance.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    A bolt/test/AArch64/tls.c

  Log Message:
  -----------
  [PR] Fix aarch64 TLS relocations handling

Summary:
There are few problems found when dealing with TLS relocations for
aarch64.

* RewriteInstance.cpp
** While analyzing TLS relocation we don't have to modify
SymbolAddress (which is the offset from the TLS section), so we need to
just skip verifiction
** The non-got related TLS relocations on aarch64 might be skipped too
** The forse relocation must be applied for GOT relocations on
Aarch64. The symbol adress for GOT relocation might no be pointing
on GOT section (for example ADRP GOT may point to the wrong section,
since GOT table is not page-aligned), so we won't try to get section by
the symbol address.

* Relocation.cpp - Remove R_AARCH64_TLSLE_ADD_TPREL_HI12 and
R_AARCH64_TLSLE_ADD_TPREL_LO12_NC from isGOT check, since they are not
got-related relocations

* BinaryFunction.h
** Remove R_AARCH64_TLSLE_ADD_TPREL_HI12 and
R_AARCH64_TLSLE_ADD_TPREL_LO12_NC from adding to relocation list, since
this is actually an offset in TLS section and BOLT does not change it we
don't need to do something with this relocations, the value won't change
in new binary files
** Refactor the code, separating aarch64 and x86 relocations

* AArch64MCPlusBuilder.cpp
** Add forgotten LO12 relocations to switch case to getTargetExprFor

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31003349)


  Commit: 00c0659b1389d80af0caa5a4ebc442f99802a2c1
      https://github.com/llvm/llvm-project/commit/00c0659b1389d80af0caa5a4ebc442f99802a2c1
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-09-08 (Wed, 08 Sep 2021)

  Changed paths:
    M bolt/src/Relocation.cpp
    M bolt/src/Relocation.h
    M bolt/src/RewriteInstance.cpp
    M bolt/src/RewriteInstance.h

  Log Message:
  -----------
  [PR] AArch64: Skip some of the relocations processing

Summary:
There are some cases, when relocations must not be processed by bolt.
This patch handles three of such cases:
* The linker might eliminate the instruction and replace it with NOP
* The linker might perform TLS relocations relaxations, replacing the
got to direct TP + offset access.
* Due to errata 843419 the linker might create a veneer, replacing the
load/store instruction with branching.

In both cases linker leaves old relocations, that are no longer matches
the instruction emmited to binary, so we must avoid processing of these
relocations.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31002384)


  Commit: 43fffff671eb137eee48396fc5e0aa6297742442
      https://github.com/llvm/llvm-project/commit/43fffff671eb137eee48396fc5e0aa6297742442
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF][NFC] Refactor code

Summary: Minor refactoring to improve code readability.

(cherry picked from FBD31122375)


  Commit: d4fdc98140facb794bb0ab3917fc80d1a2b13675
      https://github.com/llvm/llvm-project/commit/d4fdc98140facb794bb0ab3917fc80d1a2b13675
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    M bolt/test/AArch64/adrrelaxationpass.s
    M bolt/test/AArch64/tls.c
    M bolt/test/CMakeLists.txt
    M bolt/test/X86/bb_with_two_tail_calls.s
    M bolt/test/X86/bug-reorder-bb-jrcxz.s
    M bolt/test/X86/debug-fission-single.s
    M bolt/test/X86/debugTypesBug.s
    M bolt/test/X86/false-jump-table.s
    M bolt/test/X86/fdata-escape-chars.ll
    M bolt/test/X86/fix-branches-jrcxz.s
    M bolt/test/X86/hot_end_symbol.s
    M bolt/test/X86/icf-jump-tables.test
    M bolt/test/X86/inline-debug-info.test
    M bolt/test/X86/instrumentation-dup-jts.s
    M bolt/test/X86/instrumentation-ind-calls.s
    M bolt/test/X86/instrumentation-indirect.c
    M bolt/test/X86/instrumentation-pie.c
    M bolt/test/X86/instrumentation-shlib.c
    M bolt/test/X86/interp-overwrite-bug.s
    M bolt/test/X86/interprocedural_ref_entry_point.s
    M bolt/test/X86/issue20.s
    M bolt/test/X86/issue26.s
    M bolt/test/X86/loop-inversion-pass.s
    M bolt/test/X86/no-output.test
    M bolt/test/X86/section_reloc_with_addend.s
    M bolt/test/X86/shrinkwrapping-alignment.s
    M bolt/test/X86/shrinkwrapping-critedge.s
    M bolt/test/X86/shrinkwrapping-insertcfi.s
    M bolt/test/X86/shrinkwrapping-lock.s
    M bolt/test/X86/shrinkwrapping-pushpop.s
    M bolt/test/X86/split_func_jump_table_fragment.s
    M bolt/test/X86/split_func_jump_table_fragment_noparent.s
    M bolt/test/X86/split_func_jump_table_fragment_reverse.s
    M bolt/test/X86/tail-duplication-complex.s
    M bolt/test/X86/tail-duplication-constant-prop.s
    M bolt/test/X86/tail-duplication-pass.s
    M bolt/test/X86/three-way-branch-pass.s
    M bolt/test/X86/user-func-reorder.c
    M bolt/test/X86/zero-sized-object.s
    M bolt/test/lit.cfg.py
    M bolt/test/lit.site.cfg.py.in

  Log Message:
  -----------
  [BOLT][TEST] Remove dependence on host_cc and host_cxx

Summary: Add dependency on clang and clangxx instead.

(cherry picked from FBD31128140)


  Commit: e1da1539e3a2c23e2e468a12584a9030e3b33405
      https://github.com/llvm/llvm-project/commit/e1da1539e3a2c23e2e468a12584a9030e3b33405
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-09-23 (Thu, 23 Sep 2021)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/Relocation.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    A bolt/test/AArch64/issue177.s

  Log Message:
  -----------
  [PR] Add AARCH64_MOVW_UABS_G* relocations support

Summary:
This patch fixes issue facebookincubator/BOLT#177

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31130162)


  Commit: 4d5cd1bf82ecfbeb29c2c980862ccda3afdae5d2
      https://github.com/llvm/llvm-project/commit/4d5cd1bf82ecfbeb29c2c980862ccda3afdae5d2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-17 (Fri, 17 Sep 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Write new .debug_abbrev sections

Summary:
Instead of patching the original .debug_abbrev section contents,
generate new section data based on parsed compilation unit
abbreviations.

This eliminates the dependency on the LLVM extension that records
abbreviation attribute offsets while parsing .debug_abbrev contents.

The output with this patch should stay the same (NFC).

(cherry picked from FBD31133611)


  Commit: 64db3e7b7ccc10ccf1ca0bc2a13b032e3dc1d730
      https://github.com/llvm/llvm-project/commit/64db3e7b7ccc10ccf1ca0bc2a13b032e3dc1d730
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-23 (Thu, 23 Sep 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF][NFC] Use only skeleton/main CUs to update .debug_aranges

Summary:
Previously, we were registering all CUs with aranges writer. Since DWO
CUs have offsets set to 0, and we were registering them after the
skeleton unit at offset 0 was already registered, it was mostly
harmless as DWO CUs were effectively ignored.

(cherry picked from FBD31162621)


  Commit: 122254bc35c5907c41b602494677ad5d7251336f
      https://github.com/llvm/llvm-project/commit/122254bc35c5907c41b602494677ad5d7251336f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-23 (Thu, 23 Sep 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h

  Log Message:
  -----------
  [BOLT][DWARF][NFC] Get rid of updateRangeBase() helper function

Summary:
Move attribute patching code out of updateRangesBase into
convertToRanges() functions.

(cherry picked from FBD31154742)


  Commit: 6b4eb0b94a6d5e6b65aa874a65e01d8772cf7054
      https://github.com/llvm/llvm-project/commit/6b4eb0b94a6d5e6b65aa874a65e01d8772cf7054
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-09-22 (Wed, 22 Sep 2021)

  Changed paths:
    R bolt/test/AArch64/adrrelaxationpass.s
    R bolt/test/AArch64/issue177.s
    R bolt/test/AArch64/lit.local.cfg
    M bolt/test/AArch64/tls.c
    R bolt/test/X86/Inputs/fdata-escape-chars-syms.txt
    R bolt/test/X86/Inputs/fdata-escape-chars.txt
    R bolt/test/X86/Inputs/user_func_order.txt
    R bolt/test/X86/fdata-escape-chars.ll
    R bolt/test/X86/fix-branches-jrcxz.s
    R bolt/test/X86/hot_end_symbol.s
    R bolt/test/X86/instrumentation-dup-jts.s
    R bolt/test/X86/instrumentation-ind-calls.s
    R bolt/test/X86/instrumentation-indirect.c
    R bolt/test/X86/instrumentation-pie.c
    R bolt/test/X86/instrumentation-shlib.c
    R bolt/test/X86/interp-overwrite-bug.s
    R bolt/test/X86/lit.local.cfg
    R bolt/test/X86/section_reloc_with_addend.s
    R bolt/test/X86/shrinkwrapping-alignment.s
    R bolt/test/X86/shrinkwrapping-lock.s
    R bolt/test/X86/shrinkwrapping-pushpop.s
    R bolt/test/X86/tail-duplication-constant-prop.s
    R bolt/test/X86/three-way-branch-pass.s
    R bolt/test/X86/user-func-reorder.c
    A bolt/test/runtime/AArch64/adrrelaxationpass.s
    A bolt/test/runtime/AArch64/issue177.s
    A bolt/test/runtime/AArch64/lit.local.cfg
    A bolt/test/runtime/X86/Inputs/fdata-escape-chars-syms.txt
    A bolt/test/runtime/X86/Inputs/fdata-escape-chars.txt
    A bolt/test/runtime/X86/Inputs/user_func_order.txt
    A bolt/test/runtime/X86/fdata-escape-chars.ll
    A bolt/test/runtime/X86/fix-branches-jrcxz.s
    A bolt/test/runtime/X86/hot_end_symbol.s
    A bolt/test/runtime/X86/instrumentation-dup-jts.s
    A bolt/test/runtime/X86/instrumentation-ind-calls.s
    A bolt/test/runtime/X86/instrumentation-indirect.c
    A bolt/test/runtime/X86/instrumentation-pie.c
    A bolt/test/runtime/X86/instrumentation-shlib.c
    A bolt/test/runtime/X86/interp-overwrite-bug.s
    A bolt/test/runtime/X86/lit.local.cfg
    A bolt/test/runtime/X86/section_reloc_with_addend.s
    A bolt/test/runtime/X86/shrinkwrapping-alignment.s
    A bolt/test/runtime/X86/shrinkwrapping-lock.s
    A bolt/test/runtime/X86/shrinkwrapping-pushpop.s
    A bolt/test/runtime/X86/tail-duplication-constant-prop.s
    A bolt/test/runtime/X86/three-way-branch-pass.s
    A bolt/test/runtime/X86/user-func-reorder.c

  Log Message:
  -----------
  [BOLT][TEST] Split runtime tests into test/runtime folder

Summary:
Create bolt/test/runtime folder and move tests that execute the binary.
Move lit.local.cfg with host_arch check to the corresponding folder.
Addresses issue facebookincubator/BOLT#132.

AArch64/tls.c shows a different behavior with clang hence marked as XFAIL

TODO: add a check for non-exec tests for a corresponding LLVM_TARGETS_TO_BUILD.

(cherry picked from FBD31132234)


  Commit: 4157682fd925f2a7aa775cb40f24011a00f5447f
      https://github.com/llvm/llvm-project/commit/4157682fd925f2a7aa775cb40f24011a00f5447f
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-09-23 (Thu, 23 Sep 2021)

  Changed paths:
    A bolt/test/X86/internal_call_instrument.s

  Log Message:
  -----------
  [BOLT][TEST] Import internal_call_instrument.s

Summary: Imported standalone assembly test

(cherry picked from FBD31161181)


  Commit: 62550dd22cbe8b63a696505e85016d9f5ef80010
      https://github.com/llvm/llvm-project/commit/62550dd22cbe8b63a696505e85016d9f5ef80010
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-09-25 (Sat, 25 Sep 2021)

  Changed paths:
    M bolt/README.md

  Log Message:
  -----------
  Rebase: [PR] Fix build instructions

Summary:
As titled.

(cherry picked from FBD32740596)


  Commit: 47455e98b34482c4e35101deeafb7f6dd9c536e5
      https://github.com/llvm/llvm-project/commit/47455e98b34482c4e35101deeafb7f6dd9c536e5
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-09-28 (Tue, 28 Sep 2021)

  Changed paths:
    A bolt/test/X86/Inputs/avx512.c
    A bolt/test/X86/Inputs/switch_statement.cpp
    A bolt/test/X86/R_X86_64_64.pic.lld.cpp
    A bolt/test/X86/avx512_trap.test
    A bolt/test/X86/bad_exe.test
    A bolt/test/X86/bolt_info.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- R_X86_64_64.pic.lld.cpp
- avx512_trap.test
- bad_exe.test
- bolt_info.test

(cherry picked from FBD31251439)


  Commit: e3b901aaee0a6a4948b611df894f7fba89969854
      https://github.com/llvm/llvm-project/commit/e3b901aaee0a6a4948b611df894f7fba89969854
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-28 (Tue, 28 Sep 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT][DWARF] Fix abbrev offsets for type units

Summary:
When rewriting .debug_abbrev section, update abbrev offsets for type
units in addition to compile units.

Reuse abbreviation entries if they were shared by multiple compile/type
units.

(cherry picked from FBD31262326)


  Commit: ba1f503f1b8f3f92b2ac4c0962bbdab1314dda7f
      https://github.com/llvm/llvm-project/commit/ba1f503f1b8f3f92b2ac4c0962bbdab1314dda7f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-29 (Wed, 29 Sep 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][NFC] Remove redundant code

Summary:
For historical reasons, we are populating FailedAddresses twice in
RewriteInstance. Remove the second (happening later) call to avoid the
confusion.

(cherry picked from FBD31278956)


  Commit: d4a0e8526aa976ef2b67f8c4526bf95f59985119
      https://github.com/llvm/llvm-project/commit/d4a0e8526aa976ef2b67f8c4526bf95f59985119
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-01 (Wed, 01 Sep 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT][DWARF] Move line info emission into BOLT

Summary:
BOLT needs to generate line info tables using absolute addresses as well
as using the standard MC way of labels attached to instructions. Move
line table generation code under BOLT.

Ideally, we should be able to extend existing interfaces in LLVM, but
without other users of the interface it will be hard to justify the
change.

(cherry picked from FBD30723466)


  Commit: 7b61cb78121e5c1c325a82069e006d8f0a474d0c
      https://github.com/llvm/llvm-project/commit/7b61cb78121e5c1c325a82069e006d8f0a474d0c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-10-01 (Fri, 01 Oct 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Deprecate usage of DWARFAbbreviationDeclaration::findAttribute()

Summary: Deprecate the usage of extension to LLVM API.

(cherry picked from FBD31360154)


  Commit: e903671bbf6a45fb14f562136200ed40b8e006cb
      https://github.com/llvm/llvm-project/commit/e903671bbf6a45fb14f562136200ed40b8e006cb
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-01 (Fri, 01 Oct 2021)

  Changed paths:
    R bolt/test/X86/Inputs/switch_statement.cpp
    M bolt/test/X86/bad_exe.test
    M bolt/test/X86/bolt_info.test
    A bolt/test/X86/call_zero.s
    A bolt/test/X86/cfi_expr_rewrite.s
    A bolt/test/X86/cfi_instrs_count.s
    A bolt/test/runtime/X86/Inputs/exception3.cpp
    A bolt/test/runtime/X86/Inputs/exception4.cpp
    A bolt/test/runtime/X86/exceptions_pic.test
    A bolt/test/runtime/X86/exceptions_run.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests, removed duplicate input

Summary:
Imported small internal tests.
- call_zero.s
- cfi_expr_rewrite.s
- cfi_insts_count.s
- exceptions_pic.test
- exceptions_run.test

Removed duplicate input file (switch_statement.cpp)

(cherry picked from FBD31355466)


  Commit: 98bc9876fbf09e8bb8df9631e7bdc80bce93598f
      https://github.com/llvm/llvm-project/commit/98bc9876fbf09e8bb8df9631e7bdc80bce93598f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-08 (Wed, 08 Sep 2021)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT][DWARF] Change line info emission for unmodified functions

Summary:
Generate line tables for original/unmodified functions directly from
input line tables, bypassing conversion into intermediate structures,
such as BinaryLineDivisions.

Emit end-of-sequence markers only when necessary, i.e. when the line
sequence is not adjacent to the next one, or at the end of the line
sequence for the compilation unit.

If the sequence starts with ambiguous line info (multiple lines per
address), make sure we emit all such lines.

Reduce memory consumption when updating debug info by eliminating
intermediate data structures allocation.

(cherry picked from FBD30829448)


  Commit: 8ef3b2783434d1ee4feb2a0efbd0f04b4e6c8d18
      https://github.com/llvm/llvm-project/commit/8ef3b2783434d1ee4feb2a0efbd0f04b4e6c8d18
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-09-30 (Thu, 30 Sep 2021)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h
    M bolt/test/X86/debugTypesBug.s

  Log Message:
  -----------
  [BOLT][DWARF] Properly emit of end-of-sequence entries for line tables

Summary:
When the compiler emits line table program, it emits EOS using the label
at the end of the containing code section. Since each compilation unit
has its own set of code sections it works as expected (* see the excerpt
from the standard below). However, in BOLT the code from many CUs is
combined into a common section, such as hot text or cold text.
As a result, the symbol at the end of the section may point way past the
code sequence for a given unit.

Since we can emit functions in any order, we conservatively emit
end-of-sequence at the end of every emitted function.

Fixes a problem while intermixing source code with disassembly in
binutils' objdump.

(*) DWARF v4 6.2.5.3:
"Every line number program sequence must end with a DW_LNE_end_sequence
instruction which creates a row whose address is that of the byte after
the last target machine instruction of the sequence."

(cherry picked from FBD31347870)


  Commit: a8cbc8093f6569e7d48dc64e27640da4a7b36958
      https://github.com/llvm/llvm-project/commit/a8cbc8093f6569e7d48dc64e27640da4a7b36958
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-10-06 (Wed, 06 Oct 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Do not process DWARF relocs

Summary:
Use the new API introduced in https://reviews.llvm.org/D106624
to request LLVM do not process relocations for debug sections, since
BOLT processes final binaries that are already relocated.

(cherry picked from FBD31449206)


  Commit: c637fcf24ef706d3edca289ed82fe2e1ef5ffae4
      https://github.com/llvm/llvm-project/commit/c637fcf24ef706d3edca289ed82fe2e1ef5ffae4
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-04 (Mon, 04 Oct 2021)

  Changed paths:
    M bolt/src/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT][NFC] Use const pointers in PrintProgramStats

Summary: Small refactoring to use const BinaryFunction pointers in PrintProgramStats.

(cherry picked from FBD31387253)


  Commit: 848f07792c0f5aee9f5f37d4102218649357d31e
      https://github.com/llvm/llvm-project/commit/848f07792c0f5aee9f5f37d4102218649357d31e
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-01 (Fri, 01 Oct 2021)

  Changed paths:
    M bolt/src/Relocation.cpp
    M bolt/test/AArch64/tls.c

  Log Message:
  -----------
  [PR] Update skipRelocationProcess

Summary:
The ELF::R_AARCH64_TLSDESC_LD64_LO12 and
ELF::R_AARCH64_TLSDESC_ADR_PAGE21 relocations might also be relaxed to
mov instructions, handle these cases

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31353063)


  Commit: e424d16f0e6e03ffa353f3c88604147b2098bd90
      https://github.com/llvm/llvm-project/commit/e424d16f0e6e03ffa353f3c88604147b2098bd90
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-03 (Sun, 03 Oct 2021)

  Changed paths:
    M bolt/src/BinaryFunction.h
    M bolt/src/Relocation.cpp
    A bolt/test/runtime/AArch64/controlflow.s

  Log Message:
  -----------
  [PR] AArch64: Add TSTBR14 and CONDB19 relocations support

Summary:
This patch adds R_AARCH64_TSTBR14 and R_AARCH64_CONDBR19 relocations
support in order to handle condition branches, cbz/cnbz and tbz/tbnz
instructions correctly

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31416734)


  Commit: b86c91eae05f3d4a30c1aacde30e579888e75029
      https://github.com/llvm/llvm-project/commit/b86c91eae05f3d4a30c1aacde30e579888e75029
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-06 (Wed, 06 Oct 2021)

  Changed paths:
    A bolt/test/X86/invalid_profile.test
    A bolt/test/runtime/X86/Inputs/internalcall-main.c
    A bolt/test/runtime/X86/Inputs/internalcall.S
    A bolt/test/runtime/X86/internal_call.test
    A bolt/test/runtime/X86/internal_call_instrument.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- invalid_profile.test
- internal_call.test
- internal_call_instrument.test

(cherry picked from FBD31452386)


  Commit: 8ab49cb4aa52469b2518e578856995325f807f6a
      https://github.com/llvm/llvm-project/commit/8ab49cb4aa52469b2518e578856995325f807f6a
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-09-30 (Thu, 30 Sep 2021)

  Changed paths:
    M bolt/test/link_fdata.sh

  Log Message:
  -----------
  [BOLT] link_fdata: accept symbols with slash in the name

Summary:
Change sed separator to allow replacing symbols with slash in the name.
This is required for symbol names produced by BOLT which include
"/1" suffix.

(cherry picked from FBD31324540)


  Commit: 5f953277a92de1184e490abde3260d3cd4293fad
      https://github.com/llvm/llvm-project/commit/5f953277a92de1184e490abde3260d3cd4293fad
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-04 (Mon, 04 Oct 2021)

  Changed paths:
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.h
    M bolt/test/runtime/AArch64/adrrelaxationpass.s
    A bolt/test/runtime/AArch64/constant-island-relocations.s

  Log Message:
  -----------
  [PR] Handle relocations in constant islands

Summary:
In non-PIC binaries compiler could save absolute addresses in constant
isalnd which we should handle properly. This patch adds relocations
handling in constant islands.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31416848)


  Commit: 92e306de0ca649f9d222ff31574c97e596bbf564
      https://github.com/llvm/llvm-project/commit/92e306de0ca649f9d222ff31574c97e596bbf564
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-06 (Wed, 06 Oct 2021)

  Changed paths:
    A bolt/test/X86/Inputs/indirect_goto.c
    A bolt/test/X86/Inputs/inlined.cpp
    A bolt/test/X86/Inputs/inlinee.cpp
    A bolt/test/X86/indirect_goto.test
    A bolt/test/X86/inlined_function_mixed.test
    A bolt/test/runtime/X86/Inputs/indirect_goto.c
    A bolt/test/runtime/X86/indirect_goto_pie.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- indirect_goto.test
- indirect_goto_pie.test
- inlined_function_mixed.test

(cherry picked from FBD31446571)


  Commit: c74e5bfee385a1aeb296d89e226473c4675293e7
      https://github.com/llvm/llvm-project/commit/c74e5bfee385a1aeb296d89e226473c4675293e7
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-06 (Wed, 06 Oct 2021)

  Changed paths:
    A bolt/test/X86/Inputs/jmp_opt.cpp
    A bolt/test/X86/Inputs/jmp_opt2.cpp
    A bolt/test/X86/Inputs/jmp_opt3.cpp
    A bolt/test/X86/Inputs/jmpjmp.s
    A bolt/test/X86/Inputs/jump_table_footprint_reduction.s
    A bolt/test/X86/Inputs/jump_table_reference.s
    A bolt/test/X86/jmp_optimization.test
    A bolt/test/X86/jmpjmp.test
    A bolt/test/X86/jump_table_footprint_reduction.test
    A bolt/test/X86/jump_table_reference.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- jmp_optimization.test
- jmpjmp.test
- jump_table_footprint_reduction.test
- jump_table_reference.test

(cherry picked from FBD31483122)


  Commit: d41b4e6e2d2699854dd715698c565b522626e99d
      https://github.com/llvm/llvm-project/commit/d41b4e6e2d2699854dd715698c565b522626e99d
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-07 (Thu, 07 Oct 2021)

  Changed paths:
    A bolt/test/X86/Inputs/blarge.fdata
    A bolt/test/X86/Inputs/icf_baz.c
    A bolt/test/X86/Inputs/icf_main.c
    A bolt/test/X86/Inputs/linenumber.cpp
    A bolt/test/X86/block_reordering.test
    A bolt/test/X86/branch_data.test
    A bolt/test/X86/keep_aranges.test
    A bolt/test/X86/layout_heuristic.test
    A bolt/test/X86/line_number.test
    A bolt/test/X86/reader.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- keep_aranges.test
- layout_heuristic.test
- line_number.test
- block_reordering.test
- branch_data.test
- reader.test

(cherry picked from FBD31486371)


  Commit: 872013e0778fa72349ff56731811eba339eebf9b
      https://github.com/llvm/llvm-project/commit/872013e0778fa72349ff56731811eba339eebf9b
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-08 (Fri, 08 Oct 2021)

  Changed paths:
    A bolt/test/X86/Inputs/entry.s
    A bolt/test/X86/Inputs/jump_table_icp.cpp
    A bolt/test/X86/cfi_instrs_reordered.s
    A bolt/test/X86/no_entry_reordering.test
    A bolt/test/X86/no_relocs.test
    A bolt/test/X86/pie.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- cfi_instrs_reordered.s
- no_entry_reordering.test
- no_relocs.test
- pie.test

(cherry picked from FBD31514823)


  Commit: f44e1df9d0c3ef1b642a467764569d97b6a699d7
      https://github.com/llvm/llvm-project/commit/f44e1df9d0c3ef1b642a467764569d97b6a699d7
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-08 (Fri, 08 Oct 2021)

  Changed paths:
    A bolt/test/X86/Inputs/relaxed_tc.s
    A bolt/test/X86/re-optimize.test
    A bolt/test/X86/relaxed_tailcall.test
    A bolt/test/X86/remove_unused.test
    A bolt/test/runtime/X86/Inputs/retpoline_synthetic.cpp
    A bolt/test/runtime/X86/retpoline_synthetic.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- re-optimize.test
- relaxed_tailcall.test
- remove_unused.test
- retpoline_synthetic.test

(cherry picked from FBD31516680)


  Commit: 44e08ead3051b5272084b97fb7c6f0c36e12c4b0
      https://github.com/llvm/llvm-project/commit/44e08ead3051b5272084b97fb7c6f0c36e12c4b0
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-08 (Fri, 08 Oct 2021)

  Changed paths:
    A bolt/test/X86/Inputs/sctc_bug.s
    A bolt/test/X86/Inputs/sctc_bug2.s
    A bolt/test/X86/Inputs/sctc_bug3.s
    A bolt/test/X86/Inputs/sctc_bug4.s
    A bolt/test/X86/sctc_bug.test
    A bolt/test/X86/sctc_bug2.test
    A bolt/test/X86/sctc_bug3.test
    A bolt/test/X86/sctc_bug4.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- sctc_bug{,2,3,4}.test

(cherry picked from FBD31517120)


  Commit: 01a81dca413fd9962f954e529447aedb91c4b119
      https://github.com/llvm/llvm-project/commit/01a81dca413fd9962f954e529447aedb91c4b119
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-08 (Fri, 08 Oct 2021)

  Changed paths:
    A bolt/test/X86/Inputs/exc4sw.S
    A bolt/test/X86/Inputs/exc4sw.fdata
    A bolt/test/X86/Inputs/static_exe.s
    A bolt/test/X86/Inputs/tailcall.s
    A bolt/test/X86/Inputs/vararg.s
    A bolt/test/X86/Inputs/vararg_pic.s
    A bolt/test/X86/shared_object.test
    A bolt/test/X86/shrinkwrapping.test
    A bolt/test/X86/static_exe.test
    A bolt/test/X86/tailcall.test
    A bolt/test/X86/vararg.test

  Log Message:
  -----------
  [BOLT][TEST] Imported small tests

Summary:
Imported small internal tests:
- shared_object.test
- shrinkwrapping.test
- static_exe.test
- tailcall.test
- vararg.test

(cherry picked from FBD31523478)


  Commit: 9bb3908b61e11b3f94a083df1820ddfc1fba1290
      https://github.com/llvm/llvm-project/commit/9bb3908b61e11b3f94a083df1820ddfc1fba1290
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-10-08 (Fri, 08 Oct 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/ADRRelaxationPass.cpp

  Log Message:
  -----------
  [BOLT] Allocate memory for constant islands on-demand

Summary:
Allocate memory for storing constant island info only when needed.

(cherry picked from FBD31510149)


  Commit: 93444ce8e88d9dfcac104b960941d09b0d88299e
      https://github.com/llvm/llvm-project/commit/93444ce8e88d9dfcac104b960941d09b0d88299e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-10-11 (Mon, 11 Oct 2021)

  Changed paths:
    M bolt/src/BinaryFunction.h

  Log Message:
  -----------
  [BOLT] Fix build after auto rebase

(cherry picked from FBD31550675)


  Commit: 96bb09065364de33719de0d2a649afcb091112a1
      https://github.com/llvm/llvm-project/commit/96bb09065364de33719de0d2a649afcb091112a1
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-10-13 (Wed, 13 Oct 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Use MCAsmLayout to update stmt_list values

Summary:
Use MCAsmLayout to update stmt_list in updateLineTableOffsets() instead
of manually calculating the layout.

(cherry picked from FBD31623071)


  Commit: a2214e8f0dff057089f7abb802f833c75ef84e01
      https://github.com/llvm/llvm-project/commit/a2214e8f0dff057089f7abb802f833c75ef84e01
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-04 (Mon, 04 Oct 2021)

  Changed paths:
    M bolt/src/BinaryPassManager.cpp
    M bolt/src/DebugData.h
    M bolt/src/MCPlusBuilder.h
    M bolt/src/Passes/LongJmp.cpp
    M bolt/src/Passes/PatchEntries.cpp
    M bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/src/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [PR] Fix LongJmp pass

Summary:
This patch handles 2 problems with LongJmp pass:
1. The pass should be executed before FinalizeFunctions, since the pass
may add new entry points for the function, and the
BinaryFunction::addEntryPoint has an assert "CurrentState == State::CFG"
2. Replaced shortJmp implementation with position-independent code.
Currently we could handle PIC binaries with max +-4Gb offsets, the
longJmp uses absolute addreses and could could be used only in non-PIE
binaries.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31416925)


  Commit: 53ec21e3a10ae92682f1f4c611ce4065e026275c
      https://github.com/llvm/llvm-project/commit/53ec21e3a10ae92682f1f4c611ce4065e026275c
  Author: Elvina Yakubova <elvina.yakubova at huawei.com>
  Date:   2021-10-11 (Mon, 11 Oct 2021)

  Changed paths:
    A bolt/test/AArch64/lit.local.cfg
    M bolt/test/AArch64/tls.c
    A bolt/test/X86/lit.local.cfg
    M bolt/test/runtime/AArch64/issue177.s
    M bolt/test/runtime/AArch64/lit.local.cfg
    M bolt/test/runtime/X86/internal_call_instrument.test

  Log Message:
  -----------
  [PR][BOLT][TEST] Fix tests

Summary:
Add lit.local.cfg to X86 and AArch64 folders.
Fix host_arch in lit config for AArch64.
Fix AArch64 and X86 tests.

Elvina Yakubova,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31702068)


  Commit: fdd9184db54b1d2e63ae16c13769fb6741dc2687
      https://github.com/llvm/llvm-project/commit/fdd9184db54b1d2e63ae16c13769fb6741dc2687
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-10-11 (Mon, 11 Oct 2021)

  Changed paths:
    M bolt/src/DWARFRewriter.cpp
    M bolt/src/DWARFRewriter.h
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT][DWARF] Refactor of Loc and LocLists writers

Summary:
Refactored Loc and LocList writers to write out entries during finalization phase,
 and hid some of the details in a class.
This simplifies things from impelementation details, and also will be needed for
DWARF5 where we need to know how many locLists entries there are there.

(cherry picked from FBD31563795)


  Commit: 2d431eefbf493b3bd7f88419ec39e28247de29a0
      https://github.com/llvm/llvm-project/commit/2d431eefbf493b3bd7f88419ec39e28247de29a0
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-16 (Sat, 16 Oct 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/BinaryFunction.h
    M bolt/src/Passes/ADRRelaxationPass.cpp

  Log Message:
  -----------
  [PR] Fix constant islands handling

Summary:
After the "Allocate memory for constant islands on-demand" patch there
are couple of problems found in constant islands handling:
1. When creating constant island dependency we need to check that we
already allocated IslandInfo for BF.
2. In ADRRelaxationPass we need to set constant island check under new
hasIslandsInfo condition.
3. In binaryemitter we need to replace hasConstantIsland with
hasIslandsInfo check since originally the BF might not have constant
island, but might have access to other's BF CI.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31737935)


  Commit: dcdd37fdc2ca2cc51b8671c828c5639e23d71d07
      https://github.com/llvm/llvm-project/commit/dcdd37fdc2ca2cc51b8671c828c5639e23d71d07
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-15 (Fri, 15 Oct 2021)

  Changed paths:
    M bolt/runtime/common.h
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [PR] Instrumentation: Sync file on dump

Summary:
Sync the file with storage device on data dump to stabilize
instrumentation testing

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31738021)


  Commit: dc4b32e1b10f8025c070e05aada367f6b73aaade
      https://github.com/llvm/llvm-project/commit/dc4b32e1b10f8025c070e05aada367f6b73aaade
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-17 (Sun, 17 Oct 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [PR] Skip NONE static relocations

Summary:
To supress warning of unsupported relocations

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31738420)


  Commit: cb8d701b7bbbdb0c87fc25469b44d4d6b63973e8
      https://github.com/llvm/llvm-project/commit/cb8d701b7bbbdb0c87fc25469b44d4d6b63973e8
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-16 (Sat, 16 Oct 2021)

  Changed paths:
    M bolt/runtime/hugify.cpp
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [PR] Disable instrumentation and hugify build for aarch64

Summary:
This patch temporarily disables instrumentation and higufy build not for
x86 platforms to be able to build llvm-bolt tool on aarch64.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31738306)


  Commit: 32782574d2e70ca5bab5589ce4464b580e0ed15d
      https://github.com/llvm/llvm-project/commit/32782574d2e70ca5bab5589ce4464b580e0ed15d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-10-11 (Mon, 11 Oct 2021)

  Changed paths:
    M bolt/src/BinaryContext.cpp
    M bolt/src/BinaryContext.h
    M bolt/src/BinaryEmitter.cpp
    M bolt/src/DebugData.cpp
    M bolt/src/DebugData.h

  Log Message:
  -----------
  [BOLT][DWARF] Keep original line info for unmodified units

Summary:
Some compilation units will contain only code that is left unmodified by
BOLT, e.g. there is no profile data available for any function from such
units as they are rarely or never executed.

To save processing time and memory, we disable building line info tables
for such units and write unmodified tables to the output file.

(cherry picked from FBD31599759)


  Commit: 10088a1e15b44ba3ee8db1c05573dd3b13ef2b68
      https://github.com/llvm/llvm-project/commit/10088a1e15b44ba3ee8db1c05573dd3b13ef2b68
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-17 (Sun, 17 Oct 2021)

  Changed paths:
    M bolt/src/Passes/ExtTSPReorderAlgorithm.cpp

  Log Message:
  -----------
  [PR] Fix warning

Summary:
Fix control reaches end of non-void function warning

(cherry picked from FBD31738391)


  Commit: 95ee12977b85b624a6e103e536cd94e58bc248c5
      https://github.com/llvm/llvm-project/commit/95ee12977b85b624a6e103e536cd94e58bc248c5
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-16 (Sat, 16 Oct 2021)

  Changed paths:
    M bolt/src/RewriteInstance.cpp

  Log Message:
  -----------
  [PR] Introduce remove-symtab option

Summary:
This patch introduces remove-symtab option to be able to skip emitting
symtab section in the final binary.
Also this patch adds ".zdebug_*" (compressed debug section) in the list
of debug section names.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31738239)


  Commit: 1ccc3d500ed9ac0eb5aefd15c6f368f885da328c
      https://github.com/llvm/llvm-project/commit/1ccc3d500ed9ac0eb5aefd15c6f368f885da328c
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-10-23 (Sat, 23 Oct 2021)

  Changed paths:
    A bolt/utils/docker/Dockerfile

  Log Message:
  -----------
  [BOLT] Add Dockerfile

Summary:
Dockerfile based on Ubuntu:20.04.

Fixes facebookincubator/BOLT#214.

(cherry picked from FBD31883210)


  Commit: 46bc197d72a63ded00d7fce2b891e4324b7bbd9c
      https://github.com/llvm/llvm-project/commit/46bc197d72a63ded00d7fce2b891e4324b7bbd9c
  Author: Marius Wachtler <undingen at gmail.com>
  Date:   2021-10-25 (Mon, 25 Oct 2021)

  Changed paths:
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [PR] bolt_rt: getBinaryPath() increase max file path

Summary:
Increase the hard limit from 256 to 4096.
This fixes the 'Assertion failed: failed to open binary path' error I'm seeing.

(cherry picked from FBD31911946)


  Commit: a34c753fe709a624f5b087397fb05adeac2311e4
      https://github.com/llvm/llvm-project/commit/a34c753fe709a624f5b087397fb05adeac2311e4
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-10-08 (Fri, 08 Oct 2021)

  Changed paths:
    M bolt/CMakeLists.txt
    A bolt/include/bolt/Core/BinaryBasicBlock.h
    A bolt/include/bolt/Core/BinaryContext.h
    A bolt/include/bolt/Core/BinaryData.h
    A bolt/include/bolt/Core/BinaryEmitter.h
    A bolt/include/bolt/Core/BinaryFunction.h
    A bolt/include/bolt/Core/BinaryLoop.h
    A bolt/include/bolt/Core/BinarySection.h
    A bolt/include/bolt/Core/DebugData.h
    A bolt/include/bolt/Core/DynoStats.h
    A bolt/include/bolt/Core/Exceptions.h
    A bolt/include/bolt/Core/JumpTable.h
    A bolt/include/bolt/Core/MCPlus.h
    A bolt/include/bolt/Core/MCPlusBuilder.h
    A bolt/include/bolt/Core/ParallelUtilities.h
    A bolt/include/bolt/Core/Relocation.h
    A bolt/include/bolt/Passes/ADRRelaxationPass.h
    A bolt/include/bolt/Passes/Aligner.h
    A bolt/include/bolt/Passes/AllocCombiner.h
    A bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
    A bolt/include/bolt/Passes/BinaryPasses.h
    A bolt/include/bolt/Passes/CacheMetrics.h
    A bolt/include/bolt/Passes/CallGraph.h
    A bolt/include/bolt/Passes/CallGraphWalker.h
    A bolt/include/bolt/Passes/DataflowAnalysis.h
    A bolt/include/bolt/Passes/DataflowInfoManager.h
    A bolt/include/bolt/Passes/DominatorAnalysis.h
    A bolt/include/bolt/Passes/FrameAnalysis.h
    A bolt/include/bolt/Passes/FrameOptimizer.h
    A bolt/include/bolt/Passes/HFSort.h
    A bolt/include/bolt/Passes/IdenticalCodeFolding.h
    A bolt/include/bolt/Passes/IndirectCallPromotion.h
    A bolt/include/bolt/Passes/Inliner.h
    A bolt/include/bolt/Passes/Instrumentation.h
    A bolt/include/bolt/Passes/InstrumentationSummary.h
    A bolt/include/bolt/Passes/JTFootprintReduction.h
    A bolt/include/bolt/Passes/LivenessAnalysis.h
    A bolt/include/bolt/Passes/LongJmp.h
    A bolt/include/bolt/Passes/LoopInversionPass.h
    A bolt/include/bolt/Passes/MCF.h
    A bolt/include/bolt/Passes/PLTCall.h
    A bolt/include/bolt/Passes/PatchEntries.h
    A bolt/include/bolt/Passes/ReachingDefOrUse.h
    A bolt/include/bolt/Passes/ReachingInsns.h
    A bolt/include/bolt/Passes/RegAnalysis.h
    A bolt/include/bolt/Passes/RegReAssign.h
    A bolt/include/bolt/Passes/ReorderAlgorithm.h
    A bolt/include/bolt/Passes/ReorderData.h
    A bolt/include/bolt/Passes/ReorderFunctions.h
    A bolt/include/bolt/Passes/ReorderUtils.h
    A bolt/include/bolt/Passes/RetpolineInsertion.h
    A bolt/include/bolt/Passes/ShrinkWrapping.h
    A bolt/include/bolt/Passes/SplitFunctions.h
    A bolt/include/bolt/Passes/StackAllocationAnalysis.h
    A bolt/include/bolt/Passes/StackAvailableExpressions.h
    A bolt/include/bolt/Passes/StackPointerTracking.h
    A bolt/include/bolt/Passes/StackReachingUses.h
    A bolt/include/bolt/Passes/StokeInfo.h
    A bolt/include/bolt/Passes/TailDuplication.h
    A bolt/include/bolt/Passes/ThreeWayBranch.h
    A bolt/include/bolt/Passes/ValidateInternalCalls.h
    A bolt/include/bolt/Passes/VeneerElimination.h
    A bolt/include/bolt/Profile/BoltAddressTranslation.h
    A bolt/include/bolt/Profile/DataAggregator.h
    A bolt/include/bolt/Profile/DataReader.h
    A bolt/include/bolt/Profile/Heatmap.h
    A bolt/include/bolt/Profile/ProfileReaderBase.h
    A bolt/include/bolt/Profile/ProfileYAMLMapping.h
    A bolt/include/bolt/Profile/YAMLProfileReader.h
    A bolt/include/bolt/Profile/YAMLProfileWriter.h
    A bolt/include/bolt/Rewrite/BinaryPassManager.h
    A bolt/include/bolt/Rewrite/DWARFRewriter.h
    A bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h
    A bolt/include/bolt/Rewrite/MachORewriteInstance.h
    A bolt/include/bolt/Rewrite/RewriteInstance.h
    A bolt/include/bolt/RuntimeLibs/HugifyRuntimeLibrary.h
    A bolt/include/bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h
    A bolt/include/bolt/RuntimeLibs/RuntimeLibrary.h
    A bolt/include/bolt/Utils/CommandLineOpts.h
    A bolt/include/bolt/Utils/NameResolver.h
    A bolt/include/bolt/Utils/NameShortener.h
    A bolt/include/bolt/Utils/Utils.h
    A bolt/lib/CMakeLists.txt
    A bolt/lib/Core/BinaryBasicBlock.cpp
    A bolt/lib/Core/BinaryContext.cpp
    A bolt/lib/Core/BinaryData.cpp
    A bolt/lib/Core/BinaryEmitter.cpp
    A bolt/lib/Core/BinaryFunction.cpp
    A bolt/lib/Core/BinaryFunctionProfile.cpp
    A bolt/lib/Core/BinarySection.cpp
    A bolt/lib/Core/CMakeLists.txt
    A bolt/lib/Core/DebugData.cpp
    A bolt/lib/Core/DynoStats.cpp
    A bolt/lib/Core/Exceptions.cpp
    A bolt/lib/Core/JumpTable.cpp
    A bolt/lib/Core/MCPlusBuilder.cpp
    A bolt/lib/Core/ParallelUtilities.cpp
    A bolt/lib/Core/Relocation.cpp
    A bolt/lib/Passes/ADRRelaxationPass.cpp
    A bolt/lib/Passes/Aligner.cpp
    A bolt/lib/Passes/AllocCombiner.cpp
    A bolt/lib/Passes/BinaryFunctionCallGraph.cpp
    A bolt/lib/Passes/BinaryPasses.cpp
    A bolt/lib/Passes/CMakeLists.txt
    A bolt/lib/Passes/CacheMetrics.cpp
    A bolt/lib/Passes/CallGraph.cpp
    A bolt/lib/Passes/CallGraphWalker.cpp
    A bolt/lib/Passes/DataflowAnalysis.cpp
    A bolt/lib/Passes/DataflowInfoManager.cpp
    A bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
    A bolt/lib/Passes/FrameAnalysis.cpp
    A bolt/lib/Passes/FrameOptimizer.cpp
    A bolt/lib/Passes/HFSort.cpp
    A bolt/lib/Passes/HFSortPlus.cpp
    A bolt/lib/Passes/IdenticalCodeFolding.cpp
    A bolt/lib/Passes/IndirectCallPromotion.cpp
    A bolt/lib/Passes/Inliner.cpp
    A bolt/lib/Passes/Instrumentation.cpp
    A bolt/lib/Passes/JTFootprintReduction.cpp
    A bolt/lib/Passes/LivenessAnalysis.cpp
    A bolt/lib/Passes/LongJmp.cpp
    A bolt/lib/Passes/LoopInversionPass.cpp
    A bolt/lib/Passes/MCF.cpp
    A bolt/lib/Passes/PLTCall.cpp
    A bolt/lib/Passes/PatchEntries.cpp
    A bolt/lib/Passes/PettisAndHansen.cpp
    A bolt/lib/Passes/RegAnalysis.cpp
    A bolt/lib/Passes/RegReAssign.cpp
    A bolt/lib/Passes/ReorderAlgorithm.cpp
    A bolt/lib/Passes/ReorderData.cpp
    A bolt/lib/Passes/ReorderFunctions.cpp
    A bolt/lib/Passes/RetpolineInsertion.cpp
    A bolt/lib/Passes/ShrinkWrapping.cpp
    A bolt/lib/Passes/SplitFunctions.cpp
    A bolt/lib/Passes/StackAllocationAnalysis.cpp
    A bolt/lib/Passes/StackAvailableExpressions.cpp
    A bolt/lib/Passes/StackPointerTracking.cpp
    A bolt/lib/Passes/StackReachingUses.cpp
    A bolt/lib/Passes/StokeInfo.cpp
    A bolt/lib/Passes/TailDuplication.cpp
    A bolt/lib/Passes/ThreeWayBranch.cpp
    A bolt/lib/Passes/ValidateInternalCalls.cpp
    A bolt/lib/Passes/VeneerElimination.cpp
    A bolt/lib/Profile/BoltAddressTranslation.cpp
    A bolt/lib/Profile/CMakeLists.txt
    A bolt/lib/Profile/DataAggregator.cpp
    A bolt/lib/Profile/DataReader.cpp
    A bolt/lib/Profile/Heatmap.cpp
    A bolt/lib/Profile/ProfileReaderBase.cpp
    A bolt/lib/Profile/YAMLProfileReader.cpp
    A bolt/lib/Profile/YAMLProfileWriter.cpp
    A bolt/lib/Rewrite/BinaryPassManager.cpp
    A bolt/lib/Rewrite/BoltDiff.cpp
    A bolt/lib/Rewrite/CMakeLists.txt
    A bolt/lib/Rewrite/DWARFRewriter.cpp
    A bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
    A bolt/lib/Rewrite/MachORewriteInstance.cpp
    A bolt/lib/Rewrite/RewriteInstance.cpp
    A bolt/lib/RuntimeLibs/CMakeLists.txt
    A bolt/lib/RuntimeLibs/HugifyRuntimeLibrary.cpp
    A bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    A bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
    A bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
    A bolt/lib/Target/AArch64/CMakeLists.txt
    A bolt/lib/Target/CMakeLists.txt
    A bolt/lib/Target/X86/CMakeLists.txt
    A bolt/lib/Target/X86/X86MCPlusBuilder.cpp
    A bolt/lib/Utils/CMakeLists.txt
    A bolt/lib/Utils/CommandLineOpts.cpp
    A bolt/lib/Utils/Utils.cpp
    R bolt/src/BinaryBasicBlock.cpp
    R bolt/src/BinaryBasicBlock.h
    R bolt/src/BinaryContext.cpp
    R bolt/src/BinaryContext.h
    R bolt/src/BinaryData.cpp
    R bolt/src/BinaryData.h
    R bolt/src/BinaryEmitter.cpp
    R bolt/src/BinaryEmitter.h
    R bolt/src/BinaryFunction.cpp
    R bolt/src/BinaryFunction.h
    R bolt/src/BinaryFunctionProfile.cpp
    R bolt/src/BinaryLoop.h
    R bolt/src/BinaryPassManager.cpp
    R bolt/src/BinaryPassManager.h
    R bolt/src/BinarySection.cpp
    R bolt/src/BinarySection.h
    R bolt/src/BoltAddressTranslation.cpp
    R bolt/src/BoltAddressTranslation.h
    R bolt/src/BoltDiff.cpp
    R bolt/src/CMakeLists.txt
    R bolt/src/CacheMetrics.cpp
    R bolt/src/CacheMetrics.h
    R bolt/src/DWARFRewriter.cpp
    R bolt/src/DWARFRewriter.h
    R bolt/src/DataAggregator.cpp
    R bolt/src/DataAggregator.h
    R bolt/src/DataReader.cpp
    R bolt/src/DataReader.h
    R bolt/src/DebugData.cpp
    R bolt/src/DebugData.h
    R bolt/src/DynoStats.cpp
    R bolt/src/DynoStats.h
    R bolt/src/Exceptions.cpp
    R bolt/src/Exceptions.h
    R bolt/src/ExecutableFileMemoryManager.cpp
    R bolt/src/ExecutableFileMemoryManager.h
    R bolt/src/Heatmap.cpp
    R bolt/src/Heatmap.h
    R bolt/src/JumpTable.cpp
    R bolt/src/JumpTable.h
    R bolt/src/MCPlus.h
    R bolt/src/MCPlusBuilder.cpp
    R bolt/src/MCPlusBuilder.h
    R bolt/src/MachORewriteInstance.cpp
    R bolt/src/MachORewriteInstance.h
    R bolt/src/NameResolver.h
    R bolt/src/NameShortener.h
    R bolt/src/ParallelUtilities.cpp
    R bolt/src/ParallelUtilities.h
    R bolt/src/Passes/ADRRelaxationPass.cpp
    R bolt/src/Passes/ADRRelaxationPass.h
    R bolt/src/Passes/Aligner.cpp
    R bolt/src/Passes/Aligner.h
    R bolt/src/Passes/AllocCombiner.cpp
    R bolt/src/Passes/AllocCombiner.h
    R bolt/src/Passes/BinaryFunctionCallGraph.cpp
    R bolt/src/Passes/BinaryFunctionCallGraph.h
    R bolt/src/Passes/BinaryPasses.cpp
    R bolt/src/Passes/BinaryPasses.h
    R bolt/src/Passes/CMakeLists.txt
    R bolt/src/Passes/CallGraph.cpp
    R bolt/src/Passes/CallGraph.h
    R bolt/src/Passes/CallGraphWalker.cpp
    R bolt/src/Passes/CallGraphWalker.h
    R bolt/src/Passes/DataflowAnalysis.cpp
    R bolt/src/Passes/DataflowAnalysis.h
    R bolt/src/Passes/DataflowInfoManager.cpp
    R bolt/src/Passes/DataflowInfoManager.h
    R bolt/src/Passes/DominatorAnalysis.h
    R bolt/src/Passes/ExtTSPReorderAlgorithm.cpp
    R bolt/src/Passes/FrameAnalysis.cpp
    R bolt/src/Passes/FrameAnalysis.h
    R bolt/src/Passes/FrameOptimizer.cpp
    R bolt/src/Passes/FrameOptimizer.h
    R bolt/src/Passes/HFSort.cpp
    R bolt/src/Passes/HFSort.h
    R bolt/src/Passes/HFSortPlus.cpp
    R bolt/src/Passes/IdenticalCodeFolding.cpp
    R bolt/src/Passes/IdenticalCodeFolding.h
    R bolt/src/Passes/IndirectCallPromotion.cpp
    R bolt/src/Passes/IndirectCallPromotion.h
    R bolt/src/Passes/Inliner.cpp
    R bolt/src/Passes/Inliner.h
    R bolt/src/Passes/Instrumentation.cpp
    R bolt/src/Passes/Instrumentation.h
    R bolt/src/Passes/InstrumentationSummary.h
    R bolt/src/Passes/JTFootprintReduction.cpp
    R bolt/src/Passes/JTFootprintReduction.h
    R bolt/src/Passes/LivenessAnalysis.cpp
    R bolt/src/Passes/LivenessAnalysis.h
    R bolt/src/Passes/LongJmp.cpp
    R bolt/src/Passes/LongJmp.h
    R bolt/src/Passes/LoopInversionPass.cpp
    R bolt/src/Passes/LoopInversionPass.h
    R bolt/src/Passes/MCF.cpp
    R bolt/src/Passes/MCF.h
    R bolt/src/Passes/PLTCall.cpp
    R bolt/src/Passes/PLTCall.h
    R bolt/src/Passes/PatchEntries.cpp
    R bolt/src/Passes/PatchEntries.h
    R bolt/src/Passes/PettisAndHansen.cpp
    R bolt/src/Passes/ReachingDefOrUse.h
    R bolt/src/Passes/ReachingInsns.h
    R bolt/src/Passes/RegAnalysis.cpp
    R bolt/src/Passes/RegAnalysis.h
    R bolt/src/Passes/RegReAssign.cpp
    R bolt/src/Passes/RegReAssign.h
    R bolt/src/Passes/ReorderAlgorithm.cpp
    R bolt/src/Passes/ReorderAlgorithm.h
    R bolt/src/Passes/ReorderData.cpp
    R bolt/src/Passes/ReorderData.h
    R bolt/src/Passes/ReorderFunctions.cpp
    R bolt/src/Passes/ReorderFunctions.h
    R bolt/src/Passes/ReorderUtils.h
    R bolt/src/Passes/RetpolineInsertion.cpp
    R bolt/src/Passes/RetpolineInsertion.h
    R bolt/src/Passes/ShrinkWrapping.cpp
    R bolt/src/Passes/ShrinkWrapping.h
    R bolt/src/Passes/SplitFunctions.cpp
    R bolt/src/Passes/SplitFunctions.h
    R bolt/src/Passes/StackAllocationAnalysis.cpp
    R bolt/src/Passes/StackAllocationAnalysis.h
    R bolt/src/Passes/StackAvailableExpressions.cpp
    R bolt/src/Passes/StackAvailableExpressions.h
    R bolt/src/Passes/StackPointerTracking.cpp
    R bolt/src/Passes/StackPointerTracking.h
    R bolt/src/Passes/StackReachingUses.cpp
    R bolt/src/Passes/StackReachingUses.h
    R bolt/src/Passes/StokeInfo.cpp
    R bolt/src/Passes/StokeInfo.h
    R bolt/src/Passes/TailDuplication.cpp
    R bolt/src/Passes/TailDuplication.h
    R bolt/src/Passes/ThreeWayBranch.cpp
    R bolt/src/Passes/ThreeWayBranch.h
    R bolt/src/Passes/ValidateInternalCalls.cpp
    R bolt/src/Passes/ValidateInternalCalls.h
    R bolt/src/Passes/VeneerElimination.cpp
    R bolt/src/Passes/VeneerElimination.h
    R bolt/src/ProfileReaderBase.cpp
    R bolt/src/ProfileReaderBase.h
    R bolt/src/ProfileYAMLMapping.h
    R bolt/src/Relocation.cpp
    R bolt/src/Relocation.h
    R bolt/src/RewriteInstance.cpp
    R bolt/src/RewriteInstance.h
    R bolt/src/RuntimeLibs/CMakeLists.txt
    R bolt/src/RuntimeLibs/HugifyRuntimeLibrary.cpp
    R bolt/src/RuntimeLibs/HugifyRuntimeLibrary.h
    R bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    R bolt/src/RuntimeLibs/InstrumentationRuntimeLibrary.h
    R bolt/src/RuntimeLibs/RuntimeLibrary.cpp
    R bolt/src/RuntimeLibs/RuntimeLibrary.h
    R bolt/src/Target/AArch64/AArch64MCPlusBuilder.cpp
    R bolt/src/Target/AArch64/CMakeLists.txt
    R bolt/src/Target/CMakeLists.txt
    R bolt/src/Target/X86/CMakeLists.txt
    R bolt/src/Target/X86/X86MCPlusBuilder.cpp
    R bolt/src/Utils.cpp
    R bolt/src/Utils.h
    R bolt/src/YAMLProfileReader.cpp
    R bolt/src/YAMLProfileReader.h
    R bolt/src/YAMLProfileWriter.cpp
    R bolt/src/YAMLProfileWriter.h
    R bolt/src/llvm-bolt.cpp
    R bolt/src/merge-fdata/CMakeLists.txt
    R bolt/src/merge-fdata/merge-fdata.cpp
    A bolt/tools/CMakeLists.txt
    A bolt/tools/driver/CMakeLists.txt
    A bolt/tools/driver/llvm-bolt.cpp
    A bolt/tools/merge-fdata/CMakeLists.txt
    A bolt/tools/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  Rebase: [NFC] Refactor sources to be buildable in shared mode

Summary:
Moves source files into separate components, and make explicit
component dependency on each other, so LLVM build system knows how to
build BOLT in BUILD_SHARED_LIBS=ON.

Please use the -c merge.renamelimit=230 git option when rebasing your
work on top of this change.

To achieve this, we create a new library to hold core IR files (most
classes beginning with Binary in their names), a new library to hold
Utils, some command line options shared across both RewriteInstance
and core IR files, a new library called Rewrite to hold most classes
concerned with running top-level functions coordinating the binary
rewriting process, and a new library called Profile to hold classes
dealing with profile reading and writing.

To remove the dependency from BinaryContext into X86-specific classes,
we do some refactoring on the BinaryContext constructor to receive a
reference to the specific backend directly from RewriteInstance. Then,
the dependency on X86 or AArch64-specific classes is transfered to the
Rewrite library. We can't have the Core library depend on targets
because targets depend on Core (which would create a cycle).

Files implementing the entry point of a tool are transferred to the
tools/ folder. All header files are transferred to the include/
folder. The src/ folder was renamed to lib/.

(cherry picked from FBD32746834)


  Commit: 0559dab5463259e9309c13d27b034a0318400557
      https://github.com/llvm/llvm-project/commit/0559dab5463259e9309c13d27b034a0318400557
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-10-26 (Tue, 26 Oct 2021)

  Changed paths:
    M bolt/CMakeLists.txt
    M bolt/lib/Target/CMakeLists.txt
    M bolt/test/CMakeLists.txt
    M bolt/test/X86/internal_call_instrument.s
    M bolt/test/lit.cfg.py
    M bolt/test/lit.site.cfg.py.in
    M bolt/test/runtime/X86/fdata-escape-chars.ll
    M bolt/test/runtime/X86/instrumentation-dup-jts.s
    M bolt/test/runtime/X86/instrumentation-ind-calls.s
    M bolt/test/runtime/X86/instrumentation-pie.c
    M bolt/test/runtime/X86/instrumentation-shlib.c
    M bolt/test/runtime/X86/internal_call_instrument.test
    M bolt/test/runtime/X86/user-func-reorder.c
    M bolt/tools/driver/CMakeLists.txt

  Log Message:
  -----------
  [BOLT] Improve cmake configs for opensource

Summary:
Change cmake config in BOLT to only support Linux. In other
platforms, we print a warning that we won't build BOLT.  Change
configs to determine whether we will build BOLT runtime libs. This
only happens in x86 hosts. If true, we will build the runtime and
enable bolt-runtime tests. New tests that depend on the bolt_rt lib
needs to be marked REQUIRES:bolt-runtime. I updated the relevant
tests.  Fix cmake to do not crash when building llvm with a target
that BOLT does not support.

(cherry picked from FBD31935760)


  Commit: 60b09997237c6b4a9d92baa054089bf4d838cdbf
      https://github.com/llvm/llvm-project/commit/60b09997237c6b4a9d92baa054089bf4d838cdbf
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-10-26 (Tue, 26 Oct 2021)

  Changed paths:
    M bolt/include/bolt/Passes/ADRRelaxationPass.h
    M bolt/include/bolt/Passes/AllocCombiner.h
    M bolt/include/bolt/Passes/BinaryPasses.h
    M bolt/include/bolt/Passes/DataflowAnalysis.h
    M bolt/include/bolt/Passes/DataflowInfoManager.h
    M bolt/include/bolt/Passes/DominatorAnalysis.h
    M bolt/include/bolt/Passes/FrameAnalysis.h
    M bolt/include/bolt/Passes/FrameOptimizer.h
    M bolt/include/bolt/Passes/IndirectCallPromotion.h
    M bolt/include/bolt/Passes/Instrumentation.h
    M bolt/include/bolt/Passes/JTFootprintReduction.h
    M bolt/include/bolt/Passes/LivenessAnalysis.h
    M bolt/include/bolt/Passes/ReachingDefOrUse.h
    M bolt/include/bolt/Passes/ReachingInsns.h
    M bolt/include/bolt/Passes/RegReAssign.h
    M bolt/include/bolt/Passes/ShrinkWrapping.h
    M bolt/include/bolt/Passes/StackAllocationAnalysis.h
    M bolt/include/bolt/Passes/StackAvailableExpressions.h
    M bolt/include/bolt/Passes/StackPointerTracking.h
    M bolt/include/bolt/Passes/StackReachingUses.h
    M bolt/include/bolt/Passes/StokeInfo.h
    M bolt/lib/Passes/ADRRelaxationPass.cpp
    M bolt/lib/Passes/AllocCombiner.cpp
    M bolt/lib/Passes/BinaryPasses.cpp
    M bolt/lib/Passes/DataflowAnalysis.cpp
    M bolt/lib/Passes/DataflowInfoManager.cpp
    M bolt/lib/Passes/FrameAnalysis.cpp
    M bolt/lib/Passes/FrameOptimizer.cpp
    M bolt/lib/Passes/IndirectCallPromotion.cpp
    M bolt/lib/Passes/Instrumentation.cpp
    M bolt/lib/Passes/JTFootprintReduction.cpp
    M bolt/lib/Passes/MCF.cpp
    M bolt/lib/Passes/RegReAssign.cpp
    M bolt/lib/Passes/ShrinkWrapping.cpp
    M bolt/lib/Passes/StackAvailableExpressions.cpp
    M bolt/lib/Passes/StackPointerTracking.cpp
    M bolt/lib/Passes/StokeInfo.cpp
    M bolt/lib/Passes/ValidateInternalCalls.cpp

  Log Message:
  -----------
  [BOLT][NFC] Do not pass BinaryContext alongside BinaryFunction

Summary:
BinaryContext is available via BinaryFunction::getBinaryContext(),
hence there's no reason to pass both as arguments to a function.

In a similar fashion, BinaryBasicBlock has an access to BinaryFunction
via getFunction(). Eliminate unneeded arguments.

(cherry picked from FBD31921680)


  Commit: 443f1b4ff458035029ac190d808c532117eaf596
      https://github.com/llvm/llvm-project/commit/443f1b4ff458035029ac190d808c532117eaf596
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-09-27 (Mon, 27 Sep 2021)

  Changed paths:
    A bolt/include/bolt/Passes/AsmDump.h
    A bolt/lib/Passes/AsmDump.cpp
    M bolt/lib/Passes/CMakeLists.txt
    M bolt/lib/Rewrite/BinaryPassManager.cpp
    A bolt/test/X86/asm_dump.c

  Log Message:
  -----------
  Rebase: [BOLT] AsmDump: dump function assembly and profile info

Summary:
Added new functionality of dumping simple functions into assembly.
This includes:
- function control flow (basic blocks, instructions),
- profile information as `FDATA` directives, to be consumed by link_fdata,
- data labels,
- CFI directives,
- symbols for callee functions,
- jump table symbols.

Envisioned usage:
1. Find a function that triggers BOLT crash (e.g. with `bughunter.sh`).
2. Generate reproducer asm source for that function (using `-funcs`).
3. Attach it to an issue.
4. Reduce and include as a test case.

Current limitations:
1. Emitted assembly won't match input file relocations.
2. No DWARF support.
3. Data is not emitted.

(cherry picked from FBD32746857)


  Commit: 85ffa8e4ba44475362979d4724ba23f1aec19d27
      https://github.com/llvm/llvm-project/commit/85ffa8e4ba44475362979d4724ba23f1aec19d27
  Author: Alexey Moksyakov <alexey.moksyakov at huawei.com>
  Date:   2021-10-11 (Mon, 11 Oct 2021)

  Changed paths:
    M bolt/include/bolt/Core/MCPlusBuilder.h
    M bolt/lib/Passes/Instrumentation.cpp
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [PR][BOLT][Instrumentation] Optimize eflags load/store

Summary:
This commit uses reviews.llvm.org/D6629 as a reference to optimize
X86::EFLAGS load/store in the instrumentation snippet by using lahf/sahf
instructions instead of pushf/popf.

(cherry picked from FBD31662303)


  Commit: 172deb75947eb1e538b4582b67c1305107b93975
      https://github.com/llvm/llvm-project/commit/172deb75947eb1e538b4582b67c1305107b93975
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-10-19 (Tue, 19 Oct 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/lib/Core/Relocation.cpp

  Log Message:
  -----------
  [PR] Aarch64: Add ABS32/16 relocations support

Summary:
Add R_AARCH64_ABS32 and R_AARCH64_ABS16 relocations support

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD31875254)


  Commit: 45f94abcd954d50d4b6d344c4db2ecdd6b8e867f
      https://github.com/llvm/llvm-project/commit/45f94abcd954d50d4b6d344c4db2ecdd6b8e867f
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-10-27 (Wed, 27 Oct 2021)

  Changed paths:
    M bolt/include/bolt/Core/DebugData.h
    M bolt/include/bolt/Rewrite/DWARFRewriter.h
    M bolt/lib/Core/DebugData.cpp
    M bolt/lib/Rewrite/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Fix rare problem while rewriting debug_abbrev after LTO

Summary:
With LTO, it's possible for multiple DWARF compile units to share the
same abbreviation section set, i.e. to have the same abbrev_offset.
When units sharing the same abbrev set are located next to each other
and neither of them is being processed (i.e. contain processed
functions), it can trigger a bug in BOLT. When this happened,
the abbrev set is considered empty. Additionally, different units
may patch abbrev section differently.

The fix is to not rely on the next unit offset when detecting
abbreviation set boundaries and to delay writing abbrev section
until all units are processed.

(cherry picked from FBD31985046)


  Commit: 933df2a460edd1a9f5a82ca5ea21c89140e51dd7
      https://github.com/llvm/llvm-project/commit/933df2a460edd1a9f5a82ca5ea21c89140e51dd7
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-11-08 (Mon, 08 Nov 2021)

  Changed paths:
    M bolt/lib/Core/BinaryContext.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Passes/ReorderData.cpp
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Remove references to internal tasks

(cherry picked from FBD32272387)


  Commit: 9ab066221181df148a6e110d9af66dfe8f53eeb8
      https://github.com/llvm/llvm-project/commit/9ab066221181df148a6e110d9af66dfe8f53eeb8
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-09 (Tue, 09 Nov 2021)

  Changed paths:
    M bolt/lib/Passes/TailDuplication.cpp

  Log Message:
  -----------
  [BOLT] TailDuplication: skip non-simple functions

Summary:
Replace erroneous check for function eligibility from `Function.isIgnored()`
to `shouldOptimize(Function)`. This prevents non-simple functions from being
processed.

(cherry picked from FBD32301958)


  Commit: f808ea00bd77065270cf5f25495f86b33cd4497c
      https://github.com/llvm/llvm-project/commit/f808ea00bd77065270cf5f25495f86b33cd4497c
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-10-29 (Fri, 29 Oct 2021)

  Changed paths:
    M bolt/test/CMakeLists.txt
    A bolt/test/Inputs/bolt_icf.cpp
    A bolt/test/Inputs/vararg.s
    A bolt/test/X86/Inputs/asm_foo.s
    A bolt/test/X86/Inputs/asm_main.c
    A bolt/test/X86/Inputs/ctc_and_unreachable.s
    A bolt/test/X86/Inputs/double_jump.cpp
    A bolt/test/X86/Inputs/exc_args.s
    R bolt/test/X86/Inputs/vararg.s
    A bolt/test/X86/asm_func_debug.test
    A bolt/test/X86/ctc_and_unreachable.test
    A bolt/test/X86/double_jump.test
    A bolt/test/X86/exceptions_args.test
    M bolt/test/X86/vararg.test
    A bolt/test/bolt_icf.test
    M bolt/test/lit.cfg.py
    A bolt/test/runtime/Inputs/exceptions_split.cpp
    A bolt/test/runtime/Inputs/fptr.c
    A bolt/test/runtime/X86/basic_instrumentation.test
    A bolt/test/runtime/exceptions_instrumentation.test
    A bolt/test/runtime/fptr.test

  Log Message:
  -----------
  [BOLT][TEST] Import small tests

Summary:
Imported small internal tests:
- asm_func_debug.test
- basic_instrumentation.test
- bolt_icf.test
- ctc_and_unreachable.test
- double_jump.test
- exceptions_args.test
- exceptions_instrumentation.test
- fptr.test

(cherry picked from FBD32032684)


  Commit: d1df113e3056f6e82a292f624e33ccaa8c93e529
      https://github.com/llvm/llvm-project/commit/d1df113e3056f6e82a292f624e33ccaa8c93e529
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-03 (Wed, 03 Nov 2021)

  Changed paths:
    M bolt/test/lit.cfg.py
    A bolt/test/runtime/lit.local.cfg
    A bolt/test/runtime/meta-merge-fdata.test
    M bolt/tools/merge-fdata/CMakeLists.txt

  Log Message:
  -----------
  [BOLT][TEST] Add instrumentation test using merge-fdata

Summary:
BOLT meta test using merge-fdata tool.

This tests BOLT instrumentation for a non-trivial binary, running instrumented
binary, and using the instrumentation profile for BOLT optimizations.
The results are verified between original, instrumented, and optimized binaries.
Additional tested features: boltdiff mode and merge-fdata for two profiles.

merge-fdata tool is linked with relocs on Linux to support this test.

(cherry picked from FBD32141812)


  Commit: 2e0ad6ffe42ad10bdc3efac73d8efd93ddf684a5
      https://github.com/llvm/llvm-project/commit/2e0ad6ffe42ad10bdc3efac73d8efd93ddf684a5
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-03 (Wed, 03 Nov 2021)

  Changed paths:
    A bolt/test/Inputs/icf_baz.c
    A bolt/test/Inputs/icf_main.c
    A bolt/test/X86/Inputs/ft_to_noop.s
    R bolt/test/X86/Inputs/icf_baz.c
    R bolt/test/X86/Inputs/icf_main.c
    A bolt/test/X86/fallthrough-to-noop.test
    R bolt/test/X86/keep_aranges.test
    A bolt/test/keep_aranges.test

  Log Message:
  -----------
  [BOLT][TEST] Import small tests

Summary:
Imported small internal tests:
- fallthrough-to-noop.test

(cherry picked from FBD32158100)


  Commit: 8331f75e2866edc52a62e06b8c3059fccffd1b38
      https://github.com/llvm/llvm-project/commit/8331f75e2866edc52a62e06b8c3059fccffd1b38
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-04 (Thu, 04 Nov 2021)

  Changed paths:
    A bolt/test/X86/asm-dump.c
    A bolt/test/X86/asm-func-debug.test
    R bolt/test/X86/asm_dump.c
    R bolt/test/X86/asm_func_debug.test
    A bolt/test/X86/avx512-trap.test
    R bolt/test/X86/avx512_trap.test
    A bolt/test/X86/bad-exe.test
    R bolt/test/X86/bad_exe.test
    A bolt/test/X86/bb-with-two-tail-calls.s
    R bolt/test/X86/bb_with_two_tail_calls.s
    A bolt/test/X86/block-reordering.test
    R bolt/test/X86/block_reordering.test
    A bolt/test/X86/bolt-info.test
    R bolt/test/X86/bolt_info.test
    A bolt/test/X86/branch-data.test
    R bolt/test/X86/branch_data.test
    A bolt/test/X86/call-zero.s
    R bolt/test/X86/call_zero.s
    A bolt/test/X86/cfi-expr-rewrite.s
    A bolt/test/X86/cfi-instrs-count.s
    A bolt/test/X86/cfi-instrs-reordered.s
    R bolt/test/X86/cfi_expr_rewrite.s
    R bolt/test/X86/cfi_instrs_count.s
    R bolt/test/X86/cfi_instrs_reordered.s
    A bolt/test/X86/ctc-and-unreachable.test
    R bolt/test/X86/ctc_and_unreachable.test
    A bolt/test/X86/double-jump.test
    R bolt/test/X86/double_jump.test
    A bolt/test/X86/exceptions-args.test
    R bolt/test/X86/exceptions_args.test
    A bolt/test/X86/indirect-goto.test
    R bolt/test/X86/indirect_goto.test
    A bolt/test/X86/inlined-function-mixed.test
    R bolt/test/X86/inlined_function_mixed.test
    A bolt/test/X86/internal-call-instrument.s
    R bolt/test/X86/internal_call_instrument.s
    A bolt/test/X86/interprocedural-ref-entry-point.s
    R bolt/test/X86/interprocedural_ref_entry_point.s
    A bolt/test/X86/invalid-profile.test
    R bolt/test/X86/invalid_profile.test
    A bolt/test/X86/jmp-optimization.test
    R bolt/test/X86/jmp_optimization.test
    A bolt/test/X86/jump-table-footprint-reduction.test
    A bolt/test/X86/jump-table-reference.test
    R bolt/test/X86/jump_table_footprint_reduction.test
    R bolt/test/X86/jump_table_reference.test
    A bolt/test/X86/layout-heuristic.test
    R bolt/test/X86/layout_heuristic.test
    A bolt/test/X86/line-number.test
    R bolt/test/X86/line_number.test
    A bolt/test/X86/no-entry-reordering.test
    A bolt/test/X86/no-relocs.test
    R bolt/test/X86/no_entry_reordering.test
    R bolt/test/X86/no_relocs.test
    A bolt/test/X86/relaxed-tailcall.test
    R bolt/test/X86/relaxed_tailcall.test
    A bolt/test/X86/remove-unused.test
    R bolt/test/X86/remove_unused.test
    A bolt/test/X86/sctc-bug.test
    A bolt/test/X86/sctc-bug2.test
    A bolt/test/X86/sctc-bug3.test
    A bolt/test/X86/sctc-bug4.test
    R bolt/test/X86/sctc_bug.test
    R bolt/test/X86/sctc_bug2.test
    R bolt/test/X86/sctc_bug3.test
    R bolt/test/X86/sctc_bug4.test
    A bolt/test/X86/shared-object.test
    R bolt/test/X86/shared_object.test
    A bolt/test/X86/split-func-jump-table-fragment-noparent.s
    A bolt/test/X86/split-func-jump-table-fragment-reverse.s
    A bolt/test/X86/split-func-jump-table-fragment.s
    R bolt/test/X86/split_func_jump_table_fragment.s
    R bolt/test/X86/split_func_jump_table_fragment_noparent.s
    R bolt/test/X86/split_func_jump_table_fragment_reverse.s
    A bolt/test/X86/static-exe.test
    R bolt/test/X86/static_exe.test
    A bolt/test/bolt-icf.test
    R bolt/test/bolt_icf.test
    A bolt/test/keep-aranges.test
    R bolt/test/keep_aranges.test
    A bolt/test/runtime/X86/basic-instrumentation.test
    R bolt/test/runtime/X86/basic_instrumentation.test
    A bolt/test/runtime/X86/exceptions-pic.test
    A bolt/test/runtime/X86/exceptions-run.test
    R bolt/test/runtime/X86/exceptions_pic.test
    R bolt/test/runtime/X86/exceptions_run.test
    A bolt/test/runtime/X86/hot-end-symbol.s
    R bolt/test/runtime/X86/hot_end_symbol.s
    A bolt/test/runtime/X86/indirect-goto-pie.test
    R bolt/test/runtime/X86/indirect_goto_pie.test
    A bolt/test/runtime/X86/internal-call-instrument.test
    A bolt/test/runtime/X86/internal-call.test
    R bolt/test/runtime/X86/internal_call.test
    R bolt/test/runtime/X86/internal_call_instrument.test
    A bolt/test/runtime/X86/retpoline-synthetic.test
    R bolt/test/runtime/X86/retpoline_synthetic.test
    A bolt/test/runtime/X86/section-reloc-with-addend.s
    R bolt/test/runtime/X86/section_reloc_with_addend.s
    A bolt/test/runtime/exceptions-instrumentation.test
    R bolt/test/runtime/exceptions_instrumentation.test

  Log Message:
  -----------
  [BOLT][TEST] Rename tests to follow standard naming scheme

Summary:
The majority of tests in LLVM projects are using - instead of _ in the name,
i.e. `check-something.test` is preferred over `check_something.test`.

It makes sense for us to adopt the same naming scheme for our future tests and
to rename existing ones.

(cherry picked from FBD32185879)


  Commit: 3a16f2169d1133d20f818f04a1948bdf710fb7b0
      https://github.com/llvm/llvm-project/commit/3a16f2169d1133d20f818f04a1948bdf710fb7b0
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-08 (Mon, 08 Nov 2021)

  Changed paths:
    A bolt/test/X86/Inputs/jump_table_icp.s
    A bolt/test/X86/jump-table-icp.test
    A bolt/test/link_fdata.py
    R bolt/test/link_fdata.sh
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  [BOLT][TEST] Import jump-table-icp.test, update link_fdata script

Summary:
Import the test. The assembly input has three functions with associated fdata.
The old link_fdata.sh script only replaces the symbol names with symbol values,
whereas fdata format expects to have symbol offsets against the anchor symbol.
Introduce the link_fdata.py script which is able to parse the input and produce
either an offset or an absolute symbol value.

(cherry picked from FBD32256351)


  Commit: a82502d4a84ea47620c8d57a3bf37f5e6a06d7cd
      https://github.com/llvm/llvm-project/commit/a82502d4a84ea47620c8d57a3bf37f5e6a06d7cd
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-08 (Mon, 08 Nov 2021)

  Changed paths:
    M bolt/lib/Passes/AsmDump.cpp

  Log Message:
  -----------
  [BOLT][NFC] AsmDump: disable printing of empty profile data

Summary:
Moved the FDATA printing under the condition of non-empty profile data.
The change reduces the assembly dumps.

(cherry picked from FBD32262675)


  Commit: c42d46727686023c11b0dc80c09aad50e889ab2d
      https://github.com/llvm/llvm-project/commit/c42d46727686023c11b0dc80c09aad50e889ab2d
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-11-10 (Wed, 10 Nov 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryFunction.h

  Log Message:
  -----------
  [BOLT][NFC] Remove unused function

(cherry picked from FBD32337755)


  Commit: 0e7dd1aad161704895faae4f673c63fcdf7afc9f
      https://github.com/llvm/llvm-project/commit/0e7dd1aad161704895faae4f673c63fcdf7afc9f
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-11 (Thu, 11 Nov 2021)

  Changed paths:
    A bolt/test/X86/Inputs/loop_nest.s
    A bolt/test/X86/Inputs/peephole.s
    A bolt/test/X86/Inputs/rodata_simpl_loads.s
    A bolt/test/X86/loop-nest.test
    A bolt/test/X86/peepholes.test
    A bolt/test/X86/rodata-simpl-loads.test

  Log Message:
  -----------
  [BOLT][TEST] Import small tests

Summary: Imported small internal tests.

(cherry picked from FBD32371964)


  Commit: ae585be11cfac7bccbb7bb463e44a3d95e477cbd
      https://github.com/llvm/llvm-project/commit/ae585be11cfac7bccbb7bb463e44a3d95e477cbd
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-11-11 (Thu, 11 Nov 2021)

  Changed paths:
    M bolt/CMakeLists.txt
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/include/bolt/Profile/DataAggregator.h
    A bolt/include/bolt/Utils/BoltRevision.inc.in
    M bolt/lib/Core/BinaryBasicBlock.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Passes/IndirectCallPromotion.cpp
    M bolt/lib/Profile/DataAggregator.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp
    M bolt/lib/Utils/CMakeLists.txt
    M bolt/lib/Utils/CommandLineOpts.cpp

  Log Message:
  -----------
  [BOLT] Fix Windows build

Summary:
Make BOLT build in VisualStudio compiler and run without
crashing on a simple test. Other tests are not running.

(cherry picked from FBD32378736)


  Commit: 3b00a3a2f8072e312736e15c6bb077d507139529
      https://github.com/llvm/llvm-project/commit/3b00a3a2f8072e312736e15c6bb077d507139529
  Author: Marius Wachtler <undingen at gmail.com>
  Date:   2021-11-05 (Fri, 05 Nov 2021)

  Changed paths:
    M bolt/runtime/instr.cpp

  Log Message:
  -----------
  [PR] instr: change assert to allow FD 0 return by __open()

Summary: In some cases __open() is returning 0 for me.  The open
syscall will return a negative number (-1) on error so 0 should be
valid.

This happens when one compiles a BOLT instrumented executable of
pyston (python implementation) and afterwards pip installs a package
which needs to be compiled and sets CFLAGS=-pipe.  I could not reduce
it down to a small testcase but I guess it one can trigger when
manually closing std{in, out, err}.  Everything seems to work
normally when disabling the assert for 0 in getBinaryPath() - I
decided to also modify the second case in readDescriptions() even
though I did not run into that one yet.

(cherry picked from FBD32409548)


  Commit: 7ea61dab0374311f81248d4a5b733a5c36dafb02
      https://github.com/llvm/llvm-project/commit/7ea61dab0374311f81248d4a5b733a5c36dafb02
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-11 (Thu, 11 Nov 2021)

  Changed paths:
    M bolt/test/Inputs/vararg.s
    R bolt/test/X86/Inputs/vararg_pic.s
    M bolt/test/X86/vararg.test

  Log Message:
  -----------
  [BOLT][TEST] Reduce vararg.test

Summary: Reduce assembly inputs to vararg.test using CReduce

(cherry picked from FBD32405869)


  Commit: 1d0a276c72796803e606d1a7dc8efe711c451c65
      https://github.com/llvm/llvm-project/commit/1d0a276c72796803e606d1a7dc8efe711c451c65
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-12 (Fri, 12 Nov 2021)

  Changed paths:
    A bolt/test/X86/Inputs/order.txt
    A bolt/test/X86/Inputs/shorten_mov.s
    A bolt/test/X86/Inputs/tailcall_traps.s
    A bolt/test/X86/Inputs/unreachable.s
    A bolt/test/X86/Inputs/user-order.S
    A bolt/test/X86/shorten-mov.test
    A bolt/test/X86/symtab-secondary-entries.test
    A bolt/test/X86/tailcall-traps.test
    A bolt/test/X86/unreachable.test

  Log Message:
  -----------
  [BOLT][TEST] Import small tests

Summary: Imported small internal tests.

(cherry picked from FBD32405870)


  Commit: c7f8adb87f1c7bc080481bb8215c6cc0760e7b32
      https://github.com/llvm/llvm-project/commit/c7f8adb87f1c7bc080481bb8215c6cc0760e7b32
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-15 (Mon, 15 Nov 2021)

  Changed paths:
    M bolt/test/CMakeLists.txt
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  [BOLT][TEST] Add llvm-boltdiff to build/test requirements

Summary: llvm-boltdiff is required for `runtime/meta-merge-fdata.test`

(cherry picked from FBD32442220)


  Commit: 2f3285989ece24d055b54ca0f44d716f4a03889c
      https://github.com/llvm/llvm-project/commit/2f3285989ece24d055b54ca0f44d716f4a03889c
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-11-17 (Wed, 17 Nov 2021)

  Changed paths:
    M bolt/test/X86/Inputs/tailcall_traps.s
    M bolt/test/X86/tailcall-traps.test
    A bolt/test/runtime/X86/Inputs/basic-instrumentation.s
    M bolt/test/runtime/X86/basic-instrumentation.test

  Log Message:
  -----------
  [BOLT] Fix tailcall-traps and basic-instr tests on ubuntu

Summary: These tests are failing on opensource ubuntu.

(cherry picked from FBD32514489)


  Commit: 2ccea6eac34985e1e3833967c85b5d135f5101a2
      https://github.com/llvm/llvm-project/commit/2ccea6eac34985e1e3833967c85b5d135f5101a2
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-11-15 (Mon, 15 Nov 2021)

  Changed paths:
    M bolt/lib/Core/CMakeLists.txt
    M bolt/lib/Passes/CMakeLists.txt

  Log Message:
  -----------
  Fix shared build

Summary:
We were not tracking -DBUILD_SHARED_LIBS=ON and we introduced
some commits that break that by not specifying the correct dependencies.
Fix that.

(cherry picked from FBD32453377)


  Commit: 63bebdd8131b67838c2f7140bc7bc273d3fababf
      https://github.com/llvm/llvm-project/commit/63bebdd8131b67838c2f7140bc7bc273d3fababf
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-11-18 (Thu, 18 Nov 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/BinaryData.h
    M bolt/include/bolt/Core/BinaryEmitter.h
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/include/bolt/Core/BinaryLoop.h
    M bolt/include/bolt/Core/BinarySection.h
    M bolt/include/bolt/Core/DebugData.h
    M bolt/include/bolt/Core/DynoStats.h
    M bolt/include/bolt/Core/Exceptions.h
    M bolt/include/bolt/Core/JumpTable.h
    M bolt/include/bolt/Core/MCPlus.h
    M bolt/include/bolt/Core/MCPlusBuilder.h
    M bolt/include/bolt/Core/ParallelUtilities.h
    M bolt/include/bolt/Core/Relocation.h
    M bolt/include/bolt/Passes/ADRRelaxationPass.h
    M bolt/include/bolt/Passes/Aligner.h
    M bolt/include/bolt/Passes/AllocCombiner.h
    M bolt/include/bolt/Passes/AsmDump.h
    M bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
    M bolt/include/bolt/Passes/BinaryPasses.h
    M bolt/include/bolt/Passes/CacheMetrics.h
    M bolt/include/bolt/Passes/CallGraph.h
    M bolt/include/bolt/Passes/CallGraphWalker.h
    M bolt/include/bolt/Passes/DataflowAnalysis.h
    M bolt/include/bolt/Passes/DataflowInfoManager.h
    M bolt/include/bolt/Passes/DominatorAnalysis.h
    M bolt/include/bolt/Passes/FrameAnalysis.h
    M bolt/include/bolt/Passes/FrameOptimizer.h
    M bolt/include/bolt/Passes/HFSort.h
    M bolt/include/bolt/Passes/IdenticalCodeFolding.h
    M bolt/include/bolt/Passes/IndirectCallPromotion.h
    M bolt/include/bolt/Passes/Inliner.h
    M bolt/include/bolt/Passes/Instrumentation.h
    M bolt/include/bolt/Passes/InstrumentationSummary.h
    M bolt/include/bolt/Passes/JTFootprintReduction.h
    M bolt/include/bolt/Passes/LivenessAnalysis.h
    M bolt/include/bolt/Passes/LongJmp.h
    M bolt/include/bolt/Passes/LoopInversionPass.h
    M bolt/include/bolt/Passes/MCF.h
    M bolt/include/bolt/Passes/PLTCall.h
    M bolt/include/bolt/Passes/PatchEntries.h
    M bolt/include/bolt/Passes/ReachingDefOrUse.h
    M bolt/include/bolt/Passes/ReachingInsns.h
    M bolt/include/bolt/Passes/RegAnalysis.h
    M bolt/include/bolt/Passes/RegReAssign.h
    M bolt/include/bolt/Passes/ReorderAlgorithm.h
    M bolt/include/bolt/Passes/ReorderData.h
    M bolt/include/bolt/Passes/ReorderFunctions.h
    M bolt/include/bolt/Passes/ReorderUtils.h
    M bolt/include/bolt/Passes/RetpolineInsertion.h
    M bolt/include/bolt/Passes/ShrinkWrapping.h
    M bolt/include/bolt/Passes/SplitFunctions.h
    M bolt/include/bolt/Passes/StackAllocationAnalysis.h
    M bolt/include/bolt/Passes/StackAvailableExpressions.h
    M bolt/include/bolt/Passes/StackPointerTracking.h
    M bolt/include/bolt/Passes/StackReachingUses.h
    M bolt/include/bolt/Passes/StokeInfo.h
    M bolt/include/bolt/Passes/TailDuplication.h
    M bolt/include/bolt/Passes/ThreeWayBranch.h
    M bolt/include/bolt/Passes/ValidateInternalCalls.h
    M bolt/include/bolt/Passes/VeneerElimination.h
    M bolt/include/bolt/Profile/BoltAddressTranslation.h
    M bolt/include/bolt/Profile/DataAggregator.h
    M bolt/include/bolt/Profile/DataReader.h
    M bolt/include/bolt/Profile/Heatmap.h
    M bolt/include/bolt/Profile/ProfileReaderBase.h
    M bolt/include/bolt/Profile/ProfileYAMLMapping.h
    M bolt/include/bolt/Profile/YAMLProfileReader.h
    M bolt/include/bolt/Profile/YAMLProfileWriter.h
    M bolt/include/bolt/Rewrite/BinaryPassManager.h
    M bolt/include/bolt/Rewrite/DWARFRewriter.h
    M bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h
    M bolt/include/bolt/Rewrite/MachORewriteInstance.h
    M bolt/include/bolt/Rewrite/RewriteInstance.h
    M bolt/include/bolt/RuntimeLibs/HugifyRuntimeLibrary.h
    M bolt/include/bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h
    M bolt/include/bolt/RuntimeLibs/RuntimeLibrary.h
    M bolt/include/bolt/Utils/CommandLineOpts.h
    M bolt/include/bolt/Utils/NameResolver.h
    M bolt/include/bolt/Utils/NameShortener.h
    M bolt/include/bolt/Utils/Utils.h

  Log Message:
  -----------
  [BOLT][NFC] Change guard macros in headers

Summary: Change macro names to match the new directory structure.

(cherry picked from FBD32540857)


  Commit: 68b0003ee317d93943d77c276a245d340a1da4f7
      https://github.com/llvm/llvm-project/commit/68b0003ee317d93943d77c276a245d340a1da4f7
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-11-23 (Tue, 23 Nov 2021)

  Changed paths:
    M bolt/lib/Rewrite/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Fix for Unsupported Debug section: debug_line.dwo warning

Summary: Probably copy and paste mistake or something.

(cherry picked from FBD32625751)


  Commit: a944a487ae2f03497eb2adc53918513f1c5474e9
      https://github.com/llvm/llvm-project/commit/a944a487ae2f03497eb2adc53918513f1c5474e9
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-11-14 (Sun, 14 Nov 2021)

  Changed paths:
    M bolt/lib/Passes/ShrinkWrapping.cpp
    A bolt/test/X86/shrinkwrapping-pop-order.s

  Log Message:
  -----------
  [PR] Fix ShrinkWrapping pop order

Summary:
The push and pop instructions might have wrong reorder due to this
error. Thanks rafaelauler for the provided test case.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD32478348)


  Commit: e9ee2ca1fa2711d1d1224c52b1ca2f750cabd7d0
      https://github.com/llvm/llvm-project/commit/e9ee2ca1fa2711d1d1224c52b1ca2f750cabd7d0
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-23 (Tue, 23 Nov 2021)

  Changed paths:
    M bolt/test/runtime/X86/retpoline-synthetic.test

  Log Message:
  -----------
  [BOLT][TEST] Fix runtime/X86/retpoline-synthetic.test

Summary:
Restructure the test to prevent command echo from getting to check
statements.

(cherry picked from FBD32635888)


  Commit: d474dbdfcb174a80ac6f96c996f2817740e0c65e
      https://github.com/llvm/llvm-project/commit/d474dbdfcb174a80ac6f96c996f2817740e0c65e
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-06-04 (Fri, 04 Jun 2021)

  Changed paths:
    M bolt/lib/Rewrite/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][NFC] Use function names passed in -funcs-no-regex as-is

Summary:
Currently there are two issues rendering the use of bughunter/BOLT on a binary
with a large number of functions (100k) impossible:
1) `selectFunctionsToProcess` has O(binary_fn * force_fn) run-time, which is up
to quadratic with the number of functions in the binary.
2) It unnecessarily treats supplied function names as regexes.

This diff proposes the following changes to address the issue:
1. Add two options that treat function names as is, not as regexes, matching
bughunter usage model: `-funcs-no-regex`/`-funcs-file-no-regex`.
These options are complementary to `-funcs`/`-funcs-file` and `-skip-funcs`/
`-skip-funcs-file`. `funcs` takes precedence over `funcs-no-regex`.
2. Use string set to speed up function eligibility checking with
`-funcs-file-no-regex` to O(binary_fn * log force_fn).

(cherry picked from FBD28917225)


  Commit: e4ccdfe84f8491f091171c255c814992e58b20a0
      https://github.com/llvm/llvm-project/commit/e4ccdfe84f8491f091171c255c814992e58b20a0
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-23 (Tue, 23 Nov 2021)

  Changed paths:
    A bolt/utils/bughunter.sh

  Log Message:
  -----------
  [BOLT] Import bughunter script

Summary: Import the script and update it to use `-funcs-file-no-regex`

(cherry picked from FBD32636025)


  Commit: a23726bb337729e6dfdaf554991f01230ef419eb
      https://github.com/llvm/llvm-project/commit/a23726bb337729e6dfdaf554991f01230ef419eb
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-11-16 (Tue, 16 Nov 2021)

  Changed paths:
    M bolt/lib/Rewrite/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix crash when trying to resolve external symbols for runtime libs

Summary:
As pointed out by Vladislav in issue 217, if our RTDyld-based
linker fails to locate a symbol, it will crash with segfault. Fix that.

(cherry picked from FBD32481543)


  Commit: 4e4ef2f3e7ad81c134fd6bba8f15c9d5d4b4edaa
      https://github.com/llvm/llvm-project/commit/4e4ef2f3e7ad81c134fd6bba8f15c9d5d4b4edaa
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-11-16 (Tue, 16 Nov 2021)

  Changed paths:
    M bolt/runtime/CMakeLists.txt

  Log Message:
  -----------
  [PR] Disable stack protection in runtime libraries

Summary:
In some of the system stack protection is enabled by default, which will
lead in extra symbols dependencies, which we want to avoid.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD32478426)


  Commit: 7261655d2c0ad2d855722e7f46e0aae63f6f28d6
      https://github.com/llvm/llvm-project/commit/7261655d2c0ad2d855722e7f46e0aae63f6f28d6
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-24 (Wed, 24 Nov 2021)

  Changed paths:
    M bolt/lib/Passes/TailDuplication.cpp
    A bolt/test/X86/tail-duplication-cacheline.s

  Log Message:
  -----------
  [BOLT] Tail Duplication: skip unreachable blocks

Summary:
TailDuplication::isInCacheLine makes the assumption that the block
has a valid layout index, which is not the case for unreachable blocks.
Add a check for a valid layout index.

(cherry picked from FBD32659755)


  Commit: 76cd07f9e40a696f3a0faf4768edab7e538756f6
      https://github.com/llvm/llvm-project/commit/76cd07f9e40a696f3a0faf4768edab7e538756f6
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-24 (Wed, 24 Nov 2021)

  Changed paths:
    M bolt/lib/Passes/TailDuplication.cpp
    A bolt/test/X86/tail-duplication-jt.s

  Log Message:
  -----------
  [BOLT] Tail Duplication: fix jump table check

Summary: The intent is clearly to check the current basic block.

(cherry picked from FBD32658103)


  Commit: eb9f4eb6abfaf329c8734bfff65605b3f6e18ae9
      https://github.com/llvm/llvm-project/commit/eb9f4eb6abfaf329c8734bfff65605b3f6e18ae9
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-11-29 (Mon, 29 Nov 2021)

  Changed paths:
    M bolt/lib/Core/Relocation.cpp

  Log Message:
  -----------
  [BOLT][NFC] Better diagnostics for unsupported relocation types

Summary: Print the relocation name instead of just the number.

(cherry picked from FBD32704832)


  Commit: 4f91538f5769a79687a7332c5668d6a526e4a8f6
      https://github.com/llvm/llvm-project/commit/4f91538f5769a79687a7332c5668d6a526e4a8f6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-11-25 (Thu, 25 Nov 2021)

  Changed paths:
    M bolt/lib/Core/BinaryFunction.cpp

  Log Message:
  -----------
  [BOLT][NFC] Remove misleading debug message

Summary:
The debug message for the last fall-through block was printed under the
reverse condition, i.e. when the block was not a fall-through. Remove
the debug message. If we'll need such information, we can add a pass
with more analysis, i.e. checking the last instruction, if the block is
reachable, etc.

(cherry picked from FBD32670816)


  Commit: 02145d20ab344e50d9dcecfa65d00b2a235d7cf1
      https://github.com/llvm/llvm-project/commit/02145d20ab344e50d9dcecfa65d00b2a235d7cf1
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-01 (Wed, 01 Dec 2021)

  Changed paths:
    M bolt/lib/Passes/TailDuplication.cpp
    A bolt/test/X86/tail-duplication-prop-bug.s

  Log Message:
  -----------
  [BOLT] Tail duplication: disable const/copy propagation by default as a workaround

Summary:
Disable const/copy propagation as a bug workaround.
Also add the debug logging in aggressive duplication.

(cherry picked from FBD32774744)


  Commit: 8e632eae569b52df879d6aec47ee65368c4990ff
      https://github.com/llvm/llvm-project/commit/8e632eae569b52df879d6aec47ee65368c4990ff
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-02 (Thu, 02 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/MCPlusBuilder.h
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Remove unused MCPlusBuilder::createIndirectCall method

Summary: Remove unused code identified via coverage report.

(cherry picked from FBD32818329)


  Commit: b69d487a626ad099be938bd95d9b36a14e21ef29
      https://github.com/llvm/llvm-project/commit/b69d487a626ad099be938bd95d9b36a14e21ef29
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-02 (Thu, 02 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/MCPlusBuilder.h
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Remove unused MCPlusBuilder::isEnter

Summary: Remove unused code identified via coverage report.

(cherry picked from FBD32818608)


  Commit: fd71cc51639f28c51c9af709855139d42e250e30
      https://github.com/llvm/llvm-project/commit/fd71cc51639f28c51c9af709855139d42e250e30
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-03 (Fri, 03 Dec 2021)

  Changed paths:
    R bolt/test/X86/Inputs/file1.s
    R bolt/test/X86/Inputs/file2.s
    R bolt/test/X86/Inputs/main.s
    R bolt/test/X86/debugTypesBug.s

  Log Message:
  -----------
  [BOLT][TESTS] Move debugTypesBug.s test into binary tests

Summary:
Remove the test and its inputs.
(cherry picked from FBD32855788)


  Commit: cbf530bf417ef8ea119cd3acebefc9cbbab98a0b
      https://github.com/llvm/llvm-project/commit/cbf530bf417ef8ea119cd3acebefc9cbbab98a0b
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-01 (Wed, 01 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Passes/BinaryPasses.h
    M bolt/lib/Passes/BinaryPasses.cpp
    M bolt/lib/Rewrite/BinaryPassManager.cpp
    M bolt/test/X86/bb-with-two-tail-calls.s

  Log Message:
  -----------
  [BOLT] Add pass to normalize CFG

Summary:
Some optimizations may remove all instructions in a basic block.

The pass will cleanup the CFG afterwards by removing empty basic
blocks and merging duplicate CFG edges.

The normalized CFG is printed under '-print-normalized' option.

(cherry picked from FBD32774360)


  Commit: b73c87bc4ffaecbc9c0f54d4ff95659fc13d2d65
      https://github.com/llvm/llvm-project/commit/b73c87bc4ffaecbc9c0f54d4ff95659fc13d2d65
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-06 (Mon, 06 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/DebugData.h
    M bolt/lib/Core/DebugData.cpp
    A bolt/test/Inputs/hello.c
    A bolt/test/non-empty-debug-line.test

  Log Message:
  -----------
  [BOLT][DWARF] Force allocation of debug_line in RuntimeDyld

Summary:
Currently, RuntimeDyld will not allocate a section without relocations
even if such a section is marked allocatable and defines symbols.

When we emit .debug_line for compile units with unchanged code, we
output original (input) data, without relocations. If all units are
emitted in this way, we will have no relocations in the emitted
.debug_line. RuntimeDyld will not allocate the section and as a result
we will write an empty .debug_line section.

To workaround the issue, always emit a relocation of RELOC_NONE type
when emitting raw contents to debug_line.

(cherry picked from FBD32909869)


  Commit: a2a8fb10a7439ef769eac5288741cfbb8c7da3fc
      https://github.com/llvm/llvm-project/commit/a2a8fb10a7439ef769eac5288741cfbb8c7da3fc
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-12-06 (Mon, 06 Dec 2021)

  Changed paths:
    A bolt/CODE_OWNERS.TXT

  Log Message:
  -----------
  Add code owners file

Summary: Make explicit the contact of component owners.

(cherry picked from FBD32904304)


  Commit: 1417f607bd6380f64bcb8180052ca8aa0e208b16
      https://github.com/llvm/llvm-project/commit/1417f607bd6380f64bcb8180052ca8aa0e208b16
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-12-08 (Wed, 08 Dec 2021)

  Changed paths:
    M bolt/lib/Core/DebugData.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Fix for abbrev check in DWP case

Summary:
For DWP case the AbbreviationsOffset is the offset of the abbrev
 contribution in the DWP file, so can be none zero.

(cherry picked from FBD32961240)


  Commit: a73b1b728987c95a4e62a4367e42d701f91357ee
      https://github.com/llvm/llvm-project/commit/a73b1b728987c95a4e62a4367e42d701f91357ee
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M bolt/lib/Passes/HFSort.cpp

  Log Message:
  -----------
  [BOLT][NFC] Clear HFSort copyright/license

Summary:
Remove the copyright/license message for the code originated from
Facebook.

(cherry picked from FBD32998404)


  Commit: ebe51c4d23deacbe10b0129b004f694a350fd2b6
      https://github.com/llvm/llvm-project/commit/ebe51c4d23deacbe10b0129b004f694a350fd2b6
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-08 (Wed, 08 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/lib/Core/BinaryBasicBlock.cpp
    M bolt/lib/Core/BinaryEmitter.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Core/Exceptions.cpp
    M bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/lib/Passes/IdenticalCodeFolding.cpp
    M bolt/lib/Passes/SplitFunctions.cpp
    M bolt/lib/Profile/YAMLProfileReader.cpp

  Log Message:
  -----------
  [BOLT] Use more ADT data structures for BinaryFunction

Summary:
Switched members of BinaryFunction to ADT where it was possible and
made sense. As a result, the size of BinaryFunction on x86-64 Linux
reduced from 1624 bytes to 1448.

(cherry picked from FBD32981555)


  Commit: bb201ca3e8c2739dad4ad237aa943039b2b1507a
      https://github.com/llvm/llvm-project/commit/bb201ca3e8c2739dad4ad237aa943039b2b1507a
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-12-10 (Fri, 10 Dec 2021)

  Changed paths:
    M bolt/CMakeLists.txt

  Log Message:
  -----------
  Disable Windows build

Summary:
Build is already broken because VS fails to locate
llvm-boltdiff when running tests, and VS also complains that
include/bolt/Passes/InstrumentationSummary.h is lacking an include
string header. Disable this until we have a Windows buildbot to make
sure this build is sane.

(cherry picked from FBD33039972)


  Commit: 69706eafab6b22e4e182762b43e2e7c5f299c3d7
      https://github.com/llvm/llvm-project/commit/69706eafab6b22e4e182762b43e2e7c5f299c3d7
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-09 (Thu, 09 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/include/bolt/Core/MCPlus.h
    M bolt/include/bolt/Core/MCPlusBuilder.h
    M bolt/include/bolt/Passes/Instrumentation.h
    M bolt/lib/Core/Exceptions.cpp
    M bolt/lib/Passes/ADRRelaxationPass.cpp
    M bolt/lib/Passes/BinaryPasses.cpp
    M bolt/lib/Passes/IndirectCallPromotion.cpp
    M bolt/lib/Passes/Instrumentation.cpp
    M bolt/lib/Passes/LongJmp.cpp
    M bolt/lib/Passes/PatchEntries.cpp
    M bolt/lib/Passes/RetpolineInsertion.cpp
    M bolt/lib/Passes/ShrinkWrapping.cpp
    M bolt/lib/Passes/ValidateInternalCalls.cpp
    M bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Refactor BinaryBasicBlock to use ADT

Summary:
Refactor members of BinaryBasicBlock. Replace some std containers with
ADT equivalents. The size of BinaryBasicBlock on x86-64 Linux is reduced
from 232 bytes to 192 bytes.

(cherry picked from FBD33081850)


  Commit: 6aa735ceaf63150690923e9e5e0319eace3056f8
      https://github.com/llvm/llvm-project/commit/6aa735ceaf63150690923e9e5e0319eace3056f8
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-01 (Wed, 01 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/lib/Core/BinaryContext.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp
    A bolt/test/X86/split-func-icf.s

  Log Message:
  -----------
  [BOLT] Split functions: support fragments with multiple parents

Summary:
Gracefully handle binaries with split functions where two fragments are folded
into one, resulting in a fragment with two parent functions.

This behavior is expected in GCC8+ with -O2 optimization level, where both
function splitting and ICF are enabled by default.

On the BOLT side, the changes are:
- BinaryFunction: allow multiple parent fragments:
  - `ParentFragment` --> `ParentFragments`,
  - `setParentFragment` --> `addParentFragment`.
- BinaryContext:
  - `populateJumpTables`: mark fragments to be skipped later,
  - `registerFragment`: add a name heuristic check, return false if it failed,
  - `processInterproceduralReferences`: check if `registerFragment`
succeeded, otherwise issue a warning,
  - `skipMarkedFragments`: move out fragment traversal and skipping from
  `populateJumpTables` into a separate function.

This change fixes an issue where unrelated functions might be registered
as fragments:

```
BOLT-WARNING: interprocedural reference between unrelated fragments:
bad_gs/1(*2) and amd_decode_mce.cold.27/1(*2)
```

(Linux kernel binary)

(cherry picked from FBD32786688)


  Commit: 5fc8adb529d667131c6bcb413cf0621f5b5d20c4
      https://github.com/llvm/llvm-project/commit/5fc8adb529d667131c6bcb413cf0621f5b5d20c4
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-12-15 (Wed, 15 Dec 2021)

  Changed paths:
    M bolt/CMakeLists.txt
    M bolt/tools/driver/CMakeLists.txt

  Log Message:
  -----------
  Add bolt target to cmake

Summary:
Create a new high-level target named bolt that builds all
BOLT artifacts, as well as a install-bolt target that installs them.

(cherry picked from FBD33133002)


  Commit: 40c2e0fafe5675306f4ad43910bf6e2fd2025ff3
      https://github.com/llvm/llvm-project/commit/40c2e0fafe5675306f4ad43910bf6e2fd2025ff3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-14 (Tue, 14 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/BinaryData.h
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/include/bolt/Core/BinaryLoop.h
    M bolt/include/bolt/Core/BinarySection.h
    M bolt/include/bolt/Core/DebugData.h
    M bolt/include/bolt/Core/DynoStats.h
    M bolt/include/bolt/Core/Exceptions.h
    M bolt/include/bolt/Core/JumpTable.h
    M bolt/include/bolt/Core/MCPlus.h
    M bolt/include/bolt/Core/MCPlusBuilder.h
    M bolt/include/bolt/Core/ParallelUtilities.h
    M bolt/include/bolt/Core/Relocation.h
    M bolt/include/bolt/Passes/Aligner.h
    M bolt/include/bolt/Passes/AllocCombiner.h
    M bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
    M bolt/include/bolt/Passes/BinaryPasses.h
    M bolt/include/bolt/Passes/CacheMetrics.h
    M bolt/include/bolt/Passes/CallGraph.h
    M bolt/include/bolt/Passes/CallGraphWalker.h
    M bolt/include/bolt/Passes/DataflowAnalysis.h
    M bolt/include/bolt/Passes/DominatorAnalysis.h
    M bolt/include/bolt/Passes/FrameAnalysis.h
    M bolt/include/bolt/Passes/FrameOptimizer.h
    M bolt/include/bolt/Passes/HFSort.h
    M bolt/include/bolt/Passes/IdenticalCodeFolding.h
    M bolt/include/bolt/Passes/IndirectCallPromotion.h
    M bolt/include/bolt/Passes/Inliner.h
    M bolt/include/bolt/Passes/Instrumentation.h
    M bolt/include/bolt/Passes/JTFootprintReduction.h
    M bolt/include/bolt/Passes/LivenessAnalysis.h
    M bolt/include/bolt/Passes/LongJmp.h
    M bolt/include/bolt/Passes/PLTCall.h
    M bolt/include/bolt/Passes/PatchEntries.h
    M bolt/include/bolt/Passes/ReachingDefOrUse.h
    M bolt/include/bolt/Passes/RegAnalysis.h
    M bolt/include/bolt/Passes/RegReAssign.h
    M bolt/include/bolt/Passes/ReorderAlgorithm.h
    M bolt/include/bolt/Passes/ReorderData.h
    M bolt/include/bolt/Passes/ReorderFunctions.h
    M bolt/include/bolt/Passes/RetpolineInsertion.h
    M bolt/include/bolt/Passes/ShrinkWrapping.h
    M bolt/include/bolt/Passes/SplitFunctions.h
    M bolt/include/bolt/Passes/StackAllocationAnalysis.h
    M bolt/include/bolt/Passes/StackAvailableExpressions.h
    M bolt/include/bolt/Passes/StackPointerTracking.h
    M bolt/include/bolt/Passes/StackReachingUses.h
    M bolt/include/bolt/Passes/StokeInfo.h
    M bolt/include/bolt/Passes/ValidateInternalCalls.h
    M bolt/include/bolt/Profile/BoltAddressTranslation.h
    M bolt/include/bolt/Profile/DataAggregator.h
    M bolt/include/bolt/Profile/DataReader.h
    M bolt/include/bolt/Profile/Heatmap.h
    M bolt/include/bolt/Profile/ProfileReaderBase.h
    M bolt/include/bolt/Profile/ProfileYAMLMapping.h
    M bolt/include/bolt/Profile/YAMLProfileReader.h
    M bolt/include/bolt/Profile/YAMLProfileWriter.h
    M bolt/include/bolt/Rewrite/BinaryPassManager.h
    M bolt/include/bolt/Rewrite/DWARFRewriter.h
    M bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h
    M bolt/include/bolt/Rewrite/MachORewriteInstance.h
    M bolt/include/bolt/Rewrite/RewriteInstance.h
    M bolt/include/bolt/RuntimeLibs/RuntimeLibrary.h
    M bolt/include/bolt/Utils/CommandLineOpts.h
    M bolt/include/bolt/Utils/Utils.h
    M bolt/lib/Core/BinaryBasicBlock.cpp
    M bolt/lib/Core/BinaryContext.cpp
    M bolt/lib/Core/BinaryData.cpp
    M bolt/lib/Core/BinaryEmitter.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Core/BinaryFunctionProfile.cpp
    M bolt/lib/Core/BinarySection.cpp
    M bolt/lib/Core/DebugData.cpp
    M bolt/lib/Core/DynoStats.cpp
    M bolt/lib/Core/Exceptions.cpp
    M bolt/lib/Core/JumpTable.cpp
    M bolt/lib/Core/MCPlusBuilder.cpp
    M bolt/lib/Core/Relocation.cpp
    M bolt/lib/Passes/BinaryFunctionCallGraph.cpp
    M bolt/lib/Passes/BinaryPasses.cpp
    M bolt/lib/Passes/CacheMetrics.cpp
    M bolt/lib/Passes/CallGraphWalker.cpp
    M bolt/lib/Passes/DataflowInfoManager.cpp
    M bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/lib/Passes/FrameAnalysis.cpp
    M bolt/lib/Passes/FrameOptimizer.cpp
    M bolt/lib/Passes/HFSort.cpp
    M bolt/lib/Passes/HFSortPlus.cpp
    M bolt/lib/Passes/IdenticalCodeFolding.cpp
    M bolt/lib/Passes/IndirectCallPromotion.cpp
    M bolt/lib/Passes/Inliner.cpp
    M bolt/lib/Passes/Instrumentation.cpp
    M bolt/lib/Passes/JTFootprintReduction.cpp
    M bolt/lib/Passes/LongJmp.cpp
    M bolt/lib/Passes/MCF.cpp
    M bolt/lib/Passes/PLTCall.cpp
    M bolt/lib/Passes/PatchEntries.cpp
    M bolt/lib/Passes/PettisAndHansen.cpp
    M bolt/lib/Passes/RegAnalysis.cpp
    M bolt/lib/Passes/RegReAssign.cpp
    M bolt/lib/Passes/ReorderAlgorithm.cpp
    M bolt/lib/Passes/ReorderData.cpp
    M bolt/lib/Passes/ReorderFunctions.cpp
    M bolt/lib/Passes/RetpolineInsertion.cpp
    M bolt/lib/Passes/ShrinkWrapping.cpp
    M bolt/lib/Passes/SplitFunctions.cpp
    M bolt/lib/Passes/StackAllocationAnalysis.cpp
    M bolt/lib/Passes/StokeInfo.cpp
    M bolt/lib/Passes/ValidateInternalCalls.cpp
    M bolt/lib/Profile/BoltAddressTranslation.cpp
    M bolt/lib/Profile/DataAggregator.cpp
    M bolt/lib/Profile/DataReader.cpp
    M bolt/lib/Profile/Heatmap.cpp
    M bolt/lib/Profile/ProfileReaderBase.cpp
    M bolt/lib/Profile/YAMLProfileReader.cpp
    M bolt/lib/Profile/YAMLProfileWriter.cpp
    M bolt/lib/Rewrite/BinaryPassManager.cpp
    M bolt/lib/Rewrite/BoltDiff.cpp
    M bolt/lib/Rewrite/DWARFRewriter.cpp
    M bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
    M bolt/lib/Rewrite/MachORewriteInstance.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp
    M bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
    M bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/tools/driver/llvm-bolt.cpp
    M bolt/tools/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT][NFC] Reformat with clang-format

Summary: Selectively apply clang-format to BOLT code base.

(cherry picked from FBD33119052)


  Commit: 283a87743e41b2e69432671040bf7ef55f794cbe
      https://github.com/llvm/llvm-project/commit/283a87743e41b2e69432671040bf7ef55f794cbe
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-12-15 (Wed, 15 Dec 2021)

  Changed paths:
    M bolt/CMakeLists.txt

  Log Message:
  -----------
  Fix install-bolt_rt dependencies

Summary:
This rule depends on bolt target, since it will run
install-bolt as well.

(cherry picked from FBD33152071)


  Commit: 4a4045f7408120a638be22672c52ae7e99644998
      https://github.com/llvm/llvm-project/commit/4a4045f7408120a638be22672c52ae7e99644998
  Author: Elvina Yakubova <elvina.yakubova at huawei.com>
  Date:   2021-12-08 (Wed, 08 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/Relocation.h
    M bolt/lib/Core/BinarySection.cpp
    M bolt/lib/Core/Relocation.cpp
    M bolt/lib/Rewrite/DWARFRewriter.cpp
    A bolt/test/AArch64/asm-func-debug.test
    A bolt/test/AArch64/update-debug-reloc.test
    A bolt/test/Inputs/asm_foo.s
    A bolt/test/Inputs/asm_main.c
    R bolt/test/X86/Inputs/asm_foo.s
    M bolt/test/X86/asm-func-debug.test

  Log Message:
  -----------
  [PR] Fix update-debug-sections for AArch64

Summary:
This patch adds AArch64 relocations handling in case updating of
debug sections is enabled

Elvina Yakubova,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD33077609)


  Commit: 46e93fb42703d69d187b6213204e1654709f2e64
      https://github.com/llvm/llvm-project/commit/46e93fb42703d69d187b6213204e1654709f2e64
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-12-15 (Wed, 15 Dec 2021)

  Changed paths:
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp
    A bolt/test/X86/shrinkwrapping-popf.s

  Log Message:
  -----------
  Fix frameopt crash when processing POPF

Summary: POPF instruction was triggering an assertion in our analysis.

(cherry picked from FBD33141809)


  Commit: 08f56926c2d27e033f114415cabe6b7880143892
      https://github.com/llvm/llvm-project/commit/08f56926c2d27e033f114415cabe6b7880143892
  Author: Vladislav Khmelevsky <vladislav.khmelevskyi at huawei.com>
  Date:   2021-12-18 (Sat, 18 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/include/bolt/Passes/BinaryPasses.h
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Passes/BinaryPasses.cpp
    M bolt/lib/Profile/DataReader.cpp
    M bolt/lib/Rewrite/BinaryPassManager.cpp
    R bolt/test/X86/Inputs/peephole.s
    M bolt/test/X86/layout-heuristic.test
    R bolt/test/X86/peepholes.test
    M bolt/test/X86/pre-aggregated-perf.test
    M bolt/test/X86/shorten-mov.test

  Log Message:
  -----------
  [BOLT] Move disassemble optimizations to optimization passes

Summary:
The patch moves the shortenInstructions and nop remove to separate binary
passes. As a result when llvm-bolt optimizations stage will begin the
instructions of the binary functions will be absolutely the same as it
was in the binary. This is needed for the golang support by llvm-bolt.
Some of the tests must be changed, since bb alignment nops might create
unreachable BBs in original functions.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD32896517)


  Commit: ccb99dd1261a9b40a3141fc7a63437dab5770cb2
      https://github.com/llvm/llvm-project/commit/ccb99dd1261a9b40a3141fc7a63437dab5770cb2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-18 (Sat, 18 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Passes/BinaryPasses.h
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Core/BinaryFunctionProfile.cpp
    M bolt/lib/Profile/DataReader.cpp
    M bolt/lib/Rewrite/BinaryPassManager.cpp
    M bolt/lib/Rewrite/MachORewriteInstance.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Fix profile and tests for nop-removal pass

Summary:
Since nops are now removed in a separate pass, the profile is consumed
on a CFG with nops. If previously a profile was generated without nops,
the offsets in the profile could be different if branches included nops
either as a source or a destination.

This diff adjust offsets to make the profile reading backwards
compatible.

(cherry picked from FBD33231254)


  Commit: cf624f2e63db19807726d20720381ef0e3f48402
      https://github.com/llvm/llvm-project/commit/cf624f2e63db19807726d20720381ef0e3f48402
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-02 (Thu, 02 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryFunction.h

  Log Message:
  -----------
  [BOLT][NFC] Remove unused function

Summary: Remove BinaryFunction::getBasicBlockOriginalAddress().

(cherry picked from FBD32810127)


  Commit: 226c9732806ce13713287bf8c5902ed50ae7bc02
      https://github.com/llvm/llvm-project/commit/226c9732806ce13713287bf8c5902ed50ae7bc02
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-02 (Thu, 02 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Profile/DataReader.h
    M bolt/lib/Profile/DataReader.cpp

  Log Message:
  -----------
  [BOLT][NFC] Remove another unused function

Summary: Remove DataReader::getBranchRange().

(cherry picked from FBD32810933)


  Commit: 07d9e014edf413a8429336fa51beaefccd8c28cf
      https://github.com/llvm/llvm-project/commit/07d9e014edf413a8429336fa51beaefccd8c28cf
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-12-21 (Tue, 21 Dec 2021)

  Changed paths:
    M bolt/test/AArch64/tls.c
    M bolt/test/X86/R_X86_64_64.pic.lld.cpp
    M bolt/test/keep-aranges.test
    M bolt/test/lit.cfg.py

  Log Message:
  -----------
  [BOLT] Don't use ld.lld in tests

Summary: Addressing issue 270.

(cherry picked from FBD33255608)


  Commit: 4eb237e45d191a52a2de4f83bf504d5e4a60c313
      https://github.com/llvm/llvm-project/commit/4eb237e45d191a52a2de4f83bf504d5e4a60c313
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M bolt/docs/OptimizingClang.md

  Log Message:
  -----------
  [BOLT][DOCS] Updated clang build instructions in OptimizingClang.md

Summary:
Addressing the feedback in https://lists.llvm.org/pipermail/llvm-dev/2021-December/154420.html:
Updated the instructions to reflect LLVM monorepo layout.
Resolved build issues in compiler-rt.

(cherry picked from FBD33242317)


  Commit: 0f32a5e5e1c083aeb78410ec4e5859ef78652e35
      https://github.com/llvm/llvm-project/commit/0f32a5e5e1c083aeb78410ec4e5859ef78652e35
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-22 (Wed, 22 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Passes/HFSort.h

  Log Message:
  -----------
  [BOLT][NFC] Clear HFSort copyright/license

Summary:
Remove the copyright/license message for the code originated from
Facebook.

(cherry picked from FBD33293101)


  Commit: 2f09f445b2d6b3ef197aecd8d1e06d08140380f3
      https://github.com/llvm/llvm-project/commit/2f09f445b2d6b3ef197aecd8d1e06d08140380f3
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-21 (Tue, 21 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/BinaryData.h
    M bolt/include/bolt/Core/BinaryEmitter.h
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/include/bolt/Core/BinaryLoop.h
    M bolt/include/bolt/Core/BinarySection.h
    M bolt/include/bolt/Core/DebugData.h
    M bolt/include/bolt/Core/DynoStats.h
    M bolt/include/bolt/Core/Exceptions.h
    M bolt/include/bolt/Core/JumpTable.h
    M bolt/include/bolt/Core/MCPlus.h
    M bolt/include/bolt/Core/MCPlusBuilder.h
    M bolt/include/bolt/Core/ParallelUtilities.h
    M bolt/include/bolt/Core/Relocation.h
    M bolt/include/bolt/Passes/ADRRelaxationPass.h
    M bolt/include/bolt/Passes/Aligner.h
    M bolt/include/bolt/Passes/AllocCombiner.h
    M bolt/include/bolt/Passes/AsmDump.h
    M bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
    M bolt/include/bolt/Passes/BinaryPasses.h
    M bolt/include/bolt/Passes/CacheMetrics.h
    M bolt/include/bolt/Passes/CallGraph.h
    M bolt/include/bolt/Passes/CallGraphWalker.h
    M bolt/include/bolt/Passes/DataflowAnalysis.h
    M bolt/include/bolt/Passes/DataflowInfoManager.h
    M bolt/include/bolt/Passes/DominatorAnalysis.h
    M bolt/include/bolt/Passes/FrameAnalysis.h
    M bolt/include/bolt/Passes/FrameOptimizer.h
    M bolt/include/bolt/Passes/HFSort.h
    M bolt/include/bolt/Passes/IdenticalCodeFolding.h
    M bolt/include/bolt/Passes/IndirectCallPromotion.h
    M bolt/include/bolt/Passes/Inliner.h
    M bolt/include/bolt/Passes/Instrumentation.h
    M bolt/include/bolt/Passes/InstrumentationSummary.h
    M bolt/include/bolt/Passes/JTFootprintReduction.h
    M bolt/include/bolt/Passes/LivenessAnalysis.h
    M bolt/include/bolt/Passes/LongJmp.h
    M bolt/include/bolt/Passes/LoopInversionPass.h
    M bolt/include/bolt/Passes/MCF.h
    M bolt/include/bolt/Passes/PLTCall.h
    M bolt/include/bolt/Passes/PatchEntries.h
    M bolt/include/bolt/Passes/ReachingDefOrUse.h
    M bolt/include/bolt/Passes/ReachingInsns.h
    M bolt/include/bolt/Passes/RegAnalysis.h
    M bolt/include/bolt/Passes/RegReAssign.h
    M bolt/include/bolt/Passes/ReorderAlgorithm.h
    M bolt/include/bolt/Passes/ReorderData.h
    M bolt/include/bolt/Passes/ReorderFunctions.h
    M bolt/include/bolt/Passes/ReorderUtils.h
    M bolt/include/bolt/Passes/RetpolineInsertion.h
    M bolt/include/bolt/Passes/ShrinkWrapping.h
    M bolt/include/bolt/Passes/SplitFunctions.h
    M bolt/include/bolt/Passes/StackAllocationAnalysis.h
    M bolt/include/bolt/Passes/StackAvailableExpressions.h
    M bolt/include/bolt/Passes/StackPointerTracking.h
    M bolt/include/bolt/Passes/StackReachingUses.h
    M bolt/include/bolt/Passes/StokeInfo.h
    M bolt/include/bolt/Passes/TailDuplication.h
    M bolt/include/bolt/Passes/ThreeWayBranch.h
    M bolt/include/bolt/Passes/ValidateInternalCalls.h
    M bolt/include/bolt/Passes/VeneerElimination.h
    M bolt/include/bolt/Profile/BoltAddressTranslation.h
    M bolt/include/bolt/Profile/DataAggregator.h
    M bolt/include/bolt/Profile/DataReader.h
    M bolt/include/bolt/Profile/Heatmap.h
    M bolt/include/bolt/Profile/ProfileReaderBase.h
    M bolt/include/bolt/Profile/ProfileYAMLMapping.h
    M bolt/include/bolt/Profile/YAMLProfileReader.h
    M bolt/include/bolt/Profile/YAMLProfileWriter.h
    M bolt/include/bolt/Rewrite/BinaryPassManager.h
    M bolt/include/bolt/Rewrite/DWARFRewriter.h
    M bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h
    M bolt/include/bolt/Rewrite/MachORewriteInstance.h
    M bolt/include/bolt/Rewrite/RewriteInstance.h
    M bolt/include/bolt/RuntimeLibs/HugifyRuntimeLibrary.h
    M bolt/include/bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h
    M bolt/include/bolt/RuntimeLibs/RuntimeLibrary.h
    M bolt/include/bolt/Utils/CommandLineOpts.h
    M bolt/include/bolt/Utils/NameResolver.h
    M bolt/include/bolt/Utils/NameShortener.h
    M bolt/include/bolt/Utils/Utils.h
    M bolt/lib/Core/BinaryBasicBlock.cpp
    M bolt/lib/Core/BinaryContext.cpp
    M bolt/lib/Core/BinaryData.cpp
    M bolt/lib/Core/BinaryEmitter.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Core/BinaryFunctionProfile.cpp
    M bolt/lib/Core/BinarySection.cpp
    M bolt/lib/Core/DebugData.cpp
    M bolt/lib/Core/DynoStats.cpp
    M bolt/lib/Core/Exceptions.cpp
    M bolt/lib/Core/JumpTable.cpp
    M bolt/lib/Core/MCPlusBuilder.cpp
    M bolt/lib/Core/ParallelUtilities.cpp
    M bolt/lib/Core/Relocation.cpp
    M bolt/lib/Passes/ADRRelaxationPass.cpp
    M bolt/lib/Passes/Aligner.cpp
    M bolt/lib/Passes/AllocCombiner.cpp
    M bolt/lib/Passes/AsmDump.cpp
    M bolt/lib/Passes/BinaryFunctionCallGraph.cpp
    M bolt/lib/Passes/BinaryPasses.cpp
    M bolt/lib/Passes/CacheMetrics.cpp
    M bolt/lib/Passes/CallGraph.cpp
    M bolt/lib/Passes/CallGraphWalker.cpp
    M bolt/lib/Passes/DataflowAnalysis.cpp
    M bolt/lib/Passes/DataflowInfoManager.cpp
    M bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/lib/Passes/FrameAnalysis.cpp
    M bolt/lib/Passes/FrameOptimizer.cpp
    M bolt/lib/Passes/HFSort.cpp
    M bolt/lib/Passes/HFSortPlus.cpp
    M bolt/lib/Passes/IdenticalCodeFolding.cpp
    M bolt/lib/Passes/IndirectCallPromotion.cpp
    M bolt/lib/Passes/Inliner.cpp
    M bolt/lib/Passes/Instrumentation.cpp
    M bolt/lib/Passes/JTFootprintReduction.cpp
    M bolt/lib/Passes/LivenessAnalysis.cpp
    M bolt/lib/Passes/LongJmp.cpp
    M bolt/lib/Passes/LoopInversionPass.cpp
    M bolt/lib/Passes/MCF.cpp
    M bolt/lib/Passes/PLTCall.cpp
    M bolt/lib/Passes/PatchEntries.cpp
    M bolt/lib/Passes/PettisAndHansen.cpp
    M bolt/lib/Passes/RegAnalysis.cpp
    M bolt/lib/Passes/RegReAssign.cpp
    M bolt/lib/Passes/ReorderAlgorithm.cpp
    M bolt/lib/Passes/ReorderData.cpp
    M bolt/lib/Passes/ReorderFunctions.cpp
    M bolt/lib/Passes/RetpolineInsertion.cpp
    M bolt/lib/Passes/ShrinkWrapping.cpp
    M bolt/lib/Passes/SplitFunctions.cpp
    M bolt/lib/Passes/StackAllocationAnalysis.cpp
    M bolt/lib/Passes/StackAvailableExpressions.cpp
    M bolt/lib/Passes/StackPointerTracking.cpp
    M bolt/lib/Passes/StackReachingUses.cpp
    M bolt/lib/Passes/StokeInfo.cpp
    M bolt/lib/Passes/TailDuplication.cpp
    M bolt/lib/Passes/ThreeWayBranch.cpp
    M bolt/lib/Passes/ValidateInternalCalls.cpp
    M bolt/lib/Passes/VeneerElimination.cpp
    M bolt/lib/Profile/BoltAddressTranslation.cpp
    M bolt/lib/Profile/DataAggregator.cpp
    M bolt/lib/Profile/DataReader.cpp
    M bolt/lib/Profile/Heatmap.cpp
    M bolt/lib/Profile/ProfileReaderBase.cpp
    M bolt/lib/Profile/YAMLProfileReader.cpp
    M bolt/lib/Profile/YAMLProfileWriter.cpp
    M bolt/lib/Rewrite/BinaryPassManager.cpp
    M bolt/lib/Rewrite/BoltDiff.cpp
    M bolt/lib/Rewrite/DWARFRewriter.cpp
    M bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
    M bolt/lib/Rewrite/MachORewriteInstance.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp
    M bolt/lib/RuntimeLibs/HugifyRuntimeLibrary.cpp
    M bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    M bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
    M bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp
    M bolt/lib/Utils/CommandLineOpts.cpp
    M bolt/lib/Utils/Utils.cpp
    M bolt/runtime/common.h
    M bolt/runtime/hugify.cpp
    M bolt/runtime/instr.cpp
    M bolt/tools/driver/llvm-bolt.cpp
    M bolt/tools/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT][NFC] Fix file-description comments

Summary: Fix comments at the start of source files.

(cherry picked from FBD33274597)


  Commit: 9a689946f2477173c3e4a4988d6e230a8ede34e2
      https://github.com/llvm/llvm-project/commit/9a689946f2477173c3e4a4988d6e230a8ede34e2
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-23 (Thu, 23 Dec 2021)

  Changed paths:
    M bolt/utils/bughunter.sh

  Log Message:
  -----------
  [bughunter.sh][NFC] Fix license and file description

Summary:
Convert bughunter.sh to the new LLVM license and fix file-description
comments.

(cherry picked from FBD33298823)


  Commit: 3652483c8ea7ec20e8d0cb4aef0630688011cc08
      https://github.com/llvm/llvm-project/commit/3652483c8ea7ec20e8d0cb4aef0630688011cc08
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/BinaryFunction.h
    M bolt/include/bolt/Core/DynoStats.h
    M bolt/include/bolt/Core/MCPlusBuilder.h
    M bolt/lib/Core/BinaryBasicBlock.cpp
    M bolt/lib/Core/BinaryContext.cpp
    M bolt/lib/Core/BinaryData.cpp
    M bolt/lib/Core/BinaryEmitter.cpp
    M bolt/lib/Core/BinaryFunction.cpp
    M bolt/lib/Core/BinaryFunctionProfile.cpp
    M bolt/lib/Core/BinarySection.cpp
    M bolt/lib/Core/DebugData.cpp
    M bolt/lib/Core/DynoStats.cpp
    M bolt/lib/Core/Exceptions.cpp
    M bolt/lib/Core/JumpTable.cpp
    M bolt/lib/Core/MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLTCore] [NFC] Fix braces usages according to LLVM

Summary:
Fix according to Coding Standards doc, section Don't Use
Braces on Simple Single-Statement Bodies of if/else/loop Statements.
This set of changes applies to lib Core only.

(cherry picked from FBD33240028)


  Commit: b392ec696b6add15c72181569c2591652d936c40
      https://github.com/llvm/llvm-project/commit/b392ec696b6add15c72181569c2591652d936c40
  Author: Rafael Auler <rafaelauler at fb.com>
  Date:   2021-12-23 (Thu, 23 Dec 2021)

  Changed paths:
    M bolt/CMakeLists.txt
    M bolt/include/bolt/Passes/InstrumentationSummary.h
    M bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
    M bolt/test/CMakeLists.txt
    M bolt/test/bolt-icf.test
    M bolt/test/keep-aranges.test
    M bolt/test/lit.cfg.py
    M bolt/test/non-empty-debug-line.test
    M bolt/tools/driver/CMakeLists.txt
    M bolt/tools/merge-fdata/CMakeLists.txt

  Log Message:
  -----------
  Re-enable Windows build and fix issues

Summary:
Fix missing string header file inclusion and link_fdata find
problem in lit tests. Change root-level tests to require
linux. Re-enable Windows in our root CMakeLists.txt.

(cherry picked from FBD33296290)


  Commit: e1eeef5b901ff277f9b61609670b004bb170fa27
      https://github.com/llvm/llvm-project/commit/e1eeef5b901ff277f9b61609670b004bb170fa27
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-23 (Thu, 23 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Passes/ADRRelaxationPass.h
    M bolt/lib/Passes/ADRRelaxationPass.cpp

  Log Message:
  -----------
  [BOLT][RFC] Use new LLVM license for ADRRelaxationPass

Summary: Fixes facebookincubator/BOLT#271

(cherry picked from FBD33299273)


  Commit: 2d84e344d943fd1c619ae02dd2db2eda70319f58
      https://github.com/llvm/llvm-project/commit/2d84e344d943fd1c619ae02dd2db2eda70319f58
  Author: Vladislav Khmelevsky <Vladislav.Khmelevskyi at huawei.com>
  Date:   2021-11-28 (Sun, 28 Nov 2021)

  Changed paths:
    M bolt/lib/Passes/LongJmp.cpp

  Log Message:
  -----------
  [PR][BOLT] Check for end iterator in LongJmp stub lookup

Summary:
The lower_bound might return the end iterator, the ignoring of which will
cause memory corruption.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

(cherry picked from FBD33307803)


  Commit: ee0e9ccb52d04d23c8ae761ba7fa7ab0d4cd6210
      https://github.com/llvm/llvm-project/commit/ee0e9ccb52d04d23c8ae761ba7fa7ab0d4cd6210
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-23 (Thu, 23 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Rewrite/RewriteInstance.h
    M bolt/lib/Rewrite/BinaryPassManager.cpp
    M bolt/lib/Rewrite/BoltDiff.cpp
    M bolt/lib/Rewrite/DWARFRewriter.cpp
    M bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLTRewrite][NFC] Fix braces usages

Summary:
Refactor bolt/*/Rewrite to follow the braces rule for if/else/loop from
LLVM Coding Standards.

(cherry picked from FBD33305364)


  Commit: cd7a6305851146921bcda1f6eba53db3bfe07f3a
      https://github.com/llvm/llvm-project/commit/cd7a6305851146921bcda1f6eba53db3bfe07f3a
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-23 (Thu, 23 Dec 2021)

  Changed paths:
    M bolt/CMakeLists.txt
    A bolt/docs/CMakeLists.txt
    A bolt/docs/doxygen-mainpage.dox
    A bolt/docs/doxygen.cfg.in

  Log Message:
  -----------
  [BOLT][DOCS] Build doxygen documentation

Summary:
Added doxygen configuration files and CMake directives, copy-pasta from flang.

```cmake -G Ninja ../llvm-project/llvm \
  -DLLVM_ENABLE_PROJECTS="bolt" \
  -DBOLT_INCLUDE_DOCS=YES \
  -DLLVM_ENABLE_DOXYGEN=YES
ninja doxygen-bolt
```

(cherry picked from FBD33303249)


  Commit: f92ab6af35343df1f82c3a85feb75d41b6be382e
      https://github.com/llvm/llvm-project/commit/f92ab6af35343df1f82c3a85feb75d41b6be382e
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-28 (Tue, 28 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Passes/DataflowAnalysis.h
    M bolt/include/bolt/Passes/DominatorAnalysis.h
    M bolt/include/bolt/Passes/LivenessAnalysis.h
    M bolt/include/bolt/Passes/ReachingDefOrUse.h
    M bolt/include/bolt/Passes/ReachingInsns.h
    M bolt/include/bolt/Passes/ReorderUtils.h
    M bolt/include/bolt/Passes/ShrinkWrapping.h
    M bolt/include/bolt/Passes/StackPointerTracking.h
    M bolt/include/bolt/Passes/StokeInfo.h
    M bolt/include/bolt/Passes/ValidateInternalCalls.h
    M bolt/include/bolt/Passes/VeneerElimination.h
    M bolt/lib/Passes/Aligner.cpp
    M bolt/lib/Passes/AllocCombiner.cpp
    M bolt/lib/Passes/AsmDump.cpp
    M bolt/lib/Passes/BinaryFunctionCallGraph.cpp
    M bolt/lib/Passes/BinaryPasses.cpp
    M bolt/lib/Passes/CacheMetrics.cpp
    M bolt/lib/Passes/DataflowAnalysis.cpp
    M bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
    M bolt/lib/Passes/FrameAnalysis.cpp
    M bolt/lib/Passes/FrameOptimizer.cpp
    M bolt/lib/Passes/HFSort.cpp
    M bolt/lib/Passes/HFSortPlus.cpp
    M bolt/lib/Passes/IdenticalCodeFolding.cpp
    M bolt/lib/Passes/IndirectCallPromotion.cpp
    M bolt/lib/Passes/Inliner.cpp
    M bolt/lib/Passes/Instrumentation.cpp
    M bolt/lib/Passes/JTFootprintReduction.cpp
    M bolt/lib/Passes/LongJmp.cpp
    M bolt/lib/Passes/MCF.cpp
    M bolt/lib/Passes/PettisAndHansen.cpp
    M bolt/lib/Passes/RegReAssign.cpp
    M bolt/lib/Passes/ReorderAlgorithm.cpp
    M bolt/lib/Passes/ReorderData.cpp
    M bolt/lib/Passes/ReorderFunctions.cpp
    M bolt/lib/Passes/RetpolineInsertion.cpp
    M bolt/lib/Passes/ShrinkWrapping.cpp
    M bolt/lib/Passes/SplitFunctions.cpp
    M bolt/lib/Passes/StackAvailableExpressions.cpp
    M bolt/lib/Passes/StackReachingUses.cpp
    M bolt/lib/Passes/StokeInfo.cpp
    M bolt/lib/Passes/TailDuplication.cpp
    M bolt/lib/Passes/ThreeWayBranch.cpp
    M bolt/lib/Passes/ValidateInternalCalls.cpp
    M bolt/lib/Passes/VeneerElimination.cpp

  Log Message:
  -----------
  [BOLT][NFC] Fix braces usage in Passes

Summary:
Refactor bolt/*/Passes to follow the braces rule for if/else/loop from
[LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html).

(cherry picked from FBD33344642)


  Commit: 3b01fbebeb9fda8317b12fe7b13fb02a1a54f7cb
      https://github.com/llvm/llvm-project/commit/3b01fbebeb9fda8317b12fe7b13fb02a1a54f7cb
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-28 (Tue, 28 Dec 2021)

  Changed paths:
    M bolt/lib/Passes/IndirectCallPromotion.cpp

  Log Message:
  -----------
  [BOLT] Fix debug logging in IndirectCallPromotion

Summary:
Access elements of a value pair in HotTargetMap debug logging/loop over
HotTargetMap key-value.

(cherry picked from FBD33344656)


  Commit: 89ceb779970eab525abfc4867632b9e841efcb55
      https://github.com/llvm/llvm-project/commit/89ceb779970eab525abfc4867632b9e841efcb55
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-28 (Tue, 28 Dec 2021)

  Changed paths:
    M bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Fix braces usage in Target

Summary:
Refactor bolt/lib/Target to follow the braces rule for if/else/loop from
[LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html).

(cherry picked from FBD33345353)


  Commit: def464aaaec2a0d044476bfcb2c583d300bb949c
      https://github.com/llvm/llvm-project/commit/def464aaaec2a0d044476bfcb2c583d300bb949c
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-28 (Tue, 28 Dec 2021)

  Changed paths:
    M bolt/lib/Profile/BoltAddressTranslation.cpp
    M bolt/lib/Profile/DataAggregator.cpp
    M bolt/lib/Profile/DataReader.cpp
    M bolt/lib/Profile/Heatmap.cpp
    M bolt/lib/Profile/YAMLProfileReader.cpp
    M bolt/lib/Profile/YAMLProfileWriter.cpp

  Log Message:
  -----------
  [BOLT][NFC] Fix braces usage in Profile

Summary:
Refactor bolt/*/Profile to follow the braces rule for if/else/loop from
[LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html).

(cherry picked from FBD33345741)


  Commit: 883bf0e83d5a42993f232587e16086becd80d391
      https://github.com/llvm/llvm-project/commit/883bf0e83d5a42993f232587e16086becd80d391
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-28 (Tue, 28 Dec 2021)

  Changed paths:
    M bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
    M bolt/lib/Utils/Utils.cpp
    M bolt/runtime/common.h
    M bolt/runtime/instr.cpp
    M bolt/tools/merge-fdata/merge-fdata.cpp

  Log Message:
  -----------
  [BOLT][NFC] Fix braces usage in the rest of the codebase

Summary:
Refactor remaining bolt sources to follow the braces rule for if/else/loop from
[LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html).

(cherry picked from FBD33345885)


  Commit: 513bbd3f365db319a2adc881510f6a352d94fdd3
      https://github.com/llvm/llvm-project/commit/513bbd3f365db319a2adc881510f6a352d94fdd3
  Author: Vladislav Khmelevsky <och95 at yandex.ru>
  Date:   2021-12-29 (Wed, 29 Dec 2021)

  Changed paths:
    M bolt/CODE_OWNERS.TXT

  Log Message:
  -----------
  [PR][BOLT] Add aarch64 backend code owner

Summary: Add Vladislav as AArch64 backend code owner.

(cherry picked from FBD33355160)


  Commit: ccc4d4397fd2acac5c7f7193065b51971913b213
      https://github.com/llvm/llvm-project/commit/ccc4d4397fd2acac5c7f7193065b51971913b213
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-12-29 (Wed, 29 Dec 2021)

  Changed paths:
    M bolt/docs/doxygen-mainpage.dox
    M bolt/docs/doxygen.cfg.in

  Log Message:
  -----------
  [BOLT][DOCS] Link to README instead of the github page in Doxygen

Summary:
Link to the README page built with the rest of the documentation,
a future-proof solution.

(cherry picked from FBD33357870)


  Commit: 1c2f4bbe9923b7cabd2174d7571c9cad00ebfdd8
      https://github.com/llvm/llvm-project/commit/1c2f4bbe9923b7cabd2174d7571c9cad00ebfdd8
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-11-15 (Mon, 15 Nov 2021)

  Changed paths:
    M bolt/include/bolt/Core/DebugData.h
    M bolt/include/bolt/Rewrite/DWARFRewriter.h
    M bolt/lib/Core/DebugData.cpp
    M bolt/lib/Rewrite/DWARFRewriter.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT] Rewrite of .debug_info section

Summary:
Changed the behavior of how we handle .debug_info section.
Instead of patching it will now rewrite it.
With this approach we are no longer constrained to having new values
 of the same size.
It handles re-writing by treating .debug_info as raw data.
It copies chunks of data between patches, with new data written in
 between.

(cherry picked from FBD32519952)


  Commit: 6bb26fcb20152f6b92ecf5d210c383bd8ab63af1
      https://github.com/llvm/llvm-project/commit/6bb26fcb20152f6b92ecf5d210c383bd8ab63af1
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2021-09-07 (Tue, 07 Sep 2021)

  Changed paths:
    M bolt/lib/Core/BinaryBasicBlock.cpp

  Log Message:
  -----------
  [BOLT] removeAllSuccessors: handle multiple edges between basic blocks

Summary:
If `addUnknownControlFlow` in `BinaryFunction::postProcessIndirectBranches`
is invoked with a basic block that has multiple edges to the same successor,
it leads to an assertion in `BinaryBasicBlock::removePredecessor`.

For basic blocks with multiple edges to the same successor, the default
behavior of removePredecessor is to remove all occurrences of the
predecessor block in its predecessor list (Multiple=true).

Example:
```A -> B (two edges)

A->removeAllSuccessors()
  for each successor of block A: // B twice
  // this removes both occurrences of A in B's predecessors list
  B->removePredecessor(A);
  // this invocation triggers an assert as A is no longer in B's
  // predecessor list
  B->removePredecessor(A);
```
This issue is not fixed by NormalizeCFG as `removeAllSuccessor` is called
earlier (from `buildCFG` -> `postProcessIndirectBranches`).

Solve this issue by collecting the successors into a set (`SmallPtrSet`) first,
before invoking `SuccessorBB->removePredecessor(this)`.

GitHub issue: https://github.com/facebookincubator/BOLT/issues/187

(cherry picked from FBD30796979)


  Commit: 9bf7a73787ac37a7372f5ee285a9aa3f9b3fdc69
      https://github.com/llvm/llvm-project/commit/9bf7a73787ac37a7372f5ee285a9aa3f9b3fdc69
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-12-07 (Tue, 07 Dec 2021)

  Changed paths:
    M bolt/include/bolt/Rewrite/DWARFRewriter.h
    M bolt/lib/Rewrite/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Change convertToRanges to not use indirect

Summary:
Now that we are re-writing .debug_info we are not longer restricted to have same size patches.
Simplifying logic to use direct forms.

(cherry picked from FBD32971159)


  Commit: 6b89327debf852ca00d4eaf17ec58781ea5d9035
      https://github.com/llvm/llvm-project/commit/6b89327debf852ca00d4eaf17ec58781ea5d9035
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2021-12-23 (Thu, 23 Dec 2021)

  Changed paths:
    M bolt/lib/Rewrite/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Handling more data formats for DW_AT_high_pc

Summary:
Adding support for DW_FORM_data_2, DW_FORM_data_1, DW_FORM_udata.
With new .debug_info code only need to modify the check.

(cherry picked from FBD33302731)


  Commit: df288e8487417565592d33c222968ca4681bb3aa
      https://github.com/llvm/llvm-project/commit/df288e8487417565592d33c222968ca4681bb3aa
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2021-12-28 (Tue, 28 Dec 2021)

  Changed paths:
    M bolt/lib/Rewrite/RewriteInstance.cpp

  Log Message:
  -----------
  [BOLT][NFC] Refactor if statements in RewriteInstance

(cherry picked from FBD33341796)


  Commit: bc9032c7fa179b539445443caf1d842d1f9a03fa
      https://github.com/llvm/llvm-project/commit/bc9032c7fa179b539445443caf1d842d1f9a03fa
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2022-01-05 (Wed, 05 Jan 2022)

  Changed paths:
    M bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Use uniform DEBUG_TYPE for MCPlus builders

(cherry picked from FBD33435121)


  Commit: e579f5c6e7c3dab2b2c370430d920ab6db201e17
      https://github.com/llvm/llvm-project/commit/e579f5c6e7c3dab2b2c370430d920ab6db201e17
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2022-01-05 (Wed, 05 Jan 2022)

  Changed paths:
    M bolt/include/bolt/Core/DebugData.h
    M bolt/include/bolt/Rewrite/DWARFRewriter.h
    M bolt/lib/Core/DebugData.cpp
    M bolt/lib/Rewrite/DWARFRewriter.cpp

  Log Message:
  -----------
  [BOLT][DWARF] Fix race conditions for debug fission in non-deterministic mode

Summary: Adding mutexes to avoid runtime race conditions.

(cherry picked from FBD33439854)


  Commit: 330c8e42ab36e255498fc82907f2b7c5917bd9d9
      https://github.com/llvm/llvm-project/commit/330c8e42ab36e255498fc82907f2b7c5917bd9d9
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2022-01-07 (Fri, 07 Jan 2022)

  Changed paths:
    M bolt/lib/Rewrite/BinaryPassManager.cpp

  Log Message:
  -----------
  [BOLT][NFC] Refactor command line options in BinaryPassManager

Summary:
Reformat code and put options in lexicographical order.

Comparing to clang-format output, manual formatting looks cleaner to me.

(cherry picked from FBD33481692)


  Commit: 4243b6582cf3bb5fbcde908913d4779ded731321
      https://github.com/llvm/llvm-project/commit/4243b6582cf3bb5fbcde908913d4779ded731321
  Author: Alexander Yermolovich <ayermolo at fb.com>
  Date:   2022-01-07 (Fri, 07 Jan 2022)

  Changed paths:
    M bolt/include/bolt/Core/DebugData.h

  Log Message:
  -----------
  [BOLT][DWARF] Fix size mismatch error with jemalloc

Summary:
When building with GCC and linking against jemalloc there is an
assertion when Debug Patches unique pointers are being freed from an std vector.
The base destructor gets invoked which results in type mismatch.
Added virtual destructor to the base class.

(cherry picked from FBD33489259)


  Commit: 1d3c150748230eed2a6058ec3bf1c5a0f8ede55c
      https://github.com/llvm/llvm-project/commit/1d3c150748230eed2a6058ec3bf1c5a0f8ede55c
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2022-01-07 (Fri, 07 Jan 2022)

  Changed paths:
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT] Remove ineligible macro-fusion patterns

Summary:
Remove patterns ineligible for macro-fusion:
- First instruction has a memory destination

This is a temporary commit to align BOLT with LLVM MC interfaces.
(cherry picked from FBD33479340)


  Commit: 799cbbb7970af68599e3924a13d1dd49a797ed57
      https://github.com/llvm/llvm-project/commit/799cbbb7970af68599e3924a13d1dd49a797ed57
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2022-01-05 (Wed, 05 Jan 2022)

  Changed paths:
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Reuse X86BaseInfo interfaces for macrofusion checks

Summary:
Remove X86MCPlusBuilder code that duplicates checks in X86BaseInfo.
Remove isINC and isDEC as redundant.

The new code of `X86MCPlusBuilder::isMacroOpFusionPair` is functionally
equivalent to `X86AsmBackend::isMacroFused`. However, as the method is
declared/defined in X86AsmBackend.cpp and not exported in a header file,
there's no way to use it in BOLT without changes in LLVM code.

(cherry picked from FBD33440373)


  Commit: 82278a8f2991e16d73b5da034a3a61f7339a204e
      https://github.com/llvm/llvm-project/commit/82278a8f2991e16d73b5da034a3a61f7339a204e
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2022-01-08 (Sat, 08 Jan 2022)

  Changed paths:
    M bolt/lib/Target/X86/X86MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Refactor X86MCPlusBuilder

Summary:
Selectively apply clang-format and other minor refactoring to the code
in X86MCPlusBuilder.cpp

(cherry picked from FBD33495550)


  Commit: 8aab58ba65002071dc89e8dcd5b0e09989b30644
      https://github.com/llvm/llvm-project/commit/8aab58ba65002071dc89e8dcd5b0e09989b30644
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2022-01-08 (Sat, 08 Jan 2022)

  Changed paths:
    M bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

  Log Message:
  -----------
  [BOLT][NFC] Refactor AArch64MCPlusBuilder

Summary: Selectively apply clang-format to the code in AArch64MCPlusBuilder.cpp.

(cherry picked from FBD33495653)


  Commit: b1a107db563c12a16662eabb8df3c1a6de641309
      https://github.com/llvm/llvm-project/commit/b1a107db563c12a16662eabb8df3c1a6de641309
  Author: Amir Ayupov <aaupov at fb.com>
  Date:   2022-01-10 (Mon, 10 Jan 2022)

  Changed paths:
    M bolt/include/bolt/Core/BinaryBasicBlock.h
    M bolt/lib/Passes/BinaryPasses.cpp

  Log Message:
  -----------
  [BOLT][NFC] Format braced initializer lists

Summary:
Use assignment (`=`) with braced initializer lists when constructing
aggregate temporaries in expressions.

https://llvm.org/docs/CodingStandards.html#braced-initializer-lists

(cherry picked from FBD33515669)


  Commit: 4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae
      https://github.com/llvm/llvm-project/commit/4c106cfdf7cf7eec861ad3983a3dd9a9e8f3a8ae
  Author: Maksim Panchenko <maks at fb.com>
  Date:   2022-01-11 (Tue, 11 Jan 2022)

  Changed paths:
    A bolt/CMakeLists.txt
    A bolt/CODE_OWNERS.TXT
    A bolt/LICENSE.TXT
    A bolt/README.md
    A bolt/docs/CMakeLists.txt
    A bolt/docs/Heatmap.png
    A bolt/docs/Heatmaps.md
    A bolt/docs/OptimizingClang.md
    A bolt/docs/RuntimeLibrary.md
    A bolt/docs/doxygen-mainpage.dox
    A bolt/docs/doxygen.cfg.in
    A bolt/include/bolt/Core/BinaryBasicBlock.h
    A bolt/include/bolt/Core/BinaryContext.h
    A bolt/include/bolt/Core/BinaryData.h
    A bolt/include/bolt/Core/BinaryEmitter.h
    A bolt/include/bolt/Core/BinaryFunction.h
    A bolt/include/bolt/Core/BinaryLoop.h
    A bolt/include/bolt/Core/BinarySection.h
    A bolt/include/bolt/Core/DebugData.h
    A bolt/include/bolt/Core/DynoStats.h
    A bolt/include/bolt/Core/Exceptions.h
    A bolt/include/bolt/Core/JumpTable.h
    A bolt/include/bolt/Core/MCPlus.h
    A bolt/include/bolt/Core/MCPlusBuilder.h
    A bolt/include/bolt/Core/ParallelUtilities.h
    A bolt/include/bolt/Core/Relocation.h
    A bolt/include/bolt/Passes/ADRRelaxationPass.h
    A bolt/include/bolt/Passes/Aligner.h
    A bolt/include/bolt/Passes/AllocCombiner.h
    A bolt/include/bolt/Passes/AsmDump.h
    A bolt/include/bolt/Passes/BinaryFunctionCallGraph.h
    A bolt/include/bolt/Passes/BinaryPasses.h
    A bolt/include/bolt/Passes/CacheMetrics.h
    A bolt/include/bolt/Passes/CallGraph.h
    A bolt/include/bolt/Passes/CallGraphWalker.h
    A bolt/include/bolt/Passes/DataflowAnalysis.h
    A bolt/include/bolt/Passes/DataflowInfoManager.h
    A bolt/include/bolt/Passes/DominatorAnalysis.h
    A bolt/include/bolt/Passes/FrameAnalysis.h
    A bolt/include/bolt/Passes/FrameOptimizer.h
    A bolt/include/bolt/Passes/HFSort.h
    A bolt/include/bolt/Passes/IdenticalCodeFolding.h
    A bolt/include/bolt/Passes/IndirectCallPromotion.h
    A bolt/include/bolt/Passes/Inliner.h
    A bolt/include/bolt/Passes/Instrumentation.h
    A bolt/include/bolt/Passes/InstrumentationSummary.h
    A bolt/include/bolt/Passes/JTFootprintReduction.h
    A bolt/include/bolt/Passes/LivenessAnalysis.h
    A bolt/include/bolt/Passes/LongJmp.h
    A bolt/include/bolt/Passes/LoopInversionPass.h
    A bolt/include/bolt/Passes/MCF.h
    A bolt/include/bolt/Passes/PLTCall.h
    A bolt/include/bolt/Passes/PatchEntries.h
    A bolt/include/bolt/Passes/ReachingDefOrUse.h
    A bolt/include/bolt/Passes/ReachingInsns.h
    A bolt/include/bolt/Passes/RegAnalysis.h
    A bolt/include/bolt/Passes/RegReAssign.h
    A bolt/include/bolt/Passes/ReorderAlgorithm.h
    A bolt/include/bolt/Passes/ReorderData.h
    A bolt/include/bolt/Passes/ReorderFunctions.h
    A bolt/include/bolt/Passes/ReorderUtils.h
    A bolt/include/bolt/Passes/RetpolineInsertion.h
    A bolt/include/bolt/Passes/ShrinkWrapping.h
    A bolt/include/bolt/Passes/SplitFunctions.h
    A bolt/include/bolt/Passes/StackAllocationAnalysis.h
    A bolt/include/bolt/Passes/StackAvailableExpressions.h
    A bolt/include/bolt/Passes/StackPointerTracking.h
    A bolt/include/bolt/Passes/StackReachingUses.h
    A bolt/include/bolt/Passes/StokeInfo.h
    A bolt/include/bolt/Passes/TailDuplication.h
    A bolt/include/bolt/Passes/ThreeWayBranch.h
    A bolt/include/bolt/Passes/ValidateInternalCalls.h
    A bolt/include/bolt/Passes/VeneerElimination.h
    A bolt/include/bolt/Profile/BoltAddressTranslation.h
    A bolt/include/bolt/Profile/DataAggregator.h
    A bolt/include/bolt/Profile/DataReader.h
    A bolt/include/bolt/Profile/Heatmap.h
    A bolt/include/bolt/Profile/ProfileReaderBase.h
    A bolt/include/bolt/Profile/ProfileYAMLMapping.h
    A bolt/include/bolt/Profile/YAMLProfileReader.h
    A bolt/include/bolt/Profile/YAMLProfileWriter.h
    A bolt/include/bolt/Rewrite/BinaryPassManager.h
    A bolt/include/bolt/Rewrite/DWARFRewriter.h
    A bolt/include/bolt/Rewrite/ExecutableFileMemoryManager.h
    A bolt/include/bolt/Rewrite/MachORewriteInstance.h
    A bolt/include/bolt/Rewrite/RewriteInstance.h
    A bolt/include/bolt/RuntimeLibs/HugifyRuntimeLibrary.h
    A bolt/include/bolt/RuntimeLibs/InstrumentationRuntimeLibrary.h
    A bolt/include/bolt/RuntimeLibs/RuntimeLibrary.h
    A bolt/include/bolt/Utils/BoltRevision.inc.in
    A bolt/include/bolt/Utils/CommandLineOpts.h
    A bolt/include/bolt/Utils/NameResolver.h
    A bolt/include/bolt/Utils/NameShortener.h
    A bolt/include/bolt/Utils/Utils.h
    A bolt/lib/CMakeLists.txt
    A bolt/lib/Core/BinaryBasicBlock.cpp
    A bolt/lib/Core/BinaryContext.cpp
    A bolt/lib/Core/BinaryData.cpp
    A bolt/lib/Core/BinaryEmitter.cpp
    A bolt/lib/Core/BinaryFunction.cpp
    A bolt/lib/Core/BinaryFunctionProfile.cpp
    A bolt/lib/Core/BinarySection.cpp
    A bolt/lib/Core/CMakeLists.txt
    A bolt/lib/Core/DebugData.cpp
    A bolt/lib/Core/DynoStats.cpp
    A bolt/lib/Core/Exceptions.cpp
    A bolt/lib/Core/JumpTable.cpp
    A bolt/lib/Core/MCPlusBuilder.cpp
    A bolt/lib/Core/ParallelUtilities.cpp
    A bolt/lib/Core/Relocation.cpp
    A bolt/lib/Passes/ADRRelaxationPass.cpp
    A bolt/lib/Passes/Aligner.cpp
    A bolt/lib/Passes/AllocCombiner.cpp
    A bolt/lib/Passes/AsmDump.cpp
    A bolt/lib/Passes/BinaryFunctionCallGraph.cpp
    A bolt/lib/Passes/BinaryPasses.cpp
    A bolt/lib/Passes/CMakeLists.txt
    A bolt/lib/Passes/CacheMetrics.cpp
    A bolt/lib/Passes/CallGraph.cpp
    A bolt/lib/Passes/CallGraphWalker.cpp
    A bolt/lib/Passes/DataflowAnalysis.cpp
    A bolt/lib/Passes/DataflowInfoManager.cpp
    A bolt/lib/Passes/ExtTSPReorderAlgorithm.cpp
    A bolt/lib/Passes/FrameAnalysis.cpp
    A bolt/lib/Passes/FrameOptimizer.cpp
    A bolt/lib/Passes/HFSort.cpp
    A bolt/lib/Passes/HFSortPlus.cpp
    A bolt/lib/Passes/IdenticalCodeFolding.cpp
    A bolt/lib/Passes/IndirectCallPromotion.cpp
    A bolt/lib/Passes/Inliner.cpp
    A bolt/lib/Passes/Instrumentation.cpp
    A bolt/lib/Passes/JTFootprintReduction.cpp
    A bolt/lib/Passes/LivenessAnalysis.cpp
    A bolt/lib/Passes/LongJmp.cpp
    A bolt/lib/Passes/LoopInversionPass.cpp
    A bolt/lib/Passes/MCF.cpp
    A bolt/lib/Passes/PLTCall.cpp
    A bolt/lib/Passes/PatchEntries.cpp
    A bolt/lib/Passes/PettisAndHansen.cpp
    A bolt/lib/Passes/RegAnalysis.cpp
    A bolt/lib/Passes/RegReAssign.cpp
    A bolt/lib/Passes/ReorderAlgorithm.cpp
    A bolt/lib/Passes/ReorderData.cpp
    A bolt/lib/Passes/ReorderFunctions.cpp
    A bolt/lib/Passes/RetpolineInsertion.cpp
    A bolt/lib/Passes/ShrinkWrapping.cpp
    A bolt/lib/Passes/SplitFunctions.cpp
    A bolt/lib/Passes/StackAllocationAnalysis.cpp
    A bolt/lib/Passes/StackAvailableExpressions.cpp
    A bolt/lib/Passes/StackPointerTracking.cpp
    A bolt/lib/Passes/StackReachingUses.cpp
    A bolt/lib/Passes/StokeInfo.cpp
    A bolt/lib/Passes/TailDuplication.cpp
    A bolt/lib/Passes/ThreeWayBranch.cpp
    A bolt/lib/Passes/ValidateInternalCalls.cpp
    A bolt/lib/Passes/VeneerElimination.cpp
    A bolt/lib/Profile/BoltAddressTranslation.cpp
    A bolt/lib/Profile/CMakeLists.txt
    A bolt/lib/Profile/DataAggregator.cpp
    A bolt/lib/Profile/DataReader.cpp
    A bolt/lib/Profile/Heatmap.cpp
    A bolt/lib/Profile/ProfileReaderBase.cpp
    A bolt/lib/Profile/YAMLProfileReader.cpp
    A bolt/lib/Profile/YAMLProfileWriter.cpp
    A bolt/lib/Rewrite/BinaryPassManager.cpp
    A bolt/lib/Rewrite/BoltDiff.cpp
    A bolt/lib/Rewrite/CMakeLists.txt
    A bolt/lib/Rewrite/DWARFRewriter.cpp
    A bolt/lib/Rewrite/ExecutableFileMemoryManager.cpp
    A bolt/lib/Rewrite/MachORewriteInstance.cpp
    A bolt/lib/Rewrite/RewriteInstance.cpp
    A bolt/lib/RuntimeLibs/CMakeLists.txt
    A bolt/lib/RuntimeLibs/HugifyRuntimeLibrary.cpp
    A bolt/lib/RuntimeLibs/InstrumentationRuntimeLibrary.cpp
    A bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
    A bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
    A bolt/lib/Target/AArch64/CMakeLists.txt
    A bolt/lib/Target/CMakeLists.txt
    A bolt/lib/Target/X86/CMakeLists.txt
    A bolt/lib/Target/X86/X86MCPlusBuilder.cpp
    A bolt/lib/Utils/CMakeLists.txt
    A bolt/lib/Utils/CommandLineOpts.cpp
    A bolt/lib/Utils/Utils.cpp
    A bolt/runtime/CMakeLists.txt
    A bolt/runtime/common.h
    A bolt/runtime/config.h.in
    A bolt/runtime/hugify.cpp
    A bolt/runtime/instr.cpp
    A bolt/test/AArch64/asm-func-debug.test
    A bolt/test/AArch64/lit.local.cfg
    A bolt/test/AArch64/tls.c
    A bolt/test/AArch64/update-debug-reloc.test
    A bolt/test/CMakeLists.txt
    A bolt/test/Inputs/asm_foo.s
    A bolt/test/Inputs/asm_main.c
    A bolt/test/Inputs/bolt_icf.cpp
    A bolt/test/Inputs/hello.c
    A bolt/test/Inputs/icf_baz.c
    A bolt/test/Inputs/icf_main.c
    A bolt/test/Inputs/vararg.s
    A bolt/test/X86/Inputs/asm_main.c
    A bolt/test/X86/Inputs/avx512.c
    A bolt/test/X86/Inputs/blarge.fdata
    A bolt/test/X86/Inputs/blarge.yaml
    A bolt/test/X86/Inputs/ctc_and_unreachable.s
    A bolt/test/X86/Inputs/debug-fission-script.txt
    A bolt/test/X86/Inputs/debug-fission-simple.s
    A bolt/test/X86/Inputs/double_jump.cpp
    A bolt/test/X86/Inputs/entry.s
    A bolt/test/X86/Inputs/exc4sw.S
    A bolt/test/X86/Inputs/exc4sw.fdata
    A bolt/test/X86/Inputs/exc_args.s
    A bolt/test/X86/Inputs/ft_to_noop.s
    A bolt/test/X86/Inputs/icf-jump-tables.c
    A bolt/test/X86/Inputs/indirect_goto.c
    A bolt/test/X86/Inputs/inline-foo.c
    A bolt/test/X86/Inputs/inline-main.c
    A bolt/test/X86/Inputs/inlined.cpp
    A bolt/test/X86/Inputs/inlinee.cpp
    A bolt/test/X86/Inputs/issue20.yaml
    A bolt/test/X86/Inputs/issue26.yaml
    A bolt/test/X86/Inputs/jmp_opt.cpp
    A bolt/test/X86/Inputs/jmp_opt2.cpp
    A bolt/test/X86/Inputs/jmp_opt3.cpp
    A bolt/test/X86/Inputs/jmpjmp.s
    A bolt/test/X86/Inputs/jump_table_footprint_reduction.s
    A bolt/test/X86/Inputs/jump_table_icp.cpp
    A bolt/test/X86/Inputs/jump_table_icp.s
    A bolt/test/X86/Inputs/jump_table_reference.s
    A bolt/test/X86/Inputs/linenumber.cpp
    A bolt/test/X86/Inputs/loop_nest.s
    A bolt/test/X86/Inputs/order.txt
    A bolt/test/X86/Inputs/plt-got-sec.yaml
    A bolt/test/X86/Inputs/plt-sec-8-byte.yaml
    A bolt/test/X86/Inputs/plt-sec.yaml
    A bolt/test/X86/Inputs/pre-aggregated.txt
    A bolt/test/X86/Inputs/relaxed_tc.s
    A bolt/test/X86/Inputs/rodata_simpl_loads.s
    A bolt/test/X86/Inputs/sctc_bug.s
    A bolt/test/X86/Inputs/sctc_bug2.s
    A bolt/test/X86/Inputs/sctc_bug3.s
    A bolt/test/X86/Inputs/sctc_bug4.s
    A bolt/test/X86/Inputs/shorten_mov.s
    A bolt/test/X86/Inputs/srol-bug-input.yaml
    A bolt/test/X86/Inputs/static_exe.s
    A bolt/test/X86/Inputs/tailcall.s
    A bolt/test/X86/Inputs/tailcall_traps.s
    A bolt/test/X86/Inputs/unreachable.s
    A bolt/test/X86/Inputs/user-order.S
    A bolt/test/X86/R_X86_64_64.pic.lld.cpp
    A bolt/test/X86/asm-dump.c
    A bolt/test/X86/asm-func-debug.test
    A bolt/test/X86/avx512-trap.test
    A bolt/test/X86/bad-exe.test
    A bolt/test/X86/bb-with-two-tail-calls.s
    A bolt/test/X86/block-reordering.test
    A bolt/test/X86/bolt-info.test
    A bolt/test/X86/branch-data.test
    A bolt/test/X86/bug-reorder-bb-jrcxz.s
    A bolt/test/X86/call-zero.s
    A bolt/test/X86/cfi-expr-rewrite.s
    A bolt/test/X86/cfi-instrs-count.s
    A bolt/test/X86/cfi-instrs-reordered.s
    A bolt/test/X86/ctc-and-unreachable.test
    A bolt/test/X86/debug-fission-single.s
    A bolt/test/X86/double-jump.test
    A bolt/test/X86/exceptions-args.test
    A bolt/test/X86/fallthrough-to-noop.test
    A bolt/test/X86/false-jump-table.s
    A bolt/test/X86/icf-jump-tables.test
    A bolt/test/X86/indirect-goto.test
    A bolt/test/X86/inline-debug-info.test
    A bolt/test/X86/inlined-function-mixed.test
    A bolt/test/X86/internal-call-instrument.s
    A bolt/test/X86/interprocedural-ref-entry-point.s
    A bolt/test/X86/invalid-profile.test
    A bolt/test/X86/issue20.s
    A bolt/test/X86/issue20.test
    A bolt/test/X86/issue26.s
    A bolt/test/X86/issue26.test
    A bolt/test/X86/jmp-optimization.test
    A bolt/test/X86/jmpjmp.test
    A bolt/test/X86/jump-table-footprint-reduction.test
    A bolt/test/X86/jump-table-icp.test
    A bolt/test/X86/jump-table-reference.test
    A bolt/test/X86/layout-heuristic.test
    A bolt/test/X86/line-number.test
    A bolt/test/X86/lit.local.cfg
    A bolt/test/X86/loop-inversion-pass.s
    A bolt/test/X86/loop-nest.test
    A bolt/test/X86/no-entry-reordering.test
    A bolt/test/X86/no-output.test
    A bolt/test/X86/no-relocs.test
    A bolt/test/X86/pie.test
    A bolt/test/X86/plt-sec-8-byte.test
    A bolt/test/X86/plt-sec.test
    A bolt/test/X86/pre-aggregated-perf.test
    A bolt/test/X86/re-optimize.test
    A bolt/test/X86/reader.test
    A bolt/test/X86/relaxed-tailcall.test
    A bolt/test/X86/remove-unused.test
    A bolt/test/X86/rodata-simpl-loads.test
    A bolt/test/X86/sctc-bug.test
    A bolt/test/X86/sctc-bug2.test
    A bolt/test/X86/sctc-bug3.test
    A bolt/test/X86/sctc-bug4.test
    A bolt/test/X86/shared-object.test
    A bolt/test/X86/shorten-mov.test
    A bolt/test/X86/shrinkwrapping-critedge.s
    A bolt/test/X86/shrinkwrapping-insertcfi.s
    A bolt/test/X86/shrinkwrapping-pop-order.s
    A bolt/test/X86/shrinkwrapping-popf.s
    A bolt/test/X86/shrinkwrapping.test
    A bolt/test/X86/split-func-icf.s
    A bolt/test/X86/split-func-jump-table-fragment-noparent.s
    A bolt/test/X86/split-func-jump-table-fragment-reverse.s
    A bolt/test/X86/split-func-jump-table-fragment.s
    A bolt/test/X86/srol-bug.test
    A bolt/test/X86/static-exe.test
    A bolt/test/X86/symtab-secondary-entries.test
    A bolt/test/X86/tail-duplication-cacheline.s
    A bolt/test/X86/tail-duplication-complex.s
    A bolt/test/X86/tail-duplication-jt.s
    A bolt/test/X86/tail-duplication-pass.s
    A bolt/test/X86/tail-duplication-prop-bug.s
    A bolt/test/X86/tailcall-traps.test
    A bolt/test/X86/tailcall.test
    A bolt/test/X86/unreachable.test
    A bolt/test/X86/vararg.test
    A bolt/test/X86/zero-sized-object.s
    A bolt/test/bolt-icf.test
    A bolt/test/keep-aranges.test
    A bolt/test/link_fdata.py
    A bolt/test/lit.cfg.py
    A bolt/test/lit.site.cfg.py.in
    A bolt/test/non-empty-debug-line.test
    A bolt/test/runtime/AArch64/adrrelaxationpass.s
    A bolt/test/runtime/AArch64/constant-island-relocations.s
    A bolt/test/runtime/AArch64/controlflow.s
    A bolt/test/runtime/AArch64/issue177.s
    A bolt/test/runtime/AArch64/lit.local.cfg
    A bolt/test/runtime/Inputs/exceptions_split.cpp
    A bolt/test/runtime/Inputs/fptr.c
    A bolt/test/runtime/X86/Inputs/basic-instrumentation.s
    A bolt/test/runtime/X86/Inputs/exception3.cpp
    A bolt/test/runtime/X86/Inputs/exception4.cpp
    A bolt/test/runtime/X86/Inputs/fdata-escape-chars-syms.txt
    A bolt/test/runtime/X86/Inputs/fdata-escape-chars.txt
    A bolt/test/runtime/X86/Inputs/indirect_goto.c
    A bolt/test/runtime/X86/Inputs/internalcall-main.c
    A bolt/test/runtime/X86/Inputs/internalcall.S
    A bolt/test/runtime/X86/Inputs/retpoline_synthetic.cpp
    A bolt/test/runtime/X86/Inputs/user_func_order.txt
    A bolt/test/runtime/X86/basic-instrumentation.test
    A bolt/test/runtime/X86/exceptions-pic.test
    A bolt/test/runtime/X86/exceptions-run.test
    A bolt/test/runtime/X86/fdata-escape-chars.ll
    A bolt/test/runtime/X86/fix-branches-jrcxz.s
    A bolt/test/runtime/X86/hot-end-symbol.s
    A bolt/test/runtime/X86/indirect-goto-pie.test
    A bolt/test/runtime/X86/instrumentation-dup-jts.s
    A bolt/test/runtime/X86/instrumentation-ind-calls.s
    A bolt/test/runtime/X86/instrumentation-indirect.c
    A bolt/test/runtime/X86/instrumentation-pie.c
    A bolt/test/runtime/X86/instrumentation-shlib.c
    A bolt/test/runtime/X86/internal-call-instrument.test
    A bolt/test/runtime/X86/internal-call.test
    A bolt/test/runtime/X86/interp-overwrite-bug.s
    A bolt/test/runtime/X86/lit.local.cfg
    A bolt/test/runtime/X86/retpoline-synthetic.test
    A bolt/test/runtime/X86/section-reloc-with-addend.s
    A bolt/test/runtime/X86/shrinkwrapping-alignment.s
    A bolt/test/runtime/X86/shrinkwrapping-lock.s
    A bolt/test/runtime/X86/shrinkwrapping-pushpop.s
    A bolt/test/runtime/X86/tail-duplication-constant-prop.s
    A bolt/test/runtime/X86/three-way-branch-pass.s
    A bolt/test/runtime/X86/user-func-reorder.c
    A bolt/test/runtime/exceptions-instrumentation.test
    A bolt/test/runtime/fptr.test
    A bolt/test/runtime/lit.local.cfg
    A bolt/test/runtime/meta-merge-fdata.test
    A bolt/tools/CMakeLists.txt
    A bolt/tools/driver/CMakeLists.txt
    A bolt/tools/driver/llvm-bolt.cpp
    A bolt/tools/merge-fdata/CMakeLists.txt
    A bolt/tools/merge-fdata/merge-fdata.cpp
    A bolt/utils/bughunter.sh
    A bolt/utils/docker/Dockerfile

  Log Message:
  -----------
  Merge BOLT into LLVM monorepo

Details of the merge are available at llvm-dev.

Mailing-list: https://lists.llvm.org/pipermail/llvm-dev/2022-January/154638.html [llvm-dev] Preparing BOLT for LLVM monorepo

Co-authored-by: Rafael Auler <rafaelauler at fb.com>


Compare: https://github.com/llvm/llvm-project/compare/e2e7ecf25d3d...4c106cfdf7cf


More information about the All-commits mailing list