platform/upstream/llvm.git
17 months ago[flang][runtime] Support DT edit descriptor in result of READ(SIZE=)
Peter Klausler [Fri, 17 Feb 2023 00:30:38 +0000 (16:30 -0800)]
[flang][runtime] Support DT edit descriptor in result of READ(SIZE=)

When a formatted I/O READ statement processes a DT edit descriptor to call a
user-defined I/O subroutine to read a derived type data item, all of the
characters that that subroutine reads via child I/O count as charecters
read by an edit descriptor and should accumulate in the result returned
by a SIZE= item in the original READ statement's control list.

Differential Revision: https://reviews.llvm.org/D144234

17 months ago[libc++][CI] Switches to clang-format-16.
Mark de Wever [Wed, 15 Feb 2023 20:00:06 +0000 (21:00 +0100)]
[libc++][CI] Switches to clang-format-16.

Uses an absolute path to the selected binary.
Updates the formatting of two files to match clang-format-16 style.

Depends on D144126

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D144132

17 months ago[libc++] Improve the format ignorelist generation.
Mark de Wever [Wed, 15 Feb 2023 18:50:55 +0000 (19:50 +0100)]
[libc++] Improve the format ignorelist generation.

Several improvements
- Only add files that we actually want to format.
- Sort according to a fixed locale.

Some drive-by fixes
- Rename a text file, this avoids a filter exception.
- Adds a some missing source files extensions.
- Removes unused extensions hh, hxx, cc, and cxx from clang-format.

Reviewed By: philnik, #libc

Differential Revision: https://reviews.llvm.org/D144126

17 months ago[RISCV] Add preferred function and loop alignment RISCVSubtarget. NFC
Craig Topper [Fri, 17 Feb 2023 16:43:40 +0000 (08:43 -0800)]
[RISCV] Add preferred function and loop alignment RISCVSubtarget. NFC

These seem like properties we will want to adjust based on -mtune.
Move them to subtarget like is done on ARM and AArch64. Don't add
any overrides yet.

Note there's a slight change here. We are now passing Align(1) for
preferred function alignment where we previously passed the minimum
alignment. As far as I could tell, it will be maxed with min when
it used so this should be ok.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D144048

17 months ago[libc++][NFC] Rename _LIBCPP_NO_EXCEPTIONS to _LIBCPP_HAS_NO_EXCEPTIONS
Nikolas Klauser [Thu, 2 Feb 2023 10:47:01 +0000 (11:47 +0100)]
[libc++][NFC] Rename _LIBCPP_NO_EXCEPTIONS to _LIBCPP_HAS_NO_EXCEPTIONS

Other macros that disable parts of the library are named `_LIBCPP_HAS_NO_WHATEVER`.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits, smeenai

Differential Revision: https://reviews.llvm.org/D143163

17 months ago[ADT] Add `at` method (assertive lookup) to DenseMap and StringMap
Ryan Guo [Tue, 14 Feb 2023 04:06:44 +0000 (20:06 -0800)]
[ADT] Add `at` method (assertive lookup) to DenseMap and StringMap

This patch makes it easier for users when they want to use validated
lookup on DenseMap/StringMap as a composable C++ expression. For
instance:

```
// instead of
if (auto val = map.lookup(key))
   return val;
assert("...");

// we can write
return map.at(key);
```

Differential Revision: https://reviews.llvm.org/D143976

17 months ago[clang-tidy] Clarify bugprone-branch-clone diagnostic message
Donát Nagy [Mon, 13 Feb 2023 14:35:24 +0000 (15:35 +0100)]
[clang-tidy] Clarify bugprone-branch-clone diagnostic message

This simple commit inserts "body" into the message "repeated branch _body_ in
conditional chain". This is motivated by feedback from a user who (at first
glance) thought that clang-tidy complained about a repeated branch _condition_.

Differential Revision: https://reviews.llvm.org/D143917

17 months ago[libc][bazel] Export .bzl files for libc/test and libc/test/src/math.
Tue Ly [Fri, 17 Feb 2023 16:02:22 +0000 (11:02 -0500)]
[libc][bazel] Export .bzl files for libc/test and libc/test/src/math.

17 months ago[libc++][test] Adds more generic test macros.
Mark de Wever [Sat, 21 Jan 2023 12:35:30 +0000 (13:35 +0100)]
[libc++][test] Adds more generic test macros.

These macros are intended to replace the macros in rapid-cxx-test.h.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D142808

17 months ago[gn build] Port bf0f94a5cf82
LLVM GN Syncbot [Fri, 17 Feb 2023 15:40:33 +0000 (15:40 +0000)]
[gn build] Port bf0f94a5cf82

17 months ago[mlir] add option to multi-buffering
Thomas Raoux [Fri, 17 Feb 2023 15:05:23 +0000 (15:05 +0000)]
[mlir] add option to multi-buffering

Allow user to apply multi-buffering transformation for cases where proving
that there is no loop carried dependency is not trivial. In this case user needs
to ensure that the data are written and read in the same iteration otherwise the
result is incorrect.

Differential Revision: https://reviews.llvm.org/D144227

17 months ago[InstCombine] create a pass options container and add "use-loop-info" argument
Sanjay Patel [Fri, 17 Feb 2023 15:11:40 +0000 (10:11 -0500)]
[InstCombine] create a pass options container and add "use-loop-info" argument

This is a cleanup/modernization patch requested in D144045 to make loop
analysis a proper optional parameter to the pass rather than a
semi-arbitrary value inherited via the pass pipeline.

It's a bit more complicated than the recent patch I started copying from
(D143980) because InstCombine already has an option for MaxIterations
(added with D71145).

I debated just deleting that option, but it was used by a pair of existing
tests, so I put it into a struct (code largely copied from SimplifyCFG's
implementation) to make the code more flexible for future options
enhancements.

I didn't alter the pass manager invocations of InstCombine in this patch
because the patch was already getting big, but that will be a small
follow-up as noted with the TODO comment.

Differential Revision: https://reviews.llvm.org/D144199

17 months ago[SLP]Do not reduce repeated values, use scalar red ops instead.
Alexey Bataev [Fri, 17 Jun 2022 17:15:23 +0000 (10:15 -0700)]
[SLP]Do not reduce repeated values, use scalar red ops instead.

Metric: size..text

                                                     size..text                 results     results0    diff
SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-980605-1.test      445.00      461.00  3.6%
SingleSource/Benchmarks/Adobe-C++/loop_unroll.test                               428477.00   428445.00 -0.0%
External/SPEC/CFP2006/447.dealII/447.dealII.test                                 618849.00   618785.00 -0.0%

For all tests some extra code was optimized, GCC-C-execute has some more
inlining after

Differential Revision: https://reviews.llvm.org/D132261

17 months agoNew SetOperations and unittesting for all SetOperations
Teresa Johnson [Thu, 16 Feb 2023 22:37:07 +0000 (14:37 -0800)]
New SetOperations and unittesting for all SetOperations

New set operations split out of D140908 as suggested, and I have added
unit testing for all set operations.

This adds a set_intersection, which returns the intersection instead of
updating the first set like set_intersect (using a different name
analogous to set_difference vs set_subtract).

