aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Analysis
AgeCommit message (Collapse)AuthorFilesLines
7 days[IR] Check identical alignment for atomic instructions (#155349)Ellis Hoag1-0/+3
I noticed that `hasSameSpecialState()` checks alignment for `load`/`store` instructions, but not for `cmpxchg` or `atomicrmw`, which I assume is a bug. It looks like alignment for these instructions were added in https://github.com/llvm/llvm-project/commit/74c723757e69fbe7d85e42527d07b728113699ae.
10 days[LLVM][SCEV] Look through common vscale multiplicand when simplifying ↵Paul Walker1-0/+137
compares. (#141798) My usecase is simplifying the control flow generated by LoopVectorize when vectorising loops whose tripcount is a function of the runtime vector length. This can be problematic because: * CSE is a pre-LoopVectorize transform and so it's common for an IR function to include several calls to llvm.vscale(). (NOTE: Code generation will typically remove the duplicates) * Pre-LoopVectorize instcombines will rewrite some multiplies as shifts. This leads to a mismatch between VL based maths of the scalar loop and that created for the vector loop, which prevents some obvious simplifications. SCEV does not suffer these issues because it effectively does CSE during construction and shifts are represented as multiplies.
2025-09-05[MemProf] Add ambigous memprof attribute (#157204)Teresa Johnson1-7/+14
To help track allocations that we matched with memprof profiles but for which we weren't able to disambiguate the different hotness contexts, apply an "ambiguous" memprof attribute to all allocations with matched profiles. These will be replaced if we can identify a single hotness type, possibly after cloning. Eventually we plan to translate this to a special hotness hint on the allocation call.
2025-09-05[LV] Add initial legality checks for loops with unbound loads. (#152422)Shih-Po Hung1-5/+10
This patch splits out the legality checks from PR #151300, following the landing of PR #128593. It is a step toward supporting vectorization of early-exit loops that contain potentially faulting loads. In this commit, an early-exit loop is considered legal for vectorization if it satisfies the following criteria: 1. it is a read-only loop. 2. all potentially faulting loads are unit-stride, which is the only type currently supported by vp.load.ff.
2025-09-03IR2VecTest.cpp: Suppress a warning. [-Wunused-const-variable]NAKAMURA Takumi1-0/+1
2025-08-29[NFC][IR2Vec] Change getSlotIndex parameter from Value* to Value& (#155700)S. VenkataKeerthy1-4/+4
2025-08-29[IR2Vec] Refactor vocabulary to use canonical type IDs (#155323)S. VenkataKeerthy1-95/+118
Refactor IR2Vec vocabulary to use canonical type IDs, improving the embedding representation for LLVM IR types. The previous implementation used raw Type::TypeID values directly in the vocabulary, which led to redundant entries (e.g., all float variants mapped to "FloatTy" but had separate slots). This change improves the vocabulary by: 1. Making the type representation more consistent by properly canonicalizing types 2. Reducing vocabulary size by eliminating redundant entries 3. Improving the embedding quality by ensuring similar types share the same representation (Tracking issue - #141817)
2025-08-28[IR2Vec] Add support for flow-aware embeddings (#152613)S. VenkataKeerthy1-5/+69
This patch introduces support for Flow-Aware embeddings in IR2Vec, which capture data flow information in addition to symbolic representations.
2025-08-10[IR] Handle fabs LHS in `fcmpImpliesClass` (#152913)Yingwei Zheng1-0/+36
Closes https://github.com/llvm/llvm-project/issues/152824.
2025-08-08[IR] Introduce the `ptrtoaddr` instructionAlexander Richardson1-10/+12
This introduces a new `ptrtoaddr` instruction which is similar to `ptrtoint` but has two differences: 1) Unlike `ptrtoint`, `ptrtoaddr` does not capture provenance 2) `ptrtoaddr` only extracts (and then extends/truncates) the low index-width bits of the pointer For most architectures, difference 2) does not matter since index (address) width and pointer representation width are the same, but this does make a difference for architectures that have pointers that aren't just plain integer addresses such as AMDGPU fat pointers or CHERI capabilities. This commit introduces textual and bitcode IR support as well as basic code generation, but optimization passes do not handle the new instruction yet so it may result in worse code than using ptrtoint. Follow-up changes will update capture tracking, etc. for the new instruction. RFC: https://discourse.llvm.org/t/clarifiying-the-semantics-of-ptrtoint/83987/54 Reviewed By: nikic Pull Request: https://github.com/llvm/llvm-project/pull/139357
2025-08-08[IR] Remove size argument from lifetime intrinsics (#150248)Nikita Popov1-2/+2
Now that #149310 has restricted lifetime intrinsics to only work on allocas, we can also drop the explicit size argument. Instead, the size is implied by the alloca. This removes the ability to only mark a prefix of an alloca alive/dead. We never used that capability, so we should remove the need to handle that possibility everywhere (though many key places, including stack coloring, did not actually respect this).
2025-08-05[MemoryLocation] Compute lifetime size from alloca size (#151982)Nikita Popov1-20/+15
Split out from #150248: Since #150944 the size passed to lifetime.start/end is considered meaningless. The lifetime always applies to the whole alloca. This adjusts MemoryLocation to determine the MemoryLocation size from the alloca size, instead of using the argument.
2025-07-31[llvm] Enable building Analysis plugins on Cygwin (#151397)jeremyd20192-2/+2
In #112303 they were enabled for Windows dylib builds, but the condition excluded Cygwin in that case. Their dynamic libraries work the same way, so adjust the condition accordingly. This fixes the plugin tests on Cygwin.
2025-07-28[IR2VecTest] Avoid magic constantsAlexander Richardson1-3/+3
Instead make the members of Vocabulary public. This was causing test failures with https://github.com/llvm/llvm-project/pull/139357. Reviewed By: svkeerthy, boomanaiden154 Pull Request: https://github.com/llvm/llvm-project/pull/150878
2025-07-19[InstSimplify] Add poison propagation for trivially vectorizable intrinsics ↵Jasmine Tang1-14/+14
(#149243) Fixes https://github.com/llvm/llvm-project/issues/146769 Test cases added to `llvm/test/Transforms/InstSimplify/fold-intrinsics.ll`
2025-07-17[IR2Vec][NFC] Add helper methods for numeric ID mapping in Vocabulary (#149212)S. VenkataKeerthy1-0/+63
Add helper methods to IR2Vec's Vocabulary class for numeric ID mapping and vocabulary size calculation. These APIs will be useful in triplet generation for `llvm-ir2vec` tool (See #149214). (Tracking issue - #141817)
2025-07-16[InstSimplify] Fold trig functions call of poison to poison (#148969)jjasmine1-2/+2
Fold trig functions call of poison to poison. This includes sin, cos, asin, acos, atan, atan2, sinh, cosh, sincos, sincospi. Test cases are fixed and also added to llvm/test/Transforms/InstSimplify/fold-intrinsics.ll just like in https://github.com/llvm/llvm-project/pull/146750
2025-07-14[IR2Vec] Restructuring Vocabulary (#145119)S. VenkataKeerthy2-104/+151
This PR restructures the vocabulary. * String based look-ups are removed. Vocabulary is changed from a map to vector. (#141832) * Grouped all the vocabulary related methods under a single class - `ir2vec::Vocabulary`. This replaces `IR2VecVocabResult`. * `ir2vec::Vocabulary` effectively abstracts out the _layout_ and other internal details of the vector structure. Exposes necessary APIs for accessing the Vocabulary. These changes ensure that _all_ known opcodes and types are present in the vocabulary. We have retained the original operands. This can be extended going forward. (Tracking issue - #141817)
2025-07-11[SCEV] Take global variable linkage into account when comparing values (#148071)Arthur Eubanks1-0/+30
Current the comparator is inconsistent when we have two external globals and one internal globals due to ``` if (IsGVNameSemantic(LGV) && IsGVNameSemantic(RGV)) return LGV->getName().compare(RGV->getName()); ``` The internal global compares equal to (not strictly less than) the external globals, but the external globals are not equal. Fixes #147862.
2025-07-04[InstCombine] Propagate poison pow[i], [us]add, [us]sub and [us]mul (#146750)jjasmine1-2/+2
Fixes #146560 as well as propagate poison for [us]add, [us]sub and [us]mul
2025-07-04[ConstantFolding] Consolidate poison propagation for intrinsics (#146878)Nikita Popov1-1/+1
This consolidates the "fold poison arg to poison result" constant folding logic for intrinsics, based on a common intrinsicPropagatesPoison() helper, which is also used for poison propagation reasoning in ValueTracking. This ensures that the set of supported intrinsics is consistent. This add ucmp, scmp, smul.fix, smul.fix.sat, canonicalize and sqrt to the intrinsicPropagatesPoison list, as these were handled by ConstantFolding but not ValueTracking. The ctpop test is an example of the converse, where it was handled by ValueTracking but not ConstantFolding.
2025-07-02[Analysis] Remove a redundant control flow statement (NFC) (#146708)Kazu Hirata1-1/+0
2025-07-01[IR2Vec] Add out-of-place arithmetic operators to Embedding class (#145118)S. VenkataKeerthy1-0/+39
This PR adds out-of-place arithmetic operators (`+`, `-`, `*`) to the `Embedding` class in IR2Vec, complementing the existing in-place operators (`+=`, `-=`, `*=`). Tests have been added to verify the functionality of these new operators. (Tracking issue - #141817)
2025-07-01[NFC][IR2Vec] Increasing tolerance in `approximatelyEquals()` of `Embedding` ↵S. VenkataKeerthy1-2/+2
(#145117) Increase the default tolerance for `approximatelyEquals` in IR2Vec's Embedding class from 1e-6 to 1e-4. (Tracking issue - #141817)
2025-07-01Fix MSVC implicit double -> float truncation warning. NFC.Simon Pilgrim1-2/+2
2025-06-30[NFC][IR2Vec] Remove unreachable code and simplify invalid mode test (#146459)S. VenkataKeerthy1-8/+1
The code following `llvm_unreachable` is optimized out in Release builds. In this case, `Embedder::create` do not seem to return `nullptr` causing `CreateInvalidMode` test to break. Hence removing `llvm_unreachable`.
2025-06-30[Analysis] Fix a warningKazu Hirata1-1/+1
This patch fixes: llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp:132:12: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
2025-06-30[IR2Vec] Simplifying creation of Embedder (#143999)S. VenkataKeerthy2-31/+20
This change simplifies the API by removing the error handling complexity. - Changed `Embedder::create()` to return `std::unique_ptr<Embedder>` directly instead of `Expected<std::unique_ptr<Embedder>>` - Updated documentation and tests to reflect the new API - Added death test for invalid IR2Vec kind in debug mode - In release mode, simply returns nullptr for invalid kinds instead of creating an error (Tracking issue - #141817)
2025-06-30[IR2Vec] Scale embeddings once in vocab analysis instead of repetitive ↵S. VenkataKeerthy1-33/+9
scaling (#143986) Changes to scale opcodes, types and args once in `IR2VecVocabAnalysis` so that we can avoid scaling each time while computing embeddings. This PR refactors the vocabulary to explicitly define 3 sections---Opcodes, Types, and Arguments---used for computing Embeddings. (Tracking issue - #141817 ; partly fixes - #141832)
2025-06-30Reland "[MLGO][IR2Vec] Integrating IR2Vec with MLInliner (#143479)" (#145664)S. VenkataKeerthy1-1/+119
Relanding #143479 after fixes. Removed `NumberOfFeatures` from the `FeatureIndex` enum as the number of features used depends on whether IR2Vec embeddings are used.
2025-06-28[ValueTracking] Forward-declare class instead of including header (NFC)Antonio Frighetto1-0/+1
The header inclusion was previously causing a build time regression.
2025-06-27[ValueTracking] Add `matchSimpleBinaryIntrinsicRecurrence` helperAntonio Frighetto1-0/+52
Similarly to what it is being done to match simple recurrence cycle relations, attempt to match value-accumulating recurrences of kind: ``` %umax.acc = phi i8 [ %umax, %backedge ], [ %a, %entry ] %umax = call i8 @llvm.umax.i8(i8 %umax.acc, i8 %b) ``` Preliminary work to let InstCombine avoid folding such recurrences, so that simple loop-invariant computation may get hoisted. Minor opportunity to refactor out code as well.
2025-06-26TargetLibraryInfo: Delete default TargetLibraryInfoImpl constructor (#145826)Matt Arsenault11-11/+15
It should not be possible to construct one without a triple. It would also be nice to delete TargetLibraryInfoWrapperPass, but that is more difficult.
2025-06-25[llvm] annotate remaining Analysis library interfaces for DLL export (#145359)Andrew Rogers1-1/+2
2025-06-24Revert "[MLGO][IR2Vec] Integrating IR2Vec with MLInliner (#143479)" (#145418)S. VenkataKeerthy1-119/+1
This reverts commit af2c06ecd610735dfa5d236c6d5f109e4f2334e6 as it causes failure of lit test (Transforms/Inline/ML/interactive-mode.ll)
2025-06-23[MLGO][IR2Vec] Integrating IR2Vec with MLInliner (#143479)S. VenkataKeerthy1-14/+131
Changes to use Symbolic embeddings in MLInliner. (Fixes #141836, Tracking issue - #141817)
2025-06-23[TLI] Add support for pvalloc() (#144949)Marco Elver1-0/+1
While pvalloc() is a legacy POSIX function, it remains widely available in common C libraries like glibc. Model pvalloc() in TargetLibraryInfo, allowing LLVM to correctly infer its attributes.
2025-06-13[IR2Vec] Minor vocab changes and exposing weights (#143200)S. VenkataKeerthy1-35/+102
This PR changes some asserts in Vocab to hard checks that emit error and exposes flags and constructor to help in unit tests. (Tracking issue - #141817)
2025-06-10[IR2Vec] Exposing Embedding as an data type wrapped around ↵S. VenkataKeerthy1-43/+165
std::vector<double> (#143197) Currently `Embedding` is `std::vector<double>`. This PR makes it a data type wrapped around `std::vector<double>` to overload basic arithmetic operators and expose comparison operations. It _simplifies_ the usage here and in the passes where operations on `Embedding` would be performed. (Tracking issue - #141817)
2025-06-09[DebugInfo][RemoveDIs] Rip out the UseNewDbgInfoFormat flag (#143207)Jeremy Morse1-3/+0
Start removing debug intrinsics support -- starting with the flag that controls production of their replacement, debug records. This patch removes the command-line-flag and with it the ability to switch back to intrinsics. The module / function / block level "IsNewDbgInfoFormat" flags get hardcoded to true, I'll to incrementally remove things that depend on those flags.
2025-06-09[ValueTracking] Update `Ordered` when both operands are non-NaN. (#143349)Yingwei Zheng1-0/+9
When the original predicate is ordered and both operands are non-NaN, `Ordered` should be set to true. This variable still matters even if both operands are non-NaN because FMF only applies to select, not fcmp. Closes https://github.com/llvm/llvm-project/issues/143123.
2025-06-03[ValueTracking] Make Depth last default arg (NFC) (#142384)Ramkumar Ramachandra1-47/+44
Having a finite Depth (or recursion limit) for computeKnownBits is very limiting, but is currently a load-bearing necessity, as all KnownBits are recomputed on each call and there is no caching. As a prerequisite for an effort to remove the recursion limit altogether, either using a clever caching technique, or writing a easily-invalidable KnownBits analysis, make the Depth argument in APIs in ValueTracking uniformly the last argument with a default value. This would aid in removing the argument when the time comes, as many callers that currently pass 0 explicitly are now updated to omit the argument altogether.
2025-06-02[NFC][IR2Vec] Removing Dimension from `Embedder::Create` (#142486)S. VenkataKeerthy1-6/+5
This PR removes the necessity to know the dimension of the embeddings while invoking `Embedder::Create`. Having the `Dimension` parameter introduces complexities in downstream consumers. (Tracking issue - #141817)
2025-06-02[ValueTracking] Do not use FMF from fcmp (#142266)Yingwei Zheng1-6/+5
This patch introduces an FMF parameter for `matchDecomposedSelectPattern` to pass FMF flags from select, instead of fcmp. Closes https://github.com/llvm/llvm-project/issues/137998. Closes https://github.com/llvm/llvm-project/issues/141017.
2025-05-29[IR2Vec] Support for lazy computation of BB Embeddings (#142033)S. VenkataKeerthy1-0/+10
This PR exposes interfaces to compute embeddings at BB level. This would be necessary for delta patching the embeddings in MLInliner (#141836). (Tracking issue - #141817)
2025-05-29[IR2Vec] Adding unit tests (#141873)S. VenkataKeerthy2-0/+244
This PR adds unit tests for IR2Vec (Tracking issue - #141817)
2025-05-29[DirectX] Update resource type names in DXIL metadata to include element ↵Helena Kotas1-3/+5
type (#140937) Update resource type names for globals variables that we generate in `DXILTranslateMetadata` pass to include element type. This change prevents duplicate types for identical resources and brings the DXIL metadata names it closer to what DXC generates.
2025-05-28[MemProf] Add basic summary section support (#141805)Teresa Johnson1-70/+1
This patch adds support for a basic MemProf summary section, which is built along with the indexed MemProf profile (e.g. when reading the raw or YAML profiles), and serialized through the indexed profile just after the header. Currently only 6 fields are written, specifically the number of contexts (total, cold, hot), and the max context size (cold, warm, hot). To support forwards and backwards compatibility for added fields in the indexed profile, the number of fields serialized first. The code is written to support forwards compatibility (reading newer profiles with additional summary fields), and comments indicate how to implement backwards compatibility (reading older profiles with fewer summary fields) as needed. Support is added to print the summary as YAML comments when displaying both the raw and indexed profiles via `llvm-profdata show`. Because they are YAML comments, the YAML reader ignores these (the summary is always recomputed when building the indexed profile as described above). This necessitated moving some options and a couple of interfaces out of Analysis/MemoryProfileInfo.cpp and into the new ProfileData/MemProfSummary.cpp file, as we need to classify context hotness earlier and also compute context ids to build the summary from older indexed profiles.
2025-05-28[DirectX] Gather resource names in DXIL resource analysis (#140633)Helena Kotas1-43/+30
Gather resource names from `llvm.dx.resource.handlefrombinding` calls during DXIL resource analysis and add them to `DXILResourceMap`. Part 3/4 of llvm/llvm-project#105059
2025-05-27[llvm] annotate interfaces in llvm/Analysis for DLL export (#136623)Andrew Rogers5-12/+17
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the `llvm/Analysis` library. These annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. ## Background This effort is tracked in #109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). The bulk of these changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. The following manual adjustments were also applied after running IDS on Linux: - Add `#include "llvm/Support/Compiler.h"` to files where it was not auto-added by IDS due to no pre-existing block of include statements. - Add `LLVM_TEMPLATE_ABI` and `LLVM_EXPORT_TEMPLATE` to exported instantiated templates - Add `LLVM_ABI` to a subset of private class methods and fields that require export - Add `LLVM_ABI` to a small number of symbols that require export but are not declared in headers ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang