aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-exegesis/lib/Assembler.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-05-23[NFC][CodeGen] Adopt MachineFunctionProperties convenience accessors (#141101)Rahul Joshi1-4/+2
2025-05-20[llvm-exegesis] Error instead of aborting on verification failure (#137581)Aiden Grossman1-3/+6
This patch makes llvm-exegesis emit an error when the machine function fails in MachineVerification rather than aborting. This allows downstream users (particularly https://github.com/google/gematria) to handle these errors rather than having the entire process crash. This essentially be NFC from the user perspective minus the addition of the new error message.
2025-03-21[llvm-exegesis] Avoid repeated hash lookups (NFC) (#132331)Kazu Hirata1-3/+4
2025-03-06[IR] Store Triple in Module (NFC) (#129868)Nikita Popov1-1/+1
The module currently stores the target triple as a string. This means that any code that wants to actually use the triple first has to instantiate a Triple, which is somewhat expensive. The change in #121652 caused a moderate compile-time regression due to this. While it would be easy enough to work around, I think that architecturally, it makes more sense to store the parsed Triple in the module, so that it can always be directly queried. For this change, I've opted not to add any magic conversions between std::string and Triple for backwards-compatibilty purses, and instead write out needed Triple()s or str()s explicitly. This is because I think a decent number of them should be changed to work on Triple as well, to avoid unnecessary conversions back and forth. The only interesting part in this patch is that the default triple is Triple("") instead of Triple() to preserve existing behavior. The former defaults to using the ELF object format instead of unknown object format. We should fix that as well.
2025-01-21[IR] Replace of PointerType::get(Type) with opaque version (NFC) (#123617)Mats Jun Larsen1-2/+2
In accordance with https://github.com/llvm/llvm-project/issues/123569 In order to keep the patch at reasonable size, this PR only covers for the llvm subproject, unittests excluded.
2025-01-16[llvm-exegesis] Begin replacing unsigned with MCRegister. NFC (#123109)Craig Topper1-12/+12
Some of this was needed to fix implicit conversions from MCRegister to unsigned when calling getReg() on MCOperand for example. The majority was done by reviewing parts of the code that dealt with registers, converting them to MCRegister and then seeing what new implicit conversions were created and fixing those. There were a few places where I used MCPhysReg instead of MCRegiser for static arrays since its uint16_t instead of unsigned.
2024-11-17[llvm-exegesis] Reserve members in arrayAiden Grossman1-0/+1
This patch reserves members in the RegisterSetUp vector as we statically know the size.
2024-11-14Overhaul the TargetMachine and LLVMTargetMachine Classes (#111234)Matin Raayai1-5/+3
Following discussions in #110443, and the following earlier discussions in https://lists.llvm.org/pipermail/llvm-dev/2017-October/117907.html, https://reviews.llvm.org/D38482, https://reviews.llvm.org/D38489, this PR attempts to overhaul the `TargetMachine` and `LLVMTargetMachine` interface classes. More specifically: 1. Makes `TargetMachine` the only class implemented under `TargetMachine.h` in the `Target` library. 2. `TargetMachine` contains target-specific interface functions that relate to IR/CodeGen/MC constructs, whereas before (at least on paper) it was supposed to have only IR/MC constructs. Any Target that doesn't want to use the independent code generator simply does not implement them, and returns either `false` or `nullptr`. 3. Renames `LLVMTargetMachine` to `CodeGenCommonTMImpl`. This renaming aims to make the purpose of `LLVMTargetMachine` clearer. Its interface was moved under the CodeGen library, to further emphasis its usage in Targets that use CodeGen directly. 4. Makes `TargetMachine` the only interface used across LLVM and its projects. With these changes, `CodeGenCommonTMImpl` is simply a set of shared function implementations of `TargetMachine`, and CodeGen users don't need to static cast to `LLVMTargetMachine` every time they need a CodeGen-specific feature of the `TargetMachine`. 5. More importantly, does not change any requirements regarding library linking. cc @arsenm @aeubanks
2024-03-11[CodeGen] Do not pass MF into MachineRegisterInfo methods. NFC. (#84770)Jay Foad1-1/+1
MachineRegisterInfo already knows the MF so there is no need to pass it in as an argument.
2024-01-29[llvm-exegesis] Remove llvm prefix where unnecessary (#79802)Aiden Grossman1-2/+2
This patch removes the llvm:: prefix within llvm-exegesis where it is not necessary. This is most occurrences of the prefix within exegesis as exegesis is within the llvm namespace. This patch makes things more consistent as the vast majority of the code did not use the llvm:: prefix for anything.
2024-01-26[Exegesis] Do not assume the size and layout of the assembled snippet (#79636)Min-Yih Hsu1-5/+14
Currently llvm-exegesis assumes that there will only be 3 symbols in the snippet object, in which the benchmarking function 'foo' is always the last symbol. These assumptions do not hold for object file formats of other targets we support downstream. I think it would be more ideal to generalize this part of the logics into a simple search on all symbols, as proposed by this patch.
2024-01-03[NFC][llvm-exegesis] Remove redundant register initial values argumentAiden Grossman1-13/+11
This patch removes the redundant RegisterInitialValues parameter from assembleToStream and friends as it is included within the BenchmarkKey struct that is also passed to all the functions that need this information.
2023-12-22[llvm-exegesis] Fix stack pointer register restorationAiden Grossman1-1/+1
9eb80ab3787e1851be8c686651688e870b93506b changed the method for stack pointer restoration to fix segmentation faults. However, I made a mistake in the patch and swapped a != for a ==, which caused an arbitrary register (the first one specified) to get restored rather than the stack pointer specifically. This patch fixes that issue and adds test coverage to prevent regression.
2023-12-15[llvm-exegesis] Validate that address annotations are aligned (#75554)Aiden Grossman1-0/+11
This patch adds in validation at two different levels that address annotations are page aligned. This is necessary as otherwise the mmap calls will fail as MAP_FIXED/MAP_FIXED_NOREPLACE require page aligned addresses. This happens silently in the subprocess. This patch adds validation at snippet parsing time to give feedback to the user and also adds asserts at code generation/address usage time to ensure that other users of the Exegesis APIs conform to the same requirements.
2023-11-30Reland "[llvm-exegesis] Set stack pointer register after starting perf ↵Aiden Grossman1-0/+23
counter (#72489)" This reverts commit 52b4b357268ac114f7972e37da1e5954f322df09. This commit was causing build failures on bots without libpfm installed as the CHECK requires were not set correctly. The test added should only run on machines with libpfm enabled due to the limitations currently imposed by the subprocess execution mode.
2023-11-29Revert "[llvm-exegesis] Set stack pointer register after starting perf ↵Aiden Grossman1-23/+0
counter (#72489)" This reverts commit 9eb80ab3787e1851be8c686651688e870b93506b. This is causing failures on multiple builders. Pulling it out until I have time to fix it.
2023-11-29[llvm-exegesis] Set stack pointer register after starting perf counter (#72489)Aiden Grossman1-0/+23
Before this patch, in subprocess mode, llvm-exegesis setup the stack pointer register with the rest of the registers when it was requested by the user. This would cause a segfault when the instructions to start the perf counter ran as they use the stack to preserve the three registers needed to make the syscall. This patch moves the setup of the stack register to after the configuration of the perf counter to fix this issue so that we have a valid stack pointer for all the preceeding operations. Regression test added. This fixes #72193.
2023-11-27Reland "Reland "[llvm-exegesis] Switch from MCJIT to LLJIT (#72838)"Aiden Grossman1-49/+32
This reverts commit ea5de6021cf69a233106689cc6f0ee14899e1a83. This patch was reverted as it broke a test on x86_64 Darwin due to the symbol naming being different between platforms. As Darwin isn't a supported platform for executing snippets for llvm-exegesis, we can just disable the test to fix the issue.
2023-11-27Revert "Reland "[llvm-exegesis] Switch from MCJIT to LLJIT (#72838)""Hans Wennborg1-32/+49
This broke tools/llvm-exegesis/X86/latency/dummy-counters.test on Mac, see comment on the PR. > There was an issue with certain configurations failing to build due to a > deleted Error constructor that should be fixed with this relanding. This reverts commit 92b821f2dcddbfa934689e10d8f11df150ab1043.
2023-11-25Reland "[llvm-exegesis] Switch from MCJIT to LLJIT (#72838)"Aiden Grossman1-49/+32
This reverts commit ddc6ef46418cc419041d0bd85de40d0eb9396848. This relands commit 12b0ab2c9ce8ef813d9eb888860f20daac3336bd. There was an issue with certain configurations failing to build due to a deleted Error constructor that should be fixed with this relanding.
2023-11-24Revert "[llvm-exegesis] Switch from MCJIT to LLJIT (#72838)"Aiden Grossman1-32/+49
This reverts commit 12b0ab2c9ce8ef813d9eb888860f20daac3336bd. Currently failing on certain configurations due to a missing constructor. Pulling out so that I can reproduce the issue and make sure I fix it before resubmitting.
2023-11-24[llvm-exegesis] Switch from MCJIT to LLJIT (#72838)Aiden Grossman1-49/+32
This patch switches from using MCJIT to LLJIT as MCJIT is going to be deprecated soon. Fixes #41764.
2023-11-24[llvm-exegesis] Refactor ExecutableFunction to use a named constructor (#72837)Aiden Grossman1-10/+16
This patch refactors ExecutableFunction to use a named constructor pattern, namely adding the create function, so that errors occurring during the creation of an ExecutableFunction can be propogated back up rather than having to deal with them in report_fatal_error.
2023-09-14[NFC][CodeGen] Change CodeGenOpt::Level/CodeGenFileType into enum classes ↵Arthur Eubanks1-1/+2
(#66295) This will make it easy for callers to see issues with and fix up calls to createTargetMachine after a future change to the params of TargetMachine. This matches other nearby enums. For downstream users, this should be a fairly straightforward replacement, e.g. s/CodeGenOpt::Aggressive/CodeGenOptLevel::Aggressive or s/CGFT_/CodeGenFileType::
2023-06-27[llvm-exegesis] Add support for using memory annotationsAiden Grossman1-4/+58
This patch adds in support for using memory annotations in the subprocess execution mode.
2023-06-16[llvm-exegesis] Use MCJIT only for executionPavel Kosov1-0/+34
Initially, llvm-exegesis was generating the benchmark code for the host CPU to execute it inside its own process. Thus, MCJIT was reused for fetching function's bytes to fill the assembled_snippet field in the benchmark report. Later, the --mtriple and --benchmark-phase command line options were introduced that are handy for testing snippet generation even if snippet execution is not possible. In that setup, MCJIT is asked to parse an object file for a foreign CPU or operating system that is probably not guaranteed to succeed and was actually observed to fail in https://reviews.llvm.org/D145763. This commit implements a much simplified function's code fetching, assuming the benchmark function is the only function in the object file and it spans across the entire text section (note that MCJIT-based code has more or less the same assumption - see TrackingSectionMemoryManager class). ~~~ Huawei RRI, OS Lab Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D148921
2023-05-15[llvm-exegesis] Create a proper LLVM IR Function for MachineFunctionsArthur Eubanks1-3/+4
I have upcoming changes break with invalid Function definitions. Reviewed By: aidengrossman, courbet Differential Revision: https://reviews.llvm.org/D149207
2023-04-07Remove redundant `get()` call and use auto on LHS of make_uniqueDavid Blaikie1-3/+2
2023-04-06[llvm-exegesis][AArch64] Add return statement at the end of the snippet ↵Pavel Kosov1-2/+2
correctly Currently llvm-exegesis fails to do this which causes every snippet to crash ~~ Huawei RRI, OS Lab Reviewed By: courbet Differential Revision: https://reviews.llvm.org/D147699
2022-12-08[exegesis] SnippetRepetitor: Don't access liveness if we disabled itRoman Lebedev1-0/+1
Otherwise, we get: ``` llvm-exegesis: /repositories/llvm-project/llvm/lib/CodeGen/MachineBasicBlock.cpp:1628: MachineBasicBlock::livein_iterator llvm::MachineBasicBlock::livein_begin() const: Assertion `getParent()->getProperties().hasProperty( MachineFunctionProperties::Property::TracksLiveness) && "Liveness information is accurate"' failed. ```
2021-10-06[llvm] Replace report_fatal_error(std::string) uses with ↵Simon Pilgrim1-1/+1
report_fatal_error(Twine) As described on D111049, we're trying to remove the <string> dependency from error handling and replace uses of report_fatal_error(const std::string&) with the Twine() variant which can be forward declared.
2021-09-23Pass some DataLayout arguments by const-refSimon Pilgrim1-1/+1
Avoid unnecessary copies, reported by MSVC static analyzer.
2021-01-06[GlobalISel] Base implementation for sret demotion.Christudasan Devadasan1-1/+6
If the return values can't be lowered to registers SelectionDAG performs the sret demotion. This patch contains the basic implementation for the same in the GlobalISel pipeline. Furthermore, targets should bring relevant changes during lowerFormalArguments, lowerReturn and lowerCall to make use of this feature. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D92953
2020-02-19Recommit: "[llvm-exegesis] Improve error reporting in Assembler.cpp"Miloš Stojanović1-9/+9
Summary: Commit 63bb9fee525f8f29fd9c2174fa7f15573c3d1fd7 was reverted in 7603bfb4b0a6a90137d47f0182a490fe54bf7ca3 because it broke builds that treat warnings as errors. This commit updates the calls to `assembleToStream()` in tests to check that the return value is valid. Original commit message: Followup to D74084. Replace the use of `report_fatal_error()` with returning the error to `llvm-exegesis.cpp` and handling it there. Differential Revision: https://reviews.llvm.org/D74325
2020-02-18Revert "[llvm-exegesis] Improve error reporting in Assembler.cpp"Miloš Stojanović1-9/+9
This reverts https://reviews.llvm.org/rG63bb9fee525f due to buildbot failures: http://lab.llvm.org:8011/builders/clang-ppc64le-rhel/builds/1389
2020-02-18[llvm-exegesis] Improve error reporting in Assembler.cppMiloš Stojanović1-9/+9
Followup to D74085. Replace the use of `report_fatal_error()` with returning the error to `llvm-exegesis.cpp` and handling it there. Differential Revision: https://reviews.llvm.org/D74325
2019-11-13Move CodeGenFileType enum to Support/CodeGen.hReid Kleckner1-1/+1
Avoids the need to include TargetMachine.h from various places just for an enum. Various other enums live here, such as the optimization level, TLS model, etc. Data suggests that this change probably doesn't matter, but it seems nice to have anyway.
2019-11-09llvm-exegesis - fix shadow variable warnings. NFCI.Simon Pilgrim1-2/+2
2019-10-19Prune two MachineInstr.h includes, fix up depsReid Kleckner1-0/+1
MachineInstr.h included AliasAnalysis.h, which includes a world of IR constructs mostly unneeded in CodeGen. Prune it. Same for DebugInfoMetadata.h. Noticed with -ftime-trace. llvm-svn: 375311
2019-10-11[Mips][llvm-exegesis] Add a Mips targetSimon Atanasyan1-1/+3
The target does just enough to be able to run llvm-exegesis in latency mode for at least some opcodes. Patch by Miloš Stojanović. Differential Revision: https://reviews.llvm.org/D68649 llvm-svn: 374590
2019-10-09[llvm-exegesis] Ensure that ExecutableFunction are aligned.Clement Courbet1-6/+10
Summary: Experiments show that this is the alignment we get (for ELF+Linux), but let's ensure that we have it. Reviewers: gchatelet Subscribers: tschuett, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68703 llvm-svn: 374170
2019-10-09[llvm-exegesis][NFC] Remove extra `llvm::` qualifications.Clement Courbet1-104/+92
Summary: Second patch: in the lib. Reviewers: gchatelet Subscribers: nemanjai, tschuett, MaskRay, mgrang, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68692 llvm-svn: 374158
2019-09-30[NewPM] Port MachineModuleInfo to the new pass manager.Yuanfang Chen1-11/+11
Existing clients are converted to use MachineModuleInfoWrapperPass. The new interface is for defining a new pass manager API in CodeGen. Reviewers: fedor.sergeev, philip.pfaffe, chandlerc, arsenm Reviewed By: arsenm, fedor.sergeev Differential Revision: https://reviews.llvm.org/D64183 llvm-svn: 373240
2019-09-27[llvm-exegesis] Add loop mode for repeating the snippet.Clement Courbet1-47/+73
Summary: Before this change the Executable function was made by duplicating the snippet. This change adds a --repetion-mode={loop|duplicate} flag that allows choosing between this behaviour and wrapping the snippet instructions in a loop. The new mode can help measurements when the snippet fits in the DSB by short-cirtcuiting decoding. The loop adds a dec + jmp to the measurements, but since these are not part of the critical path, they execute in parallel with the measured code and do not impact measurements in practice. Overview of the change: - New SnippetRepetitor abstraction that handles repeating the snippet. The assembler delegates repeating the instructions to this class. - ExegesisTarget learns how to decrement loop counter and jump. - Some refactoring of the assembler into FunctionFiller/BasicBlockFiller. Reviewers: gchatelet Subscribers: mgorny, tschuett, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68125 llvm-svn: 373083
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-7/+7
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth1-4/+3
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-11-08Revert "[llvm-exegesis] Add a snippet generator to generate snippets to ↵Clement Courbet1-12/+2
compute ROB sizes." This reverts accidental commit rL346394. llvm-svn: 346398
2018-11-08[llvm-exegesis] Add a snippet generator to generate snippets to compute ROB ↵Clement Courbet1-2/+12
sizes. llvm-svn: 346394
2018-11-05MachineModuleInfo: Store more specific reference to LLVMTargetMachine; NFCMatthias Braun1-1/+3
MachineModuleInfo can only be used in code using lib/CodeGen, hence we can keep a more specific reference to LLVMTargetMachine rather than just TargetMachine around. llvm-svn: 346182
2018-10-22[llvm-exegesis] Move namespace exegesis inside llvm::Fangrui Song1-0/+2
Summary: This allows simplifying references of llvm::foo with foo when the needs come in the future. Reviewers: courbet, gchatelet Reviewed By: gchatelet Subscribers: javed.absar, tschuett, llvm-commits Differential Revision: https://reviews.llvm.org/D53455 llvm-svn: 344922