platform/upstream/llvm.git
3 years ago[libc++] Fix tuple assignment from types derived from a tuple-like
Louis Dionne [Tue, 31 Jul 2018 15:56:20 +0000 (11:56 -0400)]
[libc++] Fix tuple assignment from types derived from a tuple-like

The implementation of tuple's constructors and assignment operators
currently diverges from the way the Standard specifies them, which leads
to subtle cases where the behavior is not as specified. In particular, a
class derived from a tuple-like type (e.g. pair) can't be assigned to a
tuple with corresponding members, when it should. This commit re-implements
the assignment operators (BUT NOT THE CONSTRUCTORS) in a way much closer
to the specification to get rid of this bug. Most of the tests have been
stolen from Eric's patch https://reviews.llvm.org/D27606.

As a fly-by improvement, tests for noexcept correctness have been added
to all overloads of operator=. We should tackle the same issue for the
tuple constructors in a future patch - I'm just trying to make progress
on fixing this long-standing bug.

PR17550
rdar://15837420

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

3 years ago[WebAssembly] Misc. fixes in cfg-stackify-eh.ll
Heejin Ahn [Mon, 22 Feb 2021 06:18:25 +0000 (22:18 -0800)]
[WebAssembly] Misc. fixes in cfg-stackify-eh.ll

- Fix `preds` comments
- Delete nonexistent attributes in instructions (They used to exist in
  clang-generated files, but I removed most of them to make the tests
  tidy. We have only `nounwind` and `noreturn` left here.)
- Add missing `Function Attrs` comments in function declarations

 None of these affect test function semantics or test results for now.

Reviewed By: tlively

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

3 years ago[lld-macho] Try to fix cross-platform test from D96565
Jez Ng [Mon, 22 Feb 2021 19:47:25 +0000 (14:47 -0500)]
[lld-macho] Try to fix cross-platform test from D96565

3 years ago[clang-tidy] Harden PreferMemberInitializerCheck
Nathan James [Mon, 22 Feb 2021 19:41:11 +0000 (19:41 +0000)]
[clang-tidy] Harden PreferMemberInitializerCheck

Prevent warning when the values are initialized using fields that will be initialized later or VarDecls defined in the constructors body.
Both of these cases can't be safely fixed.
Also improve logic of finding where to insert member initializers, previously it could be confused by in class member initializers.

Reviewed By: aaron.ballman

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

3 years agoAdd missing dep to fix shared libs build
Geoffrey Martin-Noble [Mon, 22 Feb 2021 19:35:32 +0000 (11:35 -0800)]
Add missing dep to fix shared libs build

Followup to https://reviews.llvm.org/D97006 which broke the shared libs
build because of a missing dependency.

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

3 years ago[OpenMP] Help static loop code avoid over/underflow
Peyton, Jonathan L [Fri, 29 Jan 2021 20:02:38 +0000 (14:02 -0600)]
[OpenMP] Help static loop code avoid over/underflow

This code alleviates some pathological loop parameters (lower,
upper, stride) within calculations involved in the static loop code.  It
bounds the chunk size to the trip count if it is greater than the trip
count and also minimizes problematic code for when trip count < nth.

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

3 years ago[MLIR] Fix tilePerfectlyNested utility for handling non-unit step size
Vivek [Mon, 22 Feb 2021 19:18:04 +0000 (00:48 +0530)]
[MLIR] Fix tilePerfectlyNested utility for handling non-unit step size

The current implementation of tilePerfectlyNested utility doesn't handle
the non-unit step size. We have added support to perform tiling
correctly even if the step size of the loop to be tiled is non-unit.
Fixes https://bugs.llvm.org/show_bug.cgi?id=49188.

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

3 years ago[OpenMP] Remove shutdown attempt on Windows process detach
Peyton, Jonathan L [Mon, 8 Feb 2021 20:31:27 +0000 (14:31 -0600)]
[OpenMP] Remove shutdown attempt on Windows process detach

Only attempt shutdown if lpReserved is NULL. The Windows documentation
states:
When handling DLL_PROCESS_DETACH, a DLL should free resources such as
heap memory only if the DLL is being unloaded dynamically (the
lpReserved parameter is NULL). If the process is terminating (the
lpReserved parameter is non-NULL), all threads in the process except the
current thread either have exited already or have been explicitly
terminated by a call to the ExitProcess function, which might leave some
process resources such as heaps in an inconsistent state. In this case,
it is not safe for the DLL to clean up the resources. Instead, the DLL
should allow the operating system to reclaim the memory.

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

3 years ago[OpenMP] Limit number of dispatch buffers
Peyton, Jonathan L [Mon, 8 Feb 2021 19:08:53 +0000 (13:08 -0600)]
[OpenMP] Limit number of dispatch buffers

This patch limits the number of dispatch buffers (used for
loop worksharing construct) to between 1 and 4096.

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

3 years agoRevert "[InstrProfiling] Use ELF section groups for counters, data and values"
Petr Hosek [Mon, 22 Feb 2021 19:10:35 +0000 (11:10 -0800)]
Revert "[InstrProfiling] Use ELF section groups for counters, data and values"

This reverts commits:
5ca21175e09fc7fb7dcaee9ebd6782d122a5688f
97184ab99c46e35ae94f828ee90f5d6af2c47e11

The instrprof-gc-sections.c is failing on AArch64 LLD bot.

3 years ago[MLIR] Add Linalg support for integer (generalized) matmuls
Geoffrey Martin-Noble [Thu, 18 Feb 2021 23:37:15 +0000 (15:37 -0800)]
[MLIR] Add Linalg support for integer (generalized) matmuls

