summaryrefslogtreecommitdiff
path: root/bolt/runtime
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""Nico Weber2023-05-171-1/+1
| | | | | | | | | | | | | | This reverts commit 65429b9af6a2c99d340ab2dcddd41dab201f399c. Broke several projects, see https://reviews.llvm.org/D144509#4347562 onwards. Also reverts follow-up commit "[OpenMP] Compile assembly files as ASM, not C" This reverts commit 4072c8aee4c89c4457f4f30d01dc9bb4dfa52559. Also reverts fix attempt "[cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump" This reverts commit 7d47dac5f828efd1d378ba44a97559114f00fb64.
* Reland "[CMake] Bumps minimum version to 3.20.0."Mark de Wever2023-05-131-1/+1
| | | | | | The owner of the last two failing buildbots updated CMake. This reverts commit e8e8707b4aa6e4cc04c0cffb2de01d2de71165fc.
* Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""Mark de Wever2023-05-061-1/+1
| | | | | | Unfortunatly not all buildbots are updated. This reverts commit ffb807ab5375b3f78df198dc5d4302b3b552242f.
* Reland "[CMake] Bumps minimum version to 3.20.0."Mark de Wever2023-05-061-1/+1
| | | | | | All build bots should be updated now. This reverts commit 44d38022ab29a3156349602733b3459df5beef93.
* [BOLT] Robustify compile-time config checkNathan Sidwell2023-04-211-2/+8
| | | | | | | | | | | The BOLT runtime is specifically hard coded for x86_64 linux or x86_64 darwin. (Using x86_64 syscalls, hardcoding syscall numbers.) Make it very clear this is for those specific pair of systems. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D148825
* Revert "Revert "Revert "[CMake] Bumps minimum version to 3.20.0."""Mark de Wever2023-04-151-1/+1
| | | | | | This reverts commit 1ef4c3c859728008cf707cad8d67f45ae5070ae1. Two buildbots still haven't been updated.
* Revert "Revert "[CMake] Bumps minimum version to 3.20.0.""Mark de Wever2023-04-151-1/+1
| | | | | | This reverts commit 92523a35a827539db8557bbc3ecab7f9ea3f6ade. Reland to see whether CIs are updated.
* Revert "Reland "[CMake] Bumps minimum version to 3.20.0.""Mark de Wever2023-03-181-1/+1
| | | | | | This reverts commit a72165e5df59032cdd54dcb18155f2630d73abd1. Some buildbots have not been updated yet.
* Reland "[CMake] Bumps minimum version to 3.20.0."Mark de Wever2023-03-181-1/+1
| | | | | | This reverts commit 92523a35a827539db8557bbc3ecab7f9ea3f6ade. Test whether all CI runners are updated.
* Revert "[CMake] Bumps minimum version to 3.20.0."Mark de Wever2023-03-041-1/+1
| | | | | | | Some build bots have not been updated to the new minimal CMake version. Reverting for now and ping the buildbot owners. This reverts commit 44c6b905f8527635e49bb3ea97dea315f92d38ec.
* [CMake] Bumps minimum version to 3.20.0.Mark de Wever2023-03-041-1/+1
| | | | | | | | | | | | | | This partly undoes D137724. This change has been discussed on discourse https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193 Note this does not remove work-arounds for older CMake versions, that will be done in followup patches. Reviewed By: mehdi_amini, MaskRay, ChuanqiXu, to268, thieta, tschuett, phosek, #libunwind, #libc_vendors, #libc, #libc_abi, sivachandra, philnik, zibi Differential Revision: https://reviews.llvm.org/D144509
* [BOLT][runtime] Change fPIE flag to fPICVladislav Khmelevsky2022-11-171-1/+1
| | | | | | | Since instrumentation could be used on libraries we need to use fPIC, not fPIE flag. Differential Revision: https://reviews.llvm.org/D138099
* [BOLT][Hugify] Fix apple buildsRafael Auler2022-11-041-3/+1
| | | | Fix placement of ifdefs in hugify.cpp after D129107 landed.
* adds huge pages support of PIE/no-PIE binariesAlexey Moksyakov2022-11-043-72/+197
| | | | | | | | | This patch adds the huge pages support (-hugify) for PIE/no-PIE binaries. Also returned functionality to support the kernels < 5.10 where there is a problem in a dynamic loader with the alignment of pages addresses. Differential Revision: https://reviews.llvm.org/D129107
* Honor LLVM_LIBDIR_SUFFIXserge-sans-paille2022-11-011-3/+6
| | | | | | | Some distribution install libraries under lib64. LLVM supports this through LLVM_LIBDIR_SUFFIX, have bolt do the same. Differential Revision: https://reviews.llvm.org/D137039
* [bolt][llvm][cmake] Use `CMAKE_INSTALL_LIBDIR` tooJohn Ericson2022-08-201-3/+4
| | | | | | | | | | | | Working back towards D130586. Bolt didn't use `LLVM_LIBDIR_SUFFIX` before, and has no in-tree reverse dependencies, it seems easier to add. The change in LLVM itself is to prevent some unexpected `lib64` from cropping up due to the `CMAKE_INSTALL_LIBDIR` defaulting logic. Differential Revision: https://reviews.llvm.org/D132297
* Revert "[cmake] Use `CMAKE_INSTALL_LIBDIR` too"John Ericson2022-08-181-4/+3
| | | | | | | This reverts commit f7a33090a91015836497c75f173775392ab0304d. Unfortunately this causes a number of failures that didn't show up in my local build.
* [cmake] Use `CMAKE_INSTALL_LIBDIR` tooJohn Ericson2022-08-181-3/+4
| | | | | | | | | | | | | | | | | | We held off on this before as `LLVM_LIBDIR_SUFFIX` conflicted with it. Now we return this. `LLVM_LIBDIR_SUFFIX` is kept as a deprecated way to set `CMAKE_INSTALL_LIBDIR`. The other `*_LIBDIR_SUFFIX` are just removed entirely. I imagine this is too potentially-breaking to make LLVM 15. That's fine. I have a more minimal version of this in the disto (NixOS) patches for LLVM 15 (like previous versions). This more expansive version I will test harder after the release is cut. Reviewed By: sebastian-ne, ldionne, #libc, #libc_abi Differential Revision: https://reviews.llvm.org/D130586
* [LLVM] Update C++ standard to 17Tobias Hieta2022-08-061-1/+1
| | | | | | | | | | | | Also make the soft toolchain requirements hard. This allows us to use C++17 features in LLVM now. If we find patterns with C++17 that improve readability it should be recommended in the coding standards. Reviewed By: jhenderson, cor3ntin, MaskRay Differential Revision: https://reviews.llvm.org/D130689
* [BOLT][Runtime] Fix memset definitionVladislav Khmelevsky2022-07-091-3/+5
| | | | Differential Revision: https://reviews.llvm.org/D129321
* [BOLT] Fix concurrent hash table modification in the instrumentation runtimeMichał Chojnowski2022-07-071-1/+1
| | | | | | | | | | | | | | | | | `__bolt_instr_data_dump()` does not lock the hash tables when iterating over them, so the iteration can happen concurrently with a modification done in another thread, when the table is in an inconsistent state. This also has been observed in practice, when it caused a segmentation fault. We fix this by locking hash tables during iteration. This is done by taking the lock in `forEachElement()`. The only other site of iteration, `resetCounters()`, has been correctly locking the table even before this patch. This patch removes its `Lock` because the lock is now taken in the inner `forEachElement()`. Reviewed By: maksfb, yota9 Differential Revision: https://reviews.llvm.org/D129089
* [BOLT] Add runtime functions required by freestanding environmentMaksim Panchenko2022-07-063-19/+49
| | | | | | | | | | | | Compiler can generate calls to some functions implicitly, even under constraints of freestanding environment. Make sure these functions are available in our runtime objects. Fixes test failures on some systems after https://reviews.llvm.org/D128960. Reviewed By: yota9 Differential Revision: https://reviews.llvm.org/D129168
* [BOLT] Change mutex implementationElvina Yakubova2022-07-061-7/+2
| | | | | | | | | | | | | Changed acquire implemetaion to __atomic_test_and_set() and release to __atomic_clear() so it eliminates inline asm usage and is arch independent. Elvina Yakubova, Advanced Software Technology Lab, Huawei Reviewers: yota9, maksfb, rafauler Differential Revision: https://reviews.llvm.org/D129162
* [BOLT] Fix instrumentation problem with floating pointMaksim Panchenko2022-07-011-1/+2
| | | | | | | | | | | | | If BOLT instrumentation runtime uses XMM registers, it can interfere with the user program causing crashes and unexpected behavior. This happens as the instrumentation code preserves general purpose registers only. Build BOLT instrumentation runtime with "-mno-sse". Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D128960
* [BOLT][CMAKE] Add missing clauses to bolt/runtime/CMakeLists.txtAmir Ayupov2022-05-131-0/+2
| | | | | | | | | Fix build with Apple Clang. Tip @tschuett for reporting the issue #55404. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D125480
* [BOLT][CMAKE][NFC] Update runtime/CMakeLists.txtAmir Ayupov2022-02-071-10/+9
| | | | | | | | | | Summary: - Specify compiler flags for runtime libraries as BOLT_RT_FLAGS, - Remove redundant CMake definitions. Reviewers: maksfb FBD34048561
* [BOLT] Fix runtime osx cross-compile buildVladislav Khmelevsky2022-02-081-6/+6
| | | | | | Place include elf.h under !apple condition Differential Revision: https://reviews.llvm.org/D119038
* [BOLT][NFC] Fix braces usage in the rest of the codebaseAmir Ayupov2021-12-282-19/+15
| | | | | | | | 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)
* [BOLT][NFC] Fix file-description commentsMaksim Panchenko2021-12-213-5/+3
| | | | | | Summary: Fix comments at the start of source files. (cherry picked from FBD33274597)
* [PR] Disable stack protection in runtime librariesVladislav Khmelevsky2021-11-161-2/+2
| | | | | | | | | | | 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)
* [PR] instr: change assert to allow FD 0 return by __open()Marius Wachtler2021-11-051-2/+2
| | | | | | | | | | | | | | | | | 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)
* [PR] bolt_rt: getBinaryPath() increase max file pathMarius Wachtler2021-10-251-1/+1
| | | | | | | | 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)
* [PR] Disable instrumentation and hugify build for aarch64Vladislav Khmelevsky2021-10-162-0/+4
| | | | | | | | | | | 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)
* [PR] Instrumentation: Sync file on dumpVladislav Khmelevsky2021-10-152-0/+12
| | | | | | | | | | | 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)
* [PR] Instrumentation: use TryLock for SimpleHashTable getterVasily Leonenko2021-08-082-3/+38
| | | | | | | | | | | | | | | | | | | | 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)
* [PR] Instrumentation: Avoid generating GOT table in instrumentation libraryVladislav Khmelevsky2021-07-221-0/+1
| | | | | | | | | | | 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)
* [PR] Instrumentation: Fix start and fini trampoline pointersVladislav Khmelevsky2021-07-311-8/+6
| | | | | | | | | | | | 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)
* [PR] Instrumentation: Introduce instrumentation-binpath argumentVasily Leonenko2021-07-301-0/+5
| | | | | | | | | | | | 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)
* [PR] Instrumentation: Fix runtime handlers for PIE filesVladislav Khmelevsky2021-06-231-16/+12
| | | | | | | | | | | Summary: This commit fixes runtime instrumentation handlers for PIE binaries case. Vladislav Khmelevsky, Advanced Software Technology Lab, Huawei (cherry picked from FBD30092522)
* [PR] Instrumentation: Add support for opening libs based on links ↵Elvina Yakubova2021-01-192-2/+89
| | | | | | | | | | | | | | | | | /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)
* [PR] Instrumentation: Add readlink and getdents supportElvina Yakubova2021-01-181-0/+29
| | | | | | | | | | | 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)
* [PR] Instrumentation: Generate and use _start and _fini trampolinesVasily Leonenko2021-06-192-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* [PR] Instrumentation: Disable signals on mutex lockVladislav Khmelevsky2021-06-041-1/+29
| | | | | | | | | | | | | | 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)
* [BOLT] Hugify: check for THP support via sysfsAmir Ayupov2021-06-022-84/+38
| | | | | | | | Summary: Remove dependence on kernel version check, query sysfs directly instead. (cherry picked from FBD28858208)
* Rebase: [BOLT][NFC] Expand auto typesAmir Ayupov2021-04-081-10/+10
| | | | | | | | Summary: Expanded auto types across BOLT semi-automatically with the aid of clangd LSP (cherry picked from FBD33289309)
* [BOLT][PR] Instrumentation: Introduce -no-counters-clear and -wait-forks optionsVladislav Khmelevsky2021-03-092-6/+74
| | | | | | | | | | | | | | | 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@huawei.com> (cherry picked from FBD26919011)
* Fix license for a few remaining filesRafael Auler2021-03-172-13/+6
| | | | | | Summary: As titled. (cherry picked from FBD28112137)
* [BOLT] Add support for dumping profile on MacOSAlexander Shaposhnikov2021-01-282-43/+91
| | | | | | Summary: Add support for dumping profile on MacOS. (cherry picked from FBD25751363)
* [BOLT] Add support for dumping counters on MacOSAlexander Shaposhnikov2021-01-282-17/+54
| | | | | | Summary: Add support for dumping counters on MacOS (cherry picked from FBD25750516)
* [BOLT] Enable intToStr for MacOSAlexander Shaposhnikov2021-01-202-55/+61
| | | | | | Summary: Enable intToStr et al. in the runtime library for MacOS. (cherry picked from FBD25745358)