platform/upstream/llvm.git
2 years ago[DAG] SimplifyDemandedBits - ensure we clear known One bits that AssertZext asserts...
Simon Pilgrim [Wed, 27 Jul 2022 12:57:37 +0000 (13:57 +0100)]
[DAG] SimplifyDemandedBits - ensure we clear known One bits that AssertZext asserts are really known Zero

Matches ComputeKnownBits behaviour

Thanks to @uabelho for the fuzz regression report on D129765

2 years agoManagedStatic: remove from ASTMatchersInternal.h
Nicolai Hähnle [Mon, 25 Jul 2022 11:07:14 +0000 (13:07 +0200)]
ManagedStatic: remove from ASTMatchersInternal.h

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

2 years agoclang: include ManagedStatic.h for llvm_shutdown
Nicolai Hähnle [Mon, 25 Jul 2022 12:17:23 +0000 (14:17 +0200)]
clang: include ManagedStatic.h for llvm_shutdown

The code relied on ManagedStatic.h being included indirectly. This is
about to change as uses of ManagedStatic are removed throughout the
codebase.

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

2 years agoClangLinkerWrapper: explicitly #include <atomic>
Nicolai Hähnle [Mon, 25 Jul 2022 12:15:10 +0000 (14:15 +0200)]
ClangLinkerWrapper: explicitly #include <atomic>

This code relied on implicitly having std::atomic available via the
ManagedStatic.h header.

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

2 years ago[mlir][LLVM] Fix incorrect GEP fold with struct constants
Markus Böck [Wed, 27 Jul 2022 12:42:24 +0000 (14:42 +0200)]
[mlir][LLVM] Fix incorrect GEP fold with struct constants

The fold in it's current state only checks whether the amount of dynamic indices is 1. This does however not check for the presence of any struct indices, leading to an incorrect fold.

This patch fixes that issue by checking that struct indices are 1, which in addition to the pre-existing check that dynamic indices are 1, guarantees that the single index is a dynamic one.

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

2 years ago[lldb] Always use APFloat for FP dumping
Pavel Labath [Thu, 14 Jul 2022 10:49:35 +0000 (12:49 +0200)]
[lldb] Always use APFloat for FP dumping

The DumpDataExtractor function had two branches for printing floating
point values. One branch (APFloat) was used if we had a Target object
around and could query it for the appropriate semantics. If we didn't
have a Target, we used host operations to read and format the value.

This patch changes second path to use APFloat as well. To make it work,
I pick reasonable defaults for different byte size. Notably, I did not
include x87 long double in that list (as it is ambibuous and
architecture-specific). This exposed a bug where we were printing
register values using the target-less branch, even though the registers
definitely belong to a target, and we had it available. Fixing this
prompted the update of several tests for register values due to slightly
different floating point outputs.

The most dubious aspect of this patch is the change in
TypeSystemClang::GetFloatTypeSemantics to recognize `10` as a valid size
for x87 long double. This was necessary because because sizeof(long
double) on x86_64 is 16 even though it only holds 10 bytes of useful
data. This generalizes the hackaround present in the target-free branch
of the dumping function.

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

2 years ago[trace] Add instruction control flow kind to JSON trace dumper's output
Jakob Johnson [Tue, 26 Jul 2022 19:19:54 +0000 (12:19 -0700)]
[trace] Add instruction control flow kind to JSON trace dumper's output

D128477 adds a '-k' flag which displays each instruction's control flow in the `thread trace dump instructions` command's non-json  output (ie no '-j' or '-J' flag)
This diff adds the instruction control flow kind to the `thread trace dump instructions` command's JSON output (ie '-j' or '-J' flag)

Test Plan:
Confirm "controlFlowKind" is present in JSON when '-k' is provided
```
(lldb) thread trace dump instructions -J -k
[
  {                                                                                                                                                                                                                                                                                 [141/1952]
    "id": 7755,
    "loadAddress": "0x400868",
    "module": "test.out",
    "symbol": "main",
    "mnemonic": "jmp",
    "controlFlowKind": "jump",
    "source": "/home/jakobjohnson/jakob-dev/test.cpp",
    "line": 41,
    "column": 29
  },
  {
    "id": 7753,
    "loadAddress": "0x7ffff7b54dab",
    "module": "libstdc++.so.6",
    "symbol": "std::ostream::flush()",
    "mnemonic": "retq",
    "controlFlowKind": "return"
  },
  {
    "id": 7752,
    "loadAddress": "0x7ffff7b54daa",
    "module": "libstdc++.so.6",
    "symbol": "std::ostream::flush()",
    "mnemonic": "popq",
    "controlFlowKind": "other"
  },
  ...
]
```
Confirm "controlFlowKind" is not present when '-k' isn't provided
```
(lldb) thread trace dump instructions -J
[
  {
    "id": 7755,
    "loadAddress": "0x400868",
    "module": "test.out",
    "symbol": "main",
    "mnemonic": "jmp",
    "source": "/home/jakobjohnson/jakob-dev/test.cpp",
    "line": 41,
    "column": 29
  },
  {
    "id": 7753,
    "loadAddress": "0x7ffff7b54dab",
    "module": "libstdc++.so.6",
    "symbol": "std::ostream::flush()",
    "mnemonic": "retq"
  },
  {
    "id": 7752,
    "loadAddress": "0x7ffff7b54daa",
    "module": "libstdc++.so.6",
    "symbol": "std::ostream::flush()",
    "mnemonic": "popq"
  },
```

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

2 years ago[gn build] (semi-manually) port 6bdb15fe844c
Nico Weber [Wed, 27 Jul 2022 11:30:44 +0000 (07:30 -0400)]
[gn build] (semi-manually) port 6bdb15fe844c

2 years agoSinking or hoisting instructions between loops before fusion
Aaron Kogon [Wed, 27 Jul 2022 10:55:09 +0000 (06:55 -0400)]
Sinking or hoisting instructions between loops before fusion

Instructions between two adjacent loops will be hoisted above the first
loop, or sunk below the second to facilitate loop fusion. Hoisting will
be attempted for an instruction that dominates the first loop.
Otherwise, sinking this instructions will be attempted.

Instructions with side effects will not be considered for sinking or
hoisting. Hoisting/sinking of any instructions between loops will only
be performed if all the instructions can be moved. As well,
sinking/hoisting is considered for each instruction in isolation,
without taking into account sinking/hoisting decisions for other
instructions in the preheader.

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

2 years ago[clang][ExtractAPI] Fix objc_property.m reference output
Daniel Grumberg [Wed, 27 Jul 2022 10:33:04 +0000 (11:33 +0100)]
[clang][ExtractAPI] Fix objc_property.m reference output

After landing 7f0387de4c600af185b2db8d748f530444fe03cd I forgot to update this
new test.

2 years ago[CMake] Enable -z defs on Solaris
Rainer Orth [Wed, 27 Jul 2022 10:33:51 +0000 (12:33 +0200)]
[CMake] Enable -z defs on Solaris

I wondered why I hadn't seen the link failures in D130571
<https://reviews.llvm.org/D130571> on Solaris/sparcv9 and found that
Solaris, unlike Linux, doesn't use `-Wl,-z,defs` when linking shared
objects.  The three affected shared objects indeed have undefined
references to several 64-bit atomics.

This patch will expose such issues in the future by defaulting to
`-Wl,-z,defs` on Solaris, as recommended in `ld(1)`.