This patch adds Linalg named ops for various types of integer matmuls.
Due to limitations in the tc spec/linalg-ods-gen ops cannot be type
polymorphic, so this instead creates new ops (improvements to the
methods for defining Linalg named ops are underway with a prototype at
https://github.com/stellaraccident/mlir-linalgpy).

To avoid the necessity of directly referencing these many new ops, this
adds additional methods to ContractionOpInterface to allow classifying
types of operations based on their indexing maps.

Reviewed By: nicolasvasilache, mravishankar

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

3 years ago[mlir][Shape] Fix a crash when folding nary broadcast ops
Benjamin Kramer [Mon, 22 Feb 2021 17:41:56 +0000 (18:41 +0100)]
[mlir][Shape] Fix a crash when folding nary broadcast ops

operands[2] can be nullptr here. I'm not able to build a lit test for
this because of the commutative reordering of operands. It's possible to
trigger this with a createOrFold<BroadcastOp> though.

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

3 years ago[OpenMP] Update HWLOC code for die level detection
Peyton, Jonathan L [Tue, 2 Feb 2021 22:22:40 +0000 (16:22 -0600)]
[OpenMP] Update HWLOC code for die level detection

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

3 years agoReland [lld-macho]Implement bundle_loader
Vy Nguyen [Mon, 22 Feb 2021 18:03:02 +0000 (13:03 -0500)]
Reland [lld-macho]Implement bundle_loader
  Reland 1a0afcf518717f61d45a1cdc6ad1a6436ec663b1
  https://reviews.llvm.org/D95913

New change: fix UB bug caused by copying empty path/name. (since the executable does not have a name)

3 years ago[KnownBits] Pull out repeated getMinValue() calls from shift analysis. NFCI.
Simon Pilgrim [Mon, 22 Feb 2021 18:40:43 +0000 (18:40 +0000)]
[KnownBits] Pull out repeated getMinValue() calls from shift analysis. NFCI.

3 years ago[llvm][Bitcode] Add bitcode reader/writer for DSOLocalEquivalent
Leonard Chan [Wed, 10 Feb 2021 18:48:22 +0000 (10:48 -0800)]
[llvm][Bitcode] Add bitcode reader/writer for DSOLocalEquivalent

This is necessary for compilation with [thin]lto.

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

3 years ago[AArch64][GlobalISel] Emit G_ASSERT_SEXT for SExt parameters in CallLowering
Jessica Paquette [Wed, 17 Feb 2021 19:43:09 +0000 (11:43 -0800)]
[AArch64][GlobalISel] Emit G_ASSERT_SEXT for SExt parameters in CallLowering

Similar to how we emit G_ASSERT_ZEXT when we have CCValAssign::LocInfo::ZExt.

This will allow us to combine away some redundant sign extends.

Example: https://godbolt.org/z/cTbKvr

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

3 years agoMaking FindCommonBlock a const member
Renaud-K [Fri, 19 Feb 2021 21:38:01 +0000 (13:38 -0800)]
Making FindCommonBlock a const member
https://reviews.llvm.org/D97093

3 years ago[ConstraintElimination] Use unsigned > 0 instead of != 0.
Florian Hahn [Mon, 22 Feb 2021 17:35:25 +0000 (17:35 +0000)]
[ConstraintElimination] Use unsigned > 0 instead of != 0.

ICMP_NE predicates cannot be directly represented as constraint. But we
can use ICMP_UGT instead ICMP_NE for %x != 0.

See https://alive2.llvm.org/ce/z/XlLCsW

3 years ago[RISCV] Custom isel the rest of the vector load/store intrinsics.
Craig Topper [Mon, 22 Feb 2021 17:39:56 +0000 (09:39 -0800)]
[RISCV] Custom isel the rest of the vector load/store intrinsics.

A previous patch moved the index versions. This moves the rest.
I also removed the custom lowering for VLEFF since we can now
do everything directly in the isel handling.

I had to update getLMUL to handle mask registers to index the
pseudo table correctly for VLE1/VSE1.

This is good for another 15K reduction in llc size.

Reviewed By: frasercrmck

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

3 years ago[MLIR][affine] Prevent fusion when ops with memory effect free are present between...
Vinayaka Bandishti [Mon, 22 Feb 2021 16:01:48 +0000 (21:31 +0530)]
[MLIR][affine] Prevent fusion when ops with memory effect free are present between producer and consumer

This commit fixes a bug in affine fusion pipeline where an
incorrect fusion is performed despite a dealloc op is present
between a producer and a consumer. This is done by creating a
node for dealloc op in the MDG.

Reviewed By: bondhugula, dcaballe

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

3 years ago[sanitizers] Pass CMAKE_C_FLAGS into TSan buildgo script
Joachim Protze [Mon, 22 Feb 2021 17:46:28 +0000 (18:46 +0100)]
[sanitizers] Pass CMAKE_C_FLAGS into TSan buildgo script

When compiling with ccache, compiler commands get split into smaller steps
and clang's default -Wunused-command-line-argument complains about unused
include directory arguments. In combination -Werror, compilation aborts.

If CMAKE_C_FLAGS contains -Wno-unused-command-line-argument or
-Wno-error=unused-command-line-argument, the latter flag is passed into the
build script.

This is a re-commit. The previous version was reverted because of failing
tests.

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

3 years ago[MemCpyOpt] Fix handling of readnone byval arguments
Nikita Popov [Mon, 22 Feb 2021 17:46:55 +0000 (18:46 +0100)]
[MemCpyOpt] Fix handling of readnone byval arguments

If the call is readnone, then there may not be any MemoryAccess
associated with the call. Bail out in that case.

This fixes the issue reported at
https://reviews.llvm.org/D94376#2578312.

3 years ago[clang] Tweaked fixit for static assert with no message
Nathan James [Mon, 22 Feb 2021 17:43:52 +0000 (17:43 +0000)]
[clang] Tweaked fixit for static assert with no message

If a static assert has a message as the right side of an and condition, suggest a fix it of replacing the '&&' to ','.

`static_assert(cond && "Failed Cond")` -> `static_assert(cond, "Failed cond")`

This use case comes up when lazily replacing asserts with static asserts.

Reviewed By: aaron.ballman

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

3 years ago[JumpThreading] Clone noalias.scope.decl when threading blocks
Nikita Popov [Sun, 21 Feb 2021 15:24:18 +0000 (16:24 +0100)]
[JumpThreading] Clone noalias.scope.decl when threading blocks

When cloning instructions during jump threading, also clone and
adapt any declared scopes. This is primarily important when
threading loop exits, because we'll end up with two dominating
scope declarations in that case (at least after additional loop
rotation). This addresses a loose thread from
https://reviews.llvm.org/rG2556b413a7b8#975012.

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

3 years agoImprove diagnostic for ignored GNU 'used' attribute
Fangrui Song [Mon, 22 Feb 2021 17:18:13 +0000 (09:18 -0800)]
Improve diagnostic for ignored GNU 'used' attribute

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

3 years ago[lld-macho] Clean up comments
Jez Ng [Mon, 22 Feb 2021 17:06:58 +0000 (12:06 -0500)]
[lld-macho] Clean up comments

3 years ago[lld-macho] Fix cpuSubtype for non-x86_64 archs
Jez Ng [Mon, 22 Feb 2021 17:12:39 +0000 (12:12 -0500)]
[lld-macho] Fix cpuSubtype for non-x86_64 archs

dyld on iOS will complain if the LIB64 bit is set.

Reviewed By: #lld-macho, thakis

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

3 years ago[ConstraintElimination] Add initial ICMP_NE test cases.
Florian Hahn [Mon, 22 Feb 2021 10:43:11 +0000 (10:43 +0000)]
[ConstraintElimination] Add initial ICMP_NE test cases.

3 years ago[flang] Add -J and -module-dir to f18 driver
Tim Keith [Mon, 22 Feb 2021 17:03:19 +0000 (09:03 -0800)]
[flang] Add -J and -module-dir to f18 driver

Add -J to the f18 driver for compatibility with gfortran.
Add -module-dir for compatibility with the new flang driver.

They both set the output directory for .mod files and add the
directory to the search list. -module still only does the former.

Clean up the new driver test to match.

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

3 years ago[InstSimplify] Cleanup out-of-range shift amount handling.
Simon Pilgrim [Mon, 22 Feb 2021 17:00:49 +0000 (17:00 +0000)]
[InstSimplify] Cleanup out-of-range shift amount handling.

Use APInt::uge() direct instead of getLimitedValue().

Use KnownBits::getMinValue() to make the bounds check more obvious.

3 years ago[LV] Directly use incoming value for single VPBlendRecipes.
Florian Hahn [Mon, 22 Feb 2021 15:05:45 +0000 (15:05 +0000)]
[LV] Directly use incoming value for single VPBlendRecipes.

VPBlendRecipes with single incoming (value, mask) pair are no-ops. Use
the incoming value directly.

3 years ago[Clang][OpenMP] Require CUDA 9.2+ for OpenMP offloading on NVPTX target
Shilei Tian [Mon, 22 Feb 2021 15:59:55 +0000 (10:59 -0500)]
[Clang][OpenMP] Require CUDA 9.2+ for OpenMP offloading on NVPTX target

In current implementation of `deviceRTLs`, we're using some functions
that are CUDA version dependent (if CUDA_VERSION < 9, it is one; otheriwse, it
is another one). As a result, we have to compile one bitcode library for each
CUDA version supported. A worse problem is forward compatibility. If a new CUDA
version is released, we have to update CMake file as well.

CUDA 9.2 has been released for three years. Instead of using various weird tricks
to make `deviceRTLs` work with different CUDA versions and still have forward
compatibility, we can simply drop support for CUDA 9.1 or lower version. It has at
least two benifits:
- We don't need to generate bitcode libraries for each CUDA version;
- Clang driver doesn't need to search for the bitcode lib based on CUDA version.

We can claim that starting from LLVM 12, OpenMP offloading on NVPTX target requires
CUDA 9.2+.

Reviewed By: jdoerfert, JonChesterfield

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

3 years ago[clang][NFC] Reorder CXXCtorInitializer members
Nathan James [Mon, 22 Feb 2021 15:25:33 +0000 (15:25 +0000)]
[clang][NFC] Reorder CXXCtorInitializer members

Swapping the order of Init and MemberOrEllipsisLocation removes 8 bytes (20%) of padding on 64bit builds.

Reviewed By: aaron.ballman

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

3 years ago[LangRef] fix typo in assume bundle description; NFC
Sanjay Patel [Mon, 22 Feb 2021 14:30:14 +0000 (09:30 -0500)]
[LangRef] fix typo in assume bundle description; NFC

3 years ago[pp-trace] Fix test for OpenCL pragmas.
Anastasia Stulova [Mon, 22 Feb 2021 14:22:02 +0000 (14:22 +0000)]
[pp-trace] Fix test for OpenCL pragmas.

After updating clang driver to include standard
OpenCL headers implicitly, the output being checked
in the test does not match because the implicit
header contains other pragmas. The test does not
aim to use the header and therefore it has to be
updated passing '-cl-no-stdinc' command-line flag.

This fixes failing bots.

3 years agoRevert "Revert "Revert "Implement nullPointerConstant() using a better API."""
Mikhail Goncharov [Mon, 22 Feb 2021 13:37:03 +0000 (14:37 +0100)]
Revert "Revert "Revert "Implement nullPointerConstant() using a better API."""

This reverts commit ba1d9546ee389ce1d2e8f353ae777a65f647d508.

3 years agoRevert "Revert "Implement nullPointerConstant() using a better API.""
Mikhail Goncharov [Mon, 22 Feb 2021 12:30:25 +0000 (13:30 +0100)]
Revert "Revert "Implement nullPointerConstant() using a better API.""

This reverts commit 6984e0d4398592a20055cb12842fc72462ce01a5.

While change by itself seems to be consistent with nullPointerConstant
docs of not matching "int i = 0;" but it's not clear why it's wrong and
9148302a2ae5ac6e5d69ae84042361889247ce64 author just forgot to update
the doc.

3 years ago[OpenCL] Add builtin declarations by default.
Anastasia Stulova [Mon, 22 Feb 2021 11:05:52 +0000 (11:05 +0000)]
[OpenCL] Add builtin declarations by default.

This change enables the builtin function declarations
in clang driver by default using the Tablegen solution
along with the implicit include of 'opencl-c-base.h'
header.

A new flag '-cl-no-stdinc' disabling all default
declarations and header includes is added. If any other
mechanisms were used to include the declarations (e.g.
with -Xclang -finclude-default-header) and the new default
approach is not sufficient the, `-cl-no-stdinc` flag has
to be used with clang to activate the old behavior.

Tags: #clang

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

3 years ago[InstCombine] Add PR45977 test coverage
Simon Pilgrim [Mon, 22 Feb 2021 12:20:06 +0000 (12:20 +0000)]
[InstCombine] Add PR45977 test coverage

3 years ago[AArch64] Adding SHA3 Intrinsics support
Ryan Santhiraraja [Mon, 22 Feb 2021 11:23:31 +0000 (11:23 +0000)]
[AArch64] Adding SHA3 Intrinsics support

    This patch adds the following SHA3 Intrinsics:
        vsha512hq_u64,
        vsha512h2q_u64,
        vsha512su0q_u64,
        vsha512su1q_u64
        veor3q_u8
        veor3q_u16
        veor3q_u32
        veor3q_u64
        veor3q_s8
        veor3q_s16
        veor3q_s32
        veor3q_s64
        vrax1q_u64
        vxarq_u64
        vbcaxq_u8
        vbcaxq_u16
        vbcaxq_u32
        vbcaxq_u64
        vbcaxq_s8
        vbcaxq_s16
        vbcaxq_s32
        vbcaxq_s64

    Note need to include +sha3 and +crypto when building from the front-end

Reviewed By: DavidSpickett

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

3 years ago[AMDGPU][MC] Corrected bound_ctrl for compatibility with sp3
Dmitry Preobrazhensky [Mon, 22 Feb 2021 11:59:40 +0000 (14:59 +0300)]
[AMDGPU][MC] Corrected bound_ctrl for compatibility with sp3

Enabled "bound_ctrl:1" and disabled "bound_ctrl:-1" syntax.
Corrected printer to output "bound_ctrl:1" instead of "bound_ctrl:0".
See bug 35397 for detailed issue description.

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

3 years ago[gn build] Port 7dc7f0c2ecc0
LLVM GN Syncbot [Mon, 22 Feb 2021 11:35:19 +0000 (11:35 +0000)]
[gn build] Port 7dc7f0c2ecc0

3 years ago[clang-tidy] Add new check 'concurrency-thread-canceltype-asynchronous' and alias...
Balázs Kéri [Mon, 22 Feb 2021 10:46:36 +0000 (11:46 +0100)]
[clang-tidy] Add new check 'concurrency-thread-canceltype-asynchronous' and alias 'cert-pos47-c'.

Reviewed By: aaron.ballman

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

3 years ago[llvm-link] fix IRMover returning wrong modified vector type
Nashe Mncube [Fri, 19 Feb 2021 11:34:58 +0000 (11:34 +0000)]
[llvm-link] fix IRMover returning wrong modified vector type

Modified scalable vector types weren't correctly returned at link-time.
The previous behaviour was a FixedVectorType was constructed
when expecting a ScalableVectorType. This commit has added a regression
test which re-creates the failure as well as a fix.

Reviewed By: sdesmalen

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

3 years agoRegenerate documentation
Stephen Kelly [Mon, 22 Feb 2021 11:07:03 +0000 (11:07 +0000)]
Regenerate documentation

3 years ago[gn build] Port 6e3071007b4c
LLVM GN Syncbot [Mon, 22 Feb 2021 10:35:33 +0000 (10:35 +0000)]
[gn build] Port 6e3071007b4c

3 years ago[VPlan] Skip VPWidenPHIRecipe in VPInterleavedACcessInfo.
Florian Hahn [Mon, 22 Feb 2021 10:24:57 +0000 (10:24 +0000)]
[VPlan] Skip VPWidenPHIRecipe in VPInterleavedACcessInfo.

Update unit tests that did not expect VPWidenPHIRecipes after
15a74b64dfa9.

3 years ago[InstCombine] Add smulo NumSignBits test from D97170
Simon Pilgrim [Mon, 22 Feb 2021 10:24:58 +0000 (10:24 +0000)]
[InstCombine] Add smulo NumSignBits test from D97170

3 years ago[flang][driver] Add -Xflang and make -test-io a frontend-only flang
Andrzej Warzynski [Wed, 17 Feb 2021 14:13:29 +0000 (14:13 +0000)]
[flang][driver] Add -Xflang and make -test-io a frontend-only flang

This patch adds support for `-Xflang` in `flang-new`. The semantics are
identical to `-Xclang`.

With the addition of `-Xflang`, we can modify `-test-io` to be a
compiler-frontend only flag. This makes more sense, this flag is:
  * very frontend specific
  * to be used for development and testing only
  * not to be exposed to the end user
Originally we added it to the compiler driver, `flang-new`, in order to
facilitate testing. With `-Xflang` this is no longer needed. Tests are
updated accordingly.

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

3 years ago[ARM] Remove dead lowering code. NFC
David Green [Mon, 22 Feb 2021 10:07:53 +0000 (10:07 +0000)]
[ARM] Remove dead lowering code. NFC

Remove the unnecessary code from 21a4faab60c34b8a8c4d09, left over from
a different way of lowering.

3 years ago[analyzer][CTU] API for CTU macro expansions
Balazs Benics [Mon, 22 Feb 2021 10:12:22 +0000 (11:12 +0100)]
[analyzer][CTU] API for CTU macro expansions

Removes `CrossTranslationUnitContext::getImportedFromSourceLocation`
Removes the corresponding unit-test segment.

Introduces the `CrossTranslationUnitContext::getMacroExpansionContextForSourceLocation`
which will return the macro expansion context for an imported TU. Also adds a
few implementation FIXME notes where applicable, since this feature is
not implemented yet. This fact is also noted as Doxygen comments.

Uplifts a few CTU LIT test to match the current **incomplete** behavior.

It is a regression to some extent since now we don't expand any
macros in imported TUs. At least we don't crash anymore.

Note that the introduced function is already covered by LIT tests.
Eg.: Analysis/plist-macros-with-expansion-ctu.c

Reviewed By: balazske, Szelethus

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

3 years ago[analyzer] Use the MacroExpansionContext for macro expansions in plists
Balazs Benics [Mon, 22 Feb 2021 10:12:18 +0000 (11:12 +0100)]
[analyzer] Use the MacroExpansionContext for macro expansions in plists

Removes the obsolete ad-hoc macro expansions during bugreport constructions.
It will skip the macro expansion if the expansion happened in an imported TU.

Also removes the expected plist file, while expanding matching context for
the tests.
Adds a previously crashing `plist-macros-with-expansion.c` testfile.
Temporarily marks `plist-macros-with-expansion-ctu.c ` to `XFAIL`.

Reviewed By: xazax.hun, Szelethus

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

3 years ago[analyzer] Create MacroExpansionContext member in AnalysisConsumer
Balazs Benics [Mon, 22 Feb 2021 10:12:14 +0000 (11:12 +0100)]
[analyzer] Create MacroExpansionContext member in AnalysisConsumer

Adds a `MacroExpansionContext` member to the `AnalysisConsumer` class.
Tracks macro expansions only if the `ShouldDisplayMacroExpansions` is set.
Passes a reference down the pipeline letting AnalysisConsumers query macro
expansions during bugreport construction.

Reviewed By: martong, Szelethus

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

3 years ago[analyzer] Introduce MacroExpansionContext to libAnalysis
Balazs Benics [Mon, 22 Feb 2021 10:11:57 +0000 (11:11 +0100)]
[analyzer] Introduce MacroExpansionContext to libAnalysis

Introduce `MacroExpansionContext` to track what and how macros in a translation
unit expand. This is the first element of the patch-stack in this direction.

The main goal is to substitute the current macro expansion generator in the
`PlistsDiagnostics`, but all the other `DiagnosticsConsumer` could benefit from
this.

`getExpandedText` and `getOriginalText` are the primary functions of this class.
The former can provide you the text that was the result of the macro expansion
chain starting from a `SourceLocation`.
While the latter will tell you **what text** was in the original source code
replaced by the macro expansion chain from that location.

Here is an example:

  void bar();
  #define retArg(x) x
  #define retArgUnclosed retArg(bar()
  #define BB CC
  #define applyInt BB(int)
  #define CC(x) retArgUnclosed

  void unbalancedMacros() {
    applyInt  );
  //^~~~~~~~~~^ is the substituted range
  // Original text is "applyInt  )"
  // Expanded text is "bar()"
  }

  #define expandArgUnclosedCommaExpr(x) (x, bar(), 1
  #define f expandArgUnclosedCommaExpr

  void unbalancedMacros2() {
    int x =  f(f(1))  ));  // Look at the parenthesis!
  //         ^~~~~~^ is the substituted range
  // Original text is "f(f(1))"
  // Expanded text is "((1,bar(),1,bar(),1"
  }

