aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Analysis
AgeCommit message (Collapse)AuthorFilesLines
3 days[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`
5 days[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)
7 days[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
8 days[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)
11 days[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
2025-05-27IR: Make Module::getOrInsertGlobal() return a GlobalVariable.Peter Collingbourne1-2/+1
After pointer element types were removed this function can only return a GlobalVariable, so reflect that in the type and comments and clean up callers. Reviewers: nikic Reviewed By: nikic Pull Request: https://github.com/llvm/llvm-project/pull/141323
2025-05-22Reland [llvm] add GenericFloatingPointPredicateUtils #140254 (#141065)Tim Gymnich1-0/+1
#140254 was previously missing 2 files in the bazel build config.
2025-05-21Revert "[llvm] add GenericFloatingPointPredicateUtils (#140254)" (#140968)Kewen121-1/+0
This reverts commit d00d74bb2564103ae3cb5ac6b6ffecf7e1cc2238. The PR breaks our buildbots and blocks downstream merge.
2025-05-21[llvm] add GenericFloatingPointPredicateUtils (#140254)Tim Gymnich1-0/+1
add `GenericFloatingPointPredicateUtils` in order to generalize effects of floating point comparisons on `KnownFPClass` for both IR and MIR. --------- Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-05-08[MemProf] Simplify unittest save and restore of options (#139117)Teresa Johnson1-4/+8
Address post-commit review feedback for PR139092 (and fix another instance of the same code). Save and restore option values via a saved bool value, instead of invoking cl::ResetAllOptionOccurrences.
2025-05-08[MemProf] Fix bug introduced by restructuring in optional handling (#139092)Teresa Johnson1-0/+73
The restructuring of the context pruning patch in PR138792 (764614e6355e214c6b64c715d105007b1a4b97fd) introduced a bug under the non-default -memprof-keep-all-not-cold-contexts handling. Added more testing of this mode which would have caught the issue. While here, fix the newly added function name to match code style.
2025-05-07ValueTracking: Handle minimumnum and maximumnum in computeKnownFPClass (#138737)Matt Arsenault1-0/+56
For now use the same treatment as minnum/maxnum, but these should diverge. alive2 seems happy with this, except for some preexisting bugs with weird denormal modes.
2025-05-04[llvm] Remove unused local variables (NFC) (#138454)Kazu Hirata1-1/+0
2025-04-18unittests: Avoid using getNumUses (#136352)Matt Arsenault2-2/+2
2025-04-18[FlattenCFG] Fix an Imprecise Usage of AA (#128117)Chengjun1-0/+15
In current `FlattenCFG`, using `isNoAlias` for two instructions is imprecise. For example, when passing a store instruction and a load instruction directly into `AA->isNoAlias`, it will always return `NoAlias`. This happens because when checking the types of the two Values, the store instruction (which has a `void` type) causes the analysis to return `NoAlias`. For instructions, we should use `getModRefInfo` instead of `isNoAlias`, as aliasing is a concept of memory locations. In this patch, `AAResults::getModRefInfo` is supported to take in two instructions. It will check whether two instructions may access the same memory location or not. And in `FlattenCFG`, we use this new helper function to do the check instead of `isNoAlias`. Unit tests and lit tests are also included to this patch.
2025-04-17[TLI] Use AArch64 vector calling convention for ArmPL routines (#135790)David Sherwood1-3/+3
Some ArmPL vector math routines that operate on fixed-width vector types obey the aarch64_vector_pcs calling convention, e.g. armpl_vsinq_f64, etc. This patch adds support for functions in the TLI to specify an optional calling convention to be added to the declared function. Once this patch lands I intend to follow up with a vectoriser patch that adds this optional calling convention when invoking the vector library variant from the loop vectoriser.
2025-04-14[HLSL] Move Resource Instance Properties from TypeInfo (#135259)Ashley Coleman1-19/+24
Fixes https://github.com/llvm/llvm-project/issues/134741 Moves Resource Instance properties from type info into resource info as described in https://github.com/llvm/wg-hlsl/blob/main/proposals/0022-resource-instance-analysis.md
2025-04-10[NFC][HLSL] Refactor DXILResourceTest for upcoming PR (#134952)Ashley Coleman1-294/+310
Local changes were getting pretty large and complex so this is an NFC refactor PR to simplify the upcoming changes
2025-04-09[DebugInfo][RemoveDIs] Eliminate another debug-info variation flag (#133917)Jeremy Morse1-1/+0
The "preserve input debug-info format" flag allowed some tooling to opt into not seeing the new debug records yet, and to not autoupgrade. This was good at the time, but un-necessary now that we'll be ditching intrinsics shortly. It also hides errors now: verify-uselistorder was hardcoding this flag to on, and as a result it hasn't seen debug records before. Thus, we missed a uselistorder variation: constant-expressions such as GEPs can be contained within debug records and completely isolated from the value hierachy, see the metadata-use-uselistorder.ll test. These Values didn't get ordered, but were legitimate uses of constants like "i64 0", and we now run into difficulty handling that. The patch to AsmWriter seeks Values to order even through debug-info now. Finally there are a few intrinsics-tests relying on this flag that we can just delete, such as one in llvm-reduce and another few in the LocalTest unit tests. For the fast-isel test, it was added in https://reviews.llvm.org/D67703 explicitly for checking the size of blocks without debug-info and in 1525abb9c94 the codepath it tests moved towards being sunsetted. It'll be totally redundant once RemoveDIs is on permanently. Note that there's now no explicit test for the textual-IR autoupgrade path. I submit that we can rely on the thousands of .ll files where we've only been bothered to update the outputs, not the inputs, to debug records.