Also adds a variant of set_subtract that updates two additional set
arguments to note which members of the subtrahend were removed from
the minuend and which were not.

Differential Revision: https://reviews.llvm.org/D144220

17 months agoTighten up a modules test
Paul Robinson [Thu, 16 Feb 2023 15:20:42 +0000 (07:20 -0800)]
Tighten up a modules test

Differential Revision: https://reviews.llvm.org/D144188

17 months ago[mlir][llvm] Fuse access_group & loop export (NFC)
Christian Ulmann [Fri, 17 Feb 2023 14:31:06 +0000 (15:31 +0100)]
[mlir][llvm] Fuse access_group & loop export (NFC)

This commit moves the access group translation into the
LoopAnnotationTranslation class as these two metadata kinds only appear
together.

Drops the access group cleanup from `ModuleTranslation::forgetMapping`
as this is only used on function regions. Access groups only appear in the
region of a global metadata operation and will thus not be cleaned here.

Analogous to https://reviews.llvm.org/D143577

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D144253

17 months ago[SVE] Add intrinsics for floating-point operations that explicitly undefine the resul...
Paul Walker [Fri, 10 Feb 2023 12:25:26 +0000 (12:25 +0000)]
[SVE] Add intrinsics for floating-point operations that explicitly undefine the result for inactive lanes.

This patch is the floating-point equivalent of D141937.

Depends on D143764.

Differential Revision: https://reviews.llvm.org/D143765

17 months ago[mlir][standalone] Extend sample with custom type
Marius Brehler [Fri, 17 Feb 2023 13:51:04 +0000 (14:51 +0100)]
[mlir][standalone] Extend sample with custom type

This extends the standalone example to illustrate how to structure the
files needed to create own types.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D143715

17 months ago[clang][CodeGen] Use base subobject type layout for potentially-overlapping fields
Vladislav Dzhidzhoev [Fri, 13 Jan 2023 23:38:10 +0000 (02:38 +0300)]
[clang][CodeGen] Use base subobject type layout for potentially-overlapping fields

RecordLayoutBuilder assumes the size of a potentially-overlapping
class/struct field with non-zero size as the size of the base subobject
type corresponding to the field type.
Make CGRecordLayoutBuilder to acknowledge that in order to avoid incorrect
padding insertion.

Differential Revision: https://reviews.llvm.org/D139741

17 months agoGH60642: Fix ICE when checking a lambda defined in a concept definition
Erich Keane [Thu, 16 Feb 2023 15:50:56 +0000 (07:50 -0800)]
GH60642: Fix ICE when checking a lambda defined in a concept definition

As reported in GH60642, we asserted when there was a lambda defined in a
template arguments inside of a concept, which caused us to not properly
set up the list of instantiation args.  This patch ensures that the
'lambda context decl' correctly falls-through the template argument
instantiation, so that it is available when instantiating the lambda,
and thus, when setting up the lambda instantiation args list.

17 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Feb 2023 13:34:05 +0000 (14:34 +0100)]
[Clang] Convert some tests to opaque pointers (NFC)

17 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Feb 2023 11:12:07 +0000 (12:12 +0100)]
[Clang] Convert some tests to opaque pointers (NFC)

17 months agoFix Clang sphinx build
Aaron Ballman [Fri, 17 Feb 2023 12:56:52 +0000 (07:56 -0500)]
Fix Clang sphinx build

This addresses issues found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/40269

17 months ago[RISCV][NFC] Add missing immediate operand types.
Dmitry Bushev [Fri, 17 Feb 2023 12:03:40 +0000 (15:03 +0300)]
[RISCV][NFC] Add missing immediate operand types.

Some immediate types in RISCV target description lack operand type field.
This leads them being listed as OPERAND_UNKNOWN in MCOperandInfo. This patch adds this fields.
This is NFC because it does not affect flow of any current tools implementation.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D144105

17 months ago[mlir][llvm] Add DINamespace attribute
Christian Ulmann [Fri, 17 Feb 2023 12:09:17 +0000 (13:09 +0100)]
[mlir][llvm] Add DINamespace attribute

This commit introduces the DINamespaceAttr to model LLVM's DINamespace metadata.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D144243

17 months ago[mlir][llvm] Make DI param optional to match LLVM
Christian Ulmann [Fri, 17 Feb 2023 12:04:51 +0000 (13:04 +0100)]
[mlir][llvm] Make DI param optional to match LLVM

This commit makes DIDerivedTypeAttr's baseType parameter optional to ensure imported IR
doesn't break the printer.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D144247

17 months ago[gn build] Port 46db8d822ecd
LLVM GN Syncbot [Fri, 17 Feb 2023 11:44:43 +0000 (11:44 +0000)]
[gn build] Port 46db8d822ecd

17 months ago[libc++] Granularize <atomic>
Nikolas Klauser [Sat, 14 Jan 2023 01:53:52 +0000 (02:53 +0100)]
[libc++] Granularize <atomic>

Reviewed By: Mordante, #libc

Spies: arichardson, libcxx-commits, krytarowski

Differential Revision: https://reviews.llvm.org/D142972

17 months ago[AMDGPU] Simplify widenScalar condition for BigTy for G_(UN)MERGE_VALUES
Jay Foad [Fri, 17 Feb 2023 10:18:38 +0000 (10:18 +0000)]
[AMDGPU] Simplify widenScalar condition for BigTy for G_(UN)MERGE_VALUES

Differential Revision: https://reviews.llvm.org/D144250

17 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Feb 2023 10:27:36 +0000 (11:27 +0100)]
[Clang] Convert some tests to opaque pointers (NFC)

17 months ago[analyzer] Remove unjustified assert from EquivalenceClass::simplify
Balazs Benics [Fri, 17 Feb 2023 10:37:02 +0000 (11:37 +0100)]
[analyzer] Remove unjustified assert from EquivalenceClass::simplify

One might think that by merging the equivalence classes (eqclasses) of
`Sym1` and `Sym2` symbols we would end up with a `State` in which the
eqclass of `Sym1` and `Sym2` should now be the same. Surprisingly, it's
not //always// true.

Such an example triggered the assertion enforcing this _unjustified_
invariant in https://github.com/llvm/llvm-project/issues/58677.
```lang=C++
unsigned a, b;
#define assert(cond) if (!(cond)) return

void f(unsigned c) {
    /*(1)*/ assert(c == b);
    /*(2)*/ assert((c | a) != a);
    /*(3)*/ assert(a);
    // a = 0  =>  c | 0 != 0  =>  c != 0  =>  b != 0
}
```

I believe, that this assertion hold for reasonable cases - where both
`MemberSym` and `SimplifiedMemberSym` refer to live symbols.
It can only fail if `SimplifiedMemberSym` refers to an already dead
symbol. See the reasoning at the very end.
In this context, I don't know any way of determining if a symbol is
alive/dead, so I cannot refine the assertion in that way.
So, I'm proposing to drop this unjustified assertion.

---

Let me elaborate on why I think the assertion is wrong in its current
shape.

Here is a quick reminder about equivalence classes in CSA.
We have 4 mappings:
1) `ClassMap`: map, associating `Symbols` with an `EquivalenceClass`.
2) `ClassMembers`: map, associating `EquivalenceClasses` with its
   members - basically an enumeration of the `Symbols` which are known
   to be equal.