Might worth investigating how to provide a reusable component, which could be
used for example by a standalone tool eg. expanding all macros to their
definitions.

I borrowed the main idea from the `PrintPreprocessedOutput.cpp` Frontend
component, providing a `PPCallbacks` instance hooking the preprocessor events.
I'm using that for calculating the source range where tokens will be expanded
to. I'm also using the `Preprocessor`'s `OnToken` callback, via the
`Preprocessor::setTokenWatcher` to reconstruct the expanded text.

Unfortunately, I concatenate the token's string representation without any
whitespaces except if the token is an identifier when I emit an extra space
to produce valid code for `int var` token sequences.
This could be improved later if needed.

Patch-stack:
  1) D93222 (this one) Introduces the MacroExpansionContext class and unittests

  2) D93223 Create MacroExpansionContext member in AnalysisConsumer and pass
     down to the diagnostics consumers

  3) D93224 Use the MacroExpansionContext for macro expansions in plists
     It replaces the 'old' macro expansion mechanism.

  4) D94673 API for CTU macro expansions
     You should be able to get a `MacroExpansionContext` for each imported TU.
     Right now it will just return `llvm::None` as this is not implemented yet.

  5) FIXME: Implement macro expansion tracking for imported TUs as well.

It would also relieve us from bugs like:
  - [fixed] D86135
  - [confirmed] The `__VA_ARGS__` and other macro nitty-gritty, such as how to
    stringify macro parameters, where to put or swallow commas, etc. are not
    handled correctly.
  - [confirmed] Unbalanced parenthesis are not well handled - resulting in
    incorrect expansions or even crashes.
  - [confirmed][crashing] https://bugs.llvm.org/show_bug.cgi?id=48358

