aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/Lint.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-09-10[LLVM][LangRef] Remove "n > 0" restriction from get.active.lanes.mask. (#152140)Paul Walker1-7/+0
The specification for get.active.lanes.mask says a limit value of zero results in poison. This seems like an artificial restriction and means you cannot use the intrinsic to create minimal loops of the form: ``` foo(int count, ....) { int i = 0; while (mask = get.active.lane.mask(i, count)) { ; do work i += count_bits(mask); } } ``` I cannot see any code that generates poison in this case, in fact ConstantFoldFixedVectorCall returns the logical result (i.e. an all false vector). There are also cases like `can_overflow_i64_induction_var` in sve-tail-folding-overflow-checks.ll that look broken by the current definition? for the case when "%N <= vscale * 4".
2025-06-03[ValueTracking] Make Depth last default arg (NFC) (#142384)Ramkumar Ramachandra1-2/+1
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-05-05[IntrinsicInst] Remove MemCpyInlineInst and MemSetInlineInst [nfc] (#138568)Philip Reames1-8/+2
I'm looking for ways to simplify the Mem*Inst class structure, and these two seem to have fairly minimal justification, so let's remove them.
2025-03-31Lint: Replace -lint-abort-on-error cl::opt with pass parameter (#132933)Matt Arsenault1-13/+14
2025-03-06[IR] Store Triple in Module (NFC) (#129868)Nikita Popov1-3/+3
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-08[Lint] Lint mismatch in ABI attributes (#121929)Nikita Popov1-0/+24
Detect cases where ABI attributes between the call-site and the called function differ. For now this only handles argument attributes. Inspired by https://discourse.llvm.org/t/difference-between-call-site-attributes-and-declaration-attributes/83902.
2024-09-25[Lint][AMDGPU] No store to const addrspace (#109181)jofrn1-2/+21
Ensure store to const addrspace is not allowed by Linter.
2024-09-04[Lint] Skip null args when checking noaliasNikita Popov1-1/+2
Do not emit a warning if there are two null noalias arguments, as they cannot be dereferenced anyway. This is a common pattern for `@.omp_outlined`, which has some optional noalias arguments.
2024-09-04[Lint] Fix another scalable vector crashNikita Popov1-1/+2
We also need to check that the memory access LocationSize is not scalable.
2024-09-04[Lint] Fix crash for insert/extract on scalable vectorNikita Popov1-8/+9
Don't assume the vector is fixed size. For scalable vectors, do not report an error, as indices outside the minimum range may be valid.
2024-09-04[Lint] Fix crash with scalable allocaNikita Popov1-2/+2
2024-07-16Reapply "[Intrinsics][PreISelInstrinsicLowering] llvm.memcpy.inline length ↵Alex Bradbury1-18/+2
no longer needs to be constant (#98281)" This reverts commit ac4b6b662630cd4d3bf6929f2b39ea203c0054a1. A test change was missing for mlir/test/Target/LLVMIR/llvmir-intrinsics.mlir in the initial commit.
2024-07-16Revert "[Intrinsics][PreISelInstrinsicLowering] llvm.memcpy.inline length no ↵Alex Bradbury1-2/+18
longer needs to be constant (#98281)" This reverts commit 522fd53838d577add8c19b5eccccae756fd27899 while unexpected mlir failures are investigated and resolved.
2024-07-16[Intrinsics][PreISelInstrinsicLowering] llvm.memcpy.inline length no longer ↵Alex Bradbury1-18/+2
needs to be constant (#98281) Following on from the discussion in https://discourse.llvm.org/t/rfc-introducing-an-llvm-memset-pattern-inline-intrinsic/79496 and the equivalent change for llvm.memset.inline (#95397), this removes the requirement that the length of llvm.memcpy.inline is constant. PreISelInstrinsicLowering will expand llvm.memcpy.inline with non-constant lengths, while the codegen path for constant lengths is left unaltered.
2024-06-28[IR] Add getDataLayout() helpers to Function and GlobalValue (#96919)Nikita Popov1-1/+1
Similar to https://github.com/llvm/llvm-project/pull/96902, this adds `getDataLayout()` helpers to Function and GlobalValue, replacing the current `getParent()->getDataLayout()` pattern.
2024-06-27[IR] Add getDataLayout() helpers to BasicBlock and Instruction (#96902)Nikita Popov1-4/+4
This is a helper to avoid writing `getModule()->getDataLayout()`. I regularly try to use this method only to remember it doesn't exist... `getModule()->getDataLayout()` is also a common (the most common?) reason why code has to include the Module.h header.
2024-06-24[Lint] Use poison instead of undef for self-referential valuesNikita Popov1-1/+1
2024-04-16Reapply "[Verifier] Reject va_start in non-variadic function (#88809)"Jon Chesterfield1-4/+1
This reverts commit f4960da6023b8034ae68925c3223d51624621b37. Includes a fix for the MLIR test case.
2024-04-16Revert "[Verifier] Reject va_start in non-variadic function (#88809)"Jon Chesterfield1-1/+4
This reverts commit 61717c1aa1f08eb57839a21fb2d9004739022e0d. Failed a MLIR test
2024-04-16[Verifier] Reject va_start in non-variadic function (#88809)Jon Chesterfield1-4/+1
A va_start intrinsic lowers to something derived from the variadic parameter to the function. If there is no such parameter, it can't lower meaningfully. Clang sema rejects the same with `error: 'va_start' used in function with fixed args`. Moves the existing lint warning into a verifier error. Updates the one lit test that had a va_start in a non-variadic function.
2024-02-20[Lint] Add option --lint-abort-on-error (#81999)Jannik Silvanus1-0/+9
This option makes the lint pass abort if errors were found. This is intended to help lit testing where the lint pass is used and lint errors should be detected. Previously, this required checking for non-empty stderr.
2024-01-24[Loads] Use BatchAAResults for available value APIs (NFCI)Nikita Popov1-1/+2
This allows caching AA queries both within and across the calls, and enables us to use a custom AAQI configuration.
2023-08-14[Lint] Permit aliasing noalias and readnone argumentsBjorn Pettersson1-0/+4
If an argument is readnone we know that it isn't dereferenced. Then it should be OK if that argument alias with a noalias argument. Differential Revision: https://reviews.llvm.org/D157737
2023-05-29[Analysis] Remove unused declarations visitEHBeginCatch and visitEHEndCatchKazu Hirata1-2/+0
The corresponding function definitions were removed by: commit 14e773500e036de57ed0ca4af6fddc1f8b6767d8 Author: Reid Kleckner <rnk@google.com> Date: Fri Oct 9 23:34:53 2015 +0000
2023-05-16Remove some includes that shouldn't be needed any longerBjorn Pettersson1-3/+0
This remove a bunch of #include statements in Scalar.cpp. I do not think those should be needed any longer (assuming that they once upon a time possibly were needed for legacy PM C bindings, but that is not supported any longer). Also removing some other #include statements not needed any longer due to deprecation of legacy PM. Differential Revision: https://reviews.llvm.org/D149438
2023-04-21[Lint] Remove legacy passArthur Eubanks1-54/+19
2023-02-06Revert "[Lint] Use new PM instead of legacy PM in lintFunction and lintModule"Bjorn Pettersson1-25/+9
This reverts commit 525ed98be483188db6dc3bb69cecd0123148ceca. Some buildbots are failing when linking bugpoint. Reverting to investigate that further.
2023-02-06[Lint] Use new PM instead of legacy PM in lintFunction and lintModuleBjorn Pettersson1-9/+25
There are some helpers in the Lint analysis pass that will setup a pass manager and then run the Lint pass on a given Function/Module. Those have been using the LegacyPassManager, but as a small step towards removing the deprecated legacy pass manager this patch is changing those helpers into using the new pass manager instead. No idea if anyone is really is using those helpers. Maybe an alternative had been to just remove them. There is at least no unit tests or similar that verifies that they work, so I validated this patch by using a hacked opt binary that called those functions before running the normal pipeline. Differential Revision: https://reviews.llvm.org/D143388
2022-12-02[Analysis] Use std::nullopt instead of None (NFC)Kazu Hirata1-15/+15
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-07-16[Analysis] Qualify auto variables in for loops (NFC)Kazu Hirata1-1/+1
2022-06-29[ConstExpr] Remove more leftovers of extractvalue expression (NFC)Nikita Popov1-5/+0
Remove some leftover bits of extractvalue handling after the removal in D125795.
2022-06-10[clang] Add support for __builtin_memset_inlineGuillaume Chatelet1-0/+6
In the same spirit as D73543 and in reply to https://reviews.llvm.org/D126768#3549920 this patch is adding support for `__builtin_memset_inline`. The idea is to get support from the compiler to easily write efficient memory function implementations. This patch could be split in two: - one for the LLVM part adding the `llvm.memset.inline.*` intrinsics. - and another one for the Clang part providing the instrinsic as a builtin. Differential Revision: https://reviews.llvm.org/D126903
2022-06-09[NFC] format InstructionSimplify & lowerCaseFunctionNamesSimon Moll1-1/+1
Clang-format InstructionSimplify and convert all "FunctionName"s to "functionName". This patch does touch a lot of files but gets done with the cleanup of InstructionSimplify in one commit. This is the alternative to the less invasive clang-format only patch: D126783 Reviewed By: spatel, rengolin Differential Revision: https://reviews.llvm.org/D126889
2022-04-05[Lint][Verifier] NFC: Rename 'Assert*' macros to 'Check*'.Tom Honermann1-101/+103
The LLVM IR verifier and analysis linter defines and uses several macros in code that performs validation of IR expectations. Previously, these macros were named with an 'Assert' prefix. These names were misleading since the macro definitions are not conditioned on build kind; they are defined identically in builds that have asserts enabled and those that do not. This was confusing since an LLVM developer might expect these macros to be conditionally enabled as 'assert' is. Further confusion was possible since the LLVM IR verifier is implicitly disabled (in Clang::ConstructJob()) for builds without asserts enabled, but only for Clang driver invocations; not for clang -cc1 invocations. This could make it appear that the macros were not active for builds without asserts enabled, e.g. when investigating behavior using the Clang driver, and thus lead to surprises when running tests that exercise the clang -cc1 interface. This change renames this set of macros as follows: Assert -> Check AssertDI -> CheckDI AssertTBAA -> CheckTBAA
2022-03-01Cleanup includes: LLVMAnalysisserge-sans-paille1-3/+0
Number of lines output by preprocessor: before: 1065940348 after: 1065307662 Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D120659
2021-11-07Put implementation details into anonymous namespaces. NFCI.Benjamin Kramer1-0/+2
2021-08-13[NFC] Remove AttributeList::hasParamAttribute()Arthur Eubanks1-2/+2
It's the same as AttributeList::hasParamAttr().
2021-04-09[NFC][AA] Prepare to convert AliasResult to class with PartialAlias offset.dfukalov1-3/+5
Main reason is preparation to transform AliasResult to class that contains offset for PartialAlias case. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D98027
2020-11-26[AA] Split up LocationSize::unknown()Nikita Popov1-6/+5
Currently, we have some confusion in the codebase regarding the meaning of LocationSize::unknown(): Some parts (including most of BasicAA) assume that LocationSize::unknown() only allows accesses after the base pointer. Some parts (various callers of AA) assume that LocationSize::unknown() allows accesses both before and after the base pointer (but within the underlying object). This patch splits up LocationSize::unknown() into LocationSize::afterPointer() and LocationSize::beforeOrAfterPointer() to make this completely unambiguous. I tried my best to determine which one is appropriate for all the existing uses. The test changes in cs-cs.ll in particular illustrate a previously clearly incorrect AA result: We were effectively assuming that argmemonly functions were only allowed to access their arguments after the passed pointer, but not before it. I'm pretty sure that this was not intentional, and it's certainly not specified by LangRef that way. Differential Revision: https://reviews.llvm.org/D91649
2020-11-19[Lint] Use MemoryLocationNikita Popov1-42/+39
Instead of separately passing pointer and size, make use of MemoryLocation. This allows us to also reuse all the existing logic for determining the MemoryLocation correponding to an instruction or call argument. Not quite NFC because used locations may be more precise in some cases.
2020-09-24OpaquePtr: Add helpers for sret to mirror byvalMatt Arsenault1-1/+1
Sret should really have a type parameter like byval does.
2020-09-17[Lint] Add check for intrinsic get.active.lane.maskSjoerd Meijer1-0/+5
As @efriedma pointed out in D86301, this "not equal to 0 check" of get.active.lane.mask's second operand needs to live here in Lint and not the Verifier. Differential Revision: https://reviews.llvm.org/D87228
2020-09-03[NewPM][Lint] Port -lint to NewPMArthur Eubanks1-140/+164
This also changes -lint from an analysis to a pass. It's similar to -verify, and that is a normal pass, and lives in llvm/IR. Reviewed By: ychen Differential Revision: https://reviews.llvm.org/D87057
2020-09-02Revert "[NewPM][Lint] Port -lint to NewPM"Arthur Eubanks1-0/+758
This reverts commit 883399c8402188520870f99e7d8b3244f000e698.
2020-09-02[NewPM][Lint] Port -lint to NewPMArthur Eubanks1-758/+0
This also changes -lint from an analysis to a pass. It's similar to -verify, and that is a normal pass, and lives in llvm/IR. Reviewed By: ychen Differential Revision: https://reviews.llvm.org/D87057
2020-07-31[NFC] Remove unused GetUnderlyingObject paramenterVitaly Buka1-1/+1
Depends on D84617. Differential Revision: https://reviews.llvm.org/D84621
2020-07-30[NFC] GetUnderlyingObject -> getUnderlyingObjectVitaly Buka1-1/+1
I am going to touch them in the next patch anyway
2020-07-22[SVE] Remove calls to VectorType::getNumElements from AnalysisChristopher Tetreault1-4/+8
Reviewers: efriedma, fpetrogalli, c-rhodes, asbirlea, RKSimon Reviewed By: RKSimon Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D81504
2020-07-01[Alignment] TargetLowering::hasPairedLoad must use Align for RequiredAlignmentGuillaume Chatelet1-37/+33
As per documentation of `hasPairLoad`: "`RequiredAlignment` gives the minimal alignment constraints that must be met to be able to select this paired load." In this sense, `0` is strictly equivalent to `1`. We make this obvious by using `Align` instead of unsigned. There is only one implementor of this interface. Differential Revision: https://reviews.llvm.org/D82958
2020-05-19[IR] Revert r119493Jay Foad1-2/+1
r119493 protected against PHINode::hasConstantValue returning the PHI node itself, but a later fix in r159687 means that can never happen, so the workarounds are no longer required.