1129 Commits

Author SHA1 Message Date
weiguozhi
c166a43c6e
New calling convention preserve_none (#76868)
The new experimental calling convention preserve_none is the opposite
side of existing preserve_all. It tries to preserve as few general
registers as possible. So all general registers are caller saved
registers. It can also uses more general registers to pass arguments.
This attribute doesn't impact floating-point registers. Floating-point
registers still follow the c calling convention.

Currently preserve_none is supported on X86-64 only. It changes the c
calling convention in following fields:
  
* RSP and RBP are the only preserved general registers, all other
general registers are caller saved registers.
* We can use [RDI, RSI, RDX, RCX, R8, R9, R11, R12, R13, R14, R15, RAX]
to pass arguments.

It can improve the performance of hot tailcall chain, because many
callee saved registers' save/restore instructions can be removed if the
tail functions are using preserve_none. In my experiment in protocol
buffer, the parsing functions are improved by 3% to 10%.
2024-02-05 13:28:43 -08:00
Nikita Popov
d91bb2fcd3 [AsmParser] Check whether use is callee when determining function type
The code ended up treating a use in a call argument as if it were
a call. Make sure this is actually the callee use.
2024-02-05 10:12:54 +01:00
Nikita Popov
f2df4bfe54
[AsmParser] Support non-consecutive global value numbers (#80013)
https://github.com/llvm/llvm-project/pull/78171 added support for
non-consecutive local value numbers. This extends the support for global
value numbers (for globals and functions).

This means that it is now possible to delete an unnamed global
definition/declaration without breaking the IR.

This is a lot less common than unnamed local values, but it seems like
something we should support for consistency. (Unnamed globals are used a
lot in Rust though.)
2024-01-31 17:04:30 +01:00
Nikita Popov
5cc87b424b
[AsmParser] Add missing globals declarations in incomplete IR mode (#79855)
If `-allow-incomplete-ir` is enabled, automatically insert declarations
for missing globals.

If a global is only used in calls with the same function type, insert a
function declaration with that type.

Otherwise, insert a dummy i8 global. The fallback case could be extended
with various heuristics (e.g. we could look at load/store types), but
I've chosen to keep it simple for now, because I'm unsure to what degree
this would really useful without more experience. I expect that in most
cases the declaration type doesn't really matter (note that the type of
an external global specifies a *minimum* size only, not a precise size).

This is a followup to https://github.com/llvm/llvm-project/pull/78421.
2024-01-31 12:24:35 +01:00
Nikita Popov
9350860824
[AsmParser] Add support for reading incomplete IR (part 1) (#78421)
Add an `-allow-incomplete-ir` flag to the IR parser, which allows
reading IR with missing declarations. This is intended to produce a
best-effort interpretation of the IR, along the same lines of what we
would manually do when taking, for example, a function from
`-print-after-all` output and fixing it up to be valid IR.

This patch only supports dropping references to undeclared metadata,
either by dropping metadata attachments from instructions/functions, or
by dropping calls to certain intrinsics (like debug intrinsics). I will
implement support for inserting missing function/global declarations in
a followup patch.

We don't have real use lists for metadata, so the approach here is to
iterate over the whole IR and identify metadata that needs to be
dropped. This does not support all possible cases, but should handle
anything that's relevant for the function-only IR use case.
2024-01-19 16:08:16 +01:00
Nikita Popov
0f20d5a8b1 [AsmParser] Deduplicate argument list parsing code (NFC)
The handling for parsing the first argument and all later arguments
was duplicated. Consolidate them into a single loop.
2024-01-19 15:03:12 +01:00
Nikita Popov
6f371149c1
[AsmParser] Don't require value numbers to be consecutive (#78171)
Currently, the IR parser requires that %n style numbered values are
consecutive. This means that the IR becomes invalid as soon as you
remove an instruction, argument or block. This makes it very annoying to
modify IR without running it through instnamer first.

I don't think there is any good reason to impose this requirement. This
PR relaxes it to allow value IDs to be non-consecutive, but it still
keeps the requirement that they're increasing (i.e. you can't skip a
value number and then assign it later).

This only implements support for skipping numbers for local values. We
should extend this to global values in the future as well.
2024-01-19 14:55:31 +01:00
Nikita Popov
34b106789a
[AsmParser] Implicitly declare intrinsics (#78251)
We currently require that all referenced globals have an explicit
declaration or definition in the IR. For intrinsics, this requirement is
redundant, because they cannot be called indirectly (including "direct"
calls with mismatched function type). The function type used in the call
directly determines the function type of the intrinsic declaration.

Relax this requirement, and implicitly declare any intrinsics that do
not have an explicit declaration. This will remove a common annoyance
when writing tests and alive2 proofs.

(I also plan to introduce a mode where declarations for all missing
symbols will be automatically added, to make working with incomplete IR
easier -- but that will be behind a default-disabled flag.)
2024-01-17 09:35:50 +01:00
Paul Walker
9c6693f901
[LLVM][IR] Add textual shorthand for specifying constant vector splats. (#74620)
Add LL parsing for `<N x ty> splat(ty <imm>)` that lowers onto
ConstantInt::get() for integer types and ConstantFP::get() for
floating-point types.

The intent is to extend ConstantInt/FP classes to support vector types
rather than redirecting to other constant classes as the get() methods
do today.

This patch gives IR writers the convenience of using the shorthand
today, thus allowing existing tests to be ported.
2023-12-08 18:41:30 +00:00
Nikita Popov
dfd36aa70e [AsmParser] Gracefully handle non-existent GV summary reference
If the module summary references a global variable that does not
exist, throw a nice error instead of asserting.

Fixes https://github.com/llvm/llvm-project/issues/74726.
2023-12-07 17:00:44 +01:00
Teresa Johnson
88fbc4d3df
[ThinLTO] Add tail call flag to call edges in summary (#74043)
This adds support for a HasTailCall flag on function call edges in the
ThinLTO summary. It is intended for use in aiding discovery of missing
frames from tail calls in profiled call stacks for MemProf of profiled
binaries that did not disable tail call elimination. A follow on change
will add the use of this new flag during MemProf context disambiguation.

The new flag is encoded in the bitcode along with either the hotness
flag from the profile, or the relative block frequency under the
-write-relbf-to-summary flag when there is no profile data.
Because we now will always have some additional call edge information, I
have removed the non-profile function summary record format, and we
simply encode the tail call flag along with a hotness type of none when
there is no profile information or relative block frequency. The change
of record format and name caused most of the test case changes.

I have added explicit testing of generation of the new tail call flag
into the bitcode and IR assembly format as part of the changes to
llvm/test/Bitcode/thinlto-function-summary-refgraph.ll. I have also
added round trip testing through assembly and bitcode to
llvm/test/Assembler/thinlto-summary.ll.
2023-12-06 08:41:44 -08:00
eleviant
432bb523e2
Fix parsing out-of-order ValueInfos (#73239)
AsmParser creates dummy values when value identifiers are not going in ascending order and tries to use those dummy values when/if they are being referenced. We need to postpone this until all required data is read.
2023-12-05 11:00:13 +01:00
hev
a8874cf50b
[llvm][IR] Add per-global code model attribute (#72077)
This adds a per-global code model attribute, which can override the
target's code model to access global variables.

Suggested-by: Arthur Eubanks <aeubanks@google.com>
Link: https://discourse.llvm.org/t/how-to-best-implement-code-model-overriding-for-certain-values/71816
Link: https://discourse.llvm.org/t/rfc-add-per-global-code-model-attribute/74944
2023-12-05 09:42:53 +08:00
Craig Topper
d9962c400f
[IR] Add disjoint flag for Or instructions. (#72583)
This flag indicates that every bit is known to be zero in at least one
of the inputs. This allows the Or to be treated as an Add since there is
no possibility of a carry from any bit.

If the flag is present and this property does not hold, the result is
poison.

This makes it easier to reverse the InstCombine transform that turns Add
into Or.

This is inspired by a comment here
https://github.com/llvm/llvm-project/pull/71955#discussion_r1391614578

Discourse thread
https://discourse.llvm.org/t/rfc-add-or-disjoint-flag/75036
2023-11-24 08:49:19 -08:00
Stephen Tozer
f99a020059 Reapply "[DebugInfo] Make DIArgList inherit from Metadata and always unique"
This reverts commit 0fd5dc94380d5fe666dc6c603b4bb782cef743e7.

The original commit removed DIArgLists from being in an MDNode map, but did
not insert a new `delete` in the LLVMContextImpl destructor. This
reapply adds that call to delete, preventing a memory leak.
2023-11-17 17:55:41 +00:00
Stephen Tozer
0fd5dc9438
Revert "[DebugInfo] Make DIArgList inherit from Metadata and always unique" (#72682)
Reverts llvm/llvm-project#72147

Reverted due to buildbot failure:
https://lab.llvm.org/buildbot/#/builders/5/builds/38410
2023-11-17 17:44:19 +00:00
Sacha Coppey
aeedc07637 [IR] Add GraalVM calling conventions
Adds GraalVM calling conventions. The only difference with the default calling conventions is that GraalVM reserves two registers for the heap base and the thread. Since the registers are then accessed by name, getRegisterByName has to be updated accordingly.

This patch implements the calling conventions only for X86, AArch64 and RISC-V.

For X86, the reserved registers are X14 and X15. For AArch64, they are X27 and X28. For RISC-V, they are X23 and X27.

This patch has been used by the LLVM backend of GraalVM's Native Image project in production for around 4 months with no major issues.

Differential Revision: https://reviews.llvm.org/D151107
2023-11-17 16:30:09 +00:00
Stephen Tozer
e77af7e1b0
[DebugInfo] Make DIArgList inherit from Metadata and always unique (#72147)
This patch changes the `DIArgList` class's inheritance from `MDNode` to
`Metadata, ReplaceableMetadataImpl`, and ensures that it is always
unique, i.e. a distinct DIArgList should never be produced.

This should not result in any changes to IR or bitcode parsing and
printing, as the format for DIArgList is unchanged, and the order in which it
appears should also be identical. As a minor note, this patch also fixes
a gap in the verifier, where the ValueAsMetadata operands to a DIArgList
would not be visited.
2023-11-17 14:04:54 +00:00
Nikita Popov
56c1d30183
[IR] Remove support for lshr/ashr constant expressions (#71955)
Remove support for the lshr and ashr constant expressions. All places
creating them have been removed beforehand, so this just removes the
APIs and uses of these constant expressions in tests.

This is part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
2023-11-14 09:25:14 +01:00
Juergen Ributzka
6d1d7be133
Obsolete WebKit Calling Convention (#71567)
The WebKit Calling Convention was created specifically for the WebKit
FTL. FTL
doesn't use LLVM anymore and therefore this calling convention is
obsolete.

This commit removes the WebKit CC, its associated tests, and
documentation.
2023-11-09 09:08:41 -08:00
Nikita Popov
17764d2c87
[IR] Remove FP cast constant expressions (#71408)
Remove support for the fptrunc, fpext, fptoui, fptosi, uitofp and sitofp
constant expressions. All places creating them have been removed
beforehand, so this just removes the APIs and uses of these constant
expressions in tests.

With this, the only remaining FP operation that still has constant
expression support is fcmp.

This is part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
2023-11-07 09:34:16 +01:00
Nikita Popov
e4a4122eb6
[IR] Remove zext and sext constant expressions (#71040)
Remove support for zext and sext constant expressions. All places
creating them have been removed beforehand, so this just removes the
APIs and uses of these constant expressions in tests.

There is some additional cleanup that can be done on top of this, e.g.
we can remove the ZExtInst vs ZExtOperator footgun.

This is part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
2023-11-03 10:46:07 +01:00
Nikita Popov
ed3f06b9b3
[IR] Add zext nneg flag (#67982)
Add an nneg flag to the zext instruction, which specifies that the
argument is non-negative. Otherwise, the result is a poison value.

The primary use-case for the flag is to preserve information when sext
gets replaced with zext due to range-based canonicalization. The nneg
flag allows us to convert the zext back into an sext later. This is
useful for some optimizations (e.g. a signed icmp can fold with sext but
not zext), as well as some targets (e.g. RISCV prefers sext over zext).

Discourse thread: https://discourse.llvm.org/t/rfc-add-zext-nneg-flag/73914

This patch is based on https://reviews.llvm.org/D156444 by
@Panagiotis156, with some implementation simplifications and additional
tests.

---------

Co-authored-by: Panagiotis K <karouzakispan@gmail.com>
2023-10-30 09:04:04 +01:00
Min-Yih Hsu
fd84b1a99d [M68k] Add new calling convention M68k_RTD
`M68k_RTD` is really similar to X86's stdcall, in which callee pops the
arguments from stack. In LLVM IR it can be written as `m68k_rtdcc`.
This patch also improves how ExpandPseudo Pass handles popping stack at
function returns in the absent of the RTD instruction.

Differential Revision: https://reviews.llvm.org/D149864
2023-10-15 16:12:31 -07:00
Craig Topper
8c26e473e7
[LLParser] Merge xor constantexpr parsing with add/mul/shl/lshr/ashr. (#67371)
Not sure if xor is sticking around or not. I see and/or was already
removed.

This changes the error messages and makes one error message more
accurate.
2023-09-26 14:48:30 -07:00
Craig Topper
d034c18e7c
[LLParser] Remove unnecessary switch from the handling of the remaini… (#67362)
…ng binary constantexprs.

FP binary operators aren't supported anymore, so we don't need a switch
to pick whether we expect an integer or FP type.
2023-09-25 13:40:00 -07:00
Teresa Johnson
bbe8cd1333 [LTO] Remove module id from summary index
The module paths string table mapped to both an id sequentially assigned
during LTO linking, and the module hash. The former is leftover from
before the module hash was added for caching and subsequently replaced
use of the module id when renaming promoted symbols (to avoid affects
due to link order changes). The sequentially assigned module id was not
removed, however, as it was still a convenience when serializing to/from
bitcode and assembly.

This patch removes the module id from this table, since it isn't
strictly needed and can lead to confusion on when it is appropriate to
use (e.g. see fix in D156525). It also takes a (likely not significant)
amount of overhead. Where an integer module id is needed (e.g. bitcode
writing), one is assigned on the fly.

There are a couple of test changes since the paths are now sorted
alphanumerically when assigning ids on the fly during assembly writing,
in order to ensure deterministic behavior.

Differential Revision: https://reviews.llvm.org/D156730
2023-09-01 13:43:08 -07:00
Nikita Popov
625113402f [IR] Remove support for and/or constant expressions
As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179,
this removes support for and and or constant expressions. Places
creating such expressions have been migrated in advance, so this
is mostly API removal and test updates.

Differential Revision: https://reviews.llvm.org/D155924
2023-08-22 09:29:54 +02:00
Nikita Popov
2cc79baf02 [LLParser] Remove checks related to typed pointers (NFC) 2023-07-14 10:41:34 +02:00
Nikita Popov
61e0822efa [llvm][clang] Remove uses of isOpaquePointerTy() (NFC)
This now always returns true (for pointer types).
2023-07-14 10:27:58 +02:00
Johannes Doerfert
a90ac20c52 [MemoryEffects][NFCI] Make the MemoryEffects class reusable
In a follow up we will reuse the logic in MemoryEffectsBase to merge
AAMemoryLocation and AAMemoryBehavior without duplicating all the bit
fiddling code already available in MemoryEffectsBase.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D153305
2023-07-03 10:07:03 -07:00
Youngsuk Kim
243f0566dc [llvm] Replace uses of Type::getPointerTo (NFC)
Partial progress towards removing in-tree uses of `Type::getPointerTo`,
before we can deprecate the API.

If the API is used solely to support an unnecessary bitcast, get rid of
the bitcast as well.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D153933
2023-06-28 09:21:34 -04:00
Diana Picus
29dcc4c143 [AMDGPU] Add amdgpu_cs_chain[_preserve] CCs to IR & verifier
Add the amdgpu_cs_chain and amdgpu_cs_chain_preserve keywords to
LLVM IR and make sure we can parse and print them. Also make sure we
perform some basic checks in the IR verifier - similar to what we check
for many of the other AMDGPU calling conventions, plus the additional
restriction that we can't have direct calls to functions with these
calling conventions.

Differential Revision: https://reviews.llvm.org/D151994
2023-06-22 10:02:45 +02:00
eopXD
c8eb535aed [1/11][IR] Permit load/store/alloca for struct of the same scalable vector type
This patch-set aims to simplify the existing RVV segment load/store
intrinsics to use a type that represents a tuple of vectors instead.

To achieve this, first we need to relax the current limitation for an
aggregate type to be a target of load/store/alloca when the aggregate
type contains homogeneous scalable vector types. Then to adjust the
prolog of an LLVM function during lowering to clang. Finally we
re-define the RVV segment load/store intrinsics to use the tuple types.

The pull request under the RVV intrinsic specification is
riscv-non-isa/rvv-intrinsic-doc#198

---

This is the 1st patch of the patch-set. This patch is originated from
D98169.

This patch allows aggregate type (StructType) that contains homogeneous
scalable vector types to be a target of load/store/alloca. The RFC of
this patch was posted in LLVM Discourse.

https://discourse.llvm.org/t/rfc-ir-permit-load-store-alloca-for-struct-of-the-same-scalable-vector-type/69527

The main changes in this patch are:

Extend `StructLayout::StructSize` from `uint64_t` to `TypeSize` to
accommodate an expression of scalable size.

Allow `StructType:isSized` to also return true for homogeneous
scalable vector types.

Let `Type::isScalableTy` return true when `Type` is `StructType`
and contains scalable vectors

Extra description is added in the LLVM Language Reference Manual on the
relaxation of this patch.

Authored-by: Hsiangkai Wang <kai.wang@sifive.com>
Co-Authored-by: eop Chen <eop.chen@sifive.com>

Reviewed By: craig.topper, nikic

Differential Revision: https://reviews.llvm.org/D146872
2023-05-19 09:39:36 -07:00
Kan Wu
b8d2f7177c [MemProf] Add hot allocation type
Add "Hot" AllocationType (in addition to existing cold, notcold).

Use lifetime access density as metric to identify hot allocations.
Treat hot as notcold for MemProfContextDisambiguation for now
before the disambiguation for "hot" is done.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D149932
2023-05-08 10:34:53 -07:00
Teresa Johnson
e0577ce367 [MemProf] Removed unused allocation type
Removes the 'notcoldandcold' allocation type summary
(de)serialization support added in D135714, after realizing that this
will never be generated in practice.

There are 2 uses of the allocation type keywords in the summary. One is
for the individual profiled memprof context summaries, and each context
can only be assigned a single type of hotness. The second is in the
clone version information produced by the MemProfContextDisambiguation
whole program step, and we only create a clone for a specific allocation
type.

Differential Revision: https://reviews.llvm.org/D149669
2023-05-02 13:11:35 -07:00
Nikita Popov
bbfb13a5ff [ConstExpr] Remove select constant expression
This removes the select constant expression, as part of
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
Uses of this expressions have already been removed in advance,
so this just removes related infrastructure and updates tests.

Differential Revision: https://reviews.llvm.org/D145382
2023-03-16 10:32:08 +01:00
Arthur Eubanks
24a08593b9 [LLParser] Error out if a name is too long and gets renamed
Typically names longer than -non-global-value-max-name-size will just get renamed if there is a collision after truncating. This is fine since we typically don't reference Values by name.

However LLParser does reference Values by name, so report an error when that happens, otherwise weird issues can crop up if there are name collisions (e.g. verifier issues with the changed test case because we end up reusing the same block for `testz` and `testa`).

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D145282
2023-03-06 15:43:34 -08:00
Matt Arsenault
a07e75352e LLParser: Fix failing nofpclass test 2023-02-24 08:46:11 -04:00
Matt Arsenault
5da674492a IR: Add nofpclass parameter attribute
This carries a bitmask indicating forbidden floating-point value kinds
in the argument or return value. This will enable interprocedural
-ffinite-math-only optimizations. This is primarily to cover the
no-nans and no-infinities cases, but also covers the other floating
point classes for free. Textually, this provides a number of names
corresponding to bits in FPClassTest, e.g.

  call nofpclass(nan inf) @must_be_finite()
  call nofpclass(snan) @cannot_be_snan()

This is more expressive than the existing nnan and ninf fast math
flags. As an added bonus, you can represent fun things like nanf:

  declare nofpclass(inf zero sub norm) float @only_nans()

Compared to nnan/ninf:
  - Can be applied to individual call operands as well as the return value
  - Can distinguish signaling and quiet nans
  - Distinguishes the sign of infinities
  - Can be safely propagated since it doesn't imply anything about
    other operands.
  - Does not apply to FP instructions; it's not a flag

This is one step closer to being able to retire "no-nans-fp-math" and
"no-infs-fp-math". The one remaining situation where we have no way to
represent no-nans/infs is for loads (if we wanted to solve this we
could introduce !nofpclass metadata, following along with
noundef/!noundef).

This is to help simplify the GPU builtin math library
distribution. Currently the library code has explicit finite math only
checks, read from global constants the compiler driver needs to set
based on the compiler flags during linking. We end up having to
internalize the library into each translation unit in case different
linked modules have different math flags. By propagating known-not-nan
and known-not-infinity information, we can automatically prune the
edge case handling in most functions if the function is only reached
from fast math uses.
2023-02-24 07:41:29 -04:00
Vasileios Porpodas
d180443570 [NFC][IR] Make Module::getIFuncList() private.
This patch adds several missing IFuncList modifier functions, like
removeIFunc(), eraseIFunc() and insertIFunc().
There is no longer need to access the list directly so it also makes
getIFuncList() private.

Differential Revision: https://reviews.llvm.org/D143968
2023-02-14 09:28:06 -08:00
Vasileios Porpodas
afad153a08 Recommit: [NFC][IR] Make Module::getAliasList() private
This reverts commit 6d4a674acbc56458bb084878d82d16e393d45a6b.
2023-02-13 20:07:56 -08:00
Vasileios Porpodas
6d4a674acb Revert "[NFC][IR] Make Module::getAliasList() private"
This reverts commit b64f7d028bdcaf679130afeed9518c09663f6dc8.
2023-02-13 19:12:30 -08:00
Vasileios Porpodas
b64f7d028b [NFC][IR] Make Module::getAliasList() private
This patch adds several missing AliasList modifier functions, like
removeAlias(), eraseAlias() and insertAlias().
There is no longer need to access the list directly so it also makes
getAliaList() private.

Differential Revision: https://reviews.llvm.org/D143958
2023-02-13 18:45:12 -08:00
Amir Aupov
782045e727 Revert "HHVM calling conventions."
This reverts commit cce239c45d6ef3865a017b5b3f935964e0348734.

HHVM calling conventions are unused. Remove them by partially reverting the commit.

Reviewed By: MaskRay, MatzeB

Differential Revision: https://reviews.llvm.org/D124330
2023-02-09 10:53:11 -08:00
Guillaume Chatelet
6280cab0fe [NFC] Use GlobalObject::setAlignment that takes an Align in LLParser 2023-02-01 09:14:23 +00:00
Guillaume Chatelet
ffc1205bde [reland][NFC] Transition GlobalObject alignment from MaybeAlign to Align
This is a follow up on https://reviews.llvm.org/D142459#4081179.
This first patch adds an overload to `GlobalObject::setAlignment` that accepts an `Align` type.
This already handles most of the calls.

This patch also converts a few call sites to the new type when this is safe.

Here is the list of the remaining call sites:

 - [clang/lib/CodeGen/CodeGenModule.cpp:1688](e195e6bad6/clang/lib/CodeGen/CodeGenModule.cpp (L1688))
 - [llvm/lib/AsmParser/LLParser.cpp:1309](e195e6bad6/llvm/lib/AsmParser/LLParser.cpp (L1309))
 - [llvm/lib/AsmParser/LLParser.cpp:6050](e195e6bad6/llvm/lib/AsmParser/LLParser.cpp (L6050))
 - [llvm/lib/Bitcode/Reader/BitcodeReader.cpp:3871](e195e6bad6/llvm/lib/Bitcode/Reader/BitcodeReader.cpp (L3871))
 - [llvm/lib/Bitcode/Reader/BitcodeReader.cpp:4030](e195e6bad6/llvm/lib/Bitcode/Reader/BitcodeReader.cpp (L4030))
 - [llvm/lib/IR/Core.cpp:2018](e195e6bad6/llvm/lib/IR/Core.cpp (L2018))
 - [llvm/lib/IR/Globals.cpp:141](e195e6bad6/llvm/lib/IR/Globals.cpp (L141))
 - [llvm/lib/Linker/IRMover.cpp:660](e195e6bad6/llvm/lib/Linker/IRMover.cpp (L660))
 - [llvm/lib/Linker/LinkModules.cpp:361](e195e6bad6/llvm/lib/Linker/LinkModules.cpp (L361))
 - [llvm/lib/Linker/LinkModules.cpp:362](e195e6bad6/llvm/lib/Linker/LinkModules.cpp (L362))
 - [llvm/lib/Transforms/IPO/MergeFunctions.cpp:782](e195e6bad6/llvm/lib/Transforms/IPO/MergeFunctions.cpp (L782))
 - [llvm/lib/Transforms/IPO/MergeFunctions.cpp:840](e195e6bad6/llvm/lib/Transforms/IPO/MergeFunctions.cpp (L840))
 - [llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1813](e195e6bad6/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp (L1813))
 - [llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp:27](e195e6bad6/llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp (L27))

Differential Revision: https://reviews.llvm.org/D142708
2023-01-31 15:09:10 +00:00
Guillaume Chatelet
e098ee726e Revert D142708 "[NFC] Transition GlobalObject alignment from MaybeAlign to Align"
This is breaking the build bots. e.g.,
https://lab.llvm.org/buildbot/#/builders/121/builds/27549

This reverts commit 6717efe74da825214cb4d307ad35e5fbda353301.
2023-01-31 14:12:51 +00:00
Guillaume Chatelet
6717efe74d [NFC] Transition GlobalObject alignment from MaybeAlign to Align
This is a follow up on https://reviews.llvm.org/D142459#4081179.
This first patch adds an overload to `GlobalObject::setAlignment` that accepts an `Align` type.
This already handles most of the calls.

This patch also converts a few call sites to the new type when this is safe.

Here is the list of the remaining call sites:

 - [clang/lib/CodeGen/CodeGenModule.cpp:1688](e195e6bad6/clang/lib/CodeGen/CodeGenModule.cpp (L1688))
 - [llvm/lib/AsmParser/LLParser.cpp:1309](e195e6bad6/llvm/lib/AsmParser/LLParser.cpp (L1309))
 - [llvm/lib/AsmParser/LLParser.cpp:6050](e195e6bad6/llvm/lib/AsmParser/LLParser.cpp (L6050))
 - [llvm/lib/Bitcode/Reader/BitcodeReader.cpp:3871](e195e6bad6/llvm/lib/Bitcode/Reader/BitcodeReader.cpp (L3871))
 - [llvm/lib/Bitcode/Reader/BitcodeReader.cpp:4030](e195e6bad6/llvm/lib/Bitcode/Reader/BitcodeReader.cpp (L4030))
 - [llvm/lib/IR/Core.cpp:2018](e195e6bad6/llvm/lib/IR/Core.cpp (L2018))
 - [llvm/lib/IR/Globals.cpp:141](e195e6bad6/llvm/lib/IR/Globals.cpp (L141))
 - [llvm/lib/Linker/IRMover.cpp:660](e195e6bad6/llvm/lib/Linker/IRMover.cpp (L660))
 - [llvm/lib/Linker/LinkModules.cpp:361](e195e6bad6/llvm/lib/Linker/LinkModules.cpp (L361))
 - [llvm/lib/Linker/LinkModules.cpp:362](e195e6bad6/llvm/lib/Linker/LinkModules.cpp (L362))
 - [llvm/lib/Transforms/IPO/MergeFunctions.cpp:782](e195e6bad6/llvm/lib/Transforms/IPO/MergeFunctions.cpp (L782))
 - [llvm/lib/Transforms/IPO/MergeFunctions.cpp:840](e195e6bad6/llvm/lib/Transforms/IPO/MergeFunctions.cpp (L840))
 - [llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp:1813](e195e6bad6/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp (L1813))
 - [llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp:27](e195e6bad6/llvm/tools/llvm-reduce/deltas/ReduceGlobalObjects.cpp (L27))

Differential Revision: https://reviews.llvm.org/D142708
2023-01-31 13:59:58 +00:00
Matt Arsenault
778cf5431c IR: Add atomicrmw uinc_wrap and udec_wrap
These are essentially add/sub 1 with a clamping value.

AMDGPU has instructions for these. CUDA/HIP expose these as
atomicInc/atomicDec. Currently we use target intrinsics for these,
but those do no carry the ordering and syncscope. Add these to
atomicrmw so we can carry these and benefit from the regular
legalization processes.
2023-01-24 17:55:11 -04:00