Reviewed By: martong, Szelethus

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

3 years ago[VPlan] Manage pairs of incoming (VPValue, VPBB) in VPWidenPHIRecipe.
Florian Hahn [Mon, 22 Feb 2021 09:39:59 +0000 (09:39 +0000)]
[VPlan] Manage pairs of incoming (VPValue, VPBB) in VPWidenPHIRecipe.

This patch extends VPWidenPHIRecipe to manage pairs of incoming
(VPValue, VPBasicBlock) in the VPlan native path. This is made possible
because we now directly manage defined VPValues for recipes.

By keeping both the incoming value and block in the recipe directly,
code-generation in the VPlan native path becomes independent of the
predecessor ordering when fixing up non-induction phis, which currently
can cause crashes in the VPlan native path.

This fixes PR45958.

Reviewed By: sguggill

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

3 years ago[ARM] Move double vector insert patterns using vins to DAG combine
David Green [Mon, 22 Feb 2021 09:29:47 +0000 (09:29 +0000)]
[ARM] Move double vector insert patterns using vins to DAG combine

This removes the existing patterns for inserting two lanes into an
f16/i16 vector register using VINS, instead using a DAG combine to
pattern match the same code sequences. The tablegen patterns were
already on the large side (foreach LANE = [0, 2, 4, 6]) and were not
handling all the cases they could. Moving that to a DAG combine, whilst
not less code, allows us to better control and expand the selection of
VINSs. Additionally this allows us to remove the AddedComplexity on
VCVTT.

