platform/upstream/llvm.git
3 years ago[DebugInfo] Add new instruction and DIExpression operator for variadic debug values
gbtozers [Fri, 11 Sep 2020 14:58:01 +0000 (15:58 +0100)]
[DebugInfo] Add new instruction and DIExpression operator for variadic debug values

This patch adds a new instruction that can represent variadic debug values,
DBG_VALUE_VAR. This patch alone covers the addition of the instruction and a set
of basic code changes in MachineInstr and a few adjacent areas, but does not
correctly handle variadic debug values outside of these areas, nor does it
generate them at any point.

The new instruction is similar to the existing DBG_VALUE instruction, with the
following differences: the operands are in a different order, any number of
values may be used in the instruction following the Variable and Expression
operands (these are referred to in code as “debug operands”) and are indexed
from 0 so that getDebugOperand(X) == getOperand(X+2), and the Expression in a
DBG_VALUE_VAR must use the DW_OP_LLVM_arg operator to pass arguments into the
expression.

The new DW_OP_LLVM_arg operator is only valid in expressions appearing in a
DBG_VALUE_VAR; it takes a single argument and pushes the debug operand at the
index given by the argument onto the Expression stack. For example the
sub-expression `DW_OP_LLVM_arg, 0` has the meaning “Push the debug operand at
index 0 onto the expression stack.”

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

3 years ago[llvm-objcopy][llvm-strip][test] Improve testing
James Henderson [Mon, 22 Feb 2021 14:30:15 +0000 (14:30 +0000)]
[llvm-objcopy][llvm-strip][test] Improve testing

This patch adds a number of new test cases that cover various
llvm-objcopy and llvm-strip features that had missing test coverage of
various descriptions:
* --add-section - checked the shdr properties, not just the content.
* Dedicated test case for --add-symbol when there are many sections.
* Show that --change-start accepts negative values without overflow.
  This was previously present but got lost between review versions.
* --dump-section - show that multiple sections can be dumped
  simultaneously to different files, and that an error is reported when
  a section cannot be found.
* --globalize-symbol(s) - show that symbols that are not mentioned are
  not globalized, if they would otherwise be, and that missing symbols
  from the list do not cause problems.
* --keep-global-symbol - show that the --regex option can be used in
  conjunction with this option.
* --keep-symbol - show that the --regex option can be used in
  conjunction with this option.
* --localize-symbol(s) - show that symbols that are not mentioned are
  not localized, if they would otherwise be, and that missing symbols
  from the list do not cause problems.
* --prefix-alloc-sections - show the behaviour of an empty string
  argument and multiple arguments.
* --prefix-symbols - show the behaviour of an empty string argument and
  multiple arguments. Also show the option applies to undefined symbols.
* --redefine-symbol - show that symbols with no name can be renamed,
  that it is not an error if a symbol is not specified, and that the
  option doesn't chain (i.e. --redefine-sym a=b --redefine-sym b=c does
  not redefine a as c).
* --rename-section - show that all section flags are preserved if none
  are specified. Also show that the option does not chain.
* --set-section-alignment - show that only specified sections have
  their alignments changed.
* --set-section-flags - show which section flags are preserved when this
  option is used. Also show that unspecified sections are not affected.
* --preserve-dates - show that -p is an alias of --preserve-dates.
* --strip-symbol - show that --regex works with this option for
  llvm-objcopy as well as llvm-strip.
* --strip-unneeded-symbol(s) - show more clearly that needed symbols are
  not stripped even if requested by this option.
* --allow-broken-links - show the sh_link of a symbol table is set to 0
  when its string table has been removed when this option is specified.
* --weaken-symbol(s) - show that symbols that are not mentioned are not
  weakened, if they would otherwise be, and that missing symbols from
  the list do not cause problems.
* --wildcard - show the wildcard behaviour for several options that were
  previously unchecked.

Reviewed by: alexshap

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

3 years agoRevert "[darwin] switch blocking mutex from osspinlock to os_unfair_lock"
Hans Wennborg [Thu, 4 Mar 2021 11:15:42 +0000 (12:15 +0100)]
Revert "[darwin] switch blocking mutex from osspinlock to os_unfair_lock"

> OSSpinLock is deprecated, so we are switching to `os_unfair_lock`. However, `os_unfair_lock` isn't available on older OSs, so we keep `OSSpinLock` as fallback.
>
> Also change runtime assumption check to static since they only ever check constant values.
>
> rdar://69588111
>
> Reviewed By: delcypher, yln
>
> Differential Revision: https://reviews.llvm.org/D97509

This reverts commit 71ef54337d5e83c6767e4816227ef340caa337fc.

3 years ago[gn build] Port d791695cb517
LLVM GN Syncbot [Thu, 4 Mar 2021 11:17:51 +0000 (11:17 +0000)]
[gn build] Port d791695cb517

3 years ago[objdump][ARM] Use correct offset when printing ARM/Thumb branch targets
Oliver Stannard [Tue, 2 Mar 2021 13:49:14 +0000 (13:49 +0000)]
[objdump][ARM] Use correct offset when printing ARM/Thumb branch targets

llvm-objdump only uses one MCInstrAnalysis object, so if ARM and Thumb
code is mixed in one object, or if an object is disassembled without
explicitly setting the triple to match the ISA used, then branch and
call targets will be printed incorrectly.

This could be fixed by creating two MCInstrAnalysis objects in
llvm-objdump, like we currently do for SubtargetInfo. However, I don't
think there's any reason we need two separate sub-classes of
MCInstrAnalysis, so instead these can be merged into one, and the ISA
determined by checking the opcode of the instruction.

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

3 years ago[MCA] Add support for in-order CPUs
Andrew Savonichev [Tue, 29 Dec 2020 16:49:09 +0000 (19:49 +0300)]
[MCA] Add support for in-order CPUs

This patch adds a pipeline to support in-order CPUs such as ARM
Cortex-A55.

In-order pipeline implements a simplified version of Dispatch,
Scheduler and Execute stages as a single stage. Entry and Retire
stages are common for both in-order and out-of-order pipelines.

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

3 years ago[X86] canonicalizeShuffleWithBinOps - handle general unaryshuffle(binop(x,c)) pattern...
Simon Pilgrim [Thu, 4 Mar 2021 10:44:23 +0000 (10:44 +0000)]
[X86] canonicalizeShuffleWithBinOps - handle general unaryshuffle(binop(x,c)) patterns not just xor(x,-1)

Generalize the shuffle(not(x)) -> not(shuffle(x)) fold to handle any binop with 0/-1.

Hopefully we can further generalize to help push target unary/binary shuffles through binops similar to what we do in DAGCombiner::visitVECTOR_SHUFFLE

3 years ago[NFC] Fix typos in CallingConvLower.h
Fraser Cormack [Thu, 4 Mar 2021 10:23:12 +0000 (10:23 +0000)]
[NFC] Fix typos in CallingConvLower.h