Tested on `sparcv9-sun-solaris2.11` and `amd64-pc-solaris2.11`.

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

2 years ago[Sema] Return primary merged decl as canonical for concepts
Ilya Biryukov [Wed, 27 Jul 2022 10:11:42 +0000 (12:11 +0200)]
[Sema] Return primary merged decl as canonical for concepts

Otherwise we get invalid results for ODR checks. See changed test for an
example: despite the fact that we merge the first concept, its **uses**
were considered different by `Profile`, leading to redefinition errors.

After this change, canonical decl for a concept can come from a
different module and may not be visible. This behavior looks suspicious,
but does not break any tests. We might want to add a mechanism to make
the canonical concept declaration visible if we find code that relies on
this invariant.

Additionally make sure we always merge with the canonical declaration to
avoid chains of merged concepts being reported as redefinitions. An
example was added to the test.

Also change the order of includes in the test. Importing a moduralized
header before its textual part causes the include guard macro to be
exported and the corresponding `#include` becomes a no-op.

Reviewed By: ChuanqiXu

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

2 years ago[flang] Disable pipefail for tests for stdin input
David Spickett [Wed, 27 Jul 2022 09:26:22 +0000 (09:26 +0000)]
[flang] Disable pipefail for tests for stdin input

We have seen the llvm test fail every so often on our bots:
https://lab.llvm.org/buildbot/#/builders/173/builds/6711

This happens because `flang-new -fc1 -S` does not wait for the
pipe to finish being written to/does not read out all the content.
You can see this in the output, cat comes after flang:
+ /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/not /home/tcwg-buildbot/worker/flang-aarch64-release/build/bin/flang-new -fc1 -S - -o -
+ cat /home/tcwg-buildbot/worker/flang-aarch64-release/llvm-project/flang/test/Driver/input-from-stdin-llvm.ll
error: Invalid input type - expecting a Fortran file

This means that cat gets SIGPIPE which causes it to exit with
code 141 and that's the final result due to pipefail.

flang isn't wrong to exit early (I think some modes of grep also do this)
and we only care about flang's exit code. So disable pipefail for
the stdin testing.

Reviewed By: awarzynski

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

2 years ago[compiler-rt][Sanitizer] Link sanitizer libs with -latomic on SPARC
Rainer Orth [Wed, 27 Jul 2022 10:30:18 +0000 (12:30 +0200)]
[compiler-rt][Sanitizer] Link sanitizer libs with -latomic on SPARC

When building on Linux/sparc64, the 32-bit `libclang_rt.asan.so`,
`libclang_rt.ubsan_minimal.so`, and `libclang_rt.ubsan_standalone.so`
failed to link with undefined references to 64-bit atomics, which `clang`
cannot inline.  Even D130569 <https://reviews.llvm.org/D130569> didn't help
because those libraries are linked with `-nodefaultlibs`, so dependent
libraries need to be added explicitly.

That's what this patch does.

Tested on `sparc64-unknown-linux-gnu` and `sparcv9-sun-solaris2.11`.

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

2 years ago[flang] Single entry point for GET_COMMAND_ARGUMENT
Diana Picus [Fri, 1 Jul 2022 11:43:20 +0000 (11:43 +0000)]
[flang] Single entry point for GET_COMMAND_ARGUMENT

This patch refactors the runtime support for GET_COMMAND_ARGUMENT to
have a single entry point instead of 2. It also updates lowering
accordingly.

This makes it easier to handle dynamically optional arguments. See also
https://reviews.llvm.org/D118777

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

2 years ago[RISCV]Enable isIntDivCheap when attribute is minsize
LiaoChunyu [Wed, 27 Jul 2022 01:05:19 +0000 (09:05 +0800)]
[RISCV]Enable isIntDivCheap when attribute is minsize

Don't expand divisions by constants when attribute is minsize.

Reviewed By: craig.topper

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

2 years ago[Support] Handle SPARC in sys::getHostCPUName
Rainer Orth [Wed, 27 Jul 2022 10:21:03 +0000 (12:21 +0200)]
[Support] Handle SPARC in sys::getHostCPUName

While working on D118450 <https://reviews.llvm.org/D118450>, I noticed that
`sys::getHostCPUName` lacks SPARC support.