3) `ConstraintRange`: map, associating `EquivalenceClasses` with the
   range constraint which should hold for all the members of the
   eqclass.
4) `DisequalityMap`: I'm omitting this, as it's irrelevant for our
   purposes now.

Whenever we encounter/assume that two `SymbolRefs` are equal, we update
the `ClassMap` so that now both `SymbolRefs` are referring to the same
eqclass. This operation is known as `merge` or `union`.
Each eqclass is uniquely identified by the `representative` symbol, but
it could have been just a unique number or anything else - the point
is that an eqclass is identified by something unique.
Initially, all Symbols form - by itself - a trivial eqclass, as there
are no other Symbols to which it is assumed to be equal. A trivial
eqclass has //notionally// exactly one member, the representative symbol.
I'm emphasizing that //notionally// because for such cases we don't store
an entry in the `ClassMap` nor in the `ClassMembers` map, because it
could be deduced.

By `merging` two eqclasses, we essentially do what you would think it
does. An important thing to highlight is that the representative symbol
of the resulting eqclass will be the same as one of the two eqclasses.
This operation should be commutative, so that `merge(eq1,eq2)` and
`merge(eq2,eq1)` should result in the same eqclass - except for the
representative symbol, which is just a unique identifier of the class,
a name if you will. Using the representative symbol of `eq1` or `eq2`
should have no visible effect on the analysis overall.

When merging `eq1` into `eq2`, we take each of the `ClassMembers` of
`eq1` and add them to the `ClassMembers` of `eq2` while we also redirect
all the `Symbol` members of `eq1` to map to the `eq2` eqclass in the
`ClassMap`. This way all members of `eq1` will refer to the correct
eqclass. After these, `eq1` key is unreachable in the `ClassMembers`,
hence we can drop it.

---

Let's get back to the example.
Note that when I refer to symbols `a`, `b`, `c`, I'm referring to the
`SymbolRegionValue{VarRegion{.}}` - the value of that variable.

After `(1)`, we will have a constraint `c == b : [1,1]` and an eqclass
`c,b` with the `c` representative symbol.
After `(2)`, we will have an additional constraint `c|b != a : [1,1]`
with the same eqclass. We will also have disequality info about that
`c|a` is disequal to `a` - and the other way around.
However, after the full-expression, `c` will become dead. This kicks in
the garbage collection, which transforms the state into this:
 - We no longer have any constraints, because only `a` is alive, for
   which we don't have any constraints.
 - We have a single (non-trivial) eqclass with a single element `b` and
   representative symbol `c`. (Dead symbols can be representative
   symbols.)
 - We have the same disequality info as before.

At `(3)` within the false branch, `a` get perfectly constrained to zero.
This kicks in the simplification, so we try to substitute (simplify) the
variable in each SymExpr-tree. In our case, it means that the
`c|a != a : [1,1]` constraint gets re-evaluated as `c|0 != 0 : [1,1]`,
which is `c != 0 : [1,1]`.
Under the hood, it means that we will call `merge(c|a, c)`. where `c` is
the result of `simplifyToSVal(State, MemberSym).getAsSymbol()` inside
`EquivalenceClass::simplify()`.
Note that the result of `simplifyToSVal()` was a dead symbol. We
shouldn't have acquired an already dead symbol. AFAIK, this is the only
way we can get one at this point.
Since `c` is dead, we no longer have a mapping in `ClassMap` for it;
hence when we try to `find()` the eqclass of `c`, it will report that
it's a trivial eqclass with the representative symbol `c`.

After `merge(c|a, c)`, we will have a single (non-trivial) eqclass of
`b, c|a` with the representative symbol `c|a` - because we merged the
eqclass of `c` into the eqclass of `c|a`.

This means that `find(c|a)` will result in the eqclass with the
representative symbol `c|a`. So, we ended up having different eqclasses
for `find(c|a)` and `find(c)` after `merge(c|a, c)`, firing the
assertion.

I believe, that this assertion hold for reasonable cases - where both
`MemberSym` and `SimplifiedMemberSym` refer to live symbols.
`MemberSym` should be live in all cases here, because it is from
`ClassMembers` which is pruned in `removeDeadBindings()` so these must
be alive. In this context, I don't know any way of determining if a
symbol is alive/dead, so I cannot refine the assertion in that way.
So, I'm proposing to drop this unjustified assertion.

I'd like to thank @martong for helping me to conclude the investigation.
It was really difficult to track down.

PS: I mentioned that `merge(eq1, eq2)` should be commutative. We
actually exploit this for merging the smaller eqclass into the bigger
one within `EquivalenceClass::merge()`.
Yea, for some reason, if you swap the operands, 3 tests break (only
failures, no crashes) aside from the test which checks the state dumps.
But I believe, that is a different bug and orthogonal to this one. I
just wanted to mention that.
- `Analysis/solver-sym-simplification-adjustment.c`
- `Analysis/symbol-simplification-fixpoint-iteration-unreachable-code.cpp`
- `Analysis/symbol-simplification-reassume.cpp`

Fixes #58677

Reviewed By: vabridgers

Differential Revision: https://reviews.llvm.org/D138037

17 months ago[libc++] Granularize <bit> includes
Nikolas Klauser [Sun, 8 Jan 2023 14:26:32 +0000 (15:26 +0100)]
[libc++] Granularize <bit> includes

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D141228

17 months ago[MachineCombiner] Support local strategy for traces
Anton Sidorenko [Tue, 14 Feb 2023 10:32:10 +0000 (13:32 +0300)]
[MachineCombiner] Support local strategy for traces

For in-order cores MachineCombiner makes better decisions when the critical path
is calculated only for the current basic block and does not take into account
other blocks from the trace.

This patch adds a virtual method to TargetInstrInfo to allow each target decide
which strategy to use.

Depends on D140541

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D140542

17 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Feb 2023 09:01:18 +0000 (10:01 +0100)]
[Clang] Convert some tests to opaque pointers (NFC)

17 months ago[mlir] Add a folder for lbs, ubs, steps of scf.forall.
Alexander Belyaev [Fri, 17 Feb 2023 09:57:44 +0000 (10:57 +0100)]
[mlir] Add a folder for lbs, ubs, steps of scf.forall.

Differential Revision: https://reviews.llvm.org/D144245

17 months agoRevert "[LLD] [COFF] Don't try to detect MSVC installations in mingw mode"
Martin Storsjö [Fri, 17 Feb 2023 09:25:12 +0000 (11:25 +0200)]
Revert "[LLD] [COFF] Don't try to detect MSVC installations in mingw mode"

This reverts commit 389bfbd66d6f78b5fc60e51e620e7f767fc867f0.

This commit broke the compiler-rt/test/profile/Windows/coverage-weak-lld.cpp
testcase. This testcase builds and links in an MSVC environment,
but explicitly passes -lldmingw to the linker, to opt in to
certain mingw-style behaviours regarding weak symbols, since
effb87dfa810a28e763f914fe3e6e984782cc846. This patch broke that
test, which now errored out with these errors:

    lld-link: error: could not open 'libuuid.a': no such file or directory
    lld-link: error: could not open 'libLIBCMT.a': no such file or directory
    lld-link: error: could not open 'libOLDNAMES.a': no such file or directory