3 years ago[llvm-objcopy][llvm-strip] Improve --discard-all documentation and help
James Henderson [Tue, 23 Feb 2021 13:55:48 +0000 (13:55 +0000)]
[llvm-objcopy][llvm-strip] Improve --discard-all documentation and help

The help text and documentation for the --discard-all option failed to
mention that the option also causes the removal of debug sections. This
change fixes both for both llvm-objcopy and llvm-strip.

Reviewed by: MaskRay

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

3 years ago[llvm-objcopy/strip] Fix off-by-one error in SYMTAB_SHNDX need check
James Henderson [Fri, 26 Feb 2021 13:44:48 +0000 (13:44 +0000)]
[llvm-objcopy/strip] Fix off-by-one error in SYMTAB_SHNDX need check

The check for whether an extended symbol index table was required
dropped the first SHN_LORESERVE sections from the sections array before
checking whether the remaining sections had symbols. Unfortunately, the
null section header is not present in this list, so the check was
skipping the first section that might be important. If that section
contained a symbol, and no subsequent ones did, the .symtab_shndx
section would not be emitted, leading to a corrupt object.

Also consolidate and expand test coverage in the area to cover this bug
and other aspects of the SYMTAB_SHNDX section.

Reviewed by: alexshap, MaskRay

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

3 years ago[libcxx] Move Linaro AArch64 buildbots to buildkite
David Spickett [Mon, 8 Feb 2021 10:43:21 +0000 (10:43 +0000)]
[libcxx] Move Linaro AArch64 buildbots to buildkite

Reviewed By: #libc, ldionne

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

3 years ago[clangd] Introduce client state invalidation
Kadir Cetinkaya [Fri, 26 Feb 2021 13:44:01 +0000 (14:44 +0100)]
[clangd] Introduce client state invalidation

Clangd can invalidate client state of features like semantic higlighting
without client explicitly triggering, for example after a preamble build
caused by an onSave notification on a different file.

This patch introduces a mechanism to let client know of such actions,
and also calls the workspace/semanticTokens/refresh request to
demonstrate the situation after each preamble build.

Fixes https://github.com/clangd/clangd/issues/699.

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

3 years ago[ARM] Remove new ARMSelectionDAGTest unittest.
David Green [Thu, 4 Mar 2021 10:14:35 +0000 (10:14 +0000)]
[ARM] Remove new ARMSelectionDAGTest unittest.

This removes the unit test from a968e7b82eac as it reportedly causes
some link problems. It can be reinstated once the issues are understood
and sorted out.

3 years ago[Polly][Codegen] Emit access group metadata.
Michael Kruse [Thu, 4 Mar 2021 09:46:29 +0000 (03:46 -0600)]
[Polly][Codegen] Emit access group metadata.

Emit llvm.loop.parallel_accesses metadata instead of
llvm.mem.parallel_loop_access. The latter is deprecated because it
assumes that LoopIDs are persistent, which they are not.
We also emit parallel access metadata for all surrounding parallel
loops, not just the innermost parallel.

3 years ago[mlir] ODS: change OpBuilderDAG to OpBuilder
Alex Zinenko [Wed, 3 Mar 2021 14:53:09 +0000 (15:53 +0100)]
[mlir] ODS: change OpBuilderDAG to OpBuilder

We no longer have the non-DAG version.

Reviewed By: rriddle

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

3 years ago[X86][CodeGenPrepare] Try to reuse IV's incremented value instead of adding the offse...
Max Kazantsev [Thu, 4 Mar 2021 08:41:22 +0000 (15:41 +0700)]
[X86][CodeGenPrepare] Try to reuse IV's incremented value instead of adding the offset, part 2

This patch enables the case where we do not completely eliminate offset.
Supposedly in this case we reduce live range overlap that never harms, but
since there are doubts this is true, this goes as a separate change.

Differential Revision: https://reviews.llvm.org/D96399
Reviewed By: reames

3 years ago[llvm-objcopy][test] Improve many-sections object and test case
James Henderson [Wed, 17 Feb 2021 13:53:01 +0000 (13:53 +0000)]
[llvm-objcopy][test] Improve many-sections object and test case

Additionally do some test tidy-ups and improve coverage of symbol
section indexes where the logical section index >= SHN_LORESERVE.

The symbol and section names in the many-section input object were
mostly shared. This patch changes them to be distinct, enabling
different operations such as --add-symbol, to be more targeted, when
using the object. It also makes the test less confusing and removes some
oddness in the symbol table order, presumably caused by the duplicate
names.

The input object was built from assembly that was of the form:
.section s1
sym1:
.section s2
sym2:
...
with a total of 65536 such occurrences. llvm-objcopy was then used to
remove the empty .text section automatically generated by MC, and
incidentally to move .strtab to the end of the object. This ensured that
the section/symbol indexes matched their name (i.e. section index 1 was
s1, section index 2 was s2 etc, and sym1 was in s1, sym2 in s2 etc).

Reviewed by: MaskRay

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

3 years ago[RISCV] Fix crash when inserting large fixed-length subvectors
Fraser Cormack [Wed, 3 Mar 2021 16:39:43 +0000 (16:39 +0000)]
[RISCV] Fix crash when inserting large fixed-length subvectors

This patch addresses a compiler crash resulting from passing a
fixed-length type to one that expects scalable vector types. An
assertion was added to prevent this regressing in the future.

Reviewed By: craig.topper

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

3 years ago[RISCV] Preserve fixed-length VL on insert_vector_elt in more cases
Fraser Cormack [Wed, 3 Mar 2021 07:50:49 +0000 (07:50 +0000)]
[RISCV] Preserve fixed-length VL on insert_vector_elt in more cases

This patch fixes up one case where the fixed-length-vector VL was
dropped (falling back to VLMAX) when inserting vector elements, as the
code would lower via ISD::INSERT_VECTOR_ELT (at index 0) which loses the
fixed-length vector information.

To this end, a custom node, VMV_S_XF_VL, was introduced to carry the VL
operand through to the final instruction. This node wraps the RVV
vmv.s.x and vmv.s.f instructions, which were being selected by
insert_vector_elt anyway.

There should be no observable difference in scalable-vector codegen.

There is still one outstanding drop from fixed-length VL to VLMAX, when
an i64 element is inserted into a vector on RV32; the splat (which is
custom legalized) has no notion of the original fixed-length vector
type.

Reviewed By: craig.topper

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

3 years ago[ARM] Fix linking of the new unittest from a968e7b82eac
Martin Storsjö [Thu, 4 Mar 2021 09:03:44 +0000 (11:03 +0200)]
[ARM] Fix linking of the new unittest from a968e7b82eac

3 years agoRevert "[XRay][x86_64] Fix CFI directives in assembly trampolines"
Petr Hosek [Thu, 4 Mar 2021 09:03:04 +0000 (01:03 -0800)]
Revert "[XRay][x86_64] Fix CFI directives in assembly trampolines"