This patch implements it.  The code is taken from/inspired by GCC's
`gcc/config/sparc/driver-sparc.cc`.  There's one caveat: since LLVM, unlike
GCC, doesn't support the SPARC-M7, -S7, and -M8 CPUs, I map all those to
the latest supported one (UltraSparc T4/`niagara4`).

Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu` by
running `savcov --version` on

- Netra SPARC S7-2 (SPARC-S7, Solaris 11.4)
- SPARC T5-2 (SPARC T5, Solaris 11.4)
- SPARC Enterprise T5220 (UltraSPARC T2, Solaris 11.3)
- SPARC T5 (UltraSPARC T5, Debian sid)
- SPARC T3 (UltraSPARC T3, Debian sid)
- SPARC Enterprise T5220 (Debian sid)

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

2 years ago[clang][ExtractAPI] Ensure that class properties have a kind of "Type Property"
Daniel Grumberg [Thu, 14 Jul 2022 12:53:50 +0000 (13:53 +0100)]
[clang][ExtractAPI] Ensure that class properties have a kind of "Type Property"

Generated symbol graphs should distinguish between type properties and instance
properties.

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

2 years ago[clang][ExtractAPI] Add a space between type and name in property declaration fragments
Daniel Grumberg [Tue, 26 Jul 2022 16:28:43 +0000 (17:28 +0100)]
[clang][ExtractAPI] Add a space between type and name in property declaration fragments

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

2 years ago[DAG] SimplifyDemandedBits - don't early-out for multiple use values
Simon Pilgrim [Wed, 27 Jul 2022 09:53:56 +0000 (10:53 +0100)]
[DAG] SimplifyDemandedBits - don't early-out for multiple use values

SimplifyDemandedBits currently early-outs for multi-use values beyond the root node (just returning the knownbits), which is missing a number of optimizations as there are plenty of cases where we can still simplify when initially demanding all elements/bits.

@lenary has confirmed that the test cases in aea-erratum-fix.ll need refactoring and the current increase codegen is not a major concern.

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

2 years ago[mlir] update Bazel for e99fae899710b041994cef4beb6764f8dfbe8ef0
Alex Zinenko [Wed, 27 Jul 2022 09:41:22 +0000 (09:41 +0000)]
[mlir] update Bazel for e99fae899710b041994cef4beb6764f8dfbe8ef0

2 years ago[clang-tidy] Add execute perms back to add_new_check script
Nathan James [Wed, 27 Jul 2022 09:41:34 +0000 (10:41 +0100)]
[clang-tidy] Add execute perms back to add_new_check script

2 years ago[CSKY] Fix the btsti16 instruction missing in generic processor
Zi Xuan Wu (Zeson) [Wed, 27 Jul 2022 09:16:01 +0000 (17:16 +0800)]
[CSKY] Fix the btsti16 instruction missing in generic processor

Normally, generic processor does not have any SubtargetFeature. And it
can just generate most basic instructions which have no Predicates to
guard.

But it needs to enbale predicate for the btsti16 instruction as one of the most basic instructions.
Or the generic processor can't finish codegen process. So Add FeatureBTST16 SubtargetFeature to generic ProcessorModel.

2 years ago[ARM] Test more atomic sizes with +atomics-32 feature (NFC)
Nikita Popov [Wed, 27 Jul 2022 09:32:45 +0000 (11:32 +0200)]
[ARM] Test more atomic sizes with +atomics-32 feature (NFC)

Check that 8-bit and 16-bit atomics also work as expected. Also
fix the alignment on the 64-bit tests -- testing unaligned atomics
wasn't intended here.

2 years agoUpdate ProgrammersManual STL docs
Renato Golin [Wed, 27 Jul 2022 09:29:19 +0000 (10:29 +0100)]
Update ProgrammersManual STL docs

The SGI page doesn't exist anymore and isn't really relevant at this day
and age.

While at it, added the "other" main C++ website and moved all URLs to
HTTPS.

2 years ago[clang] Implement ElaboratedType sugaring for types written bare
Matheus Izvekov [Mon, 11 Oct 2021 16:15:36 +0000 (18:15 +0200)]
[clang] Implement ElaboratedType sugaring for types written bare

Without this patch, clang will not wrap in an ElaboratedType node types written
without a keyword and nested name qualifier, which goes against the intent that
we should produce an AST which retains enough details to recover how things are
written.

The lack of this sugar is incompatible with the intent of the type printer
default policy, which is to print types as written, but to fall back and print
them fully qualified when they are desugared.

An ElaboratedTypeLoc without keyword / NNS uses no storage by itself, but still
requires pointer alignment due to pre-existing bug in the TypeLoc buffer
handling.

---

Troubleshooting list to deal with any breakage seen with this patch:

1) The most likely effect one would see by this patch is a change in how
   a type is printed. The type printer will, by design and default,
   print types as written. There are customization options there, but
   not that many, and they mainly apply to how to print a type that we
   somehow failed to track how it was written. This patch fixes a
   problem where we failed to distinguish between a type
   that was written without any elaborated-type qualifiers,
   such as a 'struct'/'class' tags and name spacifiers such as 'std::',
   and one that has been stripped of any 'metadata' that identifies such,
   the so called canonical types.
   Example:
   ```
   namespace foo {
     struct A {};
     A a;
   };
   ```
   If one were to print the type of `foo::a`, prior to this patch, this
   would result in `foo::A`. This is how the type printer would have,
   by default, printed the canonical type of A as well.
   As soon as you add any name qualifiers to A, the type printer would
   suddenly start accurately printing the type as written. This patch
   will make it print it accurately even when written without
   qualifiers, so we will just print `A` for the initial example, as
   the user did not really write that `foo::` namespace qualifier.

2) This patch could expose a bug in some AST matcher. Matching types
   is harder to get right when there is sugar involved. For example,
   if you want to match a type against being a pointer to some type A,
   then you have to account for getting a type that is sugar for a
   pointer to A, or being a pointer to sugar to A, or both! Usually
   you would get the second part wrong, and this would work for a
   very simple test where you don't use any name qualifiers, but
   you would discover is broken when you do. The usual fix is to
   either use the matcher which strips sugar, which is annoying
   to use as for example if you match an N level pointer, you have
   to put N+1 such matchers in there, beginning to end and between
   all those levels. But in a lot of cases, if the property you want
   to match is present in the canonical type, it's easier and faster
   to just match on that... This goes with what is said in 1), if
   you want to match against the name of a type, and you want
   the name string to be something stable, perhaps matching on
   the name of the canonical type is the better choice.

3) This patch could expose a bug in how you get the source range of some
   TypeLoc. For some reason, a lot of code is using getLocalSourceRange(),
   which only looks at the given TypeLoc node. This patch introduces a new,
   and more common TypeLoc node which contains no source locations on itself.
   This is not an inovation here, and some other, more rare TypeLoc nodes could
   also have this property, but if you use getLocalSourceRange on them, it's not
   going to return any valid locations, because it doesn't have any. The right fix
   here is to always use getSourceRange() or getBeginLoc/getEndLoc which will dive
   into the inner TypeLoc to get the source range if it doesn't find it on the
   top level one. You can use getLocalSourceRange if you are really into
   micro-optimizations and you have some outside knowledge that the TypeLocs you are
   dealing with will always include some source location.

4) Exposed a bug somewhere in the use of the normal clang type class API, where you
   have some type, you want to see if that type is some particular kind, you try a
   `dyn_cast` such as `dyn_cast<TypedefType>` and that fails because now you have an
   ElaboratedType which has a TypeDefType inside of it, which is what you wanted to match.
   Again, like 2), this would usually have been tested poorly with some simple tests with
   no qualifications, and would have been broken had there been any other kind of type sugar,
   be it an ElaboratedType or a TemplateSpecializationType or a SubstTemplateParmType.
   The usual fix here is to use `getAs` instead of `dyn_cast`, which will look deeper
   into the type. Or use `getAsAdjusted` when dealing with TypeLocs.
   For some reason the API is inconsistent there and on TypeLocs getAs behaves like a dyn_cast.

5) It could be a bug in this patch perhaps.

Let me know if you need any help!

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D112374

2 years ago[pseudo] Fix initializer of string table
Sam McCall [Wed, 27 Jul 2022 09:03:29 +0000 (11:03 +0200)]
[pseudo] Fix initializer of string table

Apparently new string[/*no size*/]{"foo", "bar"} is a clang/gcc extension?

2 years ago[flang][NFC] Unify check prefixes in `abstract-results.fir` test
Daniil Dudkin [Wed, 27 Jul 2022 08:57:40 +0000 (11:57 +0300)]
[flang][NFC] Unify check prefixes in `abstract-results.fir` test

Now the prefixes have the same length
and they'll be easier to distinguish when
`GlobalOp` tests will be added

Depends on D129778

Reviewed By: clementval

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

2 years ago[flang] Generalize `AbstractResultOpt` pass
Daniil Dudkin [Wed, 27 Jul 2022 08:54:52 +0000 (11:54 +0300)]
[flang] Generalize `AbstractResultOpt` pass

This change decouples common functionality for convering abstract
results, so it can be reused later.

Depends on D129485

Reviewed By: clementval, jeanPerier

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

2 years ago[mlir] more aggressive folding in tiling/fusion transformations
Alex Zinenko [Wed, 13 Jul 2022 14:40:59 +0000 (14:40 +0000)]
[mlir] more aggressive folding in tiling/fusion transformations

Combine the recently added utilities for folded-by-construction affine
operations with the attribute-based Range to enable more folding. This
decreases the amount of emitted code but has little effect on test
precisely because the tests are not checking for the spurious constants.
The difference in the shape of affine maps comes from the internals of
affine folding.

Depends on D129633

Reviewed By: nicolasvasilache

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

2 years ago[mlir] Make ViewLikeInterface Range work with attributes
Alex Zinenko [Wed, 13 Jul 2022 11:11:16 +0000 (11:11 +0000)]
[mlir] Make ViewLikeInterface Range work with attributes

While most of methods in ViewLikeInterface accept an `OpFoldResult` for
the offset/size/stride that may be static, represented as `Attribute`,
or dynamic, represented as `Value`, the `Range` abstraction only
accepted `Values`. This can often lead to known-constant
offset/size/strides being materialized into constant operations and
hinder further constant propagation without explicitly running the
constant folding pass. This often leads to a more complicated than
necessary addressing code being emitted. Switch `Range` to use
`OpFoldResult`. Code that uses `Range` currently keeps materializing the
constants to minimize the effect of this change on the IR. Further
commits will make use of this.

Reviewed By: nicolasvasilache, mravishankar

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

2 years ago[mlir] Partially port splitting transform to TilingInterface
Alex Zinenko [Tue, 26 Jul 2022 10:42:17 +0000 (10:42 +0000)]
[mlir] Partially port splitting transform to TilingInterface

The structured op splitting transformation is conceptually similar to
tiling in the sense that it decomposes the iteration space of the
original op into several parts. Therefore, it is possible to implement
it using the TilingInterface to operate on iteration spaces and their
parts. However, the implementation also requires to pass updated input
operands, which is not supported by the interface, so the implementation
currently remains Linalg-specific.

Reviewed By: mravishankar

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

2 years agoRevert "[Debuginfo][llvm-dwarfutil] Add check for unsupported debug sections."
Alexey Lapshin [Wed, 27 Jul 2022 07:35:21 +0000 (10:35 +0300)]
Revert "[Debuginfo][llvm-dwarfutil] Add check for unsupported debug sections."

This reverts commit 0d191b7553e7efbf7ce57c77274b83c15b681933.

2 years agoEmit a simple StackSizesSection on PS4.
Ying Yi [Tue, 19 Jul 2022 14:22:14 +0000 (15:22 +0100)]
Emit a simple StackSizesSection on PS4.

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

2 years agoDisable stack-sizes section by default for PS4.
Ying Yi [Mon, 18 Jul 2022 18:28:43 +0000 (19:28 +0100)]
Disable stack-sizes section by default for PS4.

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

2 years ago[ARM] Correct features on pacbti instructions.
David Green [Wed, 27 Jul 2022 08:15:14 +0000 (09:15 +0100)]
[ARM] Correct features on pacbti instructions.

Given a patch like D129506, using instructions not valid for the current
feature set becomes an error. This updates the Arm hint-space
instructions for pac/bti to require thumbv7m as opposed to 8.1-m.main, to
make them valid when compiling for thumbv7m with -mbranch-protection.

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

2 years ago[mlir] Apply ClangTidyPerformance findings (NFC)
Adrian Kuegel [Wed, 27 Jul 2022 08:05:22 +0000 (10:05 +0200)]
[mlir] Apply ClangTidyPerformance findings (NFC)

2 years ago[ARM] Add target feature to force 32-bit atomics
Nikita Popov [Mon, 25 Jul 2022 13:12:10 +0000 (15:12 +0200)]
[ARM] Add target feature to force 32-bit atomics

This adds a +atomic-32 target feature, which instructs LLVM to assume
that lock-free 32-bit atomics are available for this target, even
if they usually wouldn't be.

If only atomic loads/stores are used, then this won't emit libcalls.
If atomic CAS is used, then the user is responsible for providing
any necessary __sync implementations (e.g. by masking interrupts
for single-core privileged use cases).

See https://reviews.llvm.org/D120026#3674333 for context on this
change. The tl;dr is that the thumbv6m target in Rust has
historically made atomic load/store only available, which is
incompatible with the change from D120026, which switched these to
use libatomic.

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

2 years ago[AArch64][GlobalISel] Lower vector G_CTTZ.
Amara Emerson [Wed, 27 Jul 2022 07:02:59 +0000 (00:02 -0700)]
[AArch64][GlobalISel] Lower vector G_CTTZ.

Fixes issue 56398

2 years ago[pseudo] Add dangling-else guard to missing if-statement variants
Sam McCall [Wed, 27 Jul 2022 07:08:34 +0000 (09:08 +0200)]
[pseudo] Add dangling-else guard to missing if-statement variants

2 years ago[pseudo] Remove dead header
Sam McCall [Wed, 27 Jul 2022 07:05:59 +0000 (09:05 +0200)]
[pseudo] Remove dead header

This was an earlier draft of Language.h that got committed accidentally

2 years ago[pseudo] Reorganize CXX.h enums
Sam McCall [Sat, 23 Jul 2022 07:54:48 +0000 (09:54 +0200)]
[pseudo] Reorganize CXX.h enums

- Place rules under rule::lhs::rhs__rhs__rhs
- Change mangling of keywords to ALL_CAPS (needed to turn keywords that appear
  alone on RHS into valid identifiers)
- Make enums implicitly convertible to underlying type (though still scoped,
  using alias tricks)

In principle this lets us exhaustively write a switch over all rules of a NT:
  switch ((rule::declarator)N->rule()) {
    case rule::declarator::noptr_declarator:
      ...
  }
In practice we don't do this anywhere yet as we're often switching over multiple
nonterminal kinds at once.

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

2 years agoUpdate checks legalize-cttz.mir test before change.
Amara Emerson [Wed, 27 Jul 2022 06:24:19 +0000 (23:24 -0700)]
Update checks legalize-cttz.mir test before change.

2 years ago[NFC] [C++20] [Modules] Use Sema::isModuleUnitOfCurrentTU to simplify the code
Chuanqi Xu [Wed, 27 Jul 2022 06:33:15 +0000 (14:33 +0800)]
[NFC] [C++20] [Modules] Use Sema::isModuleUnitOfCurrentTU to simplify the code

2 years ago[clang] Make parts of index test optional
Danny Mösch [Wed, 27 Jul 2022 06:25:52 +0000 (08:25 +0200)]
[clang] Make parts of index test optional

Reason is that the test behaves differently in clang-ppc64-aix in that the optional part appears in the output.

2 years ago[NFC] [C++20] [Modules] Use Sema::isCurrentModulePurview() to simplify the codes
Chuanqi Xu [Wed, 27 Jul 2022 06:14:45 +0000 (14:14 +0800)]
[NFC] [C++20] [Modules] Use Sema::isCurrentModulePurview() to simplify the codes

2 years ago[NFC] Convert a dyn_cast<> to an isa<>
Chuanqi Xu [Wed, 27 Jul 2022 05:56:38 +0000 (13:56 +0800)]
[NFC] Convert a dyn_cast<> to an isa<>

2 years agoBump the trunk major version to 16
Tom Stellard [Wed, 27 Jul 2022 02:43:55 +0000 (19:43 -0700)]
Bump the trunk major version to 16

2 years agoInline function calls.
Weverything [Wed, 27 Jul 2022 04:02:31 +0000 (21:02 -0700)]
Inline function calls.

Fix unused variable in non-assert builds after
300fbf56f89aebbe2ef9ed490066bab23e5356d1

2 years ago[lld-macho] Fix -bitcode_process_mode arg type
Keith Smiley [Tue, 26 Jul 2022 23:18:17 +0000 (16:18 -0700)]
[lld-macho] Fix -bitcode_process_mode arg type

This is still undocumented and unsupported, but if someone passed it
before you would end up with a missing file error since this takes an
argument that wouldn't be handled.

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

2 years ago[libc++][ranges] Fix the CI.
Konstantin Varlamov [Wed, 27 Jul 2022 02:45:06 +0000 (19:45 -0700)]
[libc++][ranges] Fix the CI.

2 years ago[clang][AIX] Add option to control quadword lock free atomics ABI on AIX
Kai Luo [Wed, 27 Jul 2022 01:27:07 +0000 (01:27 +0000)]
[clang][AIX] Add option to control quadword lock free atomics ABI on AIX

We are supporting quadword lock free atomics on AIX. For the situation that users on AIX are using a libatomic that is lock-based for quadword types, we can't enable quadword lock free atomics by default on AIX in case user's new code and existing code accessing the same shared atomic quadword variable, we can't guarentee atomicity. So we need an option to enable quadword lock free atomics on AIX, thus we can build a quadword lock-free libatomic(also for advanced users considering atomic performance critical) for users to make the transition smooth.

Reviewed By: shchenz

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

2 years ago[ASan] Use stack safety analysis to optimize allocas instrumentation.
Kirill Stoimenov [Wed, 27 Jul 2022 01:29:31 +0000 (18:29 -0700)]
[ASan] Use stack safety analysis to optimize allocas instrumentation.

Added alloca optimization which was missed during the implemenation of D112098.

Reviewed By: vitalybuka

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

2 years ago[asan][test] Check for __asan_stack_malloc
Vitaly Buka [Wed, 27 Jul 2022 01:26:59 +0000 (18:26 -0700)]
[asan][test] Check for __asan_stack_malloc

2 years ago[amdgpu][nfc] Separate processUsedLDS into independent pieces, rename it
Jon Chesterfield [Wed, 27 Jul 2022 00:44:36 +0000 (01:44 +0100)]
[amdgpu][nfc] Separate processUsedLDS into independent pieces, rename it

2 years ago[Polly] Insert !dbg metadata for emitted CallInsts.
Michael Kruse [Wed, 27 Jul 2022 00:02:21 +0000 (19:02 -0500)]
[Polly] Insert !dbg metadata for emitted CallInsts.

The IR Verifier requires that every call instruction to an inlineable
function (among other things, its implementation must be visible in the
translation unit) must also have !dbg metadata attached to it. When
parallelizing, Polly emits calls to OpenMP runtime function out of thin
air, or at least not directly derived from a bounded list of previous
instruction. While we could search for instructions in the SCoP that has
some debug info attached to it, there is no guarantee that we find any.
Our solution is to generate a new DILocation that points to line 0 to
represent optimized code.

The OpenMP function implementation is usually not available in the
user's translation unit, but can become visible in an LTO build. For
the bug to appear, libomp must also be built with debug symbols.

IMHO, the IR verifier rule is too strict. Runtime functions can
also be inserted by other optimization passes, such as
LoopIdiomRecognize. When inserting a call to e.g. memset, it uses the
DebugLoc from a StoreInst from the unoptimized code. It is not
required to have !dbg metadata attached either.

Fixes #56692

2 years ago[amdgpu][nfc] Extract kernel annotation from processUsedLDS
Jon Chesterfield [Wed, 27 Jul 2022 00:29:32 +0000 (01:29 +0100)]
[amdgpu][nfc] Extract kernel annotation from processUsedLDS

2 years agoworkflows: Use sccache to speed up CI builds
Tom Stellard [Wed, 27 Jul 2022 00:24:18 +0000 (17:24 -0700)]
workflows: Use sccache to speed up CI builds

Reviewed By: asl

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

2 years ago[asan][test] Cleanup asan-stack-safety.ll test
Vitaly Buka [Wed, 27 Jul 2022 00:06:18 +0000 (17:06 -0700)]
[asan][test] Cleanup asan-stack-safety.ll test

2 years agoImport CI tests from the release branch
Tom Stellard [Tue, 26 Jul 2022 23:52:53 +0000 (16:52 -0700)]
Import CI tests from the release branch

The tests still only run on pushes or pull requests for the release
branch, but having it in the main branch means we don't have to copy
the tests every time we create a new release branch.

Reviewed By: asl

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

2 years ago[libc++][NFC] Add checks for lifetime issues in classic algorithms.
Konstantin Varlamov [Tue, 26 Jul 2022 23:15:07 +0000 (16:15 -0700)]
[libc++][NFC] Add checks for lifetime issues in classic algorithms.

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

2 years ago[libc++][ranges] Implement `ranges::is_heap{,_until}`.
Konstantin Varlamov [Tue, 26 Jul 2022 23:11:09 +0000 (16:11 -0700)]
[libc++][ranges] Implement `ranges::is_heap{,_until}`.

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

2 years agoAdd string conversion for InstructionControlFlowKind enum
Jakob Johnson [Tue, 26 Jul 2022 15:14:19 +0000 (08:14 -0700)]
Add string conversion for InstructionControlFlowKind enum

Refactor the string conversion of the `lldb::InstructionControlFlowKind` enum out
of `Instruction::Dump` to enable reuse of this logic by the
JSON TraceDumper (to be implemented in separate diff).

Will coordinate the landing of this change with D130320 since there will be a minor merge conflict between
these changes.

Test Plan:
Run unittests
```
> ninja check-lldb
[4/5] Running lldb unit test suite