The extra trick that this has learned in the process is to move two
adjacent lanes using a single f32 vmov, allowing some extra
inefficiencies to be removed.

Differenial Revision: https://reviews.llvm.org/D96876

3 years ago[WebAssembly] call_indirect issues table number relocs
Andy Wingo [Fri, 12 Feb 2021 10:22:13 +0000 (11:22 +0100)]
[WebAssembly] call_indirect issues table number relocs

If the reference-types feature is enabled, call_indirect will explicitly
reference its corresponding function table via `TABLE_NUMBER`
relocations against a table symbol.

Also, as before, address-taken functions can also cause the function
table to be created, only with reference-types they additionally cause a
symbol table entry to be emitted.

We abuse the used-in-reloc flag on symbols to indicate which tables
should end up in the symbol table.  We do this because unfortunately
older wasm-ld will carp if it see a table symbol.

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

3 years ago[clang][CodeComplete] Ensure there are no crashes when completing with ParenListExprs...
Kadir Cetinkaya [Thu, 18 Feb 2021 12:48:43 +0000 (13:48 +0100)]
[clang][CodeComplete] Ensure there are no crashes when completing with ParenListExprs as LHS

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

3 years ago[clang][cli] Pass '-Wspir-compat' to cc1 from driver
Jan Svoboda [Mon, 22 Feb 2021 08:54:16 +0000 (09:54 +0100)]
[clang][cli] Pass '-Wspir-compat' to cc1 from driver

This patch moves the creation of the '-Wspir-compat' argument from cc1 to the driver.

Without this change, generating command line arguments from `CompilerInvocation` cannot be done reliably: there's no way to distinguish whether '-Wspir-compat' was passed to cc1 on the command line (should be generated), or if it was created within `CompilerInvocation::CreateFromArgs` (should not be generated).

This is also in line with how other '-W' flags are handled.

(This was introduced in D21567.)

Reviewed By: Anastasia

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

3 years ago[clang][cli] Stop creating '-Wno-stdlibcxx-not-found' in cc1
Jan Svoboda [Mon, 22 Feb 2021 08:24:12 +0000 (09:24 +0100)]
[clang][cli] Stop creating '-Wno-stdlibcxx-not-found' in cc1

This patch stops creating the '-Wno-stdlibcxx-not-found' argument in `CompilerInvocation::CreateFromArgs`.

The code was added in 2e7ab55e657f (a follow-up to D48297). However, D61963 removes relevant tests and starts explicitly passing '-Wno-stdlibcxx-not-found' to the driver. I think it's fair to assume this is a dead code.

Reviewed By: dexonsmith

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

