aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/LiveDebugValues
AgeCommit message (Collapse)AuthorFilesLines
2025-07-10[llvm] export private symbols needed by unittests (#145767)Andrew Rogers1-27/+32
## Purpose Export a small number of private LLVM symbols so that unit tests can still build/run when LLVM is built as a Windows DLL or a shared library with default hidden symbol visibility. ## Background The effort to build LLVM as a WIndows DLL is tracked in #109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307). Some LLVM unit tests use internal/private symbols that are not part of LLVM's public interface. When building LLVM as a DLL or shared library with default hidden symbol visibility, the symbols are not available when the unit test links against the DLL or shared library. This problem can be solved in one of two ways: 1. Export the private symbols from the DLL. 2. Link the unit tests against the intermediate static libraries instead of the final LLVM DLL. This PR applies option 1. Based on the discussion of option 2 in #145448, this option is preferable. ## Overview * Adds a new `LLVM_ABI_FOR_TEST` export macro, which is currently just an alias for `LLVM_ABI`. * Annotates the sub-set of symbols under `llvm/lib` that are required to get unit tests building using the new macro.
2025-06-27[InstrRef] Skip clobbered EntryValue register recovery (#142478)Shubham Sandeep Rastogi1-5/+24
This changes the final stage of InstrRef, i.e. the TransferTracker (which combines the values locations with the variable values), so that it treats a DEBUG_VALUE of an EntryValue just like a DEBUG_VALUE of a constant: a location that is never clobbered and can be propagated to subsequent BBs as long as no other DEBUG_VALUE intrinsics updated the variable. We add two tests here: 1. `entry_value_clobbered_stack_copy` that saves a register on the stack, uses this register as an entry value DBG_VALUE location, and then clobbers it. Prior to this patch, this test would crash because we would try to describe a new location for the variable in terms of what was saved on the stack, and use an invalid expression to do so. This is not needed as an EntryValue can never be clobbered. 2. `entry_value_gets_propagated`, that tests that an EntryValue DBG_VALUE is propagated in a diamond-shaped CFG. This patch is trying to reland https://github.com/llvm/llvm-project/pull/77938 but also fixes the bug with InstrRef based LiveDebugValues, where entry values were not being propagated in a diamond-shaped CFG.
2025-05-22[llvm] Use *Map::try_emplace (NFC) (#141190)Kazu Hirata1-2/+1
try_emplace can default-construct values, so we do not need to do so on our own. Plus, try_emplace(Key) is much simpler/shorter than insert({Key, LongValueType()}).
2025-05-16[CodeGen] Use llvm::lower_bound (NFC) (#140341)Kazu Hirata1-2/+2
2025-05-12[CodeGen] Use llvm::lower_bound (NFC) (#139655)Kazu Hirata1-2/+1
2025-05-05[CodeGen] Use range-based for loops (NFC) (#138488)Kazu Hirata1-4/+2
This is a reland of #138434 except that: - the bits for llvm/lib/CodeGen/RenameIndependentSubregs.cpp have been dropped because they caused a test failure under asan, and - the bits for llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp have been improved with structured bindings.
2025-05-04Revert "[CodeGen] Use range-based for loops (NFC) (#138434)"Nico Weber1-2/+4
This reverts commit a9699a334bc9666570418a3bed9520bcdc21518b. Breaks CodeGen/AMDGPU/collapse-endcf.ll in several configs (sanitizer builds; macOS; possibly more), see comments on https://github.com/llvm/llvm-project/pull/138434
2025-05-04[CodeGen] Use range-based for loops (NFC) (#138434)Kazu Hirata1-4/+2
2025-04-26[llvm] Use llvm::replace (NFC) (#137481)Kazu Hirata1-2/+1
2025-03-29[CodeGen] Use llvm::append_range (NFC) (#133603)Kazu Hirata1-3/+1
2025-03-24[CodeGen][NPM] Port LiveDebugValues to NPM (#131563)Akshat Oke1-16/+47
2025-03-23[CodeGen] Use *Set::insert_range (NFC) (#132651)Kazu Hirata1-2/+1
We can use *Set::insert_range to collapse: for (auto Elem : Range) Set.insert(E); down to: Set.insert_range(Range);
2025-03-20[llvm] Use *Set::insert_range (NFC) (#132325)Kazu Hirata1-4/+4
DenseSet, SmallPtrSet, SmallSet, SetVector, and StringSet recently gained C++23-style insert_range. This patch replaces: Dest.insert(Src.begin(), Src.end()); with: Dest.insert_range(Src); This patch does not touch custom begin like succ_begin for now.
2025-03-18[LiveDebugValues][NFC] Remove TargetPassConfig from LDVImpl (#131562)Akshat Oke5-38/+31
TPC is only used to access the option `ShouldEmitDebugEntryValues`.
2025-03-15[CodeGen] Avoid repeated hash lookups (NFC) (#131422)Kazu Hirata1-6/+8
2025-03-03[CodeGen] Avoid repeated hash lookups (NFC) (#129465)Kazu Hirata1-3/+2
2025-01-23[DebugInfo][InstrRef] Avoid producing broken DW_OP_deref_sizes (#123967)Jeremy Morse1-0/+21
We use variable locations such as DBG_VALUE $xmm0 as shorthand to refer to "the low lane of $xmm0", and this is reflected in how DWARF is interpreted too. However InstrRefBasedLDV tries to be smart and interprets such a DBG_VALUE as a 128-bit reference. We then issue a DW_OP_deref_size of 128 bits to the stack, which isn't permitted by DWARF (it's larger than a pointer). Solve this for now by not using DW_OP_deref_size if it would be illegal. Instead we'll use DW_OP_deref, and the consumer will load the variable type from the stack, which should be correct. There's still a risk of imprecision when LLVM decides to use smaller or larger value types than the source-variable type, which manifests as too-little or too-much memory being read from the stack. However we can't solve that without putting more type information in debug-info. fixes #64093
2025-01-19[CodeGen] Remove some implict conversions of MCRegister to unsigned by ↵Craig Topper2-5/+5
using(). NFC Many of these are indexing BitVectors or something where we can't using MCRegister and need the register number.
2024-12-13Reapply "[DomTreeUpdater] Move critical edge splitting code to updater" ↵paperchalice2-2/+2
(#119547) This relands commit #115111. Use traditional way to update post dominator tree, i.e. break critical edge splitting into insert, insert, delete sequence. When splitting critical edges, the post dominator tree may change its root node, and `setNewRoot` only works in normal dominator tree... See https://github.com/llvm/llvm-project/blob/6c7e5827eda26990e872eb7c3f0d7866ee3c3171/llvm/include/llvm/Support/GenericDomTree.h#L684-L687
2024-12-11Revert "[DomTreeUpdater] Move critical edge splitting code to updater" (#119512)paperchalice2-2/+2
Reverts llvm/llvm-project#115111 Causes #119511
2024-12-11[DomTreeUpdater] Move critical edge splitting code to updater (#115111)paperchalice2-2/+2
Support critical edge splitting in dominator tree updater. Continue the work in #100856. Compile time check: https://llvm-compile-time-tracker.com/compare.php?from=87c35d782795b54911b3e3a91a5b738d4d870e55&to=42b3e5623a9ab4c3648564dc0926b36f3b438a3a&stat=instructions%3Au
2024-11-21[DebugInfo][InstrRef][MIR][GlobalIsel][MachineLICM] NFC Use std::move to ↵abhishek-kaushik221-1/+1
avoid copying (#116935)
2024-11-12[CodeGen] Remove unused includes (NFC) (#115996)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-10-08[LiveDebugValues][NVPTX]VarLocBasedImpl handle vregs, enable for NVPTX (#111456)William G Hatch2-13/+20
This patch handles virtual registers in the VarLocBasedImpl of the LiveDebugVariables pass, allowing it to be used on architectures that depend on virtual registers in debugging, like NVPTX. It enables the pass for NVPTX.
2024-09-30[NFC] Use initial-stack-allocations for more data structures (#110544)Jeremy Morse1-2/+2
This replaces some of the most frequent offenders of using a DenseMap that cause a malloc, where the typical element-count is small enough to fit in an initial stack allocation. Most of these are fairly obvious, one to highlight is the collectOffset method of GEP instructions: if there's a GEP, of course it's going to have at least one offset, but every time we've called collectOffset we end up calling malloc as well for the DenseMap in the MapVector.
2024-09-29[LiveDebugValues] Simplify code with MapVector::insert_or_assign (NFC) (#110398)Kazu Hirata1-6/+2
Note that we must use insert_or_assign because operator[] would require DbgValue to have the default constructor.
2024-09-28[LiveDebugValues] Avoid repeated hash lookups (NFC) (#110379)Kazu Hirata1-6/+4
2024-09-21[LiveDebugValues] Avoid repeated hash lookups (NFC) (#109509)Kazu Hirata1-5/+3
2024-09-19[LiveDebugValues] Avoid repeated hash lookups (NFC) (#109242)Kazu Hirata1-14/+8
2024-09-13[LiveDebugValues] Avoid repeated hash lookups (NFC) (#108484)Kazu Hirata1-5/+3
2024-09-02[CodeGen] Update a few places that were passing Register to ↵Craig Topper1-2/+2
raw_ostream::operator<< (#106877) These would implicitly cast the register to `unsigned`. Switch most of them to use printReg will give a more readable output. Change some others to use Register::id() so we can eventually remove the implicit cast to `unsigned`.
2024-08-23[llvm] Use range-based for loops (NFC) (#105861)Kazu Hirata1-1/+1
2024-08-04[CodeGen] Construct SmallVector with ArrayRef (NFC) (#101841)Kazu Hirata1-2/+1
2024-07-28[llvm] Initialize SmallVector with ranges (NFC) (#100948)Kazu Hirata1-6/+2
2024-07-18suppresses unused variable warning (#99526)Christopher Di Bella1-1/+1
2024-07-18Reapply 078198f310d5 "Index DebugVariables and some DILocations"Jeremy Morse2-125/+187
Now revised to actually make the unit test compile, which I'd been ignoring. No actual functional change, it's a type difference. Original commit message follows. [DebugInfo][InstrRef] Index DebugVariables and some DILocations (#99318) A lot of time in LiveDebugValues is spent computing DenseMap keys for DebugVariables, and they're made up of three pointers, so are large. This patch installs an index for them: for the SSA and value-to-location mapping parts of InstrRefBasedLDV we don't need to access things like the variable declaration or the inlining site, so just use a uint32_t identifier for each variable fragment that's tracked. The compile-time performance improvements are substantial (almost 0.4% on the tracker). About 80% of this patch is just replacing DebugVariable references with DebugVariableIDs instead, however there are some larger consequences. We spend lots of time fetching DILocations when emitting DBG_VALUE instructions, so index those with the DebugVariables: this means all DILocations on all new DBG_VALUE instructions will normalise to the first-seen DILocation for the variable (which should be fine). We also used to keep an ordering of when each variable was seen first in a DBG_* instruction, in the AllVarsNumbering collection, so that we can emit new DBG_* instructions in a stable order. We can hang this off the DebugVariable index instead, so AllVarsNumbering is deleted. Finally, rather than ordering by AllVarsNumbering just before DBG_* instructions are linked into the output MIR, store instructions along with their DebugVariableID, so that they can be sorted by that instead.
2024-07-18Revert "[DebugInfo][InstrRef] Index DebugVariables and some DILocations ↵Jeremy Morse2-182/+125
(#99318)" This reverts commit 078198f310d55925ccd9e1aa5b6ff4af3b36bbc7. Buildbots unhappy, I must have fluffed it
2024-07-18[DebugInfo][InstrRef] Index DebugVariables and some DILocations (#99318)Jeremy Morse2-125/+182
A lot of time in LiveDebugValues is spent computing DenseMap keys for DebugVariables, and they're made up of three pointers, so are large. This patch installs an index for them: for the SSA and value-to-location mapping parts of InstrRefBasedLDV we don't need to access things like the variable declaration or the inlining site, so just use a uint32_t identifier for each variable fragment that's tracked. The compile-time performance improvements are substantial (almost 0.4% on the tracker). About 80% of this patch is just replacing DebugVariable references with DebugVariableIDs instead, however there are some larger consequences. We spend lots of time fetching DILocations when emitting DBG_VALUE instructions, so index those with the DebugVariables: this means all DILocations on all new DBG_VALUE instructions will normalise to the first-seen DILocation for the variable (which should be fine). We also used to keep an ordering of when each variable was seen first in a DBG_* instruction, in the AllVarsNumbering collection, so that we can emit new DBG_* instructions in a stable order. We can hang this off the DebugVariable index instead, so AllVarsNumbering is deleted. Finally, rather than ordering by AllVarsNumbering just before DBG_* instructions are linked into the output MIR, store instructions along with their DebugVariableID, so that they can be sorted by that instead.
2024-07-17[InstrRef][NFC] Avoid another DenseMap, use a sorted vector (#99051)Jeremy Morse1-8/+28
When resolving value-numbers to specific machine locations in the final stages of LiveDebugValues, we've been producing a DenseMap containing all the value-numbers we're interested in. However we never modify the map keys as they're all pre-known. Thus, this is a suitable collection to switch to a sorted vector that gets searched, rather than a DenseMap that gets probed. The overall operation of LiveDebugValues isn't affected at all.
2024-07-17[InstrRef][NFC] Avoid un-necessary DenseMap queries (#99048)Jeremy Morse2-19/+27
This patch adjusts how some data is stored to avoid a number of un-necessary DenseMap queries. There's no change to the compiler behaviour, and it's measurably faster on the compile time tracker. The BlockOrders vector in buildVLocValueMap collects the blocks over which a variables value have to be determined: however the Cmp ordering function makes two DenseMap queries to determine the RPO-order of blocks being compared. And given that sorting is O(N log(N)) comparisons this isn't fast. So instead, fetch the RPO-numbers of the block collection, order those, and then map back to the blocks themselves. The OrderToBB collection mapped an RPO-number to an MBB: it's completely un-necessary to have DenseMap here, we can just use the RPO number as an array index. Switch it to a SmallVector and deal with a few consequences when iterating. (And for good measure I've jammed in a couple of reserve calls).
2024-07-11Revert "[CodeGen] Remove `applySplitCriticalEdges` in `MachineDominatorTree` ↵Nikita Popov2-2/+2
(#97055)" This reverts commit c5e5088033fed170068d818c54af6862e449b545. Causes large compile-time regressions.
2024-07-11[CodeGen] Remove `applySplitCriticalEdges` in `MachineDominatorTree` (#97055)paperchalice2-2/+2
Summary: - Remove wrappers in `MachineDominatorTree`. - Remove `MachineDominatorTree` update code in `MachineBasicBlock::SplitCriticalEdge`. - Use `MachineDomTreeUpdater` in passes which call `MachineBasicBlock::SplitCriticalEdge` and preserve `MachineDominatorTreeWrapperPass` or CFG analyses. Commit abea99f65a97248974c02a5544eaf25fc4240056 introduced related methods in 2014. Now we have SemiNCA based dominator tree in 2017 and dominator tree updater, the solution adopted here seems a bit outdated.
2024-06-30SSAUpdater: use poison instead of undef in phi entries for unreachable ↵Nuno Lopes1-7/+7
predecessors
2024-05-15Fix typo "indicies" (#92232)Jay Foad1-1/+1
2024-03-17[CodeGen] Use LocationSize for MMO getSize (#84751)David Green1-2/+3
This is part of #70452 that changes the type used for the external interface of MMO to LocationSize as opposed to uint64_t. This means the constructors take LocationSize, and convert ~UINT64_C(0) to LocationSize::beforeOrAfter(). The getSize methods return a LocationSize. This allows us to be more precise with unknown sizes, not accidentally treating them as unsigned values, and in the future should allow us to add proper scalable vector support but none of that is included in this patch. It should mostly be an NFC. Global ISel is still expected to use the underlying LLT as it needs, and are not expected to see unknown sizes for generic operations. Most of the changes are hopefully fairly mechanical, adding a lot of getValue() calls and protecting them with hasValue() where needed.
2024-01-16[NFC] sentinal -> sentinelDavid Green1-2/+2
2024-01-11[InstrRef] Add debug hint for not reachable blocks from entry (#77725)HaohaiWen1-1/+8
Those not reachable blocks was not analyzed by LiveDebugValues and may raise out of bound access to VarLocs as case in #77441.
2023-12-23[LiveDebugValues][nfc] Reduce memory usage of InstrRef (#76051)Felipe de Azevedo Piovezan2-31/+65
Commit 1b531d54f623 (#74203) removed the usage of unique_ptrs of arrays in favour of using vectors, but inadvertently increased peak memory usage by removing the ability to deallocate vector memory that was no longer needed mid-LDV. In that same review, it was pointed out that `FuncValueTable` typedef could be removed, since it was "just a vector". This commit addresses both issues by making `FuncValueTable` a real data structure, capable of mapping BBs to ValueTables and able to free ValueTables as needed. This reduces peak memory usage in the compiler by 10% in the benchmarks flagged by the original review. As a consequence, we had to remove a handful of instances of the "declare-then-initialize" antipattern in unittests, as the FuncValueTable class is no longer default-constructible.
2023-12-18[InstrRef][NFC] Delete unused variables (#75501)Felipe de Azevedo Piovezan1-9/+2
`V` was unused, and all the other deletions follow from that observation.
2023-12-14[InstrRef][nfc] Remove usage of unique_ptrs of arrays (#74203)Felipe de Azevedo Piovezan2-41/+36
These are usually difficult to reason about, and they were being used to pass raw pointers around with array semantic (i.e., we were using operator [] on raw pointers). To put it in InstrRef terminology: we were passing a pointer to a ValueTable but using it as if it were a FuncValueTable. These could have easily been SmallVectors, which now allow us to have reference semantics in some places, as well as simpler initialization. In the future, we can use even more pass-by-reference with some extra changes in the code.