Testing Time: 10.13s
  Passed: 1084
```

Verify '-k' flag's output
```
(lldb) thread trace dump instructions -k
thread #1: tid = 1375377
  libstdc++.so.6`std::ostream::flush() + 43
    7048: 0x00007ffff7b54dab    return      retq
    7047: 0x00007ffff7b54daa    other       popq   %rbx
    7046: 0x00007ffff7b54da7    other       movq   %rbx, %rax
    7045: 0x00007ffff7b54da5    cond jump   je     0x11adb0                  ; <+48>
    7044: 0x00007ffff7b54da2    other       cmpl   $-0x1, %eax
  libc.so.6`_IO_fflush + 249
    7043: 0x00007ffff7161729    return      retq
    7042: 0x00007ffff7161728    other       popq   %rbp
    7041: 0x00007ffff7161727    other       popq   %rbx
    7040: 0x00007ffff7161725    other       movl   %edx, %eax
    7039: 0x00007ffff7161721    other       addq   $0x8, %rsp
    7038: 0x00007ffff7161709    cond jump   je     0x87721                   ; <+241>
    7037: 0x00007ffff7161707    other       decl   (%rsi)
    7036: 0x00007ffff71616fe    cond jump   je     0x87707                   ; <+215>
    7035: 0x00007ffff71616f7    other       cmpl   $0x0, 0x33de92(%rip)      ; __libc_multiple_threads
    7034: 0x00007ffff71616ef    other       movq   $0x0, 0x8(%rsi)
    7033: 0x00007ffff71616ed    cond jump   jne    0x87721                   ; <+241>
    7032: 0x00007ffff71616e9    other       subl   $0x1, 0x4(%rsi)
    7031: 0x00007ffff71616e2    other       movq   0x88(%rbx), %rsi
    7030: 0x00007ffff71616e0    cond jump   jne    0x87721                   ; <+241>
    7029: 0x00007ffff71616da    other       testl  $0x8000, (%rbx)           ; imm = 0x8000