3 years ago[mlir] Mark std.subview as NoSideEffect
Tres Popp [Thu, 18 Feb 2021 13:25:57 +0000 (14:25 +0100)]
[mlir] Mark std.subview as NoSideEffect

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

3 years ago[NFC][llvm-dwarfdump] Don't calculate unnecessary stats
Djordje Todorovic [Mon, 22 Feb 2021 07:20:37 +0000 (23:20 -0800)]
[NFC][llvm-dwarfdump] Don't calculate unnecessary stats

Small optimization of the code -- No need to calculate any stats
for NULL nodes, and also no need to call the collectStatsForDie()
if it is the CU itself.

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

3 years ago[InstrProfiling] Fix instrprof-gc-sections.c test
Petr Hosek [Mon, 22 Feb 2021 07:47:18 +0000 (23:47 -0800)]
[InstrProfiling] Fix instrprof-gc-sections.c test

After D97110 __llvm_prof_cnts has the nobits type so it's empty.

3 years ago[mlir] Export CUDA and Vulkan runtime wrappers on Windows
Kern Handa [Sun, 21 Feb 2021 09:13:48 +0000 (01:13 -0800)]
[mlir] Export CUDA and Vulkan runtime wrappers on Windows

Reviewed By: mehdi_amini

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

3 years ago[AArch64][GlobalISel] Fix <16 x s8> G_DUP regbankselect to assign source to gpr.
Amara Emerson [Mon, 22 Feb 2021 05:16:20 +0000 (21:16 -0800)]
[AArch64][GlobalISel] Fix <16 x s8> G_DUP regbankselect to assign source to gpr.

We can only select this type if the source is on GPR, not FPR.

3 years ago[CodeGen] Use range-based for loops (NFC)
Kazu Hirata [Mon, 22 Feb 2021 03:58:07 +0000 (19:58 -0800)]
[CodeGen] Use range-based for loops (NFC)

3 years ago[llvm] Fix header guards (NFC)
Kazu Hirata [Mon, 22 Feb 2021 03:58:05 +0000 (19:58 -0800)]
[llvm] Fix header guards (NFC)

Identified with llvm-header-guard.

3 years ago[Analysis] Use ListSeparator (NFC)
Kazu Hirata [Mon, 22 Feb 2021 03:58:03 +0000 (19:58 -0800)]
[Analysis] Use ListSeparator (NFC)

3 years agoRevert "[sanitizers] Pass CMAKE_C_FLAGS into TSan buildgo script"
Nico Weber [Mon, 22 Feb 2021 03:13:59 +0000 (22:13 -0500)]
Revert "[sanitizers] Pass CMAKE_C_FLAGS into TSan buildgo script"

This reverts commit ac6c13bfc49f2d67a77144c839ecf49e48cb994c.
Breaks building with PGO, see https://reviews.llvm.org/D96762#2574009

3 years ago[mlir] Add simple jupyter kernel
Jacques Pienaar [Sat, 30 Jan 2021 16:55:55 +0000 (08:55 -0800)]
[mlir] Add simple jupyter kernel

Simple jupyter kernel using mlir-opt and reproducer to run passes.
Useful for local experimentation & generating examples. The export to
markdown from here is not immediately useful nor did I define a
CodeMirror synax to make the HTML output prettier. It only supports one
level of history (e.g., `_`) as I was mostly using with expanding a
pipeline one pass at a time and so was all I needed.

I placed this in utils directory next to editor & debugger utils.

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

3 years ago[InstrProfiling] Use ELF section groups for counters, data and values
Petr Hosek [Sat, 13 Jul 2019 21:02:07 +0000 (14:02 -0700)]
[InstrProfiling] Use ELF section groups for counters, data and values

__start_/__stop_ references retain C identifier name sections such as
__llvm_prf_*. Putting these into a section group disables this logic.

The ELF section group semantics ensures that group members are retained
or discarded as a unit. When a function symbol is discarded, this allows
allows linker to discard counters, data and values associated with that
function symbol as well.

Note that `noduplicates` COMDAT is lowered to zero-flag section group in
ELF. We only set this for functions that aren't already in a COMDAT and
for those that don't have available_externally linkage since we already
use regular COMDAT groups for those.

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

3 years ago[KnownBits][RISCV] Improve known bits for srem.
Craig Topper [Sun, 21 Feb 2021 22:48:27 +0000 (14:48 -0800)]
[KnownBits][RISCV] Improve known bits for srem.

The result must be less than or equal to the LHS side, so any
leading zeros in the left hand side must also exist in the result.
This is stronger than the previous behavior where we only considered
the sign bit being 0.

The affected test case used the sign bit being known 0 to change
a sign extend to a zero extend pre type legalization. After type
legalization the types were promoted to i64, but we no longer
knew bit 31 was zero. This shifts are are the equivalent of an
AND with 0xffffffff or zext_inreg X, i32. This patch allows us to
see that bit 31 is zero and remove the shifts.

Reviewed By: RKSimon

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

3 years agoImplement simple type polymorphism for linalg named ops.
Stella Laurenzo [Sun, 21 Feb 2021 06:46:27 +0000 (22:46 -0800)]
Implement simple type polymorphism for linalg named ops.

* It was decided that this was the end of the line for the existing custom tc parser/generator, and this is the first step to replacing it with a declarative format that maps well to mathy source languages.
* One such source language is implemented here: https://github.com/stellaraccident/mlir-linalgpy/blob/main/samples/mm.py
  * In fact, this is the exact source of the declarative `polymorphic_matmul` in this change.
  * I am working separately to clean this python implementation up and add it to MLIR (probably as `mlir.tools.linalg_opgen` or equiv). The scope of the python side is greater than just generating named ops: the ops are callable and directly emit `linalg.generic` ops fully dynamically, and this is intended to be a feature for frontends like npcomp to define custom linear algebra ops at runtime.
* There is more work required to handle full type polymorphism, especially with respect to integer formulations, since they require more specificity wrt types.
* Followups to this change will bring the new generator to feature parity with the current one and delete the current. Roughly, this involves adding support for interface declarations and attribute symbol bindings.

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

3 years ago[X86] Add vector support to sub(C1, xor(X, C2)) -> add(xor(X, ~C2), C1+1) fold.
Simon Pilgrim [Sun, 21 Feb 2021 21:51:27 +0000 (21:51 +0000)]
[X86] Add vector support to sub(C1, xor(X, C2)) -> add(xor(X, ~C2), C1+1) fold.