This reverts commit 9ee61cf3f67b9fdcee7c2dd650321264376bc0f2 since
it's failing to compile on Darwin.

3 years ago[ARM] KnownBits for CSINC/CSNEG/CSINV
David Green [Thu, 4 Mar 2021 08:40:20 +0000 (08:40 +0000)]
[ARM] KnownBits for CSINC/CSNEG/CSINV

This adds some simple known bits handling for the three CSINC/NEG/INV
instructions. From the operands known bits we can compute the common
bits of the first operand and incremented/negated/inverted second
operand. The first, especially CSINC ZR, ZR, comes up fair amount in the
tests. The others are more rare so a unit test for them is added.

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

3 years ago[lld][WebAssembly] -Bsymbolic creates indirect function table if needed
Andy Wingo [Wed, 3 Mar 2021 10:13:25 +0000 (11:13 +0100)]
[lld][WebAssembly] -Bsymbolic creates indirect function table if needed

It can be that while processing relocations, we realize that in the end
we need an indirect function table.  Ensure that one is present, in that
case, to avoid writing invalid object files.

Fixes https://bugs.llvm.org/show_bug.cgi?id=49397.

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

3 years ago[X86][CodeGenPrepare] Try to reuse IV's incremented value instead of adding the offse...
Max Kazantsev [Thu, 4 Mar 2021 05:01:39 +0000 (12:01 +0700)]
[X86][CodeGenPrepare] Try to reuse IV's incremented value instead of adding the offset, part 1

While optimizing the memory instruction, we sometimes need to add
offset to the value of `IV`. We could avoid doing so if the `IV.next` is
already defined at the point of interest. In this case, we may get two
possible advantages from this:

- If the `IV` step happens to match with the offset, we don't need to add
  the offset at all;
- We reduce overlap of live ranges of `IV` and `IV.next`. They may stop overlapping
  and it will lead to better register allocation. Even if the overlap will preserve,
  we are not introducing a new overlap, so it should be a neutral transform (Disabled
  this patch, will come with follow-up).

Currently I've only added support for IVs that get decremented using `usub`
intrinsic. We could also support `AddInstr`, however there is some weird
interaction with some other transform that may lead to infinite compilation
in this case (seems like same transform is done and undone over and over).
I need to investigate why it happens, but generally we could do that too.

The first part only handles case where this reuse fully elimiates the offset.

Differential Revision: https://reviews.llvm.org/D96399
Reviewed By: reames

3 years ago[LangRef] remove links to lifetime since use marker intro already has a link
Juneyoung Lee [Thu, 4 Mar 2021 08:19:08 +0000 (17:19 +0900)]
[LangRef] remove links to lifetime since use marker intro already has a link

3 years ago[mlir] make implementations of translation to LLVM IR interfaces private
Alex Zinenko [Wed, 3 Mar 2021 13:08:30 +0000 (14:08 +0100)]
[mlir] make implementations of translation to LLVM IR interfaces private

There is no need for the interface implementations to be exposed, opaque
registration functions are sufficient for all users, similarly to passes.

Reviewed By: mehdi_amini

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

3 years ago[LangRef] fix more undefined label errors
Juneyoung Lee [Thu, 4 Mar 2021 08:09:03 +0000 (17:09 +0900)]
[LangRef] fix more undefined label errors

3 years ago[mlir] Add loop codegen options to some LLVM dialect ops.
Arpith C. Jacob [Thu, 4 Mar 2021 08:00:18 +0000 (09:00 +0100)]
[mlir] Add loop codegen options to some LLVM dialect ops.

Add a Loop Option attribute and generate llvm metadata attached to
branch instructions to control code generation.

Reviewed By: ftynse, mehdi_amini

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

3 years ago[LegalizeVectorTypes] Remove a tautological compare.
Craig Topper [Thu, 4 Mar 2021 07:25:46 +0000 (23:25 -0800)]
[LegalizeVectorTypes] Remove a tautological compare.

3 years ago[debugserver] Fix more compiler warnings on arm64
Jonas Devlieghere [Thu, 4 Mar 2021 07:09:58 +0000 (23:09 -0800)]
[debugserver] Fix more compiler warnings on arm64

This fixes the following two warnings in code that's only compiled on
arm64:

 - warning: cast from 'const void *' to 'unsigned char *' drops const
   qualifier [-Wcast-qual]
 - warning: embedding a directive within macro arguments has undefined
   behavior [-Wembedded-directive]

3 years ago[libcxx] Don't use dllimport for a static member in a template
Martin Storsjö [Sun, 21 Feb 2021 23:13:13 +0000 (01:13 +0200)]
[libcxx] Don't use dllimport for a static member in a template

This fixes clang warnings (that are treated as errors when running
the test suite):

libcxx/include/string:4409:59: error: definition of dllimport static field [-Werror,-Wdllimport-static-field-def]
               basic_string<_CharT, _Traits, _Allocator>::npos;

The warning is normally not visible as long as the libc++ headers
are treated as system headers.

The same construct is always an error in MSVC.

