aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
AgeCommit message (Collapse)AuthorFilesLines
2025-07-02[IR] Introduce `dead_on_return` attributeAntonio Frighetto1-0/+6
Add `dead_on_return` attribute, which is meant to be taken advantage by the frontend, and states that the memory pointed to by the argument is dead upon function return. As with `byval`, it is supposed to be used for passing aggregates by value. The difference lies in the ABI: `byval` implies that the pointer is explicitly passed as argument to the callee (during codegen the copy is emitted as per byval contract), whereas a `dead_on_return`-marked argument implies that the copy already exists in the IR, is located at a specific stack offset within the caller, and this memory will not be read further by the caller upon callee return – or otherwise poison, if read before being written. RFC: https://discourse.llvm.org/t/rfc-add-dead-on-return-attribute/86871.
2025-06-25[NFC][PGO] Use constants rather than free strings for metadata labels (#145721)Mircea Trofin1-3/+5
2025-06-12[DebugInfo][RemoveDIs] Delete debug-info-format flag (#143746)Jeremy Morse1-17/+1
This flag was used to let us incrementally introduce debug records into LLVM, however everything is now using records. It serves no purpose now, so delete it.
2025-06-11[LLVM][SROA] Teach SROA how to "bitcast" between fixed and scalable vectors. ↵Paul Walker1-0/+12
(#130973) For function whose vscale_range is limited to a single value we can size scalable vectors. This aids SROA by allowing scalable vector load and store operations to be considered for replacement whereby bitcasts through memory can be replaced by vector insert or extract operations.
2025-06-09[DebugInfo][RemoveDIs] Rip out the UseNewDbgInfoFormat flag (#143207)Jeremy Morse1-3/+1
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-02[llvm] annotate interfaces in llvm/IR for DLL export (#141650)Andrew Rogers1-2/+2
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the `llvm/IR`, `llvm/IRPrinter`, and `llvm/IRReader` libraries. 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_ABI_FRIEND` to friend member functions declared with `LLVM_ABI` - 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 - Reorder `LLVM_ABI` with `[[deprecated]]` and `[[nodiscard]]` attributes. ## 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-02llvm-reduce: Add values to return reduction (#132686)Matt Arsenault1-0/+82
In void functions, try to replace instruction uses with a new non-void return. If the return type matches the instruction, also try to directly return it. This handles most of the cases, but doesn't try to handle all of the weird exception related terminators. Also doesn't try to replace argument uses, although it could. We could also handle cases where we can insert a simple cast to an original return value. I didn't think too hard about where to put this in the default pass order. In many cases it obviates the need for most of the CFG folds, but I've left it near the end initially. I also think this is too aggressive about removing dead code, and should leave existing dead code alone. I'm also not sure why we have both "removeUnreachableBlocks" and EliminateUnreachableBlocks" in Utils. Fixes #66039, fixes #107327
2025-05-02[IR] Do not store Function inside BlockAddress (#137958)Nikita Popov1-9/+1
Currently BlockAddresses store both the Function and the BasicBlock they reference, and the BlockAddress is part of the use list of both the Function and BasicBlock. This is quite awkward, because this is not really a use of the function itself (and walks of function uses generally skip block addresses for that reason). This also has weird implications on function RAUW (as that will replace the function in block addresses in a way that generally doesn't make sense), and causes other peculiar issues, like the ability to have multiple block addresses for one block (with different functions). Instead, I believe it makes more sense to specify only the basic block and let the function be implied by the BB parent. This does mean that we may have block addresses without a function (if the BB is not inserted), but this should only happen during IR construction.
2025-04-17[Intrinsics] Add support for range attributes (#135642)Nikita Popov1-2/+9
Add support for specifying range attributes in Intrinsics.td. Use this to specify the ucmp/scmp range [-1,2). This case is trickier than existing intrinsic attributes, because we need to create the attribute with the correct bitwidth. As such, the attribute construction now needs to be aware of the function type. We also need to be careful to no longer assign attributes on intrinsics with invalid signatures, as we'd make invalid assumptions about the number of arguments etc otherwise. Fixes https://github.com/llvm/llvm-project/issues/130179.
2025-03-13[InferAttrs] Mark floating-point libcalls as `errno`-writingAntonio Frighetto1-1/+1
Floating-point libcalls are currently conservatively marked as may write any memory. Restrict these to clobber only `errno`.
2025-02-06[IR] Generalize Function's {set,get}SectionPrefix to GlobalObjects, the base ↵Mingming Liu1-16/+0
class of {Function, GlobalVariable, IFunc} (#125757) This is a split of https://github.com/llvm/llvm-project/pull/125756
2025-01-29[IR] Convert from nocapture to captures(none) (#123181)Nikita Popov1-1/+1
This PR removes the old `nocapture` attribute, replacing it with the new `captures` attribute introduced in #116990. This change is intended to be essentially NFC, replacing existing uses of `nocapture` with `captures(none)` without adding any new analysis capabilities. Making use of non-`none` values is left for a followup. Some notes: * `nocapture` will be upgraded to `captures(none)` by the bitcode reader. * `nocapture` will also be upgraded by the textual IR reader. This is to make it easier to use old IR files and somewhat reduce the test churn in this PR. * Helper APIs like `doesNotCapture()` will check for `captures(none)`. * MLIR import will convert `captures(none)` into an `llvm.nocapture` attribute. The representation in the LLVM IR dialect should be updated separately.
2024-11-02[IR] Remove unused includes (NFC) (#114679)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-10-17[SimplifyLibCall][Attribute] Fix bug where we may keep `range` attr with ↵goldsteinn1-0/+4
incompatible type (#112649) In a variety of places we change the bitwidth of a parameter but don't update the attributes. The issue in this case is from the `range` attribute when inlining `__memset_chk`. `optimizeMemSetChk` will replace an `i32` with an `i8`, and if the `i32` had a `range` attr assosiated it will cause an error. Fixes #112633
2024-10-06[AMDGPU] Support preloading hidden kernel arguments (#98861)Austin Kerbow1-0/+8
Adds hidden kernel arguments to the function signature and marks them inreg if they should be preloaded into user SGPRs. The normal kernarg preloading logic then takes over with some additional checks for the correct implicitarg_ptr alignment. Special care is needed so that metadata for the hidden arguments is not added twice when generating the code object.
2024-10-01[NFC] Add a new Intrinsics.cpp file for intrinsic code (#110078)Rahul Joshi1-963/+0
Add new file Intrinsics.cpp and move all functions in the `Intrinsic` namespace to it.
2024-09-30[NFC] Move intrinsic related functions to Intrinsic namespace (#110125)Rahul Joshi1-4/+4
Move static functions `Function::lookupIntrinsicID` and `Function::isTargetIntrinsic` to Intrinsic namespace.
2024-09-25[Core] Skip over target name in intrinsic name lookup (#109971)Rahul Joshi1-9/+10
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-09-16[IPSCCP] Infer attributes on arguments (#107114)Nikita Popov1-0/+5
During inter-procedural SCCP, also infer attributes on arguments, not just return values. This allows other non-interprocedural passes to make use of the information later.
2024-09-11Don't rely on undefined behavior to store how a `User` object's allocation ↵Daniel Paoliello1-3/+2
is laid out (#105714) In `User::operator new` a single allocation is created to store the `User` object itself, "intrusive" operands or a pointer for "hung off" operands, and the descriptor. After allocation, details about the layout (number of operands, how the operands are stored, if there is a descriptor) are stored in the `User` object by settings its fields. The `Value` and `User` constructors are then very careful not to initialize these fields so that the values set during allocation can be subsequently read. However, when the `User` object is returned from `operator new` [its value is technically "indeterminate" and so reading a field without first initializing it is undefined behavior (and will be erroneous in C++26)](https://en.cppreference.com/w/cpp/language/default_initialization#Indeterminate_and_erroneous_values). We discovered this issue when trying to build LLVM using MSVC's [`/sdl` flag](https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170) which clears class fields after allocation (the docs say that this feature shouldn't be turned on for custom allocators and should only clear pointers, but that doesn't seem to match the implementation). MSVC's behavior both with and without the `/sdl` flag is standards conforming since a program is supposed to initialize storage before reading from it, thus the compiler implementation changing any values will never be observed in a well-formed program. The standard also provides no provisions for making storage bytes not indeterminate by setting them during allocation or `operator new`. The fix for this is to create a set of types that encode the layout and provide these to both `operator new` and the constructor: * The `AllocMarker` types are used to select which `operator new` to use. * `AllocMarker` can then be implicitly converted to a `AllocInfo` which tells the constructor how the type was laid out.
2024-09-04[TableGen] Optimize intrinsic info type signature encoding (#106809)Rahul Joshi1-6/+8
Change the "fixed encoding" table used for encoding intrinsic type signature to use 16-bit encoding as opposed to 32-bit. This results in both space and time improvements. For space, the total static storage size (in bytes) of this info reduces by 50%: - Current = 14193*4 (Fixed table) + 16058 + 3 (Long Table) = 72833 - New size = 14193*2 (Fixed table) + 19879 + 3 (Long Table) = 48268. - Reduction = 50.9% For time, with the added benchmark, we see a 7.3% speedup in `GetIntrinsicInfoTableEntries` benchmark. Actual output of the benchmark in included in the GitHub MR.
2024-07-30[IR] Add per-function numbers to basic blocks (#101052)Alexis Engelke1-0/+24
Every basic block that is linked into a function now has a unique number, which can be queried using getNumber(). Numbers are densely allocated, but not re-assigned on block removal for stability. Block numbers are intended to be fairly stable and only be updated when removing a several basic blocks to make sure the numbering doesn't become too sparse. To reduce holes in the numbering, renumberBlocks() can be called to re-assign numbers in block order. Additionally, getMaxBlockNumber() returns a value larger than the largest block number, intended to pre-allocate/resize vectors. Furthermore, this introduces the concept of a "block number epoch" -- an integer that changes after every renumbering. This is useful for identifying use of block numbers after renumbering: on initialization, the current epoch is stored, and on all subsequent accesses, equality with the current epoch can be asserted. I added a validate method to catch cases where something goes wrong, even if I can't really imagine how invalid numbers can occur. But I think it's better to be safe and rule out this potential source of bugs when more things depend on the numbering. Previous discussion in: https://discourse.llvm.org/t/rfc-add-auxiliary-field-for-per-pass-custom-data-to-basicblock/80229
2024-07-25Remove the `x86_mmx` IR type. (#98505)James Y Knight1-4/+10
It is now translated to `<1 x i64>`, which allows the removal of a bunch of special casing. This _incompatibly_ changes the ABI of any LLVM IR function with `x86_mmx` arguments or returns: instead of passing in mmx registers, they will now be passed via integer registers. However, the real-world incompatibility caused by this is expected to be minimal, because Clang never uses the x86_mmx type -- it lowers `__m64` to either `<1 x i64>` or `double`, depending on ABI. This change does _not_ eliminate the SelectionDAG `MVT::x86mmx` type. That type simply no longer corresponds to an IR type, and is used only by MMX intrinsics and inline-asm operands. Because SelectionDAGBuilder only knows how to generate the operands/results of intrinsics based on the IR type, it thus now generates the intrinsics with the type MVT::v1i64, instead of MVT::x86mmx. We need to fix this before the DAG LegalizeTypes, and thus have the X86 backend fix them up in DAGCombine. (This may be a short-lived hack, if all the MMX intrinsics can be removed in upcoming changes.) Works towards issue #98272.
2024-07-10[llvm][ARM][AArch64] Add attributes to synthetic functions. (#83153)Daniel Kiss1-0/+29
Module flags represent the original intention. Depends on #82819 Reland as it was but reland needed as dependent patch relanded.
2024-07-10Revert "[llvm][ARM][AArch64] Add attributes to synthetic functions." (#98283)Daniel Kiss1-29/+0
Reverts llvm/llvm-project#83153
2024-07-10[llvm][ARM][AArch64] Add attributes to synthetic functions. (#83153)Daniel Kiss1-0/+29
Module flags represent the original intention. Depends on #82819
2024-06-28[IR] Add getDataLayout() helpers to Function and GlobalValue (#96919)Nikita Popov1-0/+4
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-25CodeGen, IR: Add target-{cpu,features} attributes to functions created via ↵pcc1-0/+6
createWithDefaultAttr(). Functions created with createWithDefaultAttr() need to have the correct target-{cpu,features} attributes to avoid miscompilations such as using the wrong relocation type to access globals (missing tagged-globals feature), clobbering registers specified via -ffixed-* (missing reserve-* feature), and so on. There's already a number of attributes copied from the module flags onto functions created by createWithDefaultAttr(). I don't think module flags are the right choice for the target attributes because we don't need the conflict resolution logic between modules with different target attributes, nor does it seem sensible to add it: there's no unambiguously "correct" set of target attributes when merging two modules with different attributes, and nor should there be; it's perfectly valid for two modules to be compiled with different target attributes, that's the whole reason why they are per-function. This also implies that it's unnecessary to serialize the attributes in bitcode, which implies that they shouldn't be stored on the module. We can also observe that for the most part, createWithDefaultAttr() is called from compiler passes such as sanitizers, coverage and profiling passes that are part of the compile time pipeline, not the LTO pipeline. This hints at a solution: we need to store the attributes in a non-serialized location associated with the ambient compilation context. Therefore in this patch I elected to store the attributes on the LLVMContext. There are calls to createWithDefaultAttr() in the NVPTX and AMDGPU backends, and those calls would happen at LTO time. For those callers, the bug still potentially exists and it would be necessary to refactor them to create the functions at compile time if this issue is relevant on those platforms. Fixes #93633. Reviewers: fmayer, MaskRay, eugenis Reviewed By: MaskRay Pull Request: https://github.com/llvm/llvm-project/pull/96721
2024-06-14Reapply#4 "[RemoveDIs] Load into new debug info format by default in LLVM ↵Stephen Tozer1-1/+3
(#89799)" Reapplies commit c5aeca73 (and its followup commit 21396be8), which were reverted due to missing functionality in MLIR and Flang regarding printing debug records. This has now been added in commit 08aa511, along with support for printing debug records in flang. This reverts commit 2dc2290860355dd2bac3b655eea895fe30fde257.
2024-06-11Revert new debug info format commits:Stephen Tozer1-3/+1
"[Flang] Update test to not check for tail calls on debug intrinsics" & "Reapply#3 "[RemoveDIs] Load into new debug info format by default in LLVM (#89799)" Recent updates to flang have added debug info generation via MLIR, a path which currently does not support debug records. The patch that enables debug records by default (and a small followup patch) are thus being reverted until the MLIR path has been fixed. This reverts commits: 21396be865b4640abf6afa0b05de6708a1a996e0 c5aeca732d1ff6769b0659efebd1cfb5f60487e4
2024-06-10Reapply#3 "[RemoveDIs] Load into new debug info format by default in LLVM ↵Stephen Tozer1-1/+3
(#89799)" Reapplies commit 91446e2, which was reverted due to a downstream error, discussed on the pull request. The error could not be reproduced upstream, and cannot be reproduced downstream as-of current main, so until the error can be confirmed to still exist this patch should return. This reverts commit 23f8fac745bdde70ed4f9c585d19c4913734f1b8.
2024-06-07[ARM] r11 is reserved when using -mframe-chain=aapcs (#86951)Oliver Stannard1-0/+3
When using the -mframe-chain=aapcs or -mframe-chain=aapcs-leaf options, we cannot use r11 as an allocatable register, even if -fomit-frame-pointer is also used. This is so that r11 will always point to a valid frame record, even if we don't create one in every function.
2024-05-28[IR] Fix ignoring `non-global-value-max-name-size` in ↵Daniil Fukalov1-1/+1
`ValueSymbolTable::makeUniqueName()`. (#89057) E.g. during inlining new symbol name can be duplicated and then `ValueSymbolTable::makeUniqueName()` will add unique suffix, exceeding the `non-global-value-max-name-size` restriction. Also fixed `unsigned` type of the option to `int` since `ValueSymbolTable`' constructor can use `-1` value that means unrestricted name size.
2024-05-13Revert "Repply#2 "[RemoveDIs] Load into new debug info format by default in ↵Fangrui Song1-3/+1
LLVM (#89799)"" This reverts commit 91446e2aa687ec57ad88dc0df793d0c6e694a7c9 and a unittest followup 1530f319311908b06fe935c89fca692d3e53184f (#90476). In a stage-2 -flto=thin -gsplit-dwarf -g -fdebug-info-for-profiling -fprofile-sample-use= build of clang, a ThinLTO backend compile has assertion failures: Global is external, but doesn't have external or weak linkage! ptr @_ZN5clang12ast_matchers8internal18makeAllOfCompositeINS_8QualTypeEEENS1_15BindableMatcherIT_EEN4llvm8ArrayRefIPKNS1_7MatcherIS5_EEEE function declaration may only have a unique !dbg attachment ptr @_ZN5clang12ast_matchers8internal18makeAllOfCompositeINS_8QualTypeEEENS1_15BindableMatcherIT_EEN4llvm8ArrayRefIPKNS1_7MatcherIS5_EEEE The failures somehow go away if -fprofile-sample-use= is removed.
2024-05-07[NFC][LLVM] Refactor rounding mode detection of constrained fp intrinsic IDs ↵Paul Walker1-0/+12
(#90854) I've refactored the code to genericise the implementation to better allow for target specific constrained fp intrinsics.
2024-05-03Repply#2 "[RemoveDIs] Load into new debug info format by default in LLVM ↵Stephen Tozer1-1/+3
(#89799)" Reapplies the original commit: 2f01fd99eb8c8ab3db9aba72c4f00e31e9e60a05 The previous application of this patch failed due to some missing DbgVariableRecord support in clang, which has been added now by commit 8805465e. This will probably break some downstream tools that don't already handle debug records. If your downstream code breaks as a result of this change, the simplest fix is to convert the module in question to the old debug format before you process it, using `Module::convertFromNewDbgValues()`. For more information about how to handle debug records or about what has changed, see the migration document: https://llvm.org/docs/RemoveDIsDebugInfo.html This reverts commit 4fd319ae273ed6c252f2067909c1abd9f6d97efa.
2024-05-02Revert#2 "[RemoveDIs] Load into new debug info format by default in LLVM ↵Stephen Tozer1-3/+1
(#89799)" Reverted following probably-causing failures on some clang buildbots: https://lab.llvm.org/buildbot/#/builders/245/builds/24037 This reverts commit a12622543de15df45fb9ad64e8ab723289d55169.
2024-05-02Reapply "[RemoveDIs] Load into new debug info format by default in LLVM ↵Stephen Tozer1-1/+3
(#89799)" Fixes the broken tests in the original commit: 2f01fd99eb8c8ab3db9aba72c4f00e31e9e60a05 This will probably break some downstream tools that don't already handle debug records. If your downstream code breaks as a result of this change, the simplest fix is to convert the module in question to the old debug format before you process it, using `Module::convertFromNewDbgValues()`. For more information about how to handle debug records or about what has changed, see the migration document: https://llvm.org/docs/RemoveDIsDebugInfo.html This reverts commit 00821fed09969305b0003d3313c44d1e761a7131.
2024-05-01Revert "[RemoveDIs] Load into new debug info format by default in LLVM (#89799)"Stephen Tozer1-3/+1
A unit test was broken by the above commit: https://lab.llvm.org/buildbot/#/builders/139/builds/64627 This reverts commit 2f01fd99eb8c8ab3db9aba72c4f00e31e9e60a05.
2024-05-01[RemoveDIs] Load into new debug info format by default in LLVM (#89799)Stephen Tozer1-1/+3
This patch enables parsing and creating modules directly into the new debug info format. Prior to this patch, all modules were constructed with the old debug info format by default, and would be converted into the new format just before running LLVM passes. This is an important milestone, in that this means that every tool will now be exposed to debug records, rather than those that run LLVM passes. As far as I've tested, all LLVM tools/projects now either handle debug records, or convert them to the old intrinsic format. There are a few unit tests that need updating for this patch; these are either cases of tests that previously needed to set the debug info format to function, or tests that depend on the old debug info format in some way. There should be no visible change in the output of any LLVM tool as a result of this patch, although the likelihood of this patch breaking downstream code means an NFC tag might be a little misleading, if not technically incorrect: This will probably break some downstream tools that don't already handle debug records. If your downstream code breaks as a result of this change, the simplest fix is to convert the module in question to the old debug format before you process it, using `Module::convertFromNewDbgValues()`. For more information about how to handle debug records or about what has changed, see the migration document: https://llvm.org/docs/RemoveDIsDebugInfo.html
2024-04-30[IR] Use StringRef::operator== instead of StringRef::equals (NFC) (#90550)Kazu Hirata1-8/+7
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator== outnumbers StringRef::equals by a factor of 22 under llvm/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
2024-04-26[SCCP] Swap out range metadata to range attribute (#90134)Andreas Jonson1-0/+4
Also moved the range from the function's call sites to the functions return value as that is possible now.
2024-04-19Add IIT_V10 to support 10-element vectors in intrinsics (#89383)Jay Foad1-0/+4
Needed for a future patch.
2024-04-19[AsmParser] Support calling intrinsics without mangling suffix (#89172)Nikita Popov1-6/+9
This adds proper support for calling intrinsics without mangling suffix when parsing textual IR. This already worked (mostly by accident) when only a single mangling suffix was in use. This patch extends support to the case where the intrinsic is used with multiple signatures, and as such multiple different intrinsic declarations have to be inserted. The final IR will have intrinsics with mangling suffix as usual. Motivated by the discussion at: https://discourse.llvm.org/t/recent-improvements-to-the-ir-parser/77366
2024-04-17[VP] Correct lowering of predicated fma and faddmul to avoid strictfp. (#85272)Kevin P. Neal1-9/+13
Correct missing cases in a switch that result in @llvm.vp.fma.v4f32 getting lowered to a constrained fma intrinsic. Vector predicated lowering to contrained intrinsics is not supported currently, and there's no consensus on the path forward. We certainly shouldn't be introducing constrained intrinsics into a function that isn't strictfp. Problem found with D146845.
2024-04-12Add IIT_V6 to support 6-element vectors in intrinsics. (#88196)Stanislav Mekhanoshin1-0/+4
Needed for the future patch.
2024-04-05[RemoveDIs] Add flag to preserve the debug info format of input IR (#87379)Stephen Tozer1-0/+6
This patch adds a new flag: `--preserve-input-debuginfo-format` This flag instructs the tool to not convert the debug info format (intrinsics/records) of input IR, but to instead determine the format of the input IR and overwrite the other format-determining flags so that we process and output the file in the same format that we received it in. This flag is turned off by llvm-link, llvm-lto, and llvm-lto2, and should be turned off by any other tool that expects to parse multiple IR modules and have their debug info formats match. The motivation for this flag is to allow tools to not convert the debug info format - verify-uselistorder and llvm-reduce, and any downstream tools that seek to test or mutate IR as-is, without applying extraneous modifications to the input. This is a necessary step to using debug records by default in all (other) LLVM tools.
2024-03-20[ValueTracking] Handle range attributes (#85143)Andreas Jonson1-0/+8
Handle the range attribute in ValueTracking.
2024-03-12[InstSimpliy] Use range attribute to simplify comparisons (#84627)Andreas Jonson1-0/+4
Use the new range attribute from https://github.com/llvm/llvm-project/pull/84617 to simplify comparisons where both sides have range information.
2024-02-20[DebugInfo][RemoveDIs] Set new-dbg-info flag from Modules correctly (#82373)Jeremy Morse1-1/+3
It turns out there's a pathway for Functions to be inserted into modules without having the "New" debug-info flag set correctly, which this patch fixes. Sadly there isn't a Module::insert method to instrument out there, everyone touches the list directly. This fix exposes a path where such functions are produced in the outliner in the wrong mode; requiring a fix there to correctly drop RemoveDIs-mode debug-info. This is covered by test/DebugInfo/AArch64/ir-outliner.ll