```

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

2 years ago[libc++][ranges] Make sure all range algorithms support differing projection types:
Konstantin Varlamov [Tue, 26 Jul 2022 22:51:37 +0000 (15:51 -0700)]
[libc++][ranges] Make sure all range algorithms support differing projection types:

- for all algorithms taking more than one range, add a `robust` test to
  check the case where the ranges have different value types and the
  given projections are different, with each projection applying to
  a different value type;
- fix `ranges::include` to apply the correct projection to each range.

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

2 years ago[libc++][ranges] Implement `ranges::generate{,_n}`.
Konstantin Varlamov [Tue, 26 Jul 2022 22:50:14 +0000 (15:50 -0700)]
[libc++][ranges] Implement `ranges::generate{,_n}`.

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

2 years agoRevert "[Support] Workaround compiler bug in MSVC"
Tom Stellard [Tue, 26 Jul 2022 22:49:35 +0000 (15:49 -0700)]
Revert "[Support] Workaround compiler bug in MSVC"

This reverts commit ec8f4fd68cd401a0ba41bb160d6acce670486fab.

This caused a failure in the mlir-windows bot.

2 years agoworkflows: Add GitHub action for automating some release tasks
Tom Stellard [Tue, 26 Jul 2022 22:36:48 +0000 (15:36 -0700)]
workflows: Add GitHub action for automating some release tasks

For each release tag, this action will create a new release on GitHub,
and for each -final tag, this action will build the documentation and
upload it to GitHub.

Reviewed By: hans, kwk

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

2 years agogithub: Automatically assign reviewers for backport requests
Tom Stellard [Tue, 26 Jul 2022 22:18:23 +0000 (15:18 -0700)]
github: Automatically assign reviewers for backport requests

When there is a backport request, the GitHub Action that handles the
backport will now automatically assign the issue to the user(s) who
approved the commit in Phabricator and create an issue comment asking
them to review the request.

Reviewed By: thieta, kwk

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

2 years ago[CodeGen] Fixed ambiguous symbol ExtAddrMode in case of NDEBUG and LLVM_ENABLE_DUMP
Dmitry Vassiliev [Tue, 26 Jul 2022 22:21:57 +0000 (00:21 +0200)]
[CodeGen] Fixed ambiguous symbol ExtAddrMode in case of NDEBUG and LLVM_ENABLE_DUMP

This patch fixes the following error with MSVC 16.9.2 in case of NDEBUG and LLVM_ENABLE_DUMP:
llvm/lib/CodeGen/CodeGenPrepare.cpp(2581): error C2872: 'ExtAddrMode': ambiguous symbol
llvm/include/llvm/CodeGen/TargetInstrInfo.h(86): note: could be 'llvm::ExtAddrMode'
llvm/lib/CodeGen/CodeGenPrepare.cpp(2447): note: or '`anonymous-namespace'::ExtAddrMode'
llvm/lib/CodeGen/CodeGenPrepare.cpp(2581): error C2039: 'print': is not a member of 'llvm::ExtAddrMode'

