1. Dec 07, 2021
    • Maksim Panchenko's avatar
      [BOLT][DWARF] Force allocation of debug_line in RuntimeDyld · b73c87bc
      Maksim Panchenko authored
      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)
      b73c87bc
  2. Dec 02, 2021
    • Maksim Panchenko's avatar
      [BOLT] Add pass to normalize CFG · cbf530bf
      Maksim Panchenko authored
      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)
      cbf530bf
  3. Dec 04, 2021
  4. Dec 03, 2021
  5. Dec 02, 2021
  6. Nov 26, 2021
    • Maksim Panchenko's avatar
      [BOLT][NFC] Remove misleading debug message · 4f91538f
      Maksim Panchenko authored
      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)
      4f91538f
  7. Nov 30, 2021
  8. Nov 25, 2021
  9. Nov 16, 2021
    • Vladislav Khmelevsky's avatar
      [PR] Disable stack protection in runtime libraries · 4e4ef2f3
      Vladislav Khmelevsky authored
      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)
      4e4ef2f3
  10. Nov 17, 2021
  11. Nov 24, 2021
  12. Jun 05, 2021
    • Amir Ayupov's avatar
      [BOLT][NFC] Use function names passed in -funcs-no-regex as-is · d474dbdf
      Amir Ayupov authored
      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)
      d474dbdf
  13. Nov 24, 2021
  14. Nov 14, 2021
    • Vladislav Khmelevsky's avatar
      [PR] Fix ShrinkWrapping pop order · a944a487
      Vladislav Khmelevsky authored
      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)
      a944a487
  15. Nov 24, 2021
  16. Nov 19, 2021
  17. Nov 16, 2021
    • Rafael Auler's avatar
      Fix shared build · 2ccea6ea
      Rafael Auler authored
      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)
      2ccea6ea
  18. Nov 18, 2021
  19. Nov 16, 2021
  20. Nov 13, 2021
  21. Nov 12, 2021
  22. Nov 05, 2021
    • Marius Wachtler's avatar
      [PR] instr: change assert to allow FD 0 return by __open() · 3b00a3a2
      Marius Wachtler authored
      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)
      3b00a3a2
  23. 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
  24. Nov 11, 2021
  25. 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
  26. 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
  27. 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
  28. 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
  29. 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
  30. Nov 09, 2021
  31. 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
  32. Oct 19, 2021
  33. Oct 12, 2021
  34. 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
  35. 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