17 months ago[mlir][llvm] Verify LLVM module before import
Christian Ulmann [Fri, 17 Feb 2023 08:47:37 +0000 (09:47 +0100)]
[mlir][llvm] Verify LLVM module before import

This commit ensures that the importing of LLVM modules first verifies
that the module is even valid. As many tests did not work with valid
LLVM IR, they were fixed as part of this commit.

Some error messages were only reachable with invalid input IR, thus they
were replaced with a failures.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D144186

17 months ago[JT] Always create BPI/BFI when running in legacy PM
Benjamin Kramer [Fri, 17 Feb 2023 09:09:34 +0000 (10:09 +0100)]
[JT] Always create BPI/BFI when running in legacy PM

This is wasteful, but only affects the legacy pass manager. Otherwise
a1b78fb929fccf96acaa0212cf68fee82298e747 would crash JT when running
with that PM. There are still a few users of the legacy PM out there
that are reluctant to migrate, numba in this case.

No test as we don't test legacy PM anymore.

17 months ago[clang-repl] Support compound statement as a top-level statement.
Vassil Vassilev [Sun, 11 Dec 2022 21:08:30 +0000 (21:08 +0000)]
[clang-repl] Support compound statement as a top-level statement.

This patch teaches our incremental compilation infrastructure to push and pop a
fake function scope making the Parser happy when parsing compound statements as
part of a top-leve statement declaration.

Differential revision: https://reviews.llvm.org/D139798

17 months ago[mlir][scf] Rename ForeachThreadOp->ForallOp, PerformConcurrentlyOp->InParallelOp.
Alexander Belyaev [Fri, 17 Feb 2023 08:24:33 +0000 (09:24 +0100)]
[mlir][scf] Rename ForeachThreadOp->ForallOp, PerformConcurrentlyOp->InParallelOp.

Differential Revision: https://reviews.llvm.org/D144242

17 months ago[ConstantRange] Handle `Intrinsic::ctlz`
Antonio Frighetto [Fri, 17 Feb 2023 08:50:49 +0000 (09:50 +0100)]
[ConstantRange] Handle `Intrinsic::ctlz`

Introduce ConstantRange support for ctlz intrinsic, including
exhaustive testing. Among other things, LVI may now be able to
propagate information about cltz constant ranges lattice values.

Differential Revision: https://reviews.llvm.org/D142234

17 months ago[Support] [Windows] Don't check file access time in equivalent(file_status, file_status)
R. Voggenauer [Tue, 14 Feb 2023 14:21:06 +0000 (15:21 +0100)]
[Support] [Windows] Don't check file access time in equivalent(file_status, file_status)

The sys::fs::equivalent(file_status, file_status) function is meant to
judge whether two file_status structs denote the same individual file.
On Unix, this is implemented by only comparing the st_dev and st_ino
numbers (from stat), ignoring all other fields.

