summaryrefslogtreecommitdiff
path: root/bolt
Commit message (Collapse)AuthorAgeFilesLines
* [BOLT][NFC] Use llvm::make_rangeAmir Ayupov2023-05-172-12/+8
| | | | | | | | Use `llvm::make_range` convenience wrapper from ADT. Reviewed By: #bolt, rafauler Differential Revision: https://reviews.llvm.org/D145887
* 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.
* [BOLT] Fix state of MCSymbols in lowering passRafael Auler2023-05-163-0/+38
| | | | | | | | | | | | | | | | | We have mostly harmless data races when running BinaryContext::calculateEmittedSize() in parallel, while performing split function pass. However, it is possible to end up in a state where some MCSymbols are still registered and our clean up failed. This happens rarely but it does happen, and when it happens, it is a difficult to diagnose heisenbug. To avoid this, add a new clean pass to perform a last check on MCSymbols, before they undergo our final emission pass, to verify that they are in a sane state. If we fail to do this, we might resolve some symbols to zero and crash the output binary. Reviewed By: #bolt, Amir Differential Revision: https://reviews.llvm.org/D137984
* [BOLT][Wrapper] Fix off-by-one in find_section upper limitJob Noorman2023-05-161-1/+1
| | | | | | | | | find_section used to match offsets equal to file_offset + size causing offsets to sometimes be attributed to the wrong section. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D149047
* 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.
* [X86][AsmParser] Reapply "Refactor code and optimize more instructions from ↵Shengchen Kan2023-05-131-1/+1
| | | | | | | | | VEX3 to VEX2" This was reverted in d4994d0e7922 b/c a bolt test failed after the encoding changed. Relanded the patch with the updated test.
* [BOLT] Fix flush pending relocsRafael Auler2023-05-113-11/+10
| | | | | | | | | | https://github.com/facebookincubator/BOLT/pull/255 accidentally omitted a relocation type when refactoring the code. Add this type back and change function name so its intent is more clear. Reviewed By: #bolt, Amir Differential Revision: https://reviews.llvm.org/D150335
* [BOLT][DWARF][NFC] Fixed an assertion checkAlexander Yermolovich2023-05-091-1/+1
| | | | | | | | | Spotted this one while working on new DWARF Rewriter. We were using wrong check in assertion. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D150167
* [BOLT][test] Fix retpoline-synthetic.testAmir Aupov2023-05-081-1/+0
| | | | | Fix test on BOLT's buildbot, e.g. https://lab.llvm.org/buildbot/#/builders/244/builds/10885
* [BOLT] Use opcode name in hashBlockAmir Ayupov2023-05-081-6/+5
| | | | | | | | | | | | | | | | | | | | | | Use MCInst opcode name instead of opcode value in hashing. Opcode values are unstable wrt changes to target tablegen definitions, and we notice that as output mismatches in NFC testing. This makes BOLT YAML profile tied to a particular LLVM revision which is less portable than offset-based fdata profile. Switch to using opcode names which have 1:1 mapping with opcode values for any given LLVM revision, and are stable wrt modifications to .td files (except of course modifications to names themselves). Test Plan: D150154 is a test commit adding new X86 instruction which shifts opcode values. With current change, pre-aggregated-perf.test passes in nfc check mode. Without current change, pre-aggregated-perf.test expectedly fails. Reviewed By: #bolt, rafauler Differential Revision: https://reviews.llvm.org/D150005
* [BOLT] Use MCInstPrinter in createRetpolineFunctionTagAmir Ayupov2023-05-084-21/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make retpoline functions invariant of X86 register numbers. retpoline-synthetic.test is known to fail NFC testing due to shifting register numbers. Use canonical register names instead of tablegen numbers. Before: ``` __retpoline_r51_ __retpoline_mem_r58+DATAat0x200fe8 __retpoline_mem_r51+0 __retpoline_mem_r132+0+8*53 ``` After: ``` __retpoline_%rax_ __retpoline_mem_%rip+DATAat0x200fe8 __retpoline_mem_%rax+0 __retpoline_mem_%r12+0+8*%rbx ``` Test Plan: - Revert 67bd3c58c0c7389e39c5a2f4d3b1a30459ccf5b7 that touches X86RegisterInfo.td. - retpoline-synthetic.test passes in NFC mode with this diff, fails without it. Reviewed By: #bolt, rafauler Differential Revision: https://reviews.llvm.org/D150138
* [BOLT][DWARF] Fix dwarf5-one-loclists-two-bases testAlexander Yermolovich2023-05-081-6/+5
| | | | | | | | Fix assembly for the helper file to work with the new DWARF rewriter. Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D150147
* 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] Remove redundant dumps in AsmDumpAmir Ayupov2023-05-041-34/+0
| | | | | | | | | Dumping jump table and tail call fdata is covered by subsequent iteration over successors. Reviewed By: #bolt, maksfb Differential Revision: https://reviews.llvm.org/D149799
* [docs] Hide collaboration and include graphs in doxygen docsTimm Bäder2023-05-041-3/+3
| | | | | | | They don't convey any useful information and make the documentation unnecessarily hard to read. Differential Revision: https://reviews.llvm.org/D149641
* [BOLT][DWARF] Fix handling of loclists_base without location accessesAlexander Yermolovich2023-05-033-1/+476
| | | | | | | | | | | | There are CUs that have DW_AT_loclists_base, but no DW_AT_location in children DIEs. Pre-bolt it points to a valid offset. We were not updating it, so it ended up pointing in the middle of a list and caused LLDB to print out errors. Changed it to point to first location list. I don't think it should matter since there are no accesses to it anyway. Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D149798
* [BOLT][NFC] Add hash computation for basic blocksspupyrev2023-05-0211-106/+232
| | | | | | | | | | Extending yaml profile format with block hashes, which are used for stale profile matching. To avoid duplication of the code, created a new class with a collection of utilities for computing hashes. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D144306
* [BOLT] Make sure Mach-O binaries are actually linkedJob Noorman2023-05-023-0/+413
| | | | | | | | Note that this issue is also solved by D147544. Reviewed By: alexander-shaposhnikov Differential Revision: https://reviews.llvm.org/D149244
* [BOLT] Make sure all section allocations have deterministic contentsJob Noorman2023-05-021-0/+6
| | | | | | | | | | | | | | For empty sections, RuntimeDyld always allocates 1 byte but leaves it uninitialized. This causes the contents of some output sections to be non-deterministic. Note that this issue is also solved by D147544. Fixes #59008 Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D149243
* Revert "[BOLT] Parallelize legacy profile merging"Yi Kong2023-04-281-47/+22
| | | | | | This reverts commit 35af20d9e036deeed250b73fd3ae86d6455173c5. The patch caused a test failure.
* [BOLT] Parallelize legacy profile mergingYi Kong2023-04-271-22/+47
| | | | | | | | | | Merging profiles is quite expensive, but easily paralleizable. 8359 profiles on n2d-standard-128: single-thread: 808s multi-thread: 200s (~75% speed up) Differential Revision: https://reviews.llvm.org/D149014
* [BOLT][Wrapper] Fix off-by-one when parsing 'cmp' outputJob Noorman2023-04-241-1/+2
| | | | | | | | | | The byte offsets in the output of 'cmp' start from 1, not from 0 as the current parser assumes. This caused mismatched bytes to sometimes be attributed to the wrong section. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D149046
* [BOLT] Fix many tests detected as unsupportedJob Noorman2023-04-241-1/+1
| | | | | | | | | | | | | Since D148847, many tests are detected as being unsupported. This is caused by BOLT_TARGETS_TO_BUILD being ;-separated whereas the previously used TARGETS_TO_BUILD is space-separated. This patch fixes this by creating config.targets lit.cfg.py by splitting on ';'. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D149026
* [LoopInfo] Move generic LoopInfo into own filesChristian Ulmann2023-04-243-1/+3
| | | | | | | | | | | | | | | This commit splits the generic part of `LoopInfo` into separate files. These new `GenericLoopInfo` files are located in `llvm/Support` to be inline with `GenericDomTree`. Furthermore, this change ensures that MLIR's Bazel build does not have to link against `LLVMAnalysis` just to use these template headers. Depends on D148219 Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D148235
* [BOLT] Remove unsupported ELF type reloc handlingNathan Sidwell2023-04-231-16/+2
| | | | | | | | | Drop unsupported ELF format reloc handling -- RewriteInstance lacks this flexibility elsewhere. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D148946
* [BOLT] Remove unneeded dyncastsNathan Sidwell2023-04-211-11/+3
| | | | | | | | These checks are unnecessary -- we've already bailed if the format was wrong. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D148848
* [BOLT] Add BOLT_TARGETS_TO_BUILDNathan Sidwell2023-04-215-52/+45
| | | | | | | | | | | Adds BOLT_TARGETS_TO_BUILD, which defaults to the intersection of X86;AArch64 and LLVM_TARGETS_TO_BUILD, but allows configuration to alter that -- for instance omitting one of those two targets even if llvm supports both. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D148847
* [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
* [BOLT] Make BOLT_ENABLE_RUNTIME user-configurableNathan Sidwell2023-04-201-2/+15
| | | | | | | | | | Defaults to ON for x86_64 && (Linux | Darwin). If enabled, checks that /proc/self/map_files is readable. Some systems are configured so that getdents fails with EPERM. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D148742
* [BOLT][NFC] Remove exec permission from some testsNathan Sidwell2023-04-196-0/+0
| | | | These files unnecessarily had execute permission.
* [BOLT] Add bolt-runtime requirement to testsNathan Sidwell2023-04-197-7/+7
| | | | | | These tests rely on the X86 runtime, add the REQUIRES. Differential Revision: https://reviews.llvm.org/D148737
* [BOLT][NFC] Move phdr typedef to cpp fileNathan Sidwell2023-04-192-2/+2
| | | | | | | This typedef is only used inside the RewriteInstance source file, let's not expose it in the header file -- even if private. Differential Revision: https://reviews.llvm.org/D148667
* [BOLT] Adjust Shdr alignmentNathan Sidwell2023-04-191-2/+3
| | | | | | | Shdr's are not necesarily size 2^n, and there is no reason to align to that boundary if they are. Differential Revision: https://reviews.llvm.org/D148666
* [BOLT] Don't enable runtime when not building X86Nathan Sidwell2023-04-181-1/+2
|
* [BOLT][DWARF] Fix handling of CUs without TU referenceAlexander Yermolovich2023-04-173-1/+231
| | | | | | | | | When input is DWP with DWARF5 bolt wasn't handling correctly CUs that didn't have TU references. Which resulted in a crash. Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D148589
* [BOLT][test] Update AArch64/r_aarch64_prelxx.s testAmir Ayupov2023-04-171-1/+1
| | | | | | | | Update section flags and type after https://reviews.llvm.org/D148386 Reviewed By: #bolt, rafauler, MaskRay Differential Revision: https://reviews.llvm.org/D148511
* [BOLT] Fix use-after-free in RewriteInstance::mapCodeSectionsJob Noorman2023-04-171-1/+3
| | | | | | | | | | When a cold function is too large, its section gets deregistered. However, the section is still dereferenced later to get its RuntimeDyld ID. This patch moves the deregistration to after the last dereference. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D148427
* 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.
* [BOLT][NFC] Fix UB due to unaligned load in DebugStrOffsetsWriterJob Noorman2023-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The following tests fail when enabling UBSan due to an unaligned memory load: > runtime error: load of misaligned address 0x620000000643 for type > 'const uint32_t' (aka 'const unsigned int'), which requires 4 byte > alignment BOLT :: AArch64/asm-func-debug.test BOLT :: AArch64/update-debug-reloc.test BOLT :: X86/asm-func-debug.test BOLT :: X86/dwarf5-df-dualcu.test BOLT :: X86/dwarf5-df-mono-dualcu.test BOLT :: X86/dwarf5-ftypes-dwp-input-dwo-output.test BOLT :: X86/dwarf5-locaddrx.test BOLT :: X86/dwarf5-split-dwarf4-monolithic.test BOLT :: X86/inlined-function-mixed.test BOLT :: non-empty-debug-line.test This patch fixes this by using read32le for the load. Reviewed By: ayermolo Differential Revision: https://reviews.llvm.org/D148217
* [BOLT][NFC] Fix UB due to left shift of negative valueJob Noorman2023-04-131-1/+1
| | | | | | | | | | | | | | | The following test fails when enabling UBSan due to a left shift of a negative value: > runtime error: left shift of negative value -2 BOLT :: AArch64/ext-island-ref.s This patch fixes this by using a multiplication instead of a shift. Reviewed By: yota9 Differential Revision: https://reviews.llvm.org/D148218
* [BOLT] Fix section-end-sym.s test to only run x86/LinuxMuhammad Omair Javaid2023-04-121-1/+1
| | | | | | section-end-sym.s contains x86_64 assembly instruction execution on target. I have changed REQURIES: field system-linux --> x86_64-linux This came up while testing LLVM 16.0.1 release on AArch64 Linux.
* [BOLT] Fix creation of invalid CFG in presence of dead codeRafael Auler2023-04-112-0/+67
| | | | | | | | | | | | | | When there is a direct jump right after an indirect one, in the absence of code jumpting to this direct jump, this is obviously dead code. However, BOLT was failing to recognize that by mistakenly placing both jmp instructions in the same basic block, and creating wrong successor edges. Fix that, so we can safely run UCE on that. This bug also causes validateCFG to fail and BOLT to crash if it is running ICP on that function. Reviewed By: #bolt, Amir Differential Revision: https://reviews.llvm.org/D148055
* [MC] Always encode instruction into SmallVectorAlexis Engelke2023-04-063-6/+3
| | | | | | | | | | | | | | | All users of MCCodeEmitter::encodeInstruction use a raw_svector_ostream to encode the instruction into a SmallVector. The raw_ostream however incurs some overhead for the actual encoding. This change allows an MCCodeEmitter to directly emit an instruction into a SmallVector without using a raw_ostream and therefore allow for performance improvments in encoding. A default path that uses existing raw_ostream implementations is provided. Reviewed By: MaskRay, Amir Differential Revision: https://reviews.llvm.org/D145791
* [BOLT][NFC] Simplify code using std::optionalYi Kong2023-04-011-5/+4
| | | | | | Use std::optional instead of tracking if it is the first profile seen. Differential Revision: https://reviews.llvm.org/D147308
* [BOLT] computing raw branch count for yaml profilesspupyrev2023-03-284-3/+15
| | | | | | | | | `Function.RawBranchCount` is initialized for fdata profile but not for yaml one. The diff adds the computation of the field for yaml profiles Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D144211
* [BOLT] Don't use section relocations when computing hash for data from other ↵Denis Revunov2023-03-243-4/+96
| | | | | | | | | | | | | | | | | | | | | section When computing symbol hashes in BinarySection::hash, we try to find relocations in the section which reference the passed BinaryData. We do so by doing lower_bound on data begin offset and upper_bound on data end offset. Since offsets are relative to the current section, if it is a data from the previous section, we get underflow when computing offset and lower_bound returns Relocations.end(). If this data also ends where current section begins, upper_bound on zero offset will return some valid iterator if we have any relocations after the first byte. Then we'll try to iterate from lower_bound to upper_bound, since they're not equal, which in that case means we'll dereference Relocations.end(), increment it, and try to do so until we reach the second valid iterator. Of course we reach segfault earlier. In this patch we stop BOLT from searching relocations for symbols outside of the current section. Reviewed By: rafauler Differential Revision: https://reviews.llvm.org/D146620
* Add "REQUIRES: asserts" to test that uses --debug-only flagAmy Huang2023-03-221-1/+1
|
* [BOLT] Reject symbols pointing to section endJob Noorman2023-03-212-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | Sometimes, symbols are present that point to the end of a section (i.e., one-past the highest valid address). Currently, BOLT either rejects those symbols when they don't point to another existing section, or errs when they do and the other section is not executable. I suppose BOLT would accept the symbol when it points to an executable section. In any case, these symbols should not be considered while discovering functions and should not result in an error. This patch implements that. Note that this patch checks explicitly for symbols whose value equals the end of their section. It might make more sense to verify that the symbol's value is within [section start, section end). However, I'm not sure if this could every happen *and* its value does not equal the end. Another way to implement this is to verify that the BinarySection we find at the symbol's address actually corresponds to the symbol's section. I'm not sure what the best approach is so feedback is welcome. Reviewed By: yota9, rafauler Differential Revision: https://reviews.llvm.org/D146215