aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/AutoUpgrade.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-01-31[Thumb2] Upgrade intrinsic upgrading codeSergei Barannikov1-4/+12
Enabling opaque pointers has changed the mangled names of these two ARM intrinsics: `arm.mve.vldr.gather.offset.predicated.v2i64.p0i64.v2i64.v4i1` `arm.mve.vstr.scatter.offset.predicated.p0i64.v2i64.v2i64.v4i1` They are now spelled as: `arm.mve.vldr.gather.offset.predicated.v2i64.p0.v2i64.v4i1` `arm.mve.vstr.scatter.offset.predicated.p0.v2i64.v2i64.v4i1` Upgrade intrinsic upgrading code to account for the change in names. Differential Revision: https://reviews.llvm.org/D142900
2023-01-11[NFC] Use TypeSize::geFixedValue() instead of TypeSize::getFixedSize()Guillaume Chatelet1-5/+6
This change is one of a series to implement the discussion from https://reviews.llvm.org/D141134.
2023-01-05Move from llvm::makeArrayRef to ArrayRef deduction guides - llvm/ partserge-sans-paille1-13/+11
Use deduction guides instead of helper functions. The only non-automatic changes have been: 1. ArrayRef(some_uint8_pointer, 0) needs to be changed into ArrayRef(some_uint8_pointer, (size_t)0) to avoid an ambiguous call with ArrayRef((uint8_t*), (uint8_t*)) 2. CVSymbol sym(makeArrayRef(symStorage)); needed to be rewritten as CVSymbol sym{ArrayRef(symStorage)}; otherwise the compiler is confused and thinks we have a (bad) function prototype. There was a few similar situation across the codebase. 3. ADL doesn't seem to work the same for deduction-guides and functions, so at some point the llvm namespace must be explicitly stated. 4. The "reference mode" of makeArrayRef(ArrayRef<T> &) that acts as no-op is not supported (a constructor cannot achieve that). Per reviewers' comment, some useless makeArrayRef have been removed in the process. This is a follow-up to https://reviews.llvm.org/D140896 that introduced the deduction guides. Differential Revision: https://reviews.llvm.org/D140955
2022-12-19[Intrinsic] Rename flt.rounds intrinsic to get.roundingQiu Chaofan1-0/+7
Address the inconsistency between FLT_ROUNDS_ and SET_ROUNDING SDAG node. Rename FLT_ROUNDS_ to GET_ROUNDING and add llvm.get.rounding intrinsic to replace flt.rounds. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D139507
2022-12-07Overload all llvm.annotation intrinsics for globals argumentAlex Richardson1-7/+12
The global constant arguments could be in a different address space than the first argument, so we have to add another overloaded argument. This patch was originally made for CHERI LLVM (where globals can be in address space 200), but it also appears to be useful for in-tree targets as can be seen from the test diffs. Differential Revision: https://reviews.llvm.org/D138722
2022-12-07[SVE] Change some bfloat lane intrinsics to use i32 immediatesDavid Sherwood1-0/+25
Almost all of the other SVE LLVM IR intrinsics take i32 values for lane indices or other immediates. We should bring the bfloat intrinsics in line with that. It will also make it easier to add support for the SVE2.1 float intrinsics in future, since they reuse the same underlying instruction classes. I've maintained backwards compatibility with the old i64 variants and used the autoupgrade mechanism. Differential Revision: https://reviews.llvm.org/D138788
2022-12-02[IR] Use std::nullopt instead of None (NFC)Kazu Hirata1-1/+1
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-16AutoUpgrade: Fix assertion on invalid name mangling usageMatt Arsenault1-17/+29
This was trying to auto-upgrade a read_register call with missing type mangling. This first would break since getCalledFunction checks the callee type is consistent, so this would assert there. After that, the replacement code would die on the type mismatch. Be more defensive and let the verifier code produce an error that the IR is broken.
2022-10-28[RISCV] Adjust RV64I data layout by using n32:64 in layout stringCraig Topper1-0/+8
Although i32 type is illegal in the backend, RV64I has pretty good support for i32 types by using W instructions. By adding n32 to the DataLayout string, middle end optimizations will consider i32 to be a native type. One known effect of this is enabling LoopStrengthReduce on loops with i32 induction variables. This can be beneficial because C/C++ code often has loops with i32 induction variables due to the use of `int` or `unsigned int`. If this patch exposes performance issues, those are better addressed by tuning LSR or other passes. Reviewed By: asb, frasercrmck Differential Revision: https://reviews.llvm.org/D116735
2022-10-21[AutoUpgrade] Fix remangling when upgrading struct return typeNikita Popov1-1/+1
This was remangling the old function rather than the new one, and could result in failures when we were performing both a struct return upgrade and an opaque pointer upgrade.
2022-10-21[AutoUpgrade] Fix length check for intrinsic upgradeNikita Popov1-1/+1
The shortest intrinsics that can be upgraded via remangling have 8 characters (like "llvm.abs"). Make sure these go through the upgrade code. I think that currently this change is not observable from in-tree callers of UpgradeIntrinsicFunction(), because callers do redundant remangling checks. However, this issue shows up in existing tests if those checks are removed (which I will do in followup changes).
2022-10-19[X86][RFC] Using `__bf16` for AVX512_BF16 intrinsicsPhoebe Wang1-0/+84
This is an alternative of D120395 and D120411. Previously we use `__bfloat16` as a typedef of `unsigned short`. The name may give user an impression it is a brand new type to represent BF16. So that they may use it in arithmetic operations and we don't have a good way to block it. To solve the problem, we introduced `__bf16` to X86 psABI and landed the support in Clang by D130964. Now we can solve the problem by switching intrinsics to the new type. Reviewed By: LuoYuanke, RKSimon Differential Revision: https://reviews.llvm.org/D132329
2022-09-23[AArch64]Remove svget/svset/svcreate from llvmCaroline Concatto1-0/+77
This patch removes the aarch64 instrinsic svget/svset/svcreate from llvm. It also implements the InstCombine for vector.extract that used to be in svget. Depends on: D131547 Differential Revision: https://reviews.llvm.org/D131548
2022-09-20[LLVM][AArch64] Replace aarch64.sve.ld by aarch64.sve.ldN.sretCaroline Concatto1-1/+40
This patch removes the intrinsic aarch64.sve.ldN from tablegen in favour of using arch64.sve.ldN.sret. Depends on: D133023 Differential Revision: https://reviews.llvm.org/D133025
2022-08-18[IR] Use Min behavior for module flag "PIC Level"Fangrui Song1-12/+20
Using Max for both "PIC Level" and "PIE Level" is inconsistent. PIC imposes less restriction while PIE imposes more restriction. The result generally picks the more restrictive behavior: Min for PIC. This choice matches `ld -r`: a non-pic object and a pic object merge into a result which should be treated as non-pic. To allow linking "PIC Level" using Error/Max from old bitcode files, upgrade Error/Max to Min. Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D130531
2022-06-29[Bitcode] Restore bitcast expression auto-upgradeNikita Popov1-1/+1
Restore the autoupgrade from bitcast to ptrtoint+inttoptr, which was lost as part of D127729. This fixes the backwards compatibility issue noted in: https://reviews.llvm.org/D127729#inline-1236519
2022-06-27[IR] Move vector.insert/vector.extract out of experimental namespaceBradley Smith1-0/+17
These intrinsics are now fundemental for SVE code generation and have been present for a year and a half, hence move them out of the experimental namespace. Differential Revision: https://reviews.llvm.org/D127976
2022-06-20[llvm] Don't use Optional::getValue (NFC)Kazu Hirata1-1/+1
2022-05-20[ObjCARC] Drop nullary clang.arc.attachedcall bundles in autoupgrade.Ahmed Bougacha1-0/+12
In certain use-cases, these can be emitted by old compilers, but the operand is now always required. These are only used for optimizations, so it's safe to drop them if they happen to have the now-invalid format. The semantically-required call is already a separate instruction. Differential Revision: https://reviews.llvm.org/D123811
2022-04-13[AutoUpgrade] Don't lose attributes when upgrading mem intrinsicsAlex Richardson1-0/+6
The original AutoUpgrade code from 1e68724d24ba38de7c7cdb2e1939d78c8b37cc0d did not retain existing attributes. I noticed this in some downstream test cases, but it turns out there are also two affected testcase upstream. Differential Revision: https://reviews.llvm.org/D121971
2022-04-13Support the min of module flags when linking, use for AArch64 BTI/PAC-RETDaniel Kiss1-0/+18
LTO objects might compiled with different `mbranch-protection` flags which will cause an error in the linker. Such a setup is allowed in the normal build with this change that is possible. Reviewed By: pcc Differential Revision: https://reviews.llvm.org/D123493
2022-03-30[AutoUpgrade] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off buildsFangrui Song1-3/+3
2022-03-30[AutoUpgrade] Don't upgrade intrinsics returning overloaded struct typeNikita Popov1-3/+9
We only want to do the upgrade from named to anonymous struct return if the intrinsic is declared to return a struct, but not if it has an overloaded return type that just happens to be a struct. In that case the struct type will be mangled into the intrinsic name and there is no problem. This should address the problem reported in https://reviews.llvm.org/D122471#3416598.
2022-03-30[IR] Require intrinsic struct return type to be anonymousNikita Popov1-26/+46
This is an alternative to D122376. Rather than working around the problem, this patch requires that struct return types in intrinsics are anonymous/literal and adds auto-upgrade code to convert existing uses of intrinsics with named struct types. This ensures that the mapping between intrinsic name and intrinsic function type is actually bijective, as it is supposed to be. This also fixes https://github.com/llvm/llvm-project/issues/37891. Differential Revision: https://reviews.llvm.org/D122471
2022-03-04[Bitcode] Move x86_intrcc upgrade to bitcode readerNikita Popov1-7/+0
This upgrade requires access the legacy pointer element type, so it needs to happen inside the bitcode reader.
2022-02-08[AutoUpgrade] Handle remangling upgrade for ptr.annotationNikita Popov1-2/+5
The code assumed that the upgrade would happen due to the argument count changing from 4 to 5. However, a remangling upgrade is also possible here.
2022-02-08[AutoUpgrade] Also upgrade intrinsics in invokesNikita Popov1-19/+19
We currently don't have any specialized upgrades for intrinsics that can be used in invokes, but they can still be subject to a generic remangling upgrade. In particular, this happens when upgrading statepoint intrinsics under -opaque-pointers. This patch just changes the upgrade code to work on CallBase instead of CallInst in particular.
2022-02-06[llvm] Use = default (NFC)Kazu Hirata1-1/+1
2022-02-04Reduce dependencies on llvm/BinaryFormat/Dwarf.hserge-sans-paille1-0/+1
This header is very large (3M Lines once expended) and was included in location where dwarf-specific information were not needed. More specifically, this commit suppresses the dependencies on llvm/BinaryFormat/Dwarf.h in two headers: llvm/IR/IRBuilder.h and llvm/IR/DebugInfoMetadata.h. As these headers (esp. the former) are widely used, this has a decent impact on number of preprocessed lines generated during compilation of LLVM, as showcased below. This is achieved by moving some definitions back to the .cpp file, no performance impact implied[0]. As a consequence of that patch, downstream user may need to manually some extra files: llvm/IR/IRBuilder.h no longer includes llvm/BinaryFormat/Dwarf.h llvm/IR/DebugInfoMetadata.h no longer includes llvm/BinaryFormat/Dwarf.h In some situations, codes maybe relying on the fact that llvm/BinaryFormat/Dwarf.h was including llvm/ADT/Triple.h, this hidden dependency now needs to be explicit. $ clang++ -E -Iinclude -I../llvm/include ../llvm/lib/Transforms/Scalar/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l after: 10978519 before: 11245451 Related Discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup [0] https://llvm-compile-time-tracker.com/compare.php?from=fa7145dfbf94cb93b1c3e610582c495cb806569b&to=995d3e326ee1d9489145e20762c65465a9caeab4&stat=instructions Differential Revision: https://reviews.llvm.org/D118781
2022-02-02Cleanup header dependencies in LLVMCoreserge-sans-paille1-1/+0
Based on the output of include-what-you-use. This is a big chunk of changes. It is very likely to break downstream code unless they took a lot of care in avoiding hidden ehader dependencies, something the LLVM codebase doesn't do that well :-/ I've tried to summarize the biggest change below: - llvm/include/llvm-c/Core.h: no longer includes llvm-c/ErrorHandling.h - llvm/IR/DIBuilder.h no longer includes llvm/IR/DebugInfo.h - llvm/IR/IRBuilder.h no longer includes llvm/IR/IntrinsicInst.h - llvm/IR/LLVMRemarkStreamer.h no longer includes llvm/Support/ToolOutputFile.h - llvm/IR/LegacyPassManager.h no longer include llvm/Pass.h - llvm/IR/Type.h no longer includes llvm/ADT/SmallPtrSet.h - llvm/IR/PassManager.h no longer includes llvm/Pass.h nor llvm/Support/Debug.h And the usual count of preprocessed lines: $ clang++ -E -Iinclude -I../llvm/include ../llvm/lib/IR/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l before: 6400831 after: 6189948 200k lines less to process is no that bad ;-) Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D118652
2022-01-25[NFC] Remove uses of PointerType::getElementType()Nikita Popov1-1/+1
Instead use either Type::getPointerElementType() or Type::getNonOpaquePointerElementType(). This is part of D117885, in preparation for deprecating the API.
2022-01-23[X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits to match ↵Phoebe Wang1-9/+22
with ICC MSVC currently doesn't support 80 bits long double. ICC supports it when the option `/Qlong-double` is specified. Changing the alignment of f80 to 16 bytes so that we can be compatible with ICC's option. Reviewed By: rnk, craig.topper Differential Revision: https://reviews.llvm.org/D115942
2022-01-18AMDGPU: Remove llvm.amdgcn.alignbit and handle bitcode upgrade to fshrMatt Arsenault1-0/+7
2022-01-18[AttrBuilder] Add string attribute getter (NFC)Nikita Popov1-9/+6
This avoids the need to scan through td_attrs() in AutoUpgrade, decoupling it from AttrBuilder implementation details.
2022-01-15Revert "[X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits ↵Phoebe Wang1-15/+4
to match with ICC" This reverts commit 1bb0caf561688681be67cc91560348c9e43fcbf3.
2022-01-12[X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits to match ↵Phoebe Wang1-4/+15
with ICC MSVC currently doesn't support 80 bits long double. ICC supports it when the option `/Qlong-double` is specified. Changing the alignment of f80 to 16 bytes so that we can be compatible with ICC's option. Reviewed By: rnk, craig.topper Differential Revision: https://reviews.llvm.org/D115942
2022-01-10Use a sorted array instead of a map to store AttrBuilder string attributesSerge Guelton1-6/+6
Using and std::map<SmallString, SmallString> for target dependent attributes is inefficient: it makes its constructor slightly heavier, and involves extra allocation for each new string attribute. Storing the attribute key/value as strings implies extra allocation/copy step. Use a sorted vector instead. Given the low number of attributes generally involved, this is cheaper, as showcased by https://llvm-compile-time-tracker.com/compare.php?from=5de322295f4ade692dc4f1823ae4450ad3c48af2&to=05bc480bf641a9e3b466619af43a2d123ee3f71d&stat=instructions Differential Revision: https://reviews.llvm.org/D116599
2021-12-03[IR][AutoUpgrade] Merge x86 mask load intrinsic upgrades. NFC.Simon Pilgrim1-8/+6
Helps appease MSVC which is complaining about "fatal error C1061: compiler limit: blocks nested too deeply" - we already do the same thing for avx512.mask.store intrinsics. This is only a stopgap solution until another else-if case needs adding - we really need to refactor this chain of ifs properly.
2021-12-03[ARM] Separate ARM autoupgrade code into a separate functionDavid Green1-85/+92
Try to appease the microsoft compiler which is apparently running out of if statements. Separate the new ARM code into a separate function to keep it simpler.
2021-12-03[ARM] Replace if's with a switch, NFCDavid Green1-15/+22
I'm not having a lot of luck with the microosft compiler recently. Maybe this will help it with its errors: llvm\lib\IR\AutoUpgrade.cpp(3726): fatal error C1061: compiler limit: blocks nested too deeply If not, it's a good code cleanup anyway.
2021-12-03[ARM] Use v2i1 for MVE and CDE intrinsicsDavid Green1-0/+106
This adjusts all the MVE and CDE intrinsics now that v2i1 is a legal type, to use a <2 x i1> as opposed to emulating the predicate with a <4 x i1>. The v4i1 workarounds have been removed leaving the natural v2i1 types, notably in vctp64 which now generates a v2i1 type. AutoUpgrade code has been added to upgrade old IR, which needs to convert the old v4i1 to a v2i1 be converting it back and forth to an integer with arm.mve.v2i and arm.mve.i2v intrinsics. These should be optimized away in the final assembly. Differential Revision: https://reviews.llvm.org/D114455
2021-10-23[llvm] Use StringRef::contains (NFC)Kazu Hirata1-1/+1
2021-10-04[IR] Migrate from getNumArgOperands to arg_size (NFC)Kazu Hirata1-33/+32
Note that arg_operands is considered a legacy name. See llvm/include/llvm/IR/InstrTypes.h for details.
2021-09-30[llvm] Migrate from arg_operands to args (NFC)Kazu Hirata1-1/+1
Note that arg_operands is considered a legacy name. See llvm/include/llvm/IR/InstrTypes.h for details.
2021-09-28[IR] Change the default value of InstertElement to poison (1/4)hyeongyu kim1-1/+1
This patch is for fixing potential insertElement-related bugs like D93818. ``` V = UndefValue::get(VecTy); for(...) V = Builder.CreateInsertElementy(V, Elt, Idx); => V = PoisonValue::get(VecTy); for(...) V = Builder.CreateInsertElementy(V, Elt, Idx); ``` Like above, this patch changes the placeholder V to poison. The patch will be separated into several commits. Reviewed By: aqjune Differential Revision: https://reviews.llvm.org/D110311
2021-09-11[ARM] Support neon.vld auto-upgrade with opaque pointersNikita Popov1-1/+3
This code manually constructs the intrinsic name, so we need to use p0 instead of p0i8 in opaque pointer mode.
2021-09-08[IR] Construct SmallVector with iterator ranges (NFC)Kazu Hirata1-16/+8
Note that arg_operands has been deprecated in favor of args.
2021-08-17[NFC] More get/removeAttribute() cleanupArthur Eubanks1-2/+2
2021-08-17[NFC] Migrate some callers away from Function/AttributeLists methods that ↵Arthur Eubanks1-2/+1
take an index These methods can be confusing.
2021-07-04[IRBuilder] Add type argument to CreateMaskedLoad/GatherNikita Popov1-3/+2
Same as other CreateLoad-style APIs, these need an explicit type argument to support opaque pointers. Differential Revision: https://reviews.llvm.org/D105395