Reviewed By: aaron.ballman

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

2 years agogithub: Fix release automation /branch command with new repo
Tom Stellard [Tue, 26 Jul 2022 22:05:03 +0000 (15:05 -0700)]
github: Fix release automation /branch command with new repo

We started using the llvm/llvm-project-release-prs repo for
backport pull requests, but since this repo is not a fork of
llvm/llvm-project it will reject pull requests from other repos. In
order to fix this, when ever someone uses the /branch command to request
a branch be merged into the release branch, we first copy the branch to
the llvm-project-release-prs repo and then create the pull request.

Reviewed By: thieta

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

2 years ago[ELF] addDependentLibrary: fix a use-after-free bug in archiveName
Fangrui Song [Tue, 26 Jul 2022 21:52:06 +0000 (14:52 -0700)]
[ELF] addDependentLibrary: fix a use-after-free bug in archiveName

2 years ago[mlir] Refactor SubElementInterface replace support
River Riddle [Tue, 26 Jul 2022 20:22:19 +0000 (13:22 -0700)]
[mlir] Refactor SubElementInterface replace support

The current support was essentially the amount necessary
to support replacing SymbolRefAttrs, but suffers from various
deficiencies (both ergonomic and functional):

* Replace crashes if unsupported
 This makes it really hard to use safely, given that you don't know
 if you are going to crash or not when using it.

* Types aren't supported
This seems like a simple missed addition when the attribute replacement
support was originally added.

* The ergonomics are weird
It currently uses an index based replacement, which makes the implementations
quite clunky.

This commit refactors support to be a bit more ergonomic, and also
adds support for types in the process. This was also a great oppurtunity
to greatly simplify how replacement is done in the symbol table.

Fixes #56355

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

2 years ago[ELF] addLibrary: fix a use-after-free bug in archiveName
Fangrui Song [Tue, 26 Jul 2022 21:36:56 +0000 (14:36 -0700)]
[ELF] addLibrary: fix a use-after-free bug in archiveName

It manifests as an incorrect name in --print-archive-stats=.

2 years ago[ELF][test] Clean up print-archive-stats.s
Fangrui Song [Tue, 26 Jul 2022 21:36:09 +0000 (14:36 -0700)]
[ELF][test] Clean up print-archive-stats.s

2 years ago[RISCV] Pre-commit tests for D130146. NFC
Craig Topper [Tue, 26 Jul 2022 21:21:58 +0000 (14:21 -0700)]
[RISCV] Pre-commit tests for D130146. NFC

