1. Nov 12, 2021
    • Rafael Auler's avatar
      [BOLT] Fix Windows build · ae585be1
      Rafael Auler authored
      Summary:
      Make BOLT build in VisualStudio compiler and run without
      crashing on a simple test. Other tests are not running.
      
      (cherry picked from FBD32378736)
      ae585be1
    • Amir Ayupov's avatar
      [BOLT][TEST] Import small tests · 0e7dd1aa
      Amir Ayupov authored
      Summary: Imported small internal tests.
      
      (cherry picked from FBD32371964)
      0e7dd1aa
  2. Nov 11, 2021
  3. Nov 09, 2021
    • Amir Ayupov's avatar
      [BOLT][NFC] AsmDump: disable printing of empty profile data · a82502d4
      Amir Ayupov authored
      Summary:
      Moved the FDATA printing under the condition of non-empty profile data.
      The change reduces the assembly dumps.
      
      (cherry picked from FBD32262675)
      a82502d4
    • Amir Ayupov's avatar
      [BOLT][TEST] Import jump-table-icp.test, update link_fdata script · 3a16f216
      Amir Ayupov authored
      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)
      3a16f216
  4. Nov 05, 2021
    • Amir Ayupov's avatar
      [BOLT][TEST] Rename tests to follow standard naming scheme · 8331f75e
      Amir Ayupov authored
      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)
      8331f75e
  5. Nov 04, 2021
    • Amir Ayupov's avatar
      [BOLT][TEST] Import small tests · 2e0ad6ff
      Amir Ayupov authored
      Summary:
      Imported small internal tests:
      - fallthrough-to-noop.test
      
      (cherry picked from FBD32158100)
      2e0ad6ff
    • Amir Ayupov's avatar
      [BOLT][TEST] Add instrumentation test using merge-fdata · d1df113e
      Amir Ayupov authored
      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)
      d1df113e
  6. Oct 30, 2021
    • Amir Ayupov's avatar
      [BOLT][TEST] Import small tests · f808ea00
      Amir Ayupov authored
      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)
      f808ea00
  7. Nov 10, 2021
    • Amir Ayupov's avatar
      [BOLT] TailDuplication: skip non-simple functions · 9ab06622
      Amir Ayupov authored
      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)
      9ab06622
  8. Nov 09, 2021
  9. Oct 28, 2021
    • Maksim Panchenko's avatar
      [BOLT][DWARF] Fix rare problem while rewriting debug_abbrev after LTO · 45f94abc
      Maksim Panchenko authored
      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)
      45f94abc
  10. Oct 19, 2021
  11. Oct 12, 2021
  12. Sep 28, 2021
    • Rafael Auler's avatar
      Rebase: [BOLT] AsmDump: dump function assembly and profile info · 443f1b4f
      Rafael Auler authored
      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)
      443f1b4f
  13. Oct 26, 2021
    • Maksim Panchenko's avatar
      [BOLT][NFC] Do not pass BinaryContext alongside BinaryFunction · 60b09997
      Maksim Panchenko authored
      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)
      60b09997
  14. Oct 27, 2021
    • Rafael Auler's avatar
      [BOLT] Improve cmake configs for opensource · 0559dab5
      Rafael Auler authored
      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)
      0559dab5
  15. Oct 09, 2021
    • Rafael Auler's avatar
      Rebase: [NFC] Refactor sources to be buildable in shared mode · a34c753f
      Rafael Auler authored
      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)
      a34c753f
  16. Oct 26, 2021
  17. Oct 24, 2021
    • Maksim Panchenko's avatar
      [BOLT] Add Dockerfile · 1ccc3d50
      Maksim Panchenko authored
      Summary:
      Dockerfile based on Ubuntu:20.04.
      
      Fixes facebookincubator/BOLT#214.
      
      (cherry picked from FBD31883210)
      1ccc3d50
  18. Oct 16, 2021
    • Vladislav Khmelevsky's avatar
      [PR] Introduce remove-symtab option · 95ee1297
      Vladislav Khmelevsky authored
      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)
      95ee1297
  19. Oct 17, 2021
  20. Oct 12, 2021
    • Maksim Panchenko's avatar
      [BOLT][DWARF] Keep original line info for unmodified units · 32782574
      Maksim Panchenko authored
      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)
      32782574
  21. Oct 16, 2021
  22. Oct 17, 2021
  23. Oct 16, 2021
    • Vladislav Khmelevsky's avatar
      [PR] Instrumentation: Sync file on dump · dcdd37fd
      Vladislav Khmelevsky authored
      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)
      dcdd37fd
    • Vladislav Khmelevsky's avatar
      [PR] Fix constant islands handling · 2d431eef
      Vladislav Khmelevsky authored
      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)
      2d431eef
  24. Oct 12, 2021
    • Alexander Yermolovich's avatar
      [BOLT][DWARF] Refactor of Loc and LocLists writers · fdd9184d
      Alexander Yermolovich authored
      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)
      fdd9184d
  25. Oct 11, 2021
    • Elvina Yakubova's avatar
      [PR][BOLT][TEST] Fix tests · 53ec21e3
      Elvina Yakubova authored
      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)
      53ec21e3
  26. Oct 05, 2021
    • Vladislav Khmelevsky's avatar
      [PR] Fix LongJmp pass · a2214e8f
      Vladislav Khmelevsky authored
      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)
      a2214e8f
  27. Oct 14, 2021
  28. Oct 12, 2021
  29. Oct 09, 2021
  30. Oct 08, 2021
    • Amir Ayupov's avatar
      [BOLT][TEST] Imported small tests · d41b4e6e
      Amir Ayupov authored
      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)
      d41b4e6e
  31. Oct 07, 2021
    • Amir Ayupov's avatar
      [BOLT][TEST] Imported small tests · c74e5bfe
      Amir Ayupov authored
      Summary:
      Imported small internal tests:
      - jmp_optimization.test
      - jmpjmp.test
      - jump_table_footprint_reduction.test
      - jump_table_reference.test
      
      (cherry picked from FBD31483122)
      c74e5bfe
    • Amir Ayupov's avatar
      [BOLT][TEST] Imported small tests · 92e306de
      Amir Ayupov authored
      Summary:
      Imported small internal tests:
      - indirect_goto.test
      - indirect_goto_pie.test
      - inlined_function_mixed.test
      
      (cherry picked from FBD31446571)
      92e306de