(One _LIBCPP_FUNC_VIS was added in
2d8f23f571635c1fb983b40c4c2548716a5b65b6, which broke DLL builds.
59919c4d6b6370da7133bbca0d31844e21646bb1 fixed this by adding another
_LIBCPP_FUNC_VIS on the declaration for consistency, but the underlying
issue remained, that one can't use dllimport here.)

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

3 years ago[CSSPGO] Deduplicating dangling pseudo probes.
Hongtao Yu [Thu, 25 Feb 2021 07:47:29 +0000 (23:47 -0800)]
[CSSPGO] Deduplicating dangling pseudo probes.

Same dangling probes are redundant since they all have the same semantic that is to rely on the counts inference tool to get reasonable count for the same original block. Therefore, there's no need to keep multiple copies of them. I've seen jump threading created tons of redundant dangling probes that slowed down the compiler dramatically. Other optimization passes can also result in redundant probes though without an observed impact so far.

This change removes block-wise redundant dangling probes specifically introduced by jump threading. To support removing redundant dangling probes caused by all other passes, a final function-wise deduplication is also added.

An 18% size win of the .pseudo_probe section was seen for SPEC2017. No performance difference was observed.

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

3 years ago[CSSPGO] Unblocking optimizations by dangling pseudo probes.
Hongtao Yu [Thu, 25 Feb 2021 08:52:58 +0000 (00:52 -0800)]
[CSSPGO] Unblocking optimizations by dangling pseudo probes.

This change fixes a couple places where the pseudo probe intrinsic blocks optimizations because they are not naturally removable. To unblock those optimizations, the blocking pseudo probes are moved out of the original blocks and tagged dangling, instead of allowing pseudo probes to be literally removed. The reason is that when the original block is removed, we won't be able to sample it. Instead of assigning it a zero weight, moving all its pseudo probes into another block and marking them dangling should allow the counts inference a chance to assign them a more reasonable weight. We have not seen counts quality degradation from our experiments.

The optimizations being unblocked are:

1. Removing conditional probes for if-converted branches. Conditional probes are tagged dangling when their homing branch arms are folded so that they will not be over-counted.
2. Unblocking jump threading from removing empty blocks. Pseudo probe prevents jump threading from removing logically empty blocks that only has one unconditional jump instructions.
3. Unblocking SimplifyCFG and MIR tail duplicate to thread empty blocks and blocks with redundant branch checks.

Since dangling probes are logically deleted, they should not consume any samples in LTO postLink. This can be achieved by setting their distribution factors to zero when dangled.

Reviewed By: wmi

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

3 years ago[CSSPGO] Introducing dangling pseudo probes.
Hongtao Yu [Thu, 25 Feb 2021 08:43:17 +0000 (00:43 -0800)]
[CSSPGO] Introducing dangling pseudo probes.

Dangling probes are the probes associated to an empty block. This usually happens when all real instructions are optimized away from the block. There is a problem with dangling probes during the offline counts processing. The way the sample profiler works is that samples collected on the first physical instruction following a probe will be counted towards the probe. This logically equals to treating the instruction next to a probe as if it is from the same block of the probe. In the dangling probe case, the real instruction following a dangling probe actually starts a new block, and samples collected on the new block may cause issues when counted towards the empty block.

To mitigate this issue, we first try to move around a dangling probe inside its owning block. If there are still native instructions preceding the probe in the same block, we can then use them as a place holder to collect samples for the probe. A pass is added to walk each block backwards looking for probes not followed by any real instruction and moving them before the first real instruction. This is done right before the object emission.

If we are unlucky to find such in-block preceding instructions for a probe, the solution we are taking is to tag such probe as dangling so that the samples reported for them will not be trusted by the compiler. We leave it up to the counts inference algorithm to get such probes a reasonable count. The number `UINT64_MAX` is used to mark sample count as collected for a dangling probe.

Reviewed By: wmi

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

3 years ago[libcxx] adds concept `std::assignable_from`
Christopher Di Bella [Thu, 4 Mar 2021 06:27:21 +0000 (22:27 -0800)]
[libcxx] adds concept `std::assignable_from`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc

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

3 years ago[Docs] Remove `no-aa` from the alias analysis documentation
Johannes Doerfert [Mon, 25 Jan 2021 21:45:53 +0000 (15:45 -0600)]
[Docs] Remove `no-aa` from the alias analysis documentation

The `no-aa` pass has been removed with 7b560d40bddf.

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

3 years ago[Attributor] Make DepClass a required argument
Johannes Doerfert [Tue, 2 Mar 2021 01:31:42 +0000 (19:31 -0600)]
[Attributor] Make DepClass a required argument

We often used a sub-optimal dependence class in the past because we
didn't see the argument. Let's make it explicit so we remember to think
about it.

3 years ago[Attributor] Fold "TrackDependence" into the DepClassTy enum
Johannes Doerfert [Mon, 1 Mar 2021 23:04:49 +0000 (17:04 -0600)]
[Attributor] Fold "TrackDependence" into the DepClassTy enum

We don't need a bool and an enum to express the three options we
currently have. This makes the interface nicer and much easier to
use optional dependencies. Also avoids mistakes where the bool is
false and enum ignored.

3 years ago[Attributor] Avoid work for GEPs and wait till the users are visited
Johannes Doerfert [Mon, 1 Mar 2021 23:16:08 +0000 (17:16 -0600)]
[Attributor] Avoid work for GEPs and wait till the users are visited

3 years ago[Attributor] Use known alignment as lower bound to avoid work
Johannes Doerfert [Mon, 1 Mar 2021 23:10:01 +0000 (17:10 -0600)]
[Attributor] Use known alignment as lower bound to avoid work

If we know already more than available from a use, we don't need to
invest time on it.

3 years ago[Attributor][NFC] Move some trivial checks up
Johannes Doerfert [Mon, 1 Mar 2021 23:15:26 +0000 (17:15 -0600)]
[Attributor][NFC] Move some trivial checks up

3 years ago[Attributor] Use sensible initialization in AANoCaptureCallSiteReturned
Johannes Doerfert [Tue, 2 Mar 2021 02:21:21 +0000 (20:21 -0600)]
[Attributor] Use sensible initialization in AANoCaptureCallSiteReturned

3 years ago[doc] Fix description of _Float16
Kito Cheng [Tue, 2 Mar 2021 09:24:08 +0000 (17:24 +0800)]
[doc] Fix description of _Float16

According to ISO/IEC TS 18661-3:2015 _FloatN is interchange floating
point type, extended floating-point type is _FloatNx.

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2342.pdf

Reviewed By: SjoerdMeijer

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

3 years ago[libc] Remove redundant header files included from internal paths.
Siva Chandra Reddy [Thu, 4 Mar 2021 05:29:46 +0000 (21:29 -0800)]
[libc] Remove redundant header files included from internal paths.

3 years ago[DSE] Add support for not aligned begin/end
Evgeniy Brevnov [Fri, 4 Dec 2020 09:57:35 +0000 (16:57 +0700)]
[DSE] Add support for not aligned begin/end

This is an attempt to improve handling of partial overlaps in case of unaligned begin\end.

Existing implementation just bails out if it encounters such cases. Even when it doesn't I believe existing code checking alignment constraints is not quite correct. It tries to ensure alignment of the "later" start/end offset while should be preserving relative alignment between earlier and later start/end.

The idea behind the change is simple. When start/end is not aligned as we wish instead of bailing out let's adjust it as necessary to get desired alignment.

I'll update with performance results as measured by the test-suite...it's still running...

Reviewed By: fhahn

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

3 years agolibclc: Add clspv target to libclc
Alan Baker [Mon, 7 Dec 2020 20:54:14 +0000 (15:54 -0500)]
libclc: Add clspv target to libclc

Add clspv as a new target for libclc. clspv is an open-source compiler that compiles OpenCL C to Vulkan SPIR-V. Compiles for the spir target.

The clspv target differs from the the spirv target in the following ways:
* fma is modified to use uint2 instead of ulong for mantissas. This results in lower performance fma, but provides a implementation that can be used on more Vulkan devices where 64-bit integer support is less common.
* Use of a software implementation of nextafter because the generic implementation depends on nextafter being a defined builtin function for which clspv has no definition.
* Full optimization of the library (-O3) and no conversion to SPIR-V

This library is close to what would be produced by running opt -O3 < builtins.opt.spirv-mesa3d-.bc > builtins.opt.clspv--.bc and continuing the build from that point.

Reviewer: jvesely

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

3 years ago[compiler-rt | interceptors] Provide an intercept override knob.
Siva Chandra Reddy [Mon, 1 Mar 2021 22:58:14 +0000 (14:58 -0800)]
[compiler-rt | interceptors] Provide an intercept override knob.

This knob is useful for downstream users who want that some of their
libc functions to not be intercepted.

Reviewed By: eugenis

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

3 years ago[libcxx] adds concept `std::common_with`
Christopher Di Bella [Tue, 2 Mar 2021 21:52:30 +0000 (13:52 -0800)]
[libcxx] adds concept `std::common_with`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96660

Reviewed By: ldionne, #libc

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

3 years ago[InstCombine] Move statepoint intrinsic handling from visitCall to visitCallBase
Serguei Katkov [Wed, 3 Mar 2021 05:41:00 +0000 (12:41 +0700)]
[InstCombine] Move statepoint intrinsic handling from visitCall to visitCallBase

statepoint intrinsic can be used in invoke context,
so it should be handled in visitCallBase to cover both call and invoke.

Reviewers: reames, dantrushin
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D97833

3 years agoAdd Windows ehcont section support (/guard:ehcont).
Wang, Pengfei [Wed, 3 Mar 2021 02:38:21 +0000 (10:38 +0800)]
Add Windows ehcont section support (/guard:ehcont).

Add option /guard:ehcont

Reviewed By: rnk

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

3 years agoLanguageRuntime for 0th frame unwind, simplify getting pc-for-symbolication
Jason Molenda [Thu, 4 Mar 2021 03:25:30 +0000 (19:25 -0800)]
LanguageRuntime for 0th frame unwind, simplify getting pc-for-symbolication

Add calls into LanguageRuntime when finding the unwind method to
use out of the 0th (currently executing) stack frame.

Allow for the LanguageRuntimes to indicate if this stack frames
should be treated like a zeroth-frame -- symbolication should be
done based on the saved pc address, not decremented like normal ABI
function calls.

Add methods to RegisterContext and StackFrame to get a pc value
suitable for symbolication, to reduce the number of places in lldb
where we decrement the saved pc values before symbolication.

<rdar://problem/70398009>
Differential Revision: https://reviews.llvm.org/D97644

3 years ago[libc++] Introduce __identity_t<T>. NFCI.
Arthur O'Dwyer [Wed, 3 Mar 2021 16:10:49 +0000 (11:10 -0500)]
[libc++] Introduce __identity_t<T>. NFCI.

This is just a shorter synonym for `__identity<T>::type`.
Use it consistently throughout, where possible.

There is still some metaprogramming in <memory> and <variant>
where `__identity` is being used _without_ immediately calling
`::type` on it; but this is the unusual case, and it will become
even less usual as we start deliberately protecting certain types
against deduction (e.g. D97742).

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

3 years ago[libcxx] adds concept `std::common_reference_with`
Christopher Di Bella [Tue, 2 Mar 2021 21:48:06 +0000 (13:48 -0800)]
[libcxx] adds concept `std::common_reference_with`

Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96657

Reviewed By: ldionne, Mordante, #libc

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

3 years ago[mlir][sparse] fix bug in reduction chain
Aart Bik [Wed, 3 Mar 2021 20:37:19 +0000 (12:37 -0800)]
[mlir][sparse] fix bug in reduction chain

Found with exhaustive testing, it is possible that a while loop
appears in between chainable for loops. As long as we don't
scalarize reductions in while loops, this means we need to
terminate the chain at the while. This also refactors the
reduction code into more readable helper methods.

Reviewed By: bixia

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

3 years ago[LangRef] fix undefined label
Juneyoung Lee [Thu, 4 Mar 2021 01:12:57 +0000 (10:12 +0900)]
[LangRef] fix undefined label

3 years ago[LangRef] Make lifetime intrinsic's semantics consistent with StackColoring's comment
Juneyoung Lee [Thu, 4 Mar 2021 00:57:50 +0000 (09:57 +0900)]
[LangRef] Make lifetime intrinsic's semantics consistent with StackColoring's comment

This patch is an update to LangRef by describing lifetime intrinsics' behavior
by following the description of MIR's LIFETIME_START/LIFETIME_END markers
at StackColoring.cpp (https://github.com/llvm/llvm-project/blob/eb44682d671d66e422b02595a636050582a4d84a/llvm/lib/CodeGen/StackColoring.cpp#L163) and the discussion in llvm-dev.

In order to explicitly define the meaning of an object lifetime, I added 'Object Lifetime' subsection.

Reviewed By: nlopes

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

3 years ago[mlir] Add support for generating Attribute classes for ODS
River Riddle [Thu, 4 Mar 2021 00:37:32 +0000 (16:37 -0800)]
[mlir] Add support for generating Attribute classes for ODS

The support for attributes closely maps that of Types (basically 1-1) given that Attributes are defined in exactly the same way as Types. All of the current ODS TypeDef classes get an Attr equivalent. The generation of the attribute classes themselves share the same generator as types.

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

3 years ago[RISCV] Make use of the required features in BuiltinInfo to store that V extension...
Craig Topper [Thu, 4 Mar 2021 00:21:23 +0000 (16:21 -0800)]
[RISCV] Make use of the required features in BuiltinInfo to store that V extension builtins require 'experimental-v'.

Use that to print the diagnostic in SemaChecking instead of
listing all of the builtins in a switch.

With the required features, IR generation will also be able
to error on this. Checking this here allows us to have a RISCV
focused error message.

Reviewed By: HsiangKai

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

3 years ago[IRSymTab] Set FB_used on llvm.compiler.used symbols
Fangrui Song [Thu, 4 Mar 2021 00:22:30 +0000 (16:22 -0800)]
[IRSymTab] Set FB_used on llvm.compiler.used symbols

IR symbol table does not parse inline asm. A symbol only referenced by inline
asm is not in the IR symbol table, so LTO does not know that the definition (in
another translation unit) is referenced and may internalize it, even if that
definition has `__attribute__((used))` (which lowers to `llvm.compiler.used` on
ELF targets since D97446).

```
// cabac.c
__attribute__((used)) const uint8_t ff_h264_cabac_tables[...] = {...};

// h264_cabac.c
  asm("lea ff_h264_cabac_tables(%rip), %0" : ...);
```

`__attribute__((used))` is the recommended way to tell the compiler there may
be inline asm references, so the usage is perfectly fine. This patch
conservatively sets the `FB_used` bit on `llvm.compiler.used` symbols to work
around the IR symbol table limitation. Note: before D97446, Clang never emitted
symbols in the `llvm.compiler.used` list, so this change does not punish any
Clang emitted global object.

Without the patch, `ff_h264_cabac_tables` may be assigned to a non-external
partition and get internalized. Then we will get a linker error because the
`cabac.c` definition is not exposed.

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

3 years ago[AIX] Update default arch on AIX
Steven Wan [Thu, 4 Mar 2021 00:06:37 +0000 (19:06 -0500)]
[AIX] Update default arch on AIX

On AIX, the default arch level should match the minimum supported arch level of the OS version.

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

3 years ago[mlir][pdl][NFC] Rename InputOp to OperandOp
River Riddle [Wed, 3 Mar 2021 23:34:18 +0000 (15:34 -0800)]
[mlir][pdl][NFC] Rename InputOp to OperandOp

This better matches the actual IR concept that is being modeled, and is consistent with how the rest of PDL is structured.

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

3 years ago[mlir][pdl] Add a new !pdl.range<> type
River Riddle [Wed, 3 Mar 2021 23:33:15 +0000 (15:33 -0800)]
[mlir][pdl] Add a new !pdl.range<> type

This type represents a range of positional values. It will be used in followup revisions to add support for variadic constructs to PDL, such as operand and result ranges.

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

3 years ago[LICM][Coroutine] Don't sink stores from loops with coro.suspend instructions
Xun Li [Wed, 3 Mar 2021 23:21:57 +0000 (15:21 -0800)]
[LICM][Coroutine] Don't sink stores from loops with coro.suspend instructions

See pr46990(https://bugs.llvm.org/show_bug.cgi?id=46990). LICM should not sink store instructions to loop exit blocks which cross coro.suspend intrinsics. This breaks semantic of coro.suspend intrinsic which return to caller directly. Also this leads to use-after-free if the coroutine is freed before control returns to the caller in multithread environment.

This patch disable promotion by check whether loop contains coro.suspend intrinsics.
This is a resubmit of D86190.
Disabling LICM for loops with coroutine suspension is a better option not only for correctness purpose but also for performance purpose.
In most cases LICM sinks memory operations. In the case of coroutine, sinking memory operation out of the loop does not improve performance since coroutien needs to get data from the frame anyway. In fact LICM would hurt coroutine performance since it adds more entries to the frame.

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

3 years ago[test] Fix profiling.ll
Fangrui Song [Wed, 3 Mar 2021 23:18:44 +0000 (15:18 -0800)]
[test] Fix profiling.ll

`__llvm_prf_nm` is compressed if zlib is available. In addition, its size may not be that stable.

3 years agoAdd the use of register r for outlined function when register r is live in and define...
Jin Lin [Wed, 3 Mar 2021 20:06:42 +0000 (12:06 -0800)]
Add the use of register r for outlined function when register r is live in and defined later.

The compiler needs to mark register $x0 as live in for the following case.

    $x1 = ADDXri $sp, 16, 0
    BL @spam, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit $x0, implicit killed $x1, implicit-def $sp, implicit-def dead $x0

Reviewed By: paquette

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

3 years agoFix flang build after D97804
River Riddle [Wed, 3 Mar 2021 23:06:42 +0000 (15:06 -0800)]
Fix flang build after D97804

3 years ago[dfsan] Remove hard-coded shadow width in more tests
George Balatsouras [Wed, 3 Mar 2021 20:30:20 +0000 (12:30 -0800)]
[dfsan] Remove hard-coded shadow width in more tests

As a preparation step for fast8 support, we need to update the tests
to pass in both modes. That requires generalizing the shadow width
and remove any hard coded references that assume it's always 2 bytes.

Reviewed By: stephan.yichao.zhao

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

3 years ago[lld-link] Add safe icf mode to lld-link, which does safe icf for all sections.
Zequan Wu [Sat, 27 Feb 2021 00:38:24 +0000 (16:38 -0800)]
[lld-link] Add safe icf mode to lld-link, which does safe icf for all sections.

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

3 years ago[mlir][IR] Refactor the internal implementation of Value
River Riddle [Wed, 3 Mar 2021 22:23:14 +0000 (14:23 -0800)]
[mlir][IR] Refactor the internal implementation of Value

The current implementation of Value involves a pointer int pair with several different kinds of owners, i.e. BlockArgumentImpl*, Operation *, TrailingOpResult*. This design arose from the desire to save memory overhead for operations that have a very small number of results (generally 0-2). There are, unfortunately, many problematic aspects of the current implementation that make Values difficult to work with or just inefficient.

Operation result types are stored as a separate array on the Operation. This is very inefficient for many reasons: we use TupleType for multiple results, which can lead to huge amounts of memory usage if multi-result operations change types frequently(they do). It also means that simple methods like Value::getType/Value::setType now require complex logic to get to the desired type.

Value only has one pointer bit free, severely limiting the ability to use it in things like PointerUnion/PointerIntPair. Given that we store the kind of a Value along with the "owner" pointer, we only leave one bit free for users of Value. This creates situations where we end up nesting PointerUnions to be able to use Value in one.

As noted above, most of the methods in Value need to branch on at least 3 different cases which is both inefficient, possibly error prone, and verbose. The current storage of results also creates problems for utilities like ValueRange/TypeRange, which want to efficiently store base pointers to ranges (of which Operation* isn't really useful as one).

This revision greatly simplifies the implementation of Value by the introduction of a new ValueImpl class. This class contains all of the state shared between all of the various derived value classes; i.e. the use list, the type, and the kind. This shared implementation class provides several large benefits:

* Most of the methods on value are now branchless, and often one-liners.

* The "kind" of the value is now stored in ValueImpl instead of Value
This frees up all of Value's pointer bits, allowing for users to take full advantage of PointerUnion/PointerIntPair/etc. It also allows for storing more operation results as "inline", 6 now instead of 2, freeing up 1 word per new inline result.

* Operation result types are now stored in the result, instead of a side array
This drops the size of zero-result operations by 1 word. It also removes the memory crushing use of TupleType for operations results (which could lead up to hundreds of megabytes of "dead" TupleTypes in the context). This also allowed restructured ValueRange, making it simpler and one word smaller.

This revision does come with two conceptual downsides:
* Operation::getResultTypes no longer returns an ArrayRef<Type>
This conceptually makes some usages slower, as the iterator increment is slightly more complex.
* OpResult::getOwner is slightly more expensive, as it now requires a little bit of arithmetic

From profiling, neither of the conceptual downsides have resulted in any perceivable hit to performance. Given the advantages of the new design, most compiles are slightly faster.

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

3 years ago[lld-macho] Fix test breakage introduced by D97799
Jez Ng [Wed, 3 Mar 2021 22:31:03 +0000 (17:31 -0500)]
[lld-macho] Fix test breakage introduced by D97799

3 years ago[Analysis] simplify propagation of FMF in recurrences; NFC
Sanjay Patel [Wed, 3 Mar 2021 21:53:49 +0000 (16:53 -0500)]
[Analysis] simplify propagation of FMF in recurrences; NFC

This is a mess, but this is hopefully no-functional-change.
The 'Prev' descriptor is only used for min/max recurrences
or when starting a match from a phi, so it should not be a
factor when propagating FMF for fmul/fadd.

The API is confusing (and should be reduced in subsequent steps)
because the "UnsafeAlgebraInst" appears to actually be a placeholder
for a recurrence that does NOT have FMF, but we still want to
treat it as reassociative.

3 years ago[lli] Add JITLink link component after 99a6d003edbe
Stefan Gränitz [Wed, 3 Mar 2021 22:14:21 +0000 (23:14 +0100)]
[lli] Add JITLink link component after 99a6d003edbe

3 years agoFix use of deprecated API
David Blaikie [Wed, 3 Mar 2021 22:07:28 +0000 (14:07 -0800)]
Fix use of deprecated API

3 years ago[libc++] Temporary hack: disable Apple back-deployment testing
Louis Dionne [Wed, 3 Mar 2021 22:01:15 +0000 (17:01 -0500)]
[libc++] Temporary hack: disable Apple back-deployment testing

Apple back-deployment testing is currently failing because Green Dragon
is down. To avoid stalling the whole CI pipeline because of that, I am
temporarily disabling those jobs until Green Dragon is back, or even
better we have found a different way to store those small artifacts.

3 years ago[mlir] Remove incorrect folding for SubTensorInsertOp
MaheshRavishankar [Wed, 3 Mar 2021 21:56:09 +0000 (13:56 -0800)]
[mlir] Remove incorrect folding for SubTensorInsertOp

The SubTensorInsertOp has a requirement that dest type and result
type match. Just folding the tensor.cast operation violates this and
creates verification errors during canonicalization. Also fix other
canonicalization methods that werent inserting casts properly.

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

3 years ago[AArch64] Add implicit uses for operands when expanding BLR_RVMARKER.
Florian Hahn [Wed, 3 Mar 2021 19:44:43 +0000 (19:44 +0000)]
[AArch64] Add implicit uses for operands when expanding BLR_RVMARKER.

Make sure we preserve info about passed arguments as implicit uses, to
make sure later passes still have access to this information.

This fixes a mis-compile where the machine-combiner would pick an
incorrect free register.

3 years agoRevert "hack to unbreak check-llvm on win after D97335" in attempt for actual fix
Stefan Gränitz [Wed, 3 Mar 2021 21:29:43 +0000 (22:29 +0100)]
Revert "hack to unbreak check-llvm on win after D97335" in attempt for actual fix

This reverts commit 900f076113302e26e1939541b546b0075e3e9721 and attempts an actual fix: All failing tests for llvm-jitlink use the `-noexec` flag. The inputs they operate on are not meant for execution on the host system. Looking e.g. at the MachO_test_harness_harnesss.s test, llvm-mc generates input machine code with "x86_64-apple-macosx10.9".

My previous attempt in bbdb4c8c9bcef0e8db751630accc04ad874f54e7 disabled the debug support plugin for Windows targets, but what we would actually want is to disable it on Windows HOSTS.

With the new patch here, I don't do exactly that, but instead follow the approach for the EH frame plugin and include the `-noexec` flag in the condition. It should have the desired effect when it comes to the test suite. It appears a little workaround'ish, but should work reliably for now. I will discuss the issue with Lang and see if we can do better. Thanks @thakis again for the temporary fix.

3 years ago[WebAssembly] Add missing default cases in switch statements
Soumi Manna [Wed, 3 Mar 2021 21:15:23 +0000 (13:15 -0800)]
[WebAssembly] Add missing default cases in switch statements

unsigned variable 'IntNo' has been declared but not been defined inside function
EmitWebAssemblyBuiltinExpr().

static code analysis tool complains about uninitialized variable "IntNo" since
this enters to default branch without setting any intrinsics and calls Function
*Callee = CGM.getIntrinsic(IntNo).

This patch fixes the problem by adding default cases in switch statements.

3 years ago[lld-macho] Require -arch and -platform_version to always be specified
Jez Ng [Wed, 3 Mar 2021 20:52:10 +0000 (15:52 -0500)]
[lld-macho] Require -arch and -platform_version to always be specified

We previously defaulted to x86_64 and an unknown platform, which was fine when
we only supported one arch and did no platform checks, but that will no longer
be true going ahead. Therefore, we should require those flags to be specified
whenever the linker is invoked.

Note that LLD-ELF and ld64 both infer the arch from their input object files,
but the usefulness of that is questionable since clang will always specify these
flags, and most of the time `lld` will be invoked via clang.

Reviewed By: #lld-macho, thakis

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

3 years ago[lld-macho][nfc] Parse more options using getLastArg{Value}
Jez Ng [Wed, 3 Mar 2021 20:52:06 +0000 (15:52 -0500)]
[lld-macho][nfc] Parse more options using getLastArg{Value}

The option-iterating loop should be reserved for options whose command-line
order is important. I think LLD-ELF follows a similar design.

Reviewed By: #lld-macho, smeenai

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

3 years ago[LoopUnrollRuntime] Add option to assume the non latch exit block to be
Whitney Tsang [Wed, 3 Mar 2021 20:41:41 +0000 (20:41 +0000)]
[LoopUnrollRuntime] Add option to assume the non latch exit block to be
predictable.

Reviewed By: Meinersbur, bmahjour

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

3 years ago[Cost]Add tests for boolean and/or reductions, NFC.
Alexey Bataev [Tue, 2 Mar 2021 19:30:52 +0000 (11:30 -0800)]
[Cost]Add tests for boolean and/or reductions, NFC.

Tests with the default costs for boolean and/or reductions.

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

3 years agoAddress review comment from D97219 (follow up to 8051156)
Philip Reames [Wed, 3 Mar 2021 20:20:27 +0000 (12:20 -0800)]
Address review comment from D97219 (follow up to 8051156)

Probably should have done this before landing, but I forgot.

Basic idea is to avoid using the SCEV predicate when it doesn't buy us anything.  Also happens to set us up for handling non-add recurrences in the future if desired.

3 years agoSink routine for replacing a operand bundle to CallBase [NFC]
Philip Reames [Wed, 3 Mar 2021 20:07:00 +0000 (12:07 -0800)]
Sink routine for replacing a operand bundle to CallBase [NFC]

We had equivalent code for both CallInst and InvokeInst, but never cared about the result type.

3 years ago[LSR] Unify scheduling of existing and inserted addrecs
Philip Reames [Wed, 3 Mar 2021 19:49:46 +0000 (11:49 -0800)]
[LSR] Unify scheduling of existing and inserted addrecs

LSR goes to some lengths to schedule IV increments such that %iv and %iv.next never need to overlap. This is fairly fundamental to LSRs cost model. LSR assumes that an addrec can be represented with a single register. If %iv and %iv.next have to overlap, then that assumption does not hold.

The bug - which this patch is fixing - is that LSR only does this scheduling for IVs which it inserts, but it's cost model assumes the same for existing IVs that it reuses. It will rewrite existing IV users such that the no-overlap property holds, but will not actually reschedule said IV increment.

As you can see from the relatively lack of test updates, this doesn't actually impact codegen much. The main reason for doing it is to make a follow up patch series which improves post-increment use and scheduling easier to follow.

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

3 years ago[SystemZ] Reimplement the i8/i16 compare-and-swap logic.
Jonas Paulsson [Sat, 27 Feb 2021 00:55:44 +0000 (18:55 -0600)]
[SystemZ] Reimplement the i8/i16 compare-and-swap logic.

Even though the implementation in emitAtomicCmpSwapW() was correct, it made
Valgrind report an error. Instead of using a RISBG on CmpVal, an LL[CH]R can
be made on the OldVal, and the problem is avoided.

Review: Ulrich Weigand

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

3 years ago[flang] Prohibit MODULE procedures in the global scope
Peter Steinfeld [Wed, 3 Mar 2021 18:52:40 +0000 (10:52 -0800)]
[flang] Prohibit MODULE procedures in the global scope

We were allowing procedures with the MODULE prefix to be declared at the global
scope.  This is prohibited by C1547 and was causing an internal check of the
compiler to fail.

I fixed this by adding a check.  I also added a test that would trigger a crash
without this change.

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

3 years ago[mlir][linalg] Add depthwise_conv_2d_input_nhwc_filter_hwcf to Linalg TC ops.
Hanhan Wang [Wed, 3 Mar 2021 19:46:50 +0000 (11:46 -0800)]
[mlir][linalg] Add depthwise_conv_2d_input_nhwc_filter_hwcf to Linalg TC ops.

Different from the definition in Tensorflow and TOSA, the output is [N,H,W,C,M]. This can make transforms easier in LinAlg because the indexing maps are plain. E.g., to determine if the fill op has dependency between the depthwise conv op, the current pipeline only recognizes the dep if they are all projected affine map.

Reviewed By: asaadaldien

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

3 years ago[AArch64] Move CALL_RVMARKER definition after CALL.
Florian Hahn [Wed, 3 Mar 2021 18:58:05 +0000 (18:58 +0000)]
[AArch64] Move CALL_RVMARKER definition after CALL.

This is a NFC with respect to the generated code. But it fixes a crash
when using -debug, because of the position in the enum CALL_RVMARKER
nodes were treated as memops. That caused a crash when printing
CALL_RVMARKER nodes.

3 years ago[InstrProfiling] Place __llvm_prf_vnodes and __llvm_prf_names in llvm.used on ELF
Fangrui Song [Wed, 3 Mar 2021 19:32:24 +0000 (11:32 -0800)]
[InstrProfiling] Place __llvm_prf_vnodes and __llvm_prf_names in llvm.used on ELF

`__llvm_prf_vnodes` and `__llvm_prf_names` are used by runtime but not
referenced via relocation in the translation unit.

With `-z start-stop-gc` (LLD 13 (D96914); GNU ld 2.37 https://sourceware.org/bugzilla/show_bug.cgi?id=27451),
the linker does not let `__start_/__stop_` references retain their sections.

Place `__llvm_prf_vnodes` and `__llvm_prf_names` in `llvm.used` to make
them retained by the linker.

This patch changes most existing `UsedVars` cases to `CompilerUsedVars`
to reflect the ideal state - if the binary format properly supports
section based GC (dead stripping), `llvm.compiler.used` should be sufficient.

`__llvm_prf_vnodes` and `__llvm_prf_names` are switched to `UsedVars`
since we want them to be unconditionally retained by both compiler and linker.

Behaviors on COFF/Mach-O are not affected.

Reviewed By: davidxl

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

3 years ago[test] Improve PGO tests
Fangrui Song [Wed, 3 Mar 2021 19:29:19 +0000 (11:29 -0800)]
[test] Improve PGO tests

3 years ago[Coverage] Emit gap region between statements if first statements contains terminate...
Zequan Wu [Wed, 3 Mar 2021 04:35:19 +0000 (20:35 -0800)]
[Coverage] Emit gap region between statements if first statements contains terminate statements.

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

3 years ago[clangd] ObjC fixes for semantic highlighting and xref highlights
Sam McCall [Sat, 27 Feb 2021 21:08:07 +0000 (22:08 +0100)]
[clangd] ObjC fixes for semantic highlighting and xref highlights

- highlight references to protocols in class/protocol/extension decls
- support multi-token selector highlights in semantic + xref highlights
  (method calls and declarations only)
- In `@interface I(C)`, I now references the interface and C the category
- highlight uses of interfaces as types
- added semantic highlightings of protocol names (as "interface") and
  category names (as "namespace").
  These are both standard kinds, maybe "extension" will be standardized...
- highlight `auto` as "class" when it resolves to an ObjC pointer
- don't highlight `self` as a variable even though the AST models it as one

Not fixed: uses of protocols in type names (needs some refactoring of
unrelated code first)

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

3 years ago[dfsan] Remove hardcoded shadow width in abilist_aggregate.ll
George Balatsouras [Wed, 3 Mar 2021 01:52:58 +0000 (17:52 -0800)]
[dfsan] Remove hardcoded shadow width in abilist_aggregate.ll

As a preparation step for fast8 support, we need to update the tests
to pass in both modes. That requires generalizing the shadow width
and remove any hard coded references that assume it's always 2 bytes.

Reviewed By: stephan.yichao.zhao

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

3 years ago[CMake] Rename RUNTIMES_BUILD to LLVM_RUNTIMES_BUILD
Petr Hosek [Wed, 3 Mar 2021 08:39:50 +0000 (00:39 -0800)]
[CMake] Rename RUNTIMES_BUILD to LLVM_RUNTIMES_BUILD

This avoid potential conflict with other internal variables.

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

3 years ago[libc++] NFC: Normalize links to bug reports
Louis Dionne [Wed, 3 Mar 2021 18:45:06 +0000 (13:45 -0500)]
[libc++] NFC: Normalize links to bug reports

3 years ago[AMDGPU] Exclude always_inline from max bb threshold
Stanislav Mekhanoshin [Tue, 2 Mar 2021 19:06:30 +0000 (11:06 -0800)]
[AMDGPU] Exclude always_inline from max bb threshold

Honor always_inline attribute when processing -amdgpu-inline-max-bb.
It was lost during the ports of the heuristic. There is no reason
to honor inline hint, but not always inline.

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

3 years agoAdd basic JIT Python Bindings
Mehdi Amini [Tue, 23 Feb 2021 01:56:01 +0000 (01:56 +0000)]
Add basic JIT Python Bindings

This offers the ability to create a JIT and invoke a function by passing
ctypes pointers to the argument and the result.

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

3 years agoAdd C bindings for mlir::ExecutionEngine
Mehdi Amini [Sat, 13 Feb 2021 19:23:06 +0000 (19:23 +0000)]
Add C bindings for mlir::ExecutionEngine

This adds minimalistic bindings for the execution engine, allowing to
invoke the JIT from the C API. This is still quite early and
experimental and shouldn't be considered stable in any way.

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

3 years ago[CSSPGO][llvm-profgen] Continue disassembling after illegal instruction is seen.
Hongtao Yu [Tue, 2 Mar 2021 06:34:30 +0000 (22:34 -0800)]
[CSSPGO][llvm-profgen] Continue disassembling after illegal instruction is seen.

Previously we errored out when disassembling illegal instructions and there would be no profile generated. In fact illegal instructions are not uncommon and we'd better skip them and print "unknown" instead of erroring out. This matches the behavior of llvm-objdump (see disassembleObject in llvm-objdump.cpp).

Reviewed By: wlei, wenlei

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