aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/IntrinsicInst.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-08-05[VP][RISCV] Add a vp.load.ff intrinsic for fault only first load. (#128593)Craig Topper1-0/+5
There's been some interest in supporting early-exit loops recently. https://discourse.llvm.org/t/rfc-supporting-more-early-exit-loops/84690 This patch was extracted from our downstream where we've been using it in our vectorizer.
2025-06-19[llvm] Remove an extraneous cast (NFC) (#144955)Kazu Hirata1-3/+3
llvm::CallBase::getArgOperand returns Value *, so we do not need const_cast<Value *>.
2025-02-05[llvm] Create() functions for ConvergenceControlInst (#125627)Sameer Sahasrabuddhe1-0/+28
2024-12-13[debug] Use poison instead of undef to set a killed dbg.assign address [NFC] ↵Pedro Lobo1-1/+1
(#119760)
2024-10-11[NFC] Rename `Intrinsic::getDeclaration` to `getOrInsertDeclaration` (#111752)Rahul Joshi1-15/+14
Rename the function to reflect its correct behavior and to be consistent with `Module::getOrInsertFunction`. This is also in preparation of adding a new `Intrinsic::getDeclaration` that will have behavior similar to `Module::getFunction` (i.e, just lookup, no creation).
2024-10-01[NFC] Add a new Intrinsics.cpp file for intrinsic code (#110078)Rahul Joshi1-42/+0
Add new file Intrinsics.cpp and move all functions in the `Intrinsic` namespace to it.
2024-09-25[Core] Skip over target name in intrinsic name lookup (#109971)Rahul Joshi1-1/+6
When searching for an intrinsic name in a target specific slice of the intrinsic name table, skip over the target prefix. For such cases, currently the first loop iteration in `lookupLLVMIntrinsicByName` does nothing (i.e., `Low` and `High` stay unchanged and it does not shrink down the search window), so we can skip this useless first iteration by skipping over the target prefix.
2024-08-29[VP] Kill VP_PROPERTY_(MEMOP,CASTOP) and simplify _CONSTRAINEDFP [nfc] (#105574)Philip Reames1-21/+18
These lists are quite static. Heavy use of macros is undesirable, and not idiomatic in LLVM, so let's just use the naive switch cases. Note that the first two fields in the CONSTRAINEDFP property were utterly unused (aside from a C++ test). In the same vien as https://github.com/llvm/llvm-project/pull/105551. Once both changes have landed, we'll be left with _BINARYOP which needs a bit of additional untangling, and the actual opcode mappings.
2024-08-29[VP] Remove VP_PROPERTY_REDUCTION and VP_PROPERTY_CMP [nfc] (#105551)Philip Reames1-44/+29
These lists are quite static and several of the parameters are actually constant across all users. Heavy use of macros is undesirable, and not idiomatic in LLVM, so let's just use the naive switch cases. I'll probably continue with removing the other property macros. These two just happened to be the two I actually had to figure out for an unrelated change.
2024-08-27[ctx_prof] Add support for ICP (#105469)Mircea Trofin1-0/+10
An overload of `llvm::promoteCallWithIfThenElse` that updates the contextual profile. High-level, this is very simple: after creating the `if... then (direct call) else (indirect call)` structure, we instrument the new callsites and BBs (the instrumentation will help with tracking for other IPO transformations, and, ultimately, to match counter values before flattening to `MD_prof`). In more detail: - move the callsite instrumentation of the indirect call to the `else` BB, before the indirect call - create a new callsite instrumentation for the direct call - create instrumentation for both the `then` and `else` BBs - we could instrument just one (MST-style) but we're not running the binary with this instrumentation, and at most this would save some space (less counters tracked). For simplicity instrumenting both at this point - update each context belonging to the caller by updating the counters, and moving the indirect callee to the new, direct callsite ID Issue #89287
2024-07-25[VP] Refactor VectorBuilder to avoid layering violation. NFC (#99276)Mel Chen1-0/+19
This patch refactors the handling of reduction to eliminate layering violations. * Introduced `getReductionIntrinsicID` in LoopUtils.h for mapping recurrence kinds to llvm.vector.reduce.* intrinsic IDs. * Updated `VectorBuilder::createSimpleTargetReduction` to accept llvm.vector.reduce.* intrinsic directly. * New function `VPIntrinsic::getForIntrinsic` for mapping intrinsic ID to the same functional VP intrinsic ID.
2024-07-17[VP][RISCV] Introduce vp.splat and RISC-V. (#98731)Yeting Kuo1-0/+3
This patch introduces a vp intrinsic for splat. It's helpful for IR-level passes to create a splat with specific vector length.
2024-05-07[NFC][LLVM] Refactor rounding mode detection of constrained fp intrinsic IDs ↵Paul Walker1-27/+13
(#90854) I've refactored the code to genericise the implementation to better allow for target specific constrained fp intrinsics.
2024-04-30[VP] Fix unit test failures caused by #90502Min Hsu1-0/+1
Forgot to add vp.cttz.elts into the unittest. Also, I didn't specify the positions of overloaded type parameters.
2024-04-26[Transforms] Debug values are not remapped when cloning. (#87747)Carlos Alberto Enciso1-1/+4
When cloning instructions from one basic block to another, the debug values are not remapped, in the same was as the normal instructions.
2024-04-25[llvm][ctx_profile] Add the `llvm.instrprof.callsite` intrinsic (#89939)Mircea Trofin1-0/+6
Add the callsite intrinsic. Structurally, it is very similar to the counter intrinsics, hence the inheritance relationship. We can probably rename `InstrProfCntrInstBase` to `InstrProfIndexedBase` later - because the "counting" aspect is really left to derived types of `InstrProfCntrInstBase`, and it only concerns itself with the index aspect (which is what we care about for `callsite`, too) (Tracking Issue: #89287, RFC referenced there)
2024-02-26[VP][RISCV] Introduce vp.lrint/llrint and RISC-V support. (#82627)Yeting Kuo1-0/+2
RISC-V implements vector lrint/llrint by vfcvt.x.f.v.
2024-02-14[InstSimplify][InstCombine] Remove unnecessary `m_c_*` matchers. (#81712)Yingwei Zheng1-1/+1
This patch removes unnecessary `m_c_*` matchers since we always canonicalize `commutive_op Cst, X` into `commutive_op X, Cst`. Compile-time impact: https://llvm-compile-time-tracker.com/compare.php?from=bfc0b7c6891896ee8e9818f22800472510093864&to=d27b058bb9acaa43d3cadbf3cd889e8f79e5c634&stat=instructions:u
2023-11-17[Statepoint] Return undef value for the statepoint of the none token (#72552)Danila Malyutin1-0/+4
Helps avoid the crash in verifier when it tries to print the error. `none` token might be produced by llvm-reduce, since it's a default value, so by extension this also fixes llvm-reduce crash, allowing it to just discard invalid IR. --------- Co-authored-by: arpilipe <apilipenko@azul.com>
2023-11-03[IR] IntrinsicInst.cpp - use StringRef::starts_with/ends_with instead of ↵Simon Pilgrim1-2/+2
startswith/endswith. NFC. startswith/endswith wrap starts_with/ends_with and will eventually go away (to more closely match string_view) Also add missing assert message
2023-10-30Reland "[InstrProf][compiler-rt] Enable MC/DC Support in LLVM Source-based ↵Alan Phipps1-2/+2
Code Coverage (1/3)" Part 1 of 3. This includes the LLVM back-end processing and profile reading/writing components. compiler-rt changes are included. Differential Revision: https://reviews.llvm.org/D138846
2023-09-21Revert "[InstrProf][compiler-rt] Enable MC/DC Support in LLVM Source-based ↵Hans Wennborg1-2/+2
Code Coverage (1/3)" This seems to cause Clang to crash, see comments on the code review. Reverting until the problem can be investigated. > Part 1 of 3. This includes the LLVM back-end processing and profile > reading/writing components. compiler-rt changes are included. > > Differential Revision: https://reviews.llvm.org/D138846 This reverts commit a50486fd736ab2fe03fcacaf8b98876db77217a7.
2023-09-19[InstrProf][compiler-rt] Enable MC/DC Support in LLVM Source-based Code ↵Alan Phipps1-2/+2
Coverage (1/3) Part 1 of 3. This includes the LLVM back-end processing and profile reading/writing components. compiler-rt changes are included. Differential Revision: https://reviews.llvm.org/D138846
2023-09-18[VP] Add missing functional_intrinsic properties and add static_assert. NFC ↵Luke Lau1-5/+39
(#66199) Some VP intrinsic definitions were missing the VP_PROPERTY_FUNCTIONAL_INTRINSIC property. This patch fills them in, and adds a static_assert that all VP intrinsics have an equivalent opcode or intrinsic defined so we don't forget them in future. Some VP intrinsics don't have an equivalent, namely merge and strided load/store. For those, a new property was added to mark that they don't have a non-VP equivalent. This adds a helper method to get the ID of the functionally equivalent intrinsic, similar to the existing getFunctionalOpcodeForVP and getConstrainedIntrinsicIDForVP method.
2023-09-13[IR][IntrinsicInst] Add VPBinOpIntrinsic (#66132)Michael Maitland1-0/+12
VPIntrinsics with VP_PROPERTY_BINARYOP property should have the ability to be queried with with VPBinOpIntrinsic::isVPBinOp, similiar to how intrinsics with the VP_PROPERTY_REDUCTION property can be queried with VPReductionIntrinsic::isVPReduction. This will be used in #65706. In that PR the usage of this class is tested.
2023-09-13[VP] Add method for looking up functional intrinsic ID for VP. NFC (#66190)Luke Lau1-1/+15
This adds a helper method to get the ID of the functionally equivalent intrinsic, similar to the existing getFunctionalOpcodeForVP and getConstrainedIntrinsicIDForVP methods. Not sure if it's notable or not, but I can't find any existing uses of VP_PROPERTY_FUNCTIONAL_INTRINSIC? It could potentially be used in #65706 to scalarize VP intrinsics.
2023-08-25[VP][RISCV] Add vp.is.fpclass and RISC-V supportLiaoChunyu1-0/+3
There is no vp.fpclass after FCLASS_VL(D151176), try to support vp.fpclass. Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D152993
2023-04-24[VP] IR expansion for fabs/fsqrt/fma/fmaddSimon Pilgrim1-0/+14
Add basic handling for VP ops that can expand to FP intrinsics Fixes #60464 Differential Revision: https://reviews.llvm.org/D149052
2023-04-11[Assignment Tracking] Fix replaceVariableLocationOp for dbg.assign with ↵OCHyams1-7/+7
DIArgList The last time this function was updated DIArgLists were not supported for dbg.assigns. Without this patch it's possible to now dereference an invalid (the end) iterator. This occurs when the Address component gets replaced and there's a DIArgList for the Value component (the contained values are irrelevant). The added unittest crashes without the code change in this patch. Reviewed By: jmorse Differential Revision: https://reviews.llvm.org/D147922
2023-03-31[Assignment Tracking] Remove assertion from DbgAssignIntrinsic::setAddressOCHyams1-2/+0
Follow up to https://reviews.llvm.org/D146987. Remove assertion that the Value must be a pointer type. This fires in real-world examples e.g. by codegenprepare introducing ptrtoint conversions. The buildbots have not caught up yet but without this change the test compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp fails with an ICE.
2023-03-16[DebugInfo][NFC] Add RawLocationWrapper to wrap location operand metadata [1/x]OCHyams1-5/+12
RawLocationWrapper wraps the location operand of a debug intrinsic which may be either (wrapped in MetadataAsValue) a DIArgList, ValueAsMetadata, or an empty MDTuple. This class lets us avoid duplicating location handling code in a later patch in this stack. Reviewed By: StephenTozer Differential Revision: https://reviews.llvm.org/D145909
2023-02-23[PatternMatch] Don't require DataLayout for m_VScale()Nikita Popov1-8/+2
The m_VScale() matcher is unusual in that it requires a DataLayout. It is currently used to determine the size of the GEP type. However, I believe it is sufficient to check for the canonical <vscale x 1 x i8> form here -- I don't think there's a need to recognize exotic variations like <vscale x 1 x i4> as a vscale constant representation as well. Differential Revision: https://reviews.llvm.org/D144566
2023-01-12[NFC][Assignment Tracking] Add is/setKillAddressOCHyams1-0/+11
Unlike D140903 this patch folds in treating an empty metadata address component of a dbg.assign the same as undef because it was already being treated that way in the AssignmentTrackingAnalysis pass. Reviewed By: scott.linder Differential Revision: https://reviews.llvm.org/D141125
2022-12-16std::optional::value => operator*/operator->Fangrui Song1-5/+5
value() has undesired exception checking semantics and calls __throw_bad_optional_access in libc++. Moreover, the API is unavailable without _LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS). This commit fixes LLVMAnalysis and its dependencies.
2022-12-04Instructions: convert Optional to std::optionalKrzysztof Parzyszek1-8/+14
2022-12-04DebugInfoMetadata: convert Optional to std::optionalKrzysztof Parzyszek1-1/+1
2022-12-03FPEnv: convert Optional to std::optionalKrzysztof Parzyszek1-4/+4
2022-12-02[IR] Use std::nullopt instead of None (NFC)Kazu Hirata1-9/+9
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-11-25[IR] Use std::optional in IntrinsicInst.cpp (NFC)Kazu Hirata1-1/+2
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-11-23[Assignment Tracking] Fix DbgVariableIntrinsic::replaceVariableLocationOpOCHyams1-0/+5
Fix replaceVariableLocationOp unconditionally replacing the first operand of a dbg.assign. Reviewed By: jryans Differential Revision: https://reviews.llvm.org/D138561
2022-11-07[Assignment Tracking][4/*] Add llvm.dbg.assign intrinsic boilerplateOCHyams1-1/+40
The Assignment Tracking debug-info feature is outlined in this RFC: https://discourse.llvm.org/t/ rfc-assignment-tracking-a-better-way-of-specifying-variable-locations-in-ir Add the llvm.dbg.assign intrinsic boilerplate. This updates the textual-bitcode roundtrip test to also check that round-tripping with the intrinsic works. The intrinsic marks the position of a source level assignment. The llvm.dbg.assign interface looks like this (each parameter is wrapped in MetadataAsValue, and Value * type parameters are first wrapped in ValueAsMetadata): void @llvm.dbg.assign(Value *Value, DIExpression *ValueExpression, DILocalVariable *Variable, DIAssignID *ID, Value *Address, DIExpression *AddressExpression) The first three parameters look and behave like an llvm.dbg.value. ID is a reference to a store. The intrinsic is "linked to" instructions in the same function that use the same ID as an attachment. That is mostly conceptual at this point; the two-way link infrastructure will come in another patch. Address is the destination address of the store and it is modified by AddressExpression. LLVM currently encodes variable fragment information in DIExpressions, so as an implementation quirk the FragmentInfo for Variable is contained within ValueExpression only. Reviewed By: jmorse Differential Revision: https://reviews.llvm.org/D132223
2022-07-26[WinEH] Apply funclet operand bundles to nounwind intrinsics that lower to ↵Stefan Gränitz1-0/+33
function calls in the course of IR transforms WinEHPrepare marks any function call from EH funclets as unreachable, if it's not a nounwind intrinsic or has no proper funclet bundle operand. This affects ARC intrinsics on Windows, because they are lowered to regular function calls in the PreISelIntrinsicLowering pass. It caused silent binary truncations and crashes during unwinding with the GNUstep ObjC runtime: https://github.com/gnustep/libobjc2/issues/222 This patch adds a new function `llvm::IntrinsicInst::mayLowerToFunctionCall()` that aims to collect all affected intrinsic IDs. * Clang CodeGen uses it to determine whether or not it must emit a funclet bundle operand. * PreISelIntrinsicLowering asserts that the function returns true for all ObjC runtime calls it lowers. * LLVM uses it to determine whether or not a funclet bundle operand must be propagated to inlined call sites. Reviewed By: theraven Differential Revision: https://reviews.llvm.org/D128190
2022-07-18[Verifier] Make Verifier recognize undef tokens as correct IRMax Kazantsev1-5/+17
Undef tokens may appear in unreached code as result of RAUW of some optimization, and it should not be considered as bad IR. Patch by Dmitry Bakunevich! Differential Revision: https://reviews.llvm.org/D128904 Reviewed By: mkazantsev
2022-07-13[llvm] Use value instead of getValue (NFC)Kazu Hirata1-5/+5
2022-06-25[llvm] Don't use Optional::hasValue (NFC)Kazu Hirata1-2/+2
This patch replaces Optional::hasValue with the implicit cast to bool in conditionals only.
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata1-8/+9
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata1-9/+8
2022-06-20[llvm] Don't use Optional::getValue (NFC)Kazu Hirata1-2/+2
2022-06-20Don't use Optional::hasValue (NFC)Kazu Hirata1-1/+1
2022-04-01[VP] Add more cast VPintrinsic and docs.yanming1-0/+9
Add vp.fptoui, vp.uitofp, vp.fptrunc, vp.fpext, vp.trunc, vp.zext, vp.sext, vp.ptrtoint, vp.inttoptr intrinsic and docs. Reviewed By: frasercrmck, craig.topper Differential Revision: https://reviews.llvm.org/D122291