3 years ago[X86] Replace explicit constant handling in sub(C1, xor(X, C2)) -> add(xor(X, ~C2...
Simon Pilgrim [Sun, 21 Feb 2021 21:40:32 +0000 (21:40 +0000)]
[X86] Replace explicit constant handling in sub(C1, xor(X, C2)) -> add(xor(X, ~C2), C1+1) fold. NFCI.

NFC cleanup before adding vector support - rely on the SelectionDAG to handle everything for us.

3 years ago[X86] Regenerate sub.ll test
Simon Pilgrim [Sun, 21 Feb 2021 21:25:26 +0000 (21:25 +0000)]
[X86] Regenerate sub.ll test

3 years ago[X86] Add 'sub C1, (xor X, C1) -> add (xor X, ~C2), C1+1' tests
Simon Pilgrim [Sun, 21 Feb 2021 21:19:39 +0000 (21:19 +0000)]
[X86] Add 'sub C1, (xor X, C1) -> add (xor X, ~C2), C1+1' tests

This is also in sub.ll but that's for a specific i686 pattern - this adds x86_64 and vector tests

3 years ago[X86] Add common CHECK check-prefix to sub combine tests
Simon Pilgrim [Sun, 21 Feb 2021 21:10:08 +0000 (21:10 +0000)]
[X86] Add common CHECK check-prefix to sub combine tests

3 years agoRevert "[lldb-vscode] Emit the breakpoint changed event on location resolved"
António Afonso [Sun, 21 Feb 2021 21:08:06 +0000 (13:08 -0800)]
Revert "[lldb-vscode] Emit the breakpoint changed event on location resolved"

This reverts commit 1f21d488bd79a06c9cf405cc5db985fcd71c4f70.

3 years ago[lldb] [docs] Update platform support status
Michał Górny [Sat, 20 Feb 2021 09:31:42 +0000 (10:31 +0100)]
[lldb] [docs] Update platform support status

Update supported features on FreeBSD, and supported platform list
on FreeBSD, Linux and NetBSD.

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

3 years ago[LLDB] [docs] Update the list of supported architectures on Windows
Martin Storsjö [Wed, 17 Feb 2021 06:56:07 +0000 (08:56 +0200)]
[LLDB] [docs] Update the list of supported architectures on Windows

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

3 years agoReapply "[lldb/test] Automatically find debug servers to test"
Pavel Labath [Thu, 4 Feb 2021 19:53:15 +0000 (20:53 +0100)]
Reapply "[lldb/test] Automatically find debug servers to test"

This reapplies 7df4eaaa93/D96202, which was reverted due to issues on
windows. These were caused by problems in the computation of the liblldb
directory, which was fixed by D96779.

The original commit message was:
Our test configuration logic assumes that the tests can be run either
with debugserver or with lldb-server. This is not entirely correct,
since lldb server has two "personalities" (platform server and debug
server) and debugserver is only a replacement for the latter.

A consequence of this is that it's not possible to test the platform
behavior of lldb-server on macos, as it is not possible to get a hold of
the lldb-server binary.

One solution to that would be to duplicate the server configuration
logic to be able to specify both executables. However, that seems
excessively redundant.

A well-behaved lldb should be able to find the debug server on its own,
and testing lldb with a different (lldb-|debug)server does not seem very
useful (even in the out-of-tree debugserver setup, we copy the server
into the build tree to make it appear "real").

Therefore, this patch deletes the configuration altogether and changes
the low-level server retrieval functions to be able to both lldb-server
and debugserver paths. They do this by consulting the "support
executable" directory of the lldb under test.

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

3 years ago[SelectionDAG][RISCV] Teach ComputeNumSignBits to handle SREM.
Craig Topper [Sun, 21 Feb 2021 19:13:34 +0000 (11:13 -0800)]
[SelectionDAG][RISCV] Teach ComputeNumSignBits to handle SREM.

This also removes a pattern from RISCV that is no longer needed
since the sexti32 on the LHS of the srem in the pattern implies
the result is sign extended so the sign_extend_inreg should be
removed in DAG combine now.

Reviewed By: luismarques, RKSimon

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

3 years ago[X86][AVX] canonicalizeLaneShuffleWithRepeatedOps - remove unnecessary BITCASTs.
Simon Pilgrim [Sun, 21 Feb 2021 18:40:23 +0000 (18:40 +0000)]
[X86][AVX] canonicalizeLaneShuffleWithRepeatedOps - remove unnecessary BITCASTs.

In conjunction with the 'vperm2x128(bitcast(x),bitcast(y),c) -> bitcast(vperm2x128(x,y,c))' fold in combineTargetShuffle, this should remove any unnecessary bitcasts around vperm2x128 lane shuffles.

3 years agoRevert "Make sure the interpreter module was loaded before making checks against it"
António Afonso [Sun, 21 Feb 2021 18:38:25 +0000 (10:38 -0800)]
Revert "Make sure the interpreter module was loaded before making checks against it"

This reverts commit a83a825e9902b54b315870e9ed85723525208f09.

3 years ago[NFC] Remove redundant word in comment
madhur13490 [Sun, 21 Feb 2021 18:02:44 +0000 (18:02 +0000)]
[NFC] Remove redundant word in comment

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

3 years ago[lldb-vscode] Emit the breakpoint changed event on location resolved
António Afonso [Fri, 19 Feb 2021 17:43:38 +0000 (09:43 -0800)]
[lldb-vscode] Emit the breakpoint changed event on location resolved

VSCode was not being informed whenever a location had been resolved (after being initated as non-resolved), so even though it was actually resolved, the IDE would show a hollow dot (instead of a red dot) because it didn't know about the change.

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

3 years ago[Loads] Add optimized FindAvailableLoadedValue() overload (NFCI)
Nikita Popov [Sun, 21 Feb 2021 16:49:49 +0000 (17:49 +0100)]
[Loads] Add optimized FindAvailableLoadedValue() overload (NFCI)

FindAvailableLoadedValue() accepts an iterator by reference. If no
available value is found, then the iterator will either be left
at a clobbering instruction or the beginning of the basic block.
This allows using FindAvailableLoadedValue() across multiple blocks.

If this functionality is not needed, as is the case in InstCombine,
then we can use a much more efficient implementation: First try
to find an available value, and only perform clobber checks if
we actually found one. As this function only looks at a very small
number of instructions (6 by default) and usually doesn't find an
available value, this saves many expensive alias analysis queries.

3 years ago[IR] restrict vector reduction intrinsic types
Sanjay Patel [Sun, 21 Feb 2021 17:33:53 +0000 (12:33 -0500)]
[IR] restrict vector reduction intrinsic types

The arguments in all cases should be vectors of exactly one of integer or FP.

All of the tests currently pass the verifier because we check for any vector
type regardless of the type of reduction.
This obviously can't work if we mix up integer and FP, and based on current
LangRef text it was not intended to work for pointers either.

The pointer case from https://llvm.org/PR49215 is what led me here. That
example was avoided with 5b250a27ec.

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

3 years agoMake sure the interpreter module was loaded before making checks against it
António Afonso [Fri, 19 Feb 2021 04:31:55 +0000 (20:31 -0800)]
Make sure the interpreter module was loaded before making checks against it

This issue was introduced in https://reviews.llvm.org/D92187.
The guard I'm changing were is supposed to act when linux is loading the linker for the second time (due to differences in paths like symlinks).
This is done by checking `module_sp != m_interpreter_module.lock()` however this will be true when `m_interpreter_module` wasn't initialized, making linux unload the linker module (the most visible result here is that lldb will stop getting notified about new modules loaded by the process, because it can't set the rendezvous breakpoint again after the stepping over it once).
The `m_interpreter_module` is not getting initialize when it goes through this path: https://github.com/llvm/llvm-project/blob/dbfdb139f75470a9abc78e7c9faf743fdd963c2d/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp#L332, which happens when lldb was able to read the address from the dynamic section of the executable.

What I'm not sure about though, is if when we go through this path if we still load the linker twice on linux. If that's the case then it means we need to somehow set the m_interpreter_module instead of the fix I provide here. I've only tested this on Android.

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

3 years ago[Loads] Extract helper frunction for available load/store (NFC)
Nikita Popov [Sun, 21 Feb 2021 17:22:34 +0000 (18:22 +0100)]
[Loads] Extract helper frunction for available load/store (NFC)

This contains the logic for extracting an available load/store
from a given instruction, to be reused in a following patch.

3 years ago[ThinLTO] Fix import of multiply defined global variables
Kristina Bessonova [Tue, 2 Feb 2021 10:13:43 +0000 (12:13 +0200)]
[ThinLTO] Fix import of multiply defined global variables

Currently, if there is a module that contains a strong definition of
a global variable and a module that has both a weak definition for
the same global and a reference to it, it may result in an undefined symbol error
while linking with ThinLTO.

It happens because:
* the strong definition become internal because it is read-only and can be imported;
* the weak definition gets replaced by a declaration because it's non-prevailing;
* the strong definition failed to be imported because the destination module
  already contains another definition of the global yet this def is non-prevailing.

The patch adds a check to computeImportForReferencedGlobals() that allows
considering a global variable for being imported even if the module contains
a definition of it in the case this def has an interposable linkage type.

Note that currently the check is based only on the linkage type
(and this seems to be enough at the moment), but it might be worth to account
the information whether the def is prevailing or not.

Reviewed By: tejohnson

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

3 years ago[DAG] Match USUBSAT patterns through zext/trunc
Simon Pilgrim [Sun, 21 Feb 2021 15:26:54 +0000 (15:26 +0000)]
[DAG] Match USUBSAT patterns through zext/trunc

This patch handles usubsat patterns hidden through zext/trunc and uses the getTruncatedUSUBSAT helper to determine if the USUBSAT can be correctly performed in the truncated form:

zext(x) >= y ? x - trunc(y) : 0 --> usubsat(x,trunc(umin(y,SatLimit)))
zext(x) >  y ? x - trunc(y) : 0 --> usubsat(x,trunc(umin(y,SatLimit)))

Based on original examples:

void foo(unsigned short *p, int max, int n) {
    int i;
    unsigned m;
    for (i = 0; i < n; i++) {
        m = *--p;
        *p = (unsigned short)(m >= max ? m-max : 0);
    }
}

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

3 years ago[X86][AVX] Fold concat(extract_subvector(v0,c0), extract_subvector(v1,c1)) -> vperm2x128
Simon Pilgrim [Sun, 21 Feb 2021 14:50:43 +0000 (14:50 +0000)]
[X86][AVX] Fold concat(extract_subvector(v0,c0), extract_subvector(v1,c1)) -> vperm2x128

Fixes regression exposed by removing bitcasts across logic-ops in D96206.

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

3 years ago[X86] Fold bitcast(logic(bitcast(X), Y)) --> logic'(X, bitcast(Y)) for int-int bitcasts
Simon Pilgrim [Sun, 21 Feb 2021 14:40:54 +0000 (14:40 +0000)]
[X86] Fold bitcast(logic(bitcast(X), Y)) --> logic'(X, bitcast(Y)) for int-int bitcasts

Extend the existing combine that handles bitcasting for fp-logic ops to also help remove logic ops across bitcasts to/from the same integer types.

This helps improve AVX512 predicate handling for D/Q logic ops and also allows DAGCombine's scalarizeExtractedBinop to remove some annoying gpr->simd->gpr transfers.

The concat_vectors regression in pr40891.ll will be addressed in a followup commit on this patch.

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

3 years ago[RISCV] Add test cases for add/sub/mul overflow intrinsics. NFC
Craig Topper [Sun, 21 Feb 2021 08:06:51 +0000 (00:06 -0800)]
[RISCV] Add test cases for add/sub/mul overflow intrinsics. NFC

Largely copied from AArch64/arm64-xaluo.ll

3 years ago[lld][ELF] __start_/__stop_ refs don't retain C-ident named group sections
Petr Hosek [Tue, 16 Feb 2021 07:41:16 +0000 (23:41 -0800)]
[lld][ELF] __start_/__stop_ refs don't retain C-ident named group sections

The special root semantics for identifier-named sections is meant
specifically for the metadata sections. In the context of group
semantics, where group members are always retained or discarded as a
unit, it's natural not to have this semantics apply to a section in a
group, otherwise we would never discard the group defeating the purpose
of using the group in the first place.

This change modifies the GC behavior so that __start_/__stop_ references
don't retain C identifier named sections in section groups which allows
for these groups to be collected. This matches the behavior of BFD ld.

The only kind of existing case that might break is interdependent
metadata sections that are all in a group together, but that group
doesn't contain any other sections referenced by anything except
implicit inclusion in a `__start_` and/or `__stop_`-referenced
identifier-named section, but such cases should be unlikely.

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

3 years ago[CodeGen] Use range-based for loops (NFC)
Kazu Hirata [Sun, 21 Feb 2021 05:46:02 +0000 (21:46 -0800)]
[CodeGen] Use range-based for loops (NFC)

3 years ago[TableGen] Use ListSeparator (NFC)
Kazu Hirata [Sun, 21 Feb 2021 05:46:00 +0000 (21:46 -0800)]
[TableGen] Use ListSeparator (NFC)