On Windows, lacking reliable fields corresponding to st_dev and st_ino,
equivalent(file_status, file_status) compares essentially all fields.
However, since 1e39ef331b2b78baec84fdb577d497511cc46bd5
(https://reviews.llvm.org/D18456), file_status also contains the file
access time.

Including the file access time in equivalent(file_status, file_status)
makes it possible to spuriously break. In particular, when invoking
equivalent(Twine, Twine), with two paths, there's a race condition - the
function calls status() on both input paths. Even if the two paths
are the same, the comparison can fail, if the file was accessed
between the two status() calls.

Thus, it seems like the inclusion of the access time in
equivalent(file_status, file_status) was a mistake.

This race condition can cause spurious failures when linking with
LLD/ELF, where LLD uses equivalent() to check whether a file
exists within a specific sysroot, and that sysroot is accessed by other
processes concurrently.

This fixes downstream issue
https://github.com/msys2/MINGW-packages/issues/15695.

Differential Revision: https://reviews.llvm.org/D144172

17 months ago[LLD] [COFF] Don't try to detect MSVC installations in mingw mode
Martin Storsjö [Wed, 15 Feb 2023 10:06:45 +0000 (12:06 +0200)]
[LLD] [COFF] Don't try to detect MSVC installations in mingw mode

In mingw mode, all linker paths are passed explicitly to the linker
by the compiler driver. Don't try to implicitly add linker paths
from the LIB environment variable or by detecting an MSVC
installation directory.

If the /winsysroot command line parameter is explicitly passed to
lld-link while /lldmingw is specified, it could be considered reasonable
to actually include those paths. However, modifying the code to
handle only the /winsysroot case but not the other ones, when the
mingw mode has been enabled, seems like much more code complexity
for a mostly hypothetical case.

Add a test for this when case when using LIB. (The code paths for
trying to detect an MSVC installation aren't really regression tested.)

Also fix an issue in the existing test for "Check that when /winsysroot
is specified, %LIB% is ignored.", where the LIB variable pointed
to a nonexistent directory, so the test would pass even if /winsysroot
wouldn't be specified.

Differential Revision: https://reviews.llvm.org/D144084

17 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Feb 2023 08:29:41 +0000 (09:29 +0100)]
[Clang] Convert some tests to opaque pointers (NFC)

17 months ago[mlir][llvm] Add atomic support to the LoadOp.
Tobias Gysi [Fri, 17 Feb 2023 08:20:08 +0000 (09:20 +0100)]
[mlir][llvm] Add atomic support to the LoadOp.

This revision adds atomic support to the LoadOp. It chooses
to print the atomic keywords together with the syncscope and
ordering arguments, which simplifies parsing and printing compared
to the LLVM IR printer that puts the atomic keyword at the beginning.
It uses the ordering attribute to check if the load is atomic.

The revision also implements verifiers to ensure the constraints
that apply to atomic load operations are checked.

Reviewed By: Dinistro

Differential Revision: https://reviews.llvm.org/D144112

17 months ago[Clang] Convert some tests to opaque pointers (NFC)
Nikita Popov [Thu, 16 Feb 2023 16:06:50 +0000 (17:06 +0100)]
[Clang] Convert some tests to opaque pointers (NFC)

17 months ago[AMDGPU] Add cross-project-tests for WMMA builtins
Diana Picus [Thu, 16 Feb 2023 10:10:54 +0000 (11:10 +0100)]
[AMDGPU] Add cross-project-tests for WMMA builtins

Add a few tests to make sure we get the expected instruction for the
WMMA builtins (and generally that our builtins and intrinsics are on the
same page and won't blow up).

Differential Revision: https://reviews.llvm.org/D144176

17 months ago[MLIR][LLVM] Only disallow inlining for selected function attributes.
Johannes de Fine Licht [Fri, 17 Feb 2023 08:04:43 +0000 (09:04 +0100)]
[MLIR][LLVM] Only disallow inlining for selected function attributes.

This loosens the requirement of no passthrough function attribute being
present to checking for specific attributes that prevent inlining. Since
these attributes are no longer strictly passthrough, they should
eventually be upgraded to some form of addressable attributes.

Drops the expensive StringSwitches over call and function attributes in
favor of selectively disallowing attributes that prevent inlining
(similiar to the LLVM inliner), thereby moving to a less conservative
approach.

Reviewed By: gysit

Differential Revision: https://reviews.llvm.org/D144104

17 months ago[Clang] Convert update_cc_test_checks tests to opaque pointers (NFC)
Nikita Popov [Fri, 17 Feb 2023 08:06:02 +0000 (09:06 +0100)]
[Clang] Convert update_cc_test_checks tests to opaque pointers (NFC)

17 months ago[DAGCombiner] Teach MatchContextClass classes to use TargetLowering::isOperationLegal...
Yeting Kuo [Wed, 15 Feb 2023 07:17:26 +0000 (15:17 +0800)]
[DAGCombiner] Teach MatchContextClass classes to use TargetLowering::isOperationLegalOrCustom().

Some of TargetLowering functions needed opcodes are often used in DAGCombiner.
The patch make those MatchContextClass classes have TargetLowering members and
pass specific opcodes for those TargetLowering functions.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D144075

17 months ago[mlir] Add loop bounds to scf.foreach_thread.
Alexander Belyaev [Fri, 17 Feb 2023 07:54:56 +0000 (08:54 +0100)]
[mlir] Add loop bounds to scf.foreach_thread.

https://discourse.llvm.org/t/rfc-parallel-loops-on-tensors-in-mlir/68332

Differential Revision: https://reviews.llvm.org/D144072

17 months agoRevert "[Coroutines] Stop supportting std::experimental::coroutine_traits"
Chuanqi Xu [Fri, 17 Feb 2023 07:50:54 +0000 (15:50 +0800)]
Revert "[Coroutines] Stop supportting std::experimental::coroutine_traits"

This reverts commit c4e6e771f255fb1da3d505534997b6a88195b012.

Since clang-tools-extra contains the use for
std::experimental::coroutine_traits, the previsou commit breaks the
build bot. Revert this one to make the bot green.

17 months ago[Coroutines] Stop supportting std::experimental::coroutine_traits
Chuanqi Xu [Fri, 17 Feb 2023 07:22:04 +0000 (15:22 +0800)]
[Coroutines] Stop supportting std::experimental::coroutine_traits

As we discussed before, we should stop supporting
std::experimental::coroutine_traits in clang17. Now the clang16 is
branched so we can clean them now.

All the removed tests have been duplicated before.

17 months ago[NDF] Revert earlier nfc commit to test commit access
Ryan Guo [Fri, 17 Feb 2023 06:57:23 +0000 (22:57 -0800)]
[NDF] Revert earlier nfc commit to test commit access

This patch reverts 511d55060454 by removing the empty newline.

17 months ago[NFC] Testing new commit access by adding newline
Ryan Guo [Fri, 17 Feb 2023 06:52:31 +0000 (22:52 -0800)]
[NFC] Testing new commit access by adding newline

17 months ago[lldb] Add missing decorators import in TestPoPersistentResult.py
Dave Lee [Fri, 17 Feb 2023 05:45:24 +0000 (21:45 -0800)]
[lldb] Add missing decorators import in TestPoPersistentResult.py

17 months ago[lldb] Limit TestPoPersistentResult to darwin
Dave Lee [Fri, 17 Feb 2023 05:11:38 +0000 (21:11 -0800)]
[lldb] Limit TestPoPersistentResult to darwin

17 months ago[lldb] Suppress persistent result when running po
Dave Lee [Tue, 14 Feb 2023 21:48:07 +0000 (13:48 -0800)]
[lldb] Suppress persistent result when running po

Remove the persistent result variable after executing `po`.

Without this change, the following behavior happens:

```
(lldb) p thing
(NSObject *) $0 = 0x600000008000
(lldb) po thing
<NSObject: 0x600000008000>
(lldb) p thing
(NSObject *) $2 = 0x600000008000
(lldb) p $1
(NSObject *) $1 = 0x600000008000
```

Even though `po` hides the persistent result variable, it's still created - as $1 in
this example. It can be accessed even though its existence is not evident.

With this change, the persistent result is removed after the object description has
printed. Instead, this is the behavior:

```
(lldb) p thing
(NSObject *) $0 = 0x600000008000
(lldb) po thing
<NSObject: 0x600000008000>
(lldb) p thing
(NSObject *) $1 = 0x600000008000
```

The difference here is that the `po` doens't silently create a persistent result.

Differential Revision: https://reviews.llvm.org/D144044

17 months ago[lldb] Rename SetResultIsInternal to SetSuppressPersistentResult (NFC)
Dave Lee [Tue, 14 Feb 2023 21:39:56 +0000 (13:39 -0800)]
[lldb] Rename SetResultIsInternal to SetSuppressPersistentResult (NFC)

Rename `SetResultIsInternal` and `GetResultIsInternal` to `SetSuppressPersistentResult`
and `GetSuppressPersistentResult` respectively.  Also rename `m_result_is_internal`.

This matches the naming in the SB API.

A separate change calls `SetSuppressPersistentResult`, where the name
`SetResultIsInternal` doesn't quite fit.

Differential Revision: https://reviews.llvm.org/D144042

17 months ago[llvm][test] enable/disable -verify-machineinstrs where possible for callbr
Nick Desaulniers [Fri, 17 Feb 2023 04:25:34 +0000 (20:25 -0800)]
[llvm][test] enable/disable -verify-machineinstrs where possible for callbr

I introduced new tests in
commit 5cc1016a57b3 ("[llvm][SelectionDAGBuilder] codegen callbr.landingpad intrinsic")
https://reviews.llvm.org/D140160
that fails expensive checks. Disable -verify-machineinstrs in those
tests for now. Enable it in other tests for now, since MachineVerifier
isn't on by default for assertion builds.

Link: https://github.com/llvm/llvm-project/issues/60827
17 months ago[clang-format] Add a space between an overloaded operator and '>'
Owen Pan [Fri, 10 Feb 2023 16:50:49 +0000 (08:50 -0800)]
[clang-format] Add a space between an overloaded operator and '>'

The token annotator doesn't annotate the template opener and closer
as such if they enclose an overloaded operator. This causes the
space between the operator and the closer to be removed, resulting
in invalid C++ code.

Fixes #58602.

Differential Revision: https://reviews.llvm.org/D143755

17 months ago[ADT] Provide C++20-style bit functions
Kazu Hirata [Fri, 17 Feb 2023 04:13:04 +0000 (20:13 -0800)]
[ADT] Provide C++20-style bit functions

Tihs patches adds APInt::count{l,r}_{zero,one} and APInt::popcount to
be consistent with those functions in ADT/bit.h.

Once this patch lands, I'll take care of the migration.

For now, I am intentionally leaving isPowerOf2 as is.

Differential Revision: https://reviews.llvm.org/D144165

17 months ago[CodeGen] Fix warnings
Kazu Hirata [Fri, 17 Feb 2023 04:08:35 +0000 (20:08 -0800)]
[CodeGen] Fix warnings

This patch fixes:

  llvm/lib/CodeGen/CallBrPrepare.cpp:154:14: error: unused variable
  'IsDominated' [-Werror,-Wunused-variable]

  llvm/lib/CodeGen/CallBrPrepare.cpp:150:13: error: unused function
  'PrintDebugDomInfo' [-Werror,-Wunused-function]

17 months ago[mlir][gpu] NFC let user pick the threadID values when distributing foreach_thread
Thomas Raoux [Fri, 17 Feb 2023 00:15:12 +0000 (00:15 +0000)]
[mlir][gpu] NFC let user pick the threadID values when distributing foreach_thread

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D144219

17 months agoRevert "[mlir][vector] Prevent duplicating operations during vector distribute"
Thomas Raoux [Fri, 17 Feb 2023 03:06:59 +0000 (03:06 +0000)]
Revert "[mlir][vector] Prevent duplicating operations during vector distribute"

This reverts commit 2fc3c5c34c4c0ce94a217717a469620e06325fb0.

17 months ago[Sema] Relax a failing assertion in TransformBlockExpr
Akira Hatanaka [Tue, 14 Feb 2023 05:06:07 +0000 (21:06 -0800)]
[Sema] Relax a failing assertion in TransformBlockExpr

The assertion fails when the expression causing the this pointer to be
captured is part of a constexpr if statement's branch and the branch
gets discarded when the enclosing method is instantiated.

Note that the test case is added to CodeGen instead of Sema since the
translation unit has to be free of errors in order for the assertion to
be checked.

Differential Revision: https://reviews.llvm.org/D144016

17 months agoOpenMP: Regenerate test checks
Matt Arsenault [Thu, 16 Feb 2023 19:49:32 +0000 (15:49 -0400)]
OpenMP: Regenerate test checks

17 months agoRecommit "Remove incorrect comment around `truncateAVX512SetCCNoBWI`; NFC" (2nd Try)
Noah Goldstein [Thu, 16 Feb 2023 09:15:48 +0000 (03:15 -0600)]
Recommit "Remove incorrect comment around `truncateAVX512SetCCNoBWI`; NFC" (2nd Try)

No bug here, just needed to revert to revert
8bd0e9481cfcba53946433011d841280fd456caa which had a bug.

17 months agoRecommit "Transform vector SET{LE/ULT/ULE} -> SETLT and SET{GE/UGT/UGE} -> SETGT...
Noah Goldstein [Fri, 17 Feb 2023 01:41:11 +0000 (19:41 -0600)]
Recommit "Transform vector SET{LE/ULT/ULE} -> SETLT and SET{GE/UGT/UGE} -> SETGT if possible" (2nd Try)

Original version hit assert in `incDecVectorConstant` because VT could
be EVT (as opposed to MVT). Fix is to add check for VT.isSimple() in
`incDecVectorConstant`.

Reviewed By: saugustine

Differential Revision: https://reviews.llvm.org/D142254

17 months ago[lldb] Stop generating swig bindings for SBLaunchInfo copy constructor
Alex Langford [Thu, 16 Feb 2023 23:38:56 +0000 (15:38 -0800)]
[lldb] Stop generating swig bindings for SBLaunchInfo copy constructor

Given the line
```
launch_info = lldb.SBLaunchInfo(None)
```

We see different behaviors across different versionf of swig. On some
older versions of swig (e.g. 3.0.2) this line fails because it attempts
to use the copy constructor and blows up with an invalid null reference.
On newer versions of swig, this is correctly routed to the constructor
taking a pointer.

Prior to generating the swig bindings with the API headers,
SBLaunchInfo's copy constructor was not exposed so we're effectively
going back to the old behavior anyway.

Differential Revision: https://reviews.llvm.org/D144228

17 months ago[ThinLTO/WPD] Handle function alias in vtable correctly
Teresa Johnson [Thu, 16 Feb 2023 19:19:27 +0000 (11:19 -0800)]
[ThinLTO/WPD] Handle function alias in vtable correctly

We were not summarizing a function alias in the vtable, leading to
incorrect WPD in some cases, and missing WPD in others.

Specifically, we would end up ignoring function aliases as they aren't
summarized, so we could incorrectly devirtualize if there was a single
other non-alias function in a compatible vtable. And if there was only
one implementation, but it was an alias, we would not be able to
identify and perform the single implementation devirtualization.

Handling the alias summary correctly also required fixing the handling
in mustBeUnreachableFunction, so that it is not incorrectly ignored.

Regular LTO is conservatively correct because it will skip
devirtualizing when any pointer within a vtable is not a function.
However, it needs additional work to be able to take advantage of
function alias within the vtable that is in fact the only
implementation. For that reason, the Regular LTO testing in the second
test case is currently disabled, and will be enabled along with a follow
on enhancement fix for Regular LTO WPD.

Differential Revision: https://reviews.llvm.org/D144209

17 months ago[clang] add __has_extension(gnu_asm_goto_with_outputs_full)
Nick Desaulniers [Fri, 17 Feb 2023 01:56:59 +0000 (17:56 -0800)]
[clang] add __has_extension(gnu_asm_goto_with_outputs_full)

Also move the line about __has_extension(gnu_asm_goto_with_outputs) so
that it is more generally about asm goto, not the paragraph on symbolic
references.

Reviewed By: efriedma, void

Differential Revision: https://reviews.llvm.org/D143205

17 months ago[clang] fix -Wuninitialized for asm goto outputs on indirect edges.
Nick Desaulniers [Fri, 17 Feb 2023 01:50:34 +0000 (17:50 -0800)]
[clang] fix -Wuninitialized for asm goto outputs on indirect edges.

Now that we support outputs from asm goto along indirect edges, we can
remove/revert some code that was added to help warn about the previous
limitation that outputs were not supported along indirect edges.

Reverts some code added in:
commit 72aa619a7fe0 ("Warn of uninitialized variables on asm goto's indirect branch")
commit 3a604fdbcd5f ("[Clang][CFG] check children statements of asm goto")
But keeps+updates the tests.

Link: https://github.com/llvm/llvm-project/issues/53562
Reviewed By: void

Differential Revision: https://reviews.llvm.org/D140508

17 months ago[Clang] support for outputs along indirect edges of asm goto
Nick Desaulniers [Fri, 17 Feb 2023 01:49:39 +0000 (17:49 -0800)]
[Clang] support for outputs along indirect edges of asm goto

Initial support for asm goto w/ outputs (D69876) only supported outputs
along the "default" (aka "fallthrough") edge.

We can support outputs along all edges by repeating the same pattern of
stores along the indirect edges that we allready do for the default
edge.  One complication is that these indirect edges may be critical
edges which would need to be split. Another issue is that mid-codgen of
LLVM IR, the control flow graph might not reflect the control flow of
the final function.

To avoid this "chicken and the egg" problem assume that any given
indirect edge may become a critical edge, and pro-actively split it.
This is unnecessary if the edge does not become critical, but LLVM will
optimize such cases via tail duplication.

Fixes: https://github.com/llvm/llvm-project/issues/53562

Reviewed By: void

Differential Revision: https://reviews.llvm.org/D136497

17 months ago[Clang] refactor CodeGenFunction::EmitAsmStmt NFC
Nick Desaulniers [Fri, 17 Feb 2023 01:49:16 +0000 (17:49 -0800)]
[Clang] refactor CodeGenFunction::EmitAsmStmt NFC

Prerequisite to further modifications in D136497.

Basically, there is a large body of code in CodeGenFunction::EmitAsmStmt
for emitting stores of outputs. We want to be able to repeat this logic,
for each destination of a callbr (rather than just the default
destination which is what the code currently does).

Also does some smaller cleanups like whitespace cleanups, and removing
pointless casts.

Reviewed By: void, jyknight

Differential Revision: https://reviews.llvm.org/D137113

17 months ago[llvm] add CallBrPrepare pass to pipelines
Nick Desaulniers [Fri, 17 Feb 2023 01:48:14 +0000 (17:48 -0800)]
[llvm] add CallBrPrepare pass to pipelines

Capstone of
https://discourse.llvm.org/t/rfc-syncing-asm-goto-with-outputs-with-gcc/65453/8

Clang changes are still necessary to enable the use of outputs along
indirect edges of asm goto statements.

Link: https://github.com/llvm/llvm-project/issues/53562
Reviewed By: void

Differential Revision: https://reviews.llvm.org/D140180

17 months ago[llvm][SelectionDAGBuilder] codegen callbr.landingpad intrinsic
Nick Desaulniers [Fri, 17 Feb 2023 01:47:37 +0000 (17:47 -0800)]
[llvm][SelectionDAGBuilder] codegen callbr.landingpad intrinsic

Given a CallBrInst, retain its first virtual register in SelectionDagBuilder's
FunctionLoweringInfo if there's corresponding landingpad. Walk the list
of COPY MachineInstr to find the original virtual and physical registers
defined by the INLINEASM_BR MachineInst.

Test cases from https://reviews.llvm.org/D139565.
Link: https://github.com/llvm/llvm-project/issues/59538
Part 3 from
https://discourse.llvm.org/t/rfc-syncing-asm-goto-with-outputs-with-gcc/65453/8

Follow up patches still need to wire up CallBrPrepare into the pass
pipelines.

Reviewed By: efriedma, void

Differential Revision: https://reviews.llvm.org/D140160

17 months ago[llvm][CallBrPrepare] use SSAUpdater to use intrinsic value
Nick Desaulniers [Fri, 17 Feb 2023 01:47:13 +0000 (17:47 -0800)]
[llvm][CallBrPrepare] use SSAUpdater to use intrinsic value

Now that we've inserted a call to an intrinsic, we need to update
certain previous uses of CallBrInst values to use the value of this
intrinsic instead.

There are 3 cases to handle:
1. The @llvm.callbr.landingpad.<type>() intrinsic call is in the same
   BasicBlock as the use of the callbr we're replacing.
2. The use is dominated by the direct destination.
3. The use is not dominated by the direct destination, and may or may
   not be dominated by the indirect destination.

Part 2c of
https://discourse.llvm.org/t/rfc-syncing-asm-goto-with-outputs-with-gcc/65453/8.

Reviewed By: efriedma, void, jyknight

Differential Revision: https://reviews.llvm.org/D139970

17 months ago[llvm][CallBrPrepare] add llvm.callbr.landingpad intrinsic
Nick Desaulniers [Fri, 17 Feb 2023 01:46:47 +0000 (17:46 -0800)]
[llvm][CallBrPrepare] add llvm.callbr.landingpad intrinsic

Insert a new intrinsic call after splitting critical edges, and verify
it. Later commits will update the SSA values to use this new value along
indirect branches rather than the callbr's value, and have SelectionDAG
consume this new value.

Part 2b of
https://discourse.llvm.org/t/rfc-syncing-asm-goto-with-outputs-with-gcc/65453/8.

Reviewed By: efriedma, jyknight

Differential Revision: https://reviews.llvm.org/D139883

17 months ago[llvm][CallBrPrepare] split critical edges
Nick Desaulniers [Fri, 17 Feb 2023 01:46:21 +0000 (17:46 -0800)]
[llvm][CallBrPrepare] split critical edges

If we have a CallBrInst with output that's used, we need to split
critical edges so that we have some place to insert COPYs for physregs
to virtregs.

Part 2a of
https://discourse.llvm.org/t/rfc-syncing-asm-goto-with-outputs-with-gcc/65453/8.

Test cases and logic re-purposed from D138078.

Reviewed By: efriedma, void, jyknight

Differential Revision: https://reviews.llvm.org/D139872

17 months ago[llvm] boilerplate for new callbrprepare codegen IR pass
Nick Desaulniers [Fri, 17 Feb 2023 01:45:50 +0000 (17:45 -0800)]
[llvm] boilerplate for new callbrprepare codegen IR pass

Because this pass is to be a codegen pass, it must use the legacy pass
manager.

Link: https://discourse.llvm.org/t/rfc-syncing-asm-goto-with-outputs-with-gcc/65453/8
Reviewed By: aeubanks, void

Differential Revision: https://reviews.llvm.org/D139861

17 months ago[Dominators] check indirect branches of callbr
Nick Desaulniers [Fri, 17 Feb 2023 01:44:02 +0000 (17:44 -0800)]
[Dominators] check indirect branches of callbr

This will be necessary to support outputs from asm goto along indirect
edges.

Test via:
  $ pushd llvm/build; ninja IRTests; popd
  $ ./llvm/build/unittests/IR/IRTests \
    --gtest_filter=DominatorTree.CallBrDomination

Also, return nullptr in Instruction::getInsertionPointAfterDef for
CallBrInst as was recommened in
https://reviews.llvm.org/D135997#3991427.  The following phab review was
folded into this commit: https://reviews.llvm.org/D140166

Link: https://discourse.llvm.org/t/rfc-syncing-asm-goto-with-outputs-with-gcc/65453/8
Reviewed By: void, efriedma, ChuanqiXu, MaskRay

Differential Revision: https://reviews.llvm.org/D135997

17 months ago[X86][MC] Fix the bug of -output-asm-variant=1 for intel syntax
Shengchen Kan [Thu, 16 Feb 2023 13:17:17 +0000 (21:17 +0800)]
[X86][MC] Fix the bug of -output-asm-variant=1 for intel syntax

Before this patch

```
$ echo "leal    (,%r15), %eax" | llvm-mc --show-encoding --output-asm-variant=1

        lea     eax, [r15]                      # encoding: [0x42,0x8d,0x04,0x3d,0x00,0x00,0x00,0x00]

$ echo "lea     eax, [r15]" | llvm-mc --show-encoding -x86-asm-syntax=intel --output-asm-variant=1

        lea     eax, [r15]                      # encoding: [0x41,0x8d,0x07]
```

MC printed the register r15 as a base in intel syntax even when it's an index.
Then we got a different encoding by using the assembly from the output of the
first command.

I believe the behavior is too weird to be called a feature.

After this patch, we get

```
$ echo "leal    (,%r15), %eax" | llvm-mc --show-encoding --output-asm-variant=1

        lea     eax, [1*r15]                    # encoding: [0x42,0x8d,0x04,0x3d,0x00,0x00,0x00,0x00]
```

Reviewed By: RKSimon, pengfei, MaskRay

Differential Revision: https://reviews.llvm.org/D144183

17 months ago[Attributor][FIX] Ensure we adjust types properly
Johannes Doerfert [Fri, 17 Feb 2023 01:40:47 +0000 (17:40 -0800)]
[Attributor][FIX] Ensure we adjust types properly

When we simplify loads we need to adjust types (esp. null-values)
properly to avoid inconsinstencies down the line. Add a cast and an
error message.

Fixes: https://github.com/llvm/llvm-project/issues/60788

17 months ago[LLDB] Remove unused variable 'lang_rt' in ClangExpressionParser.cpp (NFC)
Jie Fu [Fri, 17 Feb 2023 01:31:05 +0000 (09:31 +0800)]
[LLDB] Remove unused variable 'lang_rt' in ClangExpressionParser.cpp (NFC)

/data/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp:398:34: error: variable 'lang_rt' set but not used [-Werror,-Wunused-but-set-variable]
  lldb_private::LanguageRuntime *lang_rt = nullptr;
                                 ^
1 error generated.

17 months ago[ComplexLogicCombine] Precommit tests for complex logic combine init patch; NFC
chenglin.bi [Fri, 17 Feb 2023 01:34:04 +0000 (09:34 +0800)]
[ComplexLogicCombine] Precommit tests for complex logic combine init patch; NFC

17 months agoRevert "[LLDB] Enable 64 bit debug/type offset"
Alexander Yermolovich [Fri, 17 Feb 2023 01:20:27 +0000 (17:20 -0800)]
Revert "[LLDB] Enable 64 bit debug/type offset"

This reverts commit 2062e90aa531e8445e5dc0e16222c0f246af1bf4.

17 months ago[WebAssembly] Fix simd bit shift intrinsics codegen
Jun Ma [Thu, 16 Feb 2023 07:36:07 +0000 (15:36 +0800)]
[WebAssembly] Fix simd bit shift intrinsics codegen

According to github.com/WebAssembly/simd/blob/main/proposals/simd/SIMD.md,
the shift count of bit shift instructions is taken modulo lane width.
This patch adds such operation.

Fixes PR#60655

Differential Revision: https://reviews.llvm.org/D144169

17 months ago[WebAssembly] Update wasm.c with update_cc_test_checks.py. NFC
Jun Ma [Thu, 16 Feb 2023 07:42:40 +0000 (15:42 +0800)]
[WebAssembly] Update wasm.c with update_cc_test_checks.py. NFC

17 months ago[mlir][sparse] comment out test cases in sparse_conversion with similiar behavior.
Peiming Liu [Fri, 17 Feb 2023 01:08:00 +0000 (01:08 +0000)]
[mlir][sparse] comment out test cases in sparse_conversion with similiar behavior.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D144236

17 months ago[flang][runtime] Allow record advancement in child I/O via '/' control edit descriptor
Peter Klausler [Thu, 16 Feb 2023 18:46:50 +0000 (10:46 -0800)]
[flang][runtime] Allow record advancement in child I/O via '/' control edit descriptor

My earlier misreading of the Fortran standards had convinced me that child I/O
-- meaning the use of user-defined subroutines via generic interfaces to implement
data transfer statements -- was not allowed to advance the current record in the
ultimate unit of the original (non-child parent) data transfer statement.
This turns out to be wrong, so forward AdvanceRecord() from ChildFormattedIoStatement<>
to its parent I/O statement rather than implementing it as a no-op.

Differential Revision: https://reviews.llvm.org/D144205

17 months ago[PowerPC] remove XXSWAPD after load from CP which is a splat value
Ting Wang [Fri, 17 Feb 2023 00:21:35 +0000 (19:21 -0500)]
[PowerPC] remove XXSWAPD after load from CP which is a splat value

If the value from constant-pool is a splat value of vector type, do not
need swap after load from constant-pool.

Reviewed By: shchenz

Differential Revision: https://reviews.llvm.org/D139491

17 months ago[AArch64][ISel] Always use pre-inc/post-inc addressing mode for auto-indexed load...
Huihui Zhang [Thu, 16 Feb 2023 23:40:43 +0000 (15:40 -0800)]
[AArch64][ISel] Always use pre-inc/post-inc addressing mode for auto-indexed load/store with constant offset.

Unlike ARM target, current AArch64 target doesn't have facility to encode the
operation bit: whether to add an offset to base pointer for pre-inc/post-inc
addressing mode, or to subtract an offset from base pointer for
pre-dec/post-dec addressing mode.

A mis-compile (https://github.com/llvm/llvm-project/issues/60645) was noticed
due to this limitation.

Therefore, for AArch64 auto-indexed load/store with constant offset, always
use pre-inc/post-inc addressing mode. The constant offset is negated for
pre-dec/post-dec addressing mode.
An auto-indexed address with non-constant offset is currently not split into
base and offset parts. If we are to handle non-constant offset in the future,
offset node will need to take a negate.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D143796

17 months ago[mlir][sparse] split reshape.mlir into expand/collapse_shape.mlir.
Peiming Liu [Thu, 16 Feb 2023 23:58:02 +0000 (23:58 +0000)]
[mlir][sparse] split reshape.mlir into expand/collapse_shape.mlir.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D144231

17 months ago[MLIR][OpenMP] Add Conversion for Atomic Update Op
Kiran Chandramohan [Thu, 16 Feb 2023 18:48:49 +0000 (18:48 +0000)]
[MLIR][OpenMP] Add Conversion for Atomic Update Op

Reviewed By: TIFitis

Differential Revision: https://reviews.llvm.org/D143964

17 months ago[Pipeline] Move ControlHeightReduction to module optimization pipeline
Arthur Eubanks [Mon, 6 Feb 2023 19:04:32 +0000 (11:04 -0800)]
[Pipeline] Move ControlHeightReduction to module optimization pipeline

This pass isn't a simplification, it's a non-canonical optimization.

This makes it only run once in a (Thin)LTO pipeline during postlink, just like all the other optimization pipeline passes.

Reviewed By: xur

Differential Revision: https://reviews.llvm.org/D143424

17 months ago[mlir][sparse] allow foreach operation to generate out-of-order loop on non-annotated...
Peiming Liu [Thu, 16 Feb 2023 20:24:01 +0000 (20:24 +0000)]
[mlir][sparse] allow foreach operation to generate out-of-order loop on non-annotated tensor.

No need for a temp COO and sort even when converting dense -> CSC, we can instead rotate the loop to yield a ordered coordinates at beginning.

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D144213

17 months ago[LLDB] Enable 64 bit debug/type offset
Alexander Yermolovich [Thu, 16 Feb 2023 22:46:13 +0000 (14:46 -0800)]
[LLDB] Enable 64 bit debug/type offset

This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902
With big binaries we can have .dwp files where .debug_info.dwo section can grow
beyond 4GB. We would like to support this in LLVM and in LLDB.

The plan is to enable manual parsing of cu/tu index in DWARF library
(https://reviews.llvm.org/D137882), and then
switch internal index data structure to 64 bit.
For the second part is to enable 64bit offset support in LLDB with
this patch.

Depends on D139955

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D138618

17 months ago[gn build] Manually port D143983
Arthur Eubanks [Thu, 16 Feb 2023 21:41:05 +0000 (13:41 -0800)]
[gn build] Manually port D143983

17 months ago[Object][NFC] Remove unneeded llvm_unreachable
Gregory Alfonso [Thu, 16 Feb 2023 21:20:41 +0000 (13:20 -0800)]
[Object][NFC] Remove unneeded llvm_unreachable

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D139452