2 years ago[lldb/ClangExpressionParser] Fix compiler error due to `clang::CreateLLVMCodeGen...
Argyrios Kyrtzidis [Tue, 26 Jul 2022 21:05:22 +0000 (14:05 -0700)]
[lldb/ClangExpressionParser] Fix compiler error due to `clang::CreateLLVMCodeGen()` API change

2 years ago[CGDebugInfo] Access the current working directory from the `VFS`
Argyrios Kyrtzidis [Sat, 23 Jul 2022 07:11:44 +0000 (00:11 -0700)]
[CGDebugInfo] Access the current working directory from the `VFS`

...instead of calling `llvm::sys::fs::current_path()` directly.

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

2 years ago[clang-tidy] Avoid extra parentheses around MemberExpr
Danny Mösch [Tue, 12 Jul 2022 21:33:01 +0000 (23:33 +0200)]
[clang-tidy] Avoid extra parentheses around MemberExpr

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

Reviewed By: aaron.ballman

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

2 years ago[InstCombine] Fold strtoul and strtoull and avoid PR #56293
Martin Sebor [Thu, 7 Jul 2022 20:35:23 +0000 (14:35 -0600)]
[InstCombine] Fold strtoul and strtoull and avoid PR #56293

Reviewed By: efriedma

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

2 years ago[lldb] Disable TestStackFromStdModule.py
Augusto Noronha [Tue, 26 Jul 2022 19:59:57 +0000 (12:59 -0700)]
[lldb] Disable TestStackFromStdModule.py

TestStackFromStdModule.py started failing due to f4fb72e6d4ce
(https://reviews.llvm.org/D128146), with a clang assertion failure:
assert(isa<InjectedClassNameType>(Decl->TypeForDecl))

2 years ago[amdgpu][nfc] Separate LDS struct creation from RAUW
Jon Chesterfield [Tue, 26 Jul 2022 19:47:52 +0000 (20:47 +0100)]
[amdgpu][nfc] Separate LDS struct creation from RAUW

2 years ago[Support] Workaround compiler bug in MSVC
Tom Stellard [Tue, 26 Jul 2022 19:50:56 +0000 (12:50 -0700)]
[Support] Workaround compiler bug in MSVC

https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317

This was causing unittest failures on Windows for the GitHub actions
based CI we use in the release branches.

Failed Tests (2):
  LLVM-Unit :: Support/./SupportTests.exe/FormatVariadicTest.BigTest
  LLVM-Unit :: Support/./SupportTests.exe/NativeFormatTest.BoundaryTests

Reviewed By: RKSimon

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

2 years ago[AggressiveInstCombine] convert sqrt libcalls with "nnan" to sqrt intrinsics
Sanjay Patel [Tue, 26 Jul 2022 19:31:12 +0000 (15:31 -0400)]
[AggressiveInstCombine] convert sqrt libcalls with "nnan" to sqrt intrinsics

This is an alternate to D129155 that uses TTI.haveFastSqrt() to avoid a
potential miscompile for programs with reads of errno. Moving the transform
to AggressiveInstCombine provides access to TTI.

If a sqrt call has "nnan", that implies that the input argument is never
negative because sqrt of {negative number} --> NAN.
If the argument is never negative and the call can be lowered without a
libcall, then we can assume that errno accesses are unchanged after lowering,
so the call can be translated to the LLVM intrinsic (which is expected to
become inline code).

This affects codegen for targets like x86 that have sqrt instructions, but
still have to conservatively assume that a libcall may be needed to set
errno as shown in issue #52620 and issue #56383.

This patch won't solve those examples - we will need to extend this to use
CannotBeOrderedLessThanZero or similar, enhance that analysis for new
operators, and/or deal with llvm.assume too.

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

2 years ago[Clang][Doc] Update the release note for clang
Shilei Tian [Tue, 26 Jul 2022 19:39:00 +0000 (15:39 -0400)]
[Clang][Doc] Update the release note for clang

Add the support for `atomic compare` and `atomic compare capture` in the
release note of clang.

Reviewed By: jdoerfert

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

2 years ago[clang] Pass FoundDecl to DeclRefExpr creator for operator overloads
Danny Mösch [Sun, 17 Jul 2022 19:28:36 +0000 (21:28 +0200)]
[clang] Pass FoundDecl to DeclRefExpr creator for operator overloads

Without the "found declaration" it is later not possible to know where the operator declaration
was brought into the scope calling it.

The initial motivation for this fix came from #55095. However, this also has an influence on
`clang -ast-dump` which now prints a `UsingShadow` attribute for operators only visible through
`using` statements. Also, clangd now correctly references the `using` statement instead of the
operator directly.

Reviewed By: shafik

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

2 years agoMove GetControlFlowKind's logic to DisassemblerLLVMC.cpp
Walter Erquinigo [Tue, 26 Jul 2022 18:44:50 +0000 (11:44 -0700)]
Move GetControlFlowKind's logic to DisassemblerLLVMC.cpp

This diff move the logic of `GetControlFlowKind()` from Disassembler.cpp to DisassemblerLLVMC.cpp.
Here's details:
- Actual logic of GetControlFlowKind() move to `DisassemblerLLVMC.cpp`, and we can check underlying architecture using `DisassemblerScope` there.
- With this change, passing 'triple' to `GetControlFlowKind()` is no more required.

Reviewed By: wallace

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

2 years ago[trace][intel pt] Introduce wall clock time for each trace item
Walter Erquinigo [Mon, 18 Jul 2022 23:56:01 +0000 (16:56 -0700)]
[trace][intel pt] Introduce wall clock time for each trace item

- Decouple TSCs from trace items
- Turn TSCs into events just like CPUs. The new name is HW clock tick, wich could be reused by other vendors.
- Add a GetWallTime that returns the wall time that the trace plug-in can infer for each trace item.
- For intel pt, we are doing the following interpolation: if an instruction takes less than 1 TSC, we use that duration, otherwise, we assume the instruction took 1 TSC. This helps us avoid having to handle context switches, changes to kernel, idle times, decoding errors, etc. We are just trying to show some approximation and not the real data. For the real data, TSCs are the way to go. Besides that, we are making sure that no two trace items will give the same interpolation value. Finally, we are using as time 0 the time at which tracing started.

Sample output:

```
(lldb) r
Process 750047 launched: '/home/wallace/a.out' (x86_64)
Process 750047 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x0000000000402479 a.out`main at main.cpp:29:20
   26   };
   27
   28   int main() {
-> 29     std::vector<int> vvv;
   30     for (int i = 0; i < 100; i++)
   31       vvv.push_back(i);
   32
(lldb) process trace start -s 64kb -t --per-cpu
(lldb) b 60
Breakpoint 2: where = a.out`main + 1689 at main.cpp:60:23, address = 0x0000000000402afe
(lldb) c
Process 750047 resuming
Process 750047 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 2.1
    frame #0: 0x0000000000402afe a.out`main at main.cpp:60:23
   57     map<int, int> m;
   58     m[3] = 4;
   59
-> 60     map<string, string> m2;
   61     m2["5"] = "6";
   62
   63     std::vector<std::string> vs = {"2", "3"};
(lldb) thread trace dump instructions -t -f -e thread #1: tid = 750047
    0: [379567.000 ns] (event) HW clock tick [48599428476224707]
    1: [379569.000 ns] (event) CPU core changed [new CPU=2]
    2: [390487.000 ns] (event) HW clock tick [48599428476246495]
    3: [1602508.000 ns] (event) HW clock tick [48599428478664855]
    4: [1662745.000 ns] (event) HW clock tick [48599428478785046]
  libc.so.6`malloc
    5: [1662746.995 ns] 0x00007ffff7176660    endbr64
    6: [1662748.991 ns] 0x00007ffff7176664    movq   0x32387d(%rip), %rax      ;  + 408
    7: [1662750.986 ns] 0x00007ffff717666b    pushq  %r12
    8: [1662752.981 ns] 0x00007ffff717666d    pushq  %rbp
    9: [1662754.977 ns] 0x00007ffff717666e    pushq  %rbx
    10: [1662756.972 ns] 0x00007ffff717666f    movq   (%rax), %rax
    11: [1662758.967 ns] 0x00007ffff7176672    testq  %rax, %rax
    12: [1662760.963 ns] 0x00007ffff7176675    jne    0x9c7e0                   ; <+384>
    13: [1662762.958 ns] 0x00007ffff717667b    leaq   0x17(%rdi), %rax
    14: [1662764.953 ns] 0x00007ffff717667f    cmpq   $0x1f, %rax
    15: [1662766.949 ns] 0x00007ffff7176683    ja     0x9c730                   ; <+208>
    16: [1662768.944 ns] 0x00007ffff7176730    andq   $-0x10, %rax
    17: [1662770.939 ns] 0x00007ffff7176734    cmpq   $-0x41, %rax
    18: [1662772.935 ns] 0x00007ffff7176738    seta   %dl
    19: [1662774.930 ns] 0x00007ffff717673b    jmp    0x9c690                   ; <+48>
    20: [1662776.925 ns] 0x00007ffff7176690    cmpq   %rdi, %rax
    21: [1662778.921 ns] 0x00007ffff7176693    jb     0x9c7b0                   ; <+336>
    22: [1662780.916 ns] 0x00007ffff7176699    testb  %dl, %dl
    23: [1662782.911 ns] 0x00007ffff717669b    jne    0x9c7b0                   ; <+336>
    24: [1662784.906 ns] 0x00007ffff71766a1    movq   0x3236c0(%rip), %r12      ;  + 24
(lldb) thread trace dump instructions -t -f -e -J -c 4
[
  {
    "id": 0,
    "timestamp_ns": "379567.000000",
    "event": "HW clock tick",
    "hwClock": 48599428476224707
  },
  {
    "id": 1,
    "timestamp_ns": "379569.000000",
    "event": "CPU core changed",
    "cpuId": 2
  },
  {
    "id": 2,
    "timestamp_ns": "390487.000000",
    "event": "HW clock tick",
    "hwClock": 48599428476246495
  },
  {
    "id": 3,
    "timestamp_ns": "1602508.000000",
    "event": "HW clock tick",
    "hwClock": 48599428478664855
  },
  {
    "id": 4,
    "timestamp_ns": "1662745.000000",
    "event": "HW clock tick",
    "hwClock": 48599428478785046
  },
  {
    "id": 5,
    "timestamp_ns": "1662746.995324",
    "loadAddress": "0x7ffff7176660",
    "module": "libc.so.6",
    "symbol": "malloc",
    "mnemonic": "endbr64"
  },
  {
    "id": 6,
    "timestamp_ns": "1662748.990648",
    "loadAddress": "0x7ffff7176664",
    "module": "libc.so.6",
    "symbol": "malloc",
    "mnemonic": "movq"
  },
  {
    "id": 7,
    "timestamp_ns": "1662750.985972",
    "loadAddress": "0x7ffff717666b",
    "module": "libc.so.6",
    "symbol": "malloc",
    "mnemonic": "pushq"
  },
  {
    "id": 8,
    "timestamp_ns": "1662752.981296",
    "loadAddress": "0x7ffff717666d",
    "module": "libc.so.6",
    "symbol": "malloc",
    "mnemonic": "pushq"
  }
]
```

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

2 years ago[InstSimplify] remove redundant calls to 'isImplied'; NFCI
Sanjay Patel [Tue, 26 Jul 2022 17:29:48 +0000 (13:29 -0400)]
[InstSimplify] remove redundant calls to 'isImplied'; NFCI

We already call the more general isImpliedCondition() (which calls
isImpliedTrueByMatchingCmp() internally) from simplifyAndInst()
and simplifyOrInst().

There was a difference visible with this change on a vector test
before a925bef70c6c, but I can't find any gaps now.

2 years ago[gn build] Port 4638d7a28f62
LLVM GN Syncbot [Tue, 26 Jul 2022 18:27:34 +0000 (18:27 +0000)]
[gn build] Port 4638d7a28f62

2 years ago[Sanitizers][Darwin] Allows '-mtargetos' to used to set minimum deployment target.
Blue Gaston [Tue, 26 Jul 2022 03:47:15 +0000 (20:47 -0700)]
[Sanitizers][Darwin] Allows '-mtargetos' to used to set minimum deployment target.

Currently, m{platform}-version-min is default flag used to set min deployment target within compilter-rt and sanitizers.
However, clang uses flags -target and -mtargetos for setting target triple and minimum deployment targets.
-mtargetos will be the preferred flag to set min version in the future and the
${platform}-version-min flag will not be used for future platforms.

This change allows darwin platforms to use either ${platform}-min-version or -mtargetos
without breaking lit test flags that allows for overriding the default min value in lit tests
Tests using flags: 'darwin_min_target_with_tls_support', 'min_macos_deployment_target'
will no longer fail if they use mtargetos instead of version-min.

rdar://81028225

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

2 years agoRevert "[clang-offload-bundler] Library-ize ClangOffloadBundler"
Lambert, Jacob [Tue, 26 Jul 2022 18:22:31 +0000 (11:22 -0700)]
Revert "[clang-offload-bundler] Library-ize ClangOffloadBundler"

This reverts commit 8348c4095600ec2c0beee293267832799d2ebee3.

2 years ago[Matrix] Add assert to catch extracted vectors with poison elements
Francis Visoiu Mistrih [Wed, 20 Jul 2022 09:32:15 +0000 (11:32 +0200)]
[Matrix] Add assert to catch extracted vectors with poison elements

Assert when the extracted vector is wider than the row/column.

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

2 years ago[RISCV] Add Predicate to c.lw/c.sw/c.lwsp/c.swsp InstAliases with no offset.
Craig Topper [Tue, 26 Jul 2022 17:56:37 +0000 (10:56 -0700)]
[RISCV] Add Predicate to c.lw/c.sw/c.lwsp/c.swsp InstAliases with no offset.

These are aliases that allow the immediate offset to be ommitted.
We had predicates for the RV64, RV32+F, and D versions, but
not the base versions.

I've also re-ordered them to share Predicate lines to improve
readability.

2 years ago[Matrix] Refactor tiled loops in a struct. NFC
Francis Visoiu Mistrih [Wed, 20 Jul 2022 09:12:30 +0000 (11:12 +0200)]
[Matrix] Refactor tiled loops in a struct. NFC

The three loops have the same structure: index, header, latch.

2 years ago[GlobalISel] Import patterns for G_FMAXIMUM + G_FMINIMUM
Jessica Paquette [Tue, 26 Jul 2022 17:54:30 +0000 (10:54 -0700)]
[GlobalISel] Import patterns for G_FMAXIMUM + G_FMINIMUM

Allows us to select scalar instructions on AArch64.

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

2 years ago[clang][dataflow] Analyze calls to in-TU functions
Sam Estep [Tue, 26 Jul 2022 17:54:13 +0000 (17:54 +0000)]
[clang][dataflow] Analyze calls to in-TU functions

This patch adds initial support for context-sensitive analysis of simple functions whose definition is available in the translation unit, guarded by the `ContextSensitive` flag in the new `TransferOptions` struct. When this option is true, the `VisitCallExpr` case in the builtin transfer function has a fallthrough case which checks for a direct callee with a body. In that case, it constructs a CFG from that callee body, uses the new `pushCall` method on the `Environment` to make an environment to analyze the callee, and then calls `runDataflowAnalysis` with a `NoopAnalysis` (disabling context-sensitive analysis on that sub-analysis, to avoid problems with recursion). After the sub-analysis completes, the `Environment` from its exit block is simply assigned back to the environment at the callsite.

The `pushCall` method (which currently only supports non-method functions with some restrictions) maps the `SourceLocation`s for all the parameters to the existing source locations for the corresponding arguments from the callsite.

This patch adds a few tests to check that this context-sensitive analysis works on simple functions. More sophisticated functionality will be added later; the most important next step is to explicitly model context in some fields of the `DataflowAnalysisContext` class, as mentioned in a `FIXME` comment in the `pushCall` implementation.

Reviewed By: ymandel, xazax.hun

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

2 years ago[RISCV] Minor fixes to rv64c-valid.s test.
Craig Topper [Tue, 26 Jul 2022 17:39:20 +0000 (10:39 -0700)]
[RISCV] Minor fixes to rv64c-valid.s test.

-Missing CHECK-NO-EXT and CHECK-NO-RV64 on subw.
-Stray CHECK-NO-RV64 on c.slli.
-c.slli used immediate 1 instead of RV64 only immediate like 63.
-Missing CHECK-NO-EXT on c.srli and c.srai

2 years ago[gn build] Port 8348c4095600
Nico Weber [Tue, 26 Jul 2022 17:30:49 +0000 (13:30 -0400)]
[gn build] Port 8348c4095600

2 years ago[amdgpu][nfc] Skip operations on padding fields in LDS struct
Jon Chesterfield [Tue, 26 Jul 2022 17:04:40 +0000 (18:04 +0100)]
[amdgpu][nfc] Skip operations on padding fields in LDS struct

2 years agoRevert "[clang][dataflow] Analyze calls to in-TU functions"
Sam Estep [Tue, 26 Jul 2022 17:30:09 +0000 (17:30 +0000)]
Revert "[clang][dataflow] Analyze calls to in-TU functions"

This reverts commit fa2b83d07ecab3b24b4c5ee2e7dc4b6bbc895317.