platform/upstream/llvm.git
3 years ago[TargetLowering] move "o" and "X" constraint handling to base class
Nick Desaulniers [Mon, 19 Apr 2021 17:36:33 +0000 (10:36 -0700)]
[TargetLowering] move "o" and "X" constraint handling to base class

These constraints are machine agnostic; there's no reason to handle
these per-arch. If arches don't support these constraints, then they
will fail elsewhere during instruction selection. We don't need virtual
calls to look these up; TargetLowering::getInlineAsmMemConstraint should
only be overridden by architectures with additional unique memory
constraints.

Reviewed By: echristo, MaskRay

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

3 years ago[AArch64][GlobalISel] Regbankselect + select @llvm.aarch64.neon.uaddlv
Jessica Paquette [Tue, 13 Apr 2021 17:03:17 +0000 (10:03 -0700)]
[AArch64][GlobalISel] Regbankselect + select @llvm.aarch64.neon.uaddlv

It turns out we actually import a bunch of selection code for intrinsics. The
imported code checks that the register banks on the G_INTRINSIC instruction
are correct. If so, it goes ahead and selects it.

This adds code to AArch64RegisterBankInfo to allow us to correctly determine
register banks on intrinsics which have known register bank constraints.

For now, this only handles @llvm.aarch64.neon.uaddlv. This is necessary for
porting AArch64TargetLowering::LowerCTPOP.

Also add a utility for getting the intrinsic ID from a G_INTRINSIC instruction.
This seems a little nicer than having to know about how intrinsic instructions
are structured.

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

3 years ago[lldb] Support "absolute memory address" images in crashlog.py
Jonas Devlieghere [Mon, 19 Apr 2021 17:20:13 +0000 (10:20 -0700)]
[lldb] Support "absolute memory address" images in crashlog.py

The binary image list contains the following entry when a frame is not
found in any know binary image:

  {
    "size" : 0,
    "source" : "A",
    "base" : 0,
    "uuid" : "00000000-0000-0000-0000-000000000000"
  }

Note that this object is missing the name and path keys. This patch
makes the JSON parser resilient against their absence.

3 years ago[LowerConstantIntrinsics] avoid crashing on alloca with unexpected operand type
Sanjay Patel [Mon, 19 Apr 2021 15:47:13 +0000 (11:47 -0400)]
[LowerConstantIntrinsics] avoid crashing on alloca with unexpected operand type

The test here is reduced from the fuzzer-generated crasher in:
https://llvm.org/PR50023
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33395

I don't know if this is the best or complete solution, but the
zext of the i42 type appears to match the behavior if we run a
weird type example like this through the IR optimizer with -O1.

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

3 years agofix comment typo to cycle bots
Nico Weber [Mon, 19 Apr 2021 16:58:56 +0000 (12:58 -0400)]
fix comment typo to cycle bots

3 years ago[AIX] Diagnose thinLTO usage in clang on AIX.
Wael Yehia [Mon, 19 Apr 2021 16:01:19 +0000 (16:01 +0000)]
[AIX] Diagnose thinLTO usage in clang on AIX.

Reviewed By: Xiangling Liao

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

3 years ago[clang] NFC: Fix range-based for loop warnings related to decl lookup
Jan Svoboda [Mon, 19 Apr 2021 16:31:31 +0000 (18:31 +0200)]
[clang] NFC: Fix range-based for loop warnings related to decl lookup

3 years ago[polly] Fix check-polly after SCEVExpander PtrToInt fixes
Roman Lebedev [Mon, 19 Apr 2021 16:10:55 +0000 (19:10 +0300)]
[polly] Fix check-polly after SCEVExpander PtrToInt fixes

3 years ago[SCEVExpander] ReuseOrCreateCast(): use IRBuilder to actually create the cast
Roman Lebedev [Mon, 19 Apr 2021 15:30:56 +0000 (18:30 +0300)]
[SCEVExpander] ReuseOrCreateCast(): use IRBuilder to actually create the cast

In particular, this allows to create constant expressions
instead of IR Instruction's if the argumen is a constant.

3 years ago[SCEVExpander] Expand explicit PtrToInt casts just like we would implicit ones
Roman Lebedev [Mon, 19 Apr 2021 14:15:01 +0000 (17:15 +0300)]
[SCEVExpander] Expand explicit PtrToInt casts just like we would implicit ones

I.e., use GetOptimalInsertionPointForCastOf() helper to get the insertion
point, and try to reuse casts first.

3 years ago[SCEVExpander] GetOptimalInsertionPointForCastOf(): gracefully handle Constant's
Roman Lebedev [Mon, 19 Apr 2021 14:36:20 +0000 (17:36 +0300)]
[SCEVExpander] GetOptimalInsertionPointForCastOf(): gracefully handle Constant's

I guess this case hasn't come up thus far, and i'm not sure if it can
really happen for the existing usages, thus no test in *this* commit.

But, the following commit adds test coverage,
there we'd expirience a crash without this fix.

3 years ago[NFCI][SCEVExpander] Extract GetOptimalInsertionPointForCastOf() helper
Roman Lebedev [Mon, 19 Apr 2021 14:06:15 +0000 (17:06 +0300)]
[NFCI][SCEVExpander] Extract GetOptimalInsertionPointForCastOf() helper

3 years ago[SCEVExpander] generateOverflowCheck(): explicitly PtrToInt the Start
Roman Lebedev [Mon, 19 Apr 2021 13:48:02 +0000 (16:48 +0300)]
[SCEVExpander] generateOverflowCheck(): explicitly PtrToInt the Start

Currently, InsertNoopCastOfTo() would implicitly insert that cast,
but now that we have SCEVPtrToIntExpr, i'm hoping we could stop
InsertNoopCastOfTo() from doing that. But first all users must be fixed.

3 years ago[NFC][SCEVExpander][LoopDistribute] Add test for SCEVPtrToIntExpr in SCEVExpander...
Roman Lebedev [Mon, 19 Apr 2021 13:46:08 +0000 (16:46 +0300)]
[NFC][SCEVExpander][LoopDistribute] Add test for SCEVPtrToIntExpr in SCEVExpander::generateOverflowCheck()

We shouldn't end up with ptrtoint-of-getelementptr there.

3 years ago[NFC][SCEVExpander][LoopDistribute] Regenerate scev-inserted-runtime-check.ll check...
Roman Lebedev [Mon, 19 Apr 2021 13:44:13 +0000 (16:44 +0300)]
[NFC][SCEVExpander][LoopDistribute] Regenerate scev-inserted-runtime-check.ll check lines

3 years ago[NFC][SCEV] Assert that we don't try to create SCEVPtrToIntExpr of a non-integral...
Roman Lebedev [Mon, 19 Apr 2021 13:29:41 +0000 (16:29 +0300)]
[NFC][SCEV] Assert that we don't try to create SCEVPtrToIntExpr of a non-integral pointer

ptr<->int casts are only valid for integral pointes,
defensively assert that we don't try to break that here.

3 years ago[Analysis] ImportedFunctionsInliningStatistics.h - add <memory> and remove unused...
Simon Pilgrim [Mon, 19 Apr 2021 13:51:57 +0000 (14:51 +0100)]
[Analysis] ImportedFunctionsInliningStatistics.h - add <memory> and remove unused <string> include. NFCI.

Move <string> include to ImportedFunctionsInliningStatistics.cpp and add missing <memory> include as we have explicit uses of std::unique_ptr in the header.

3 years ago[gn build] (manually) merge 5f87ab336e9f4
Nico Weber [Mon, 19 Apr 2021 14:34:41 +0000 (10:34 -0400)]
[gn build] (manually) merge 5f87ab336e9f4

3 years ago[gn build] Add missing dependencies to clang/lib/Basic
Nico Weber [Mon, 19 Apr 2021 14:30:10 +0000 (10:30 -0400)]
[gn build] Add missing dependencies to clang/lib/Basic

These are needed when buildling `clang-format` in a clean build dir.
It's a bit unfortunate that clang's lib/Basic depends on these
random TableGen targets. In the CMake build, this is less visible
because I think all llvm-tblgen's complete before all compiles there
(not sure though).

3 years agoFix test/Frontend/print-header-includes.c
Hans Wennborg [Mon, 19 Apr 2021 13:38:59 +0000 (15:38 +0200)]
Fix test/Frontend/print-header-includes.c

I managed to run the wrong tests before committing D100759.

3 years ago[Support] Memory.h - remove unnecessary <string> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 13:07:01 +0000 (14:07 +0100)]
[Support] Memory.h - remove unnecessary <string> include. NFCI.

protectMappedMemory no longer returns an error message, so we don't need std::string - I've fixed an unnecessary doxygen entry as well (oddly I wasn't seeing a Wdocumentation warning)

3 years ago[SystemZ][z/OS] Set more text files as text
Abhina Sreeskantharajan [Mon, 19 Apr 2021 13:31:13 +0000 (09:31 -0400)]
[SystemZ][z/OS] Set more text files as text

This patch corrects more instances of text files being opened as text.

Reviewed By: Jonathan.Crowther

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

3 years agoRename -show-skipped-includes to -fshow-skipped-includes and make it a driver option
Hans Wennborg [Mon, 19 Apr 2021 13:08:49 +0000 (15:08 +0200)]
Rename -show-skipped-includes to -fshow-skipped-includes and make it a driver option

This is a user-facing option, so it doesn't make sense for it to be cc1
only.

Follow-up to D100420

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

3 years ago[AMDGPU] GCNDPPCombine: simplify API of isShrinkable. NFC.
Jay Foad [Mon, 19 Apr 2021 13:20:46 +0000 (14:20 +0100)]
[AMDGPU] GCNDPPCombine: simplify API of isShrinkable. NFC.

3 years ago[clang][deps] NFC: Remove unused FullDependencies member
Jan Svoboda [Mon, 19 Apr 2021 12:34:10 +0000 (14:34 +0200)]
[clang][deps] NFC: Remove unused FullDependencies member

This patch removes the `FullDependencies::AdditionalNonPathCommandLine` member, as it's value-initialized and never mutated.

Reviewed By: dexonsmith

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

3 years ago[TableGen] Add support for the 'assert' statement in multiclasses
Paul C. Anagnostopoulos [Thu, 1 Apr 2021 17:01:43 +0000 (13:01 -0400)]
[TableGen] Add support for the 'assert' statement in multiclasses

This is step 3 of adding the 'assert' statement.

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

3 years ago[mlir][linalg] enable library call rewrites for linalg operations with index semantics.
Tobias Gysi [Mon, 19 Apr 2021 12:23:11 +0000 (12:23 +0000)]
[mlir][linalg] enable library call rewrites for linalg operations with index semantics.

The patch enables the library call lowering for linalg operations that contain index operations.

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

3 years ago[mlir] Improve debug flag management in Python bindings
Alex Zinenko [Mon, 19 Apr 2021 11:37:01 +0000 (13:37 +0200)]
[mlir] Improve debug flag management in Python bindings

Expose the debug flag as a readable and assignable property of a
dedicated class instead of a write-only function. Actually test the fact
of setting the flag. Move test to a dedicated file, it has zero relation
to context_managers.py where it was added.

Arguably, it should be promoted from mlir.ir to mlir module, but we are
not re-exporting the latter and this functionality is purposefully
hidden so can stay in IR for now. Drop unnecessary export code.

Refactor C API and put Debug into a separate library, fix it to actually
set the flag to the given value.

Reviewed By: nicolasvasilache

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

3 years ago[clang][deps] Generate the full command-line for modules
Jan Svoboda [Tue, 30 Mar 2021 11:31:03 +0000 (13:31 +0200)]
[clang][deps] Generate the full command-line for modules

This patch uses the new `CompilerInvocation::generateCC1CommandLine` to generate the full canonical command line for modular dependencies, instead of only appending additional arguments.

Reviewed By: dexonsmith

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

3 years ago[IR] GlobalObject.h - remove unused <utility> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 12:25:24 +0000 (13:25 +0100)]
[IR] GlobalObject.h - remove unused <utility> include. NFCI.

In fact there's no explicit use of any std:: type or method in this header.

3 years ago[mlir][linalg] adding pass to run the interchange pattern.
Tobias Gysi [Mon, 19 Apr 2021 11:53:18 +0000 (11:53 +0000)]
[mlir][linalg] adding pass to run the interchange pattern.

Instead of interchanging loops during the loop lowering this pass performs the interchange by permuting the indexing maps. It also updates the iterator types and the index accesses in the body of the operation.

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

3 years ago[SystemZ][z/OS] Set files in FileRemapper.cpp are text
Abhina Sreeskantharajan [Mon, 19 Apr 2021 11:59:23 +0000 (07:59 -0400)]
[SystemZ][z/OS] Set files in FileRemapper.cpp are text

This patch sets files in FileRemapper to open as text.

Reviewed By: Jonathan.Crowther

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

3 years ago[IR] GlobalObject.h - remove unused <string> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 10:51:27 +0000 (11:51 +0100)]
[IR] GlobalObject.h - remove unused <string> include. NFCI.

All string usage is hidden behind StringRefs - so we don't need an explicit <string> include.

3 years ago[llvm-exegesis] Analysis.cpp - use for-range loop. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 10:49:35 +0000 (11:49 +0100)]
[llvm-exegesis] Analysis.cpp - use for-range loop. NFCI.

3 years ago[MCA] CodeEmitter.h - remove unused <string> include. NFCI.
Simon Pilgrim [Mon, 19 Apr 2021 10:44:12 +0000 (11:44 +0100)]
[MCA] CodeEmitter.h - remove unused <string> include. NFCI.

Add explicit SmallString.h include - which is used in the header

3 years agoTry to unbreak the compiler-rt build on s390x
Sylvestre Ledru [Mon, 19 Apr 2021 11:17:47 +0000 (13:17 +0200)]
Try to unbreak the compiler-rt build on s390x

Introduced by:
3d1d7156e9a9a794ba649b79e27fe448274fd558

3 years ago[AMDGPU] Remove MachineDCE after SIFoldOperands
Jay Foad [Thu, 8 Apr 2021 16:10:54 +0000 (17:10 +0100)]
[AMDGPU] Remove MachineDCE after SIFoldOperands

Remove the MachineDCE pass after the first SIFoldOperands pass now
that SIFoldOperands deletes its own dead instructions.

Reapply after fixing dependent change D100188.

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

3 years ago[AMDGPU] SIFoldOperands: eagerly erase dead REG_SEQUENCEs
Jay Foad [Fri, 9 Apr 2021 12:52:35 +0000 (13:52 +0100)]
[AMDGPU] SIFoldOperands: eagerly erase dead REG_SEQUENCEs

This is fairly cheap to implement and means less work for future
passes like MachineDCE.

Reapply with a fix for using InstToErase after it had been erased.

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

3 years ago[TTI] NFC: Remove unused 'OptSize' parameter from shouldMaximizeVectorBandwidth
Cullen Rhodes [Tue, 13 Apr 2021 11:46:33 +0000 (11:46 +0000)]
[TTI] NFC: Remove unused 'OptSize' parameter from shouldMaximizeVectorBandwidth

Reviewed By: sdesmalen

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

3 years ago[clang][parser] Unify rejecting (non) decl stmts with gnu attributes
Timm Bäder [Tue, 6 Apr 2021 09:54:02 +0000 (11:54 +0200)]
[clang][parser] Unify rejecting (non) decl stmts with gnu attributes

The comment here was introduced in
a3e01cf822f7415337e5424af3c6f4c94a12c1b9 and suggests that we should
handle declaration statements and non-declaration statements the same,
but don't because ProhibitAttributes() can't handle GNU attributes. That
has recently changed, so remove the comment and handle all statements
the same.

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

3 years ago[AMDGPU][MC] Corrected parsing of carry in/out operands in VOP3
Dmitry Preobrazhensky [Mon, 19 Apr 2021 10:40:00 +0000 (13:40 +0300)]
[AMDGPU][MC] Corrected parsing of carry in/out operands in VOP3

Disabled constants as carry in/out operands. See bug 48711.

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

3 years ago[clang][deps] Remove the -full-command-line flag
Jan Svoboda [Tue, 30 Mar 2021 08:45:04 +0000 (10:45 +0200)]
[clang][deps] Remove the -full-command-line flag

This patch removes the `-full-command-line` option from `clang-scan-deps`. It's only used with `-format=experimental-full`, where omitting the command lines doesn't make much sense. There are no tests without `-full-command-line`.

Depends on D100531.

Reviewed By: Bigcheese

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

3 years ago[X86][CostModel] X86TTIImpl::getShuffleCost(): subvector insertions are cheap
Roman Lebedev [Mon, 19 Apr 2021 10:23:48 +0000 (13:23 +0300)]
[X86][CostModel] X86TTIImpl::getShuffleCost(): subvector insertions are cheap

This is similar to the subvector extractions,
except that the 0'th subvector isn't free to insert,
because we generally don't know whether or not
the upper elements need to be preserved:
https://godbolt.org/z/rsxP5W4sW

This is needed to avoid regressions in D100684

Reviewed By: RKSimon

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

3 years ago[RISCV] Lower vector shuffles to vrgather operations
Fraser Cormack [Thu, 15 Apr 2021 09:06:11 +0000 (10:06 +0100)]
[RISCV] Lower vector shuffles to vrgather operations

This patch extends the lowering of RVV fixed-length vector shuffles to
avoid the default stack expansion and instead lower to vrgather
instructions.

For "permute"-style shuffles where one vector is swizzled, we can lower
to one vrgather. For shuffles involving two vector operands, we lower to
one unmasked vrgather (or splat, where appropriate) followed by a masked
vrgather which blends in the second half.

On occasion, when it's not possible to create a legal BUILD_VECTOR for
the indices, we use vrgatherei16 instructions with 16-bit index types.

For 8-bit element vectors where we may have indices over 255, we have a
fairly blunt fallback to the stack expansion to avoid custom-splitting
of the vector types.

To enable the selection of masked vrgather instructions, this patch
extends the various RISCVISD::VRGATHER nodes to take a passthru operand.

Reviewed By: craig.topper

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

3 years ago[NFC] Add tests for scalable vectorization of loops with in-order reductions
Kerry McLaughlin [Mon, 19 Apr 2021 09:47:05 +0000 (10:47 +0100)]
[NFC] Add tests for scalable vectorization of loops with in-order reductions

D98435 added support for in-order reductions and included tests for fixed-width
vectorization with the -enable-strict-reductions flag.

This patch adds similar tests to verify support for scalable vectorization of loops
with in-order reductions.

Reviewed By: david-arm

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

3 years ago[clang][deps] Simplify function discovering .pcm and .modulemap files
Jan Svoboda [Tue, 30 Mar 2021 08:45:04 +0000 (10:45 +0200)]
[clang][deps] Simplify function discovering .pcm and .modulemap files

This patch simplifies (and renames) the `appendCommonModuleArguments` function.

It no longer tries to construct the command line for explicitly building modules. Instead, it only performs the DFS traversal of modular dependencies and queries the callbacks to collect paths to `.pcm` and `.modulemap` files.

This makes it more flexible and usable in two contexts:

* Generating additional command line arguments for the main TU in modular build. The `std::vector<std::string>` output parameters can be used to manually generate appropriate command line flags.
* Generate full command line for a module. The output parameters can be the corresponding parts of `CompilerInvocation`. (In a follow-up patch.)

Reviewed By: dexonsmith

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

3 years ago[DebugInfo] Replace debug uses in replaceUsesOutsideBlock
OCHyams [Mon, 19 Apr 2021 09:31:41 +0000 (10:31 +0100)]
[DebugInfo] Replace debug uses in replaceUsesOutsideBlock

Value::replaceUsesOutsideBlock doesn't replace debug uses which leads to an
unnecessary reduction in variable location coverage. Fix this, add a unittest for
it, and add a regression test demonstrating the change through instcombine's
replacedSelectWithOperand.

Reviewed By: djtodoro

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

3 years agoAdd default DataLayout support for complex numbers
Tres Popp [Mon, 12 Apr 2021 08:27:14 +0000 (10:27 +0200)]
Add default DataLayout support for complex numbers

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

3 years ago[DebugInfo] Move the findDbg* functions into DebugInfo.cpp
OCHyams [Mon, 19 Apr 2021 08:54:22 +0000 (09:54 +0100)]
[DebugInfo] Move the findDbg* functions into DebugInfo.cpp

Move the findDbg* functions into lib/IR/DebugInfo.cpp from
lib/Transforms/Utils/Local.cpp.

D99169 adds a call to a function (findDbgUsers) that lives in
lib/Transforms/Utils/Local.cpp (LLVMTransformUtils) from lib/IR/Value.cpp
(LLVMCore). The Core lib doesn't include TransformUtils. The builtbots caught
this here: https://lab.llvm.org/buildbot/#/builders/109/builds/12664. This patch
moves the function, and the 3 similar ones for consistency, into DebugInfo.cpp
which is part of LLVMCore.

Reviewed By: dblaikie, rnk

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

3 years ago[clang][cli] NFC: Move conditional LangOptions parsing/generation
Jan Svoboda [Fri, 16 Apr 2021 15:20:04 +0000 (17:20 +0200)]
[clang][cli] NFC: Move conditional LangOptions parsing/generation

NFC, this simplifies the main parsing/generating functions by moving logic around conditional `LangOptions` where it belongs.

Reviewed By: Bigcheese

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

3 years ago[OpenCL] Change OpenCL builtin version encoding
Sven van Haastregt [Mon, 19 Apr 2021 09:23:13 +0000 (10:23 +0100)]
[OpenCL] Change OpenCL builtin version encoding

Instead of using a MinVersion and MaxVersion field, encode the version
of a builtin using a mask that aligns better with version handling in
OpenCLOptions.h.  In addition, this saves a field in the BuiltinTable.

This change allows a finer-grained control over the OpenCL versions in
which a builtin is available: instead of a range, we can now toggle
each version individually.

The fine-grained version control is not yet exposed on the TableGen
definitions side, as changes for OpenCL 3 feature optionality still
need to be defined and will affect how we want to expose these.

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

3 years ago[clang][cli] NFC: Use Diags to report parsing success/failure
Jan Svoboda [Fri, 16 Apr 2021 13:30:28 +0000 (15:30 +0200)]
[clang][cli] NFC: Use Diags to report parsing success/failure

`Success` is set to `false` whenever `Diags.Report(diag::err_)` is called. Remove the duplication and use `Diags` as the source of truth when deciding whether to report parsing success/failure.

Reviewed By: dexonsmith

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

3 years ago[clang] Implement CompilerInvocation copy assignment
Jan Svoboda [Wed, 14 Apr 2021 12:35:03 +0000 (14:35 +0200)]
[clang] Implement CompilerInvocation copy assignment

This patch implements the copy assignment for `CompilerInvocation`.

Eventually, the deep-copy operation will be moved into a `clone()` method (D100460), but until then, this is necessary for basic ergonomics.

Depends on D100455.

Reviewed By: Bigcheese

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

3 years ago[llvm-exegesis] Honor -mcpu in analysis mode.
Clement Courbet [Mon, 19 Apr 2021 07:08:44 +0000 (09:08 +0200)]
[llvm-exegesis] Honor -mcpu in analysis mode.

This is useful to set the baseline model for an unknown CPU.

Fixes PR50013.

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

3 years ago[clang] Rename CompilerInvocationBase to RefBase, split out ValueBase
Jan Svoboda [Wed, 14 Apr 2021 12:27:08 +0000 (14:27 +0200)]
[clang] Rename CompilerInvocationBase to RefBase, split out ValueBase

This patch documents the reason `CompilerInvocationBase` exists and renames it to more descriptive `CompilerInvocationRefBase`.

To make the distinction obvious, it also splits out new `CompilerInvocationValueBase` class.

Reviewed By: Bigcheese

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

3 years ago[CodeGen] Improve code generation for clamping of constant indices with scalable...
David Sherwood [Fri, 16 Apr 2021 10:39:44 +0000 (11:39 +0100)]
[CodeGen] Improve code generation for clamping of constant indices with scalable vectors

When trying to clamp a constant index into a scalable vector we can
test if the index is less than the minimum number of elements in the
vector. If so, we can simply return the index because we know it is
guaranteed to fit inside the vector.

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

3 years ago[GreedyRA ORE] Add stats for copy of virtual registers.
Serguei Katkov [Fri, 9 Apr 2021 09:31:05 +0000 (16:31 +0700)]
[GreedyRA ORE] Add stats for copy of virtual registers.

Greedy RA adds copies of virtual registers when splitting live interval.
This stat might be useful.

Reviewers: reames, MatzeB, anemet, thegameg
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D100017

3 years ago[Greedy RA] Add a check to MachineVerifier
Serguei Katkov [Tue, 13 Apr 2021 10:31:23 +0000 (17:31 +0700)]
[Greedy RA] Add a check to MachineVerifier

If Virtual Register is alive in landing pad its def must be
before the call causing the exception or it should be statepoint instruction itself and
in this case def actually means the relocation of gc pointer and is alive in
landing pad.

The test shows the triggering this check for an option under development
use-registers-for-gc-values-in-landing-pad which is off by default until
it is functionally correct.

Reviewers: reames, void, jyknight, nickdesaulniers, efriedma, arsenm, rnk
Reviewed By: rnk
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D100525

3 years ago[CVP] processCallSite returns wrong status
Evgeniy Brevnov [Wed, 14 Apr 2021 16:08:17 +0000 (23:08 +0700)]
[CVP] processCallSite returns wrong status

Recently processMinMaxIntrinsic has been added and we started to observe a number of analysis get invalidated after CVP. The problem is CVP conservatively returns 'true'  even if there were no modifications to IR. I found one more place besides processMinMaxIntrinsic  which has the same problem. I think processMinMaxIntrinsic and similar should better have boolean return status to prevent similar issue reappear in future.

Reviewed By: lebedev.ri

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

3 years ago[RISCV][Driver] Make the ordering of CmdArgs consistent between RISCV::Linker and...
ShihPo Hung [Mon, 19 Apr 2021 02:05:20 +0000 (19:05 -0700)]
[RISCV][Driver] Make the ordering of CmdArgs consistent between RISCV::Linker and baremetal::Linker

In baremetal::Linker::ConstructJob, LinkerInput is handled prior to T_Group options,
but on the other side in RISCV::Linker::ConstructJob, it is opposite.

We want it to be consistent whether users are using RISCV::Linker or baremetal::Linker.

Reviewed By: MaskRay

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

3 years ago[clangd][test] Fix build error of FeatureModulesTests
Pan, Tao [Mon, 19 Apr 2021 00:55:31 +0000 (08:55 +0800)]
[clangd][test] Fix build error of FeatureModulesTests

clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp:33:58: error:
could not convert ‘(const char*)""’ from ‘const char*’ to
llvm::StringLiteral’
       llvm::StringLiteral kind() const override { return ""; };

Reviewed By: kadircet

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

3 years agoRevert "[Coroutines] Set presplit attribute in Clang instead of CoroEarly pass"
Xun Li [Mon, 19 Apr 2021 00:20:02 +0000 (17:20 -0700)]
Revert "[Coroutines] Set presplit attribute in Clang instead of CoroEarly pass"

This reverts commit fa6b54c44ab1d5f579304eadb7ac8bd7e72d0e77.
The commited patch broke mlir tests. It seems that mlir tests depend on coroutine function properties set in CoroEarly pass.

3 years agoAdd a missing debug assertion in <list>.
Arthur O'Dwyer [Sun, 18 Apr 2021 17:55:54 +0000 (13:55 -0400)]
Add a missing debug assertion in <list>.

This came up in D100595.

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

3 years ago[TableGen] Pass SmallVector to union_modes instead of returning a std::vector.
Craig Topper [Sun, 18 Apr 2021 21:10:06 +0000 (14:10 -0700)]
[TableGen] Pass SmallVector to union_modes instead of returning a std::vector.

The number of modes is small so this should avoid a heap allocation.

Also replace std::set with SmallSet.

3 years ago[Coroutines] Set presplit attribute in Clang instead of CoroEarly pass
Xun Li [Sun, 18 Apr 2021 22:41:09 +0000 (15:41 -0700)]
[Coroutines] Set presplit attribute in Clang instead of CoroEarly pass

Presplit coroutines cannot be inlined. During AlwaysInliner we check if a function is a presplit coroutine, if so we skip inlining.
The presplit coroutine attributes are set in CoroEarly pass.
However in O0 pipeline, AlwaysInliner runs before CoroEarly, so the attribute isn't set yet and will still inline the coroutine.
This causes Clang to crash: https://bugs.llvm.org/show_bug.cgi?id=49920

To fix this, we set the attributes in the Clang front-end instead of in CoroEarly pass.

Reviewed By: rjmccall, ChuanqiXu

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

3 years agoRevert "[Coroutines] Move CoroEarly pass to before AlwaysInliner"
Xun Li [Sun, 18 Apr 2021 22:38:19 +0000 (15:38 -0700)]
Revert "[Coroutines] Move CoroEarly pass to before AlwaysInliner"

This reverts commit 2b50f5a4343f8fb06acaa5c36355bcf58092c9cd.
Forgot to update the description of the commit to sync with phabricator. Going to redo the commit.

3 years ago[Coroutines] Move CoroEarly pass to before AlwaysInliner
Xun Li [Mon, 12 Apr 2021 05:01:36 +0000 (22:01 -0700)]
[Coroutines] Move CoroEarly pass to before AlwaysInliner

Presplit coroutines cannot be inlined. During AlwaysInliner we check if a function is a presplit coroutine, if so we skip inlining.
The presplit coroutine attributes are set in CoroEarly pass.
However in O0 pipeline, AlwaysInliner runs before CoroEarly, so the attribute isn't set yet and will still inline the coroutine.
This causes Clang to crash: https://bugs.llvm.org/show_bug.cgi?id=49920

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

3 years ago[lit] Fix the return code for "not not" after evaluating "not" internally
Martin Storsjö [Sun, 18 Apr 2021 21:37:13 +0000 (00:37 +0300)]
[lit] Fix the return code for "not not" after evaluating "not" internally

This fixes cases where "not not <command>" is supposed to return
only the error codes 0 or 1, but after efee57925c3f46c74c6697,
it passed the original error code through.

This was visible on AIX in the shtest-output-printing.py testcase,
where 'wc' returns 2, while it returns 1 on other platforms, and the
test required "not not" to normalize it to 1.

3 years ago[TableGen] Use MachineValueTypeSet in place of SmallSet.
Craig Topper [Sun, 18 Apr 2021 20:35:11 +0000 (13:35 -0700)]
[TableGen] Use MachineValueTypeSet in place of SmallSet.

MachineValueTypeSet is effectively a std::bitset<256>. This allows
us quickly insert into the set and check if a type is in the set.

3 years ago[LoopDeletion] Add test for PR49967 (NFC)
Nikita Popov [Sun, 18 Apr 2021 20:07:49 +0000 (22:07 +0200)]
[LoopDeletion] Add test for PR49967 (NFC)

Test case for a SCEV invalidation bug caused by D100264, which
has since been reverted.

3 years ago[TableGen] Use range-based for loop. NFC
Craig Topper [Sun, 18 Apr 2021 04:49:45 +0000 (21:49 -0700)]
[TableGen] Use range-based for loop. NFC

3 years ago[Introspection] Dont emit json if unchanged.
Nathan James [Sun, 18 Apr 2021 19:22:08 +0000 (20:22 +0100)]
[Introspection] Dont emit json if unchanged.

Saves running the generate inc script in the, somewhat common, case where the json file doesn't need changing.

Reviewed By: steveire

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

3 years ago[sanitizer] Don't call __tls_get_addr on s390x after D98926
Fangrui Song [Sun, 18 Apr 2021 17:42:43 +0000 (10:42 -0700)]
[sanitizer] Don't call __tls_get_addr on s390x after D98926

glibc s390x doesn't define __tls_get_addr.

Fix PR50017

3 years ago[libc++] [CI] Fail if the headers contain cyclic dependencies.
Arthur O'Dwyer [Sat, 17 Apr 2021 13:56:34 +0000 (09:56 -0400)]
[libc++] [CI] Fail if the headers contain cyclic dependencies.

Since we have a tool to detect cycles now; and since we're entering
a phase where people can easily introduce cycles by accident (D100682)
or by request (D90999), I think it's increasingly important to shift
the burden of detecting these cycles onto the buildbot instead of
the poor human reviewer.

Also, grep for non-ASCII characters (such as U+200B and U+00AD)
and hard tabs; don't let those get checked in.

Differential Review: https://reviews.llvm.org/D100703

3 years agoRevert "[SCEV] Model `ashr exact x, C` as `(abs(x) EXACT/u (1<<C)) * signum(x)`"
Roman Lebedev [Sun, 18 Apr 2021 13:20:34 +0000 (16:20 +0300)]
Revert "[SCEV] Model `ashr exact x, C` as `(abs(x) EXACT/u (1<<C)) * signum(x)`"

As being discussed in https://reviews.llvm.org/D100721,
this modelling is lossy, we can't reconstruct `ash`/`ashr exact`
from it, which means that whenever we actually expand the IR,
we've just pessimized the code..

It would be good to model this pattern, after all it comes up every time
you want to compute a distance between two pointers, but not at this cost.

This reverts commit ec54867df5e7f20e12146e628af34f0384308bcb.

3 years ago[clang] Fix cross compiling clang for windows after 141945f950e2f3f
Martin Storsjö [Sun, 18 Apr 2021 12:53:48 +0000 (15:53 +0300)]
[clang] Fix cross compiling clang for windows after 141945f950e2f3f

Don't try to execute clang-ast-dump when cross compiling.

3 years ago[lldb] Remove a superfluous trailing semicolon, fixing warnings. NFC.
Martin Storsjö [Sun, 18 Apr 2021 12:53:04 +0000 (15:53 +0300)]
[lldb] Remove a superfluous trailing semicolon, fixing warnings. NFC.

3 years ago[Docs] Correct Boehm collector weblink in GarbageCollection.rst
xgupta [Sun, 18 Apr 2021 12:00:17 +0000 (17:30 +0530)]
[Docs] Correct Boehm collector weblink in GarbageCollection.rst

3 years ago[gn build] Port 01ace074fcb6
LLVM GN Syncbot [Sun, 18 Apr 2021 11:35:28 +0000 (11:35 +0000)]
[gn build] Port 01ace074fcb6

3 years ago[libc++] Implements ranges::enable_borrowed_range
Mark de Wever [Tue, 24 Nov 2020 17:08:02 +0000 (18:08 +0100)]
[libc++] Implements ranges::enable_borrowed_range

This is the initial patch to implement ranges in libc++.

Implements parts of:
- P0896R4 One Ranges Proposal
- P1870 forwarding-range is too subtle
- LWG3379 in several library names is misleading

Reviewed By: ldionne, #libc, cjdb, zoecarver, Quuxplusone

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

3 years ago[IndVarSimplify] Add test requiring ashr expansion.
Florian Hahn [Sun, 18 Apr 2021 11:09:59 +0000 (12:09 +0100)]
[IndVarSimplify] Add test requiring ashr expansion.

Add test cases showing large ashr expansion during IndVarSimplify
after ec54867df5e7.

3 years ago[AST][Introspection][NFC] Remove unnecessary temporary strings.
Nathan James [Sun, 18 Apr 2021 08:25:12 +0000 (09:25 +0100)]
[AST][Introspection][NFC] Remove unnecessary temporary strings.

3 years ago[NFC][X86][CostModel] Rewrite load_store.ll
Roman Lebedev [Sun, 18 Apr 2021 08:07:04 +0000 (11:07 +0300)]
[NFC][X86][CostModel] Rewrite load_store.ll

Test SSE41, since that added float/i64/i32/i8 inserts/extracts.
Don't forget to test vectors of pointers.
Do test byte-aligned loads/stores.
Fixup test coverage to be rather more exhaustive,
testing all reasonable element sizes vs element counts permutations
that fit up to witin ZMM.

3 years ago[NFC][LoopVectorize] Autogenerate check lines in X86/gather_scatter.ll test
Roman Lebedev [Sun, 18 Apr 2021 07:26:16 +0000 (10:26 +0300)]
[NFC][LoopVectorize] Autogenerate check lines in X86/gather_scatter.ll test

3 years agoUpdate InstCombine to use undef matcher instead
Juneyoung Lee [Sun, 18 Apr 2021 02:05:34 +0000 (11:05 +0900)]
Update InstCombine to use undef matcher instead

This is a patch to use m_Undef() matcher instead of isa<UndefValue>().

As suggested in D100122, this update is separately committed.

3 years agoUpdate m_Undef to match vectors/aggrs with undefs and poisons mixed
Juneyoung Lee [Sun, 18 Apr 2021 01:57:04 +0000 (10:57 +0900)]
Update m_Undef to match vectors/aggrs with undefs and poisons mixed

This fixes https://reviews.llvm.org/D93990#2666922
by teaching `m_Undef` to match vectors/aggrs with poison elements.

As suggested, fixes in InstCombine files to use the `m_Undef` matcher instead
of `isa<UndefValue>` will be followed.

Reviewed By: lebedev.ri

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

3 years ago[AST] Add TypeLoc support to node introspection
Stephen Kelly [Wed, 24 Mar 2021 02:29:30 +0000 (02:29 +0000)]
[AST] Add TypeLoc support to node introspection

Extend the matchers gathering API for types to record template
parameters.  The TypeLoc type hierarchy has some types which are
templates used in CRTP such as PointerLikeTypeLoc.  Record the inherited
template and template arguments of types inheriting those CRTP types in
the ClassInheritance map.  Because the name inherited from is now
computed, the value type in that map changes from StringRef to
std::string.  This also causes the toJSON override signature used to
serialize that map to change.

Remove the logic for skipping over empty ClassData instances.  Several
classes such as TypeOfExprTypeLoc inherit a CRTP class which provides
interesting locations though the derived class does not.  Record it as a
class to make the locations it inherits available.

Record the typeSourceInfo accessors too as they provide access to
TypeLocs in many classes.

The existing unit tests use UnorderedElementsAre to compare the
introspection result with the expected result.  Our current
implementation of google mock (in gmock-generated-matchers.h) is limited
to support for comparing a container of 10 elements.  As we are now
returning more than 10 results for one of the introspection tests,
change it to instead compare against an ordered vector of pairs.

Because a macro is used to generate API strings and API calls, disable
clang-format in blocks of expected results.  Otherwise clang-format
would insert whitespaces which would then be compared against the
introspected strings and fail the test.

Introduce a recursion guard in the generated code.  The TypeLoc class
has IgnoreParens() API which by default returns itself, so it would
otherwise recurse infinitely.

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

3 years ago[libc++] Remove hard tabs, U+00AD, and U+200B from all libc++ headers. NFCI.
Arthur O'Dwyer [Sat, 17 Apr 2021 21:03:20 +0000 (17:03 -0400)]
[libc++] Remove hard tabs, U+00AD, and U+200B from all libc++ headers. NFCI.

3 years ago[ADT] Update RPOT to work with specializations of different types.
Florian Hahn [Sat, 17 Apr 2021 17:16:07 +0000 (18:16 +0100)]
[ADT] Update RPOT to work with specializations of different types.

At the moment, ReversePostOrderTraversal performs a post-order walk on
the entry node of the passed in graph, rather than the graph type
itself.

If GT::NodeRef is the same as GraphT, everything works as expected and
this is the case for the current uses in-tree. But it does not work as
expected if GraphT != GT::NodeRef. In that case, we either fail to build
(if there is no GraphTrait specialization for GT:NodeRef) or we pick the
GraphTrait specialization for GT::NodeRef, instead of the specialization
of GraphT.

Both the depth-first and post-order iterators pick the expected
specalization and this patch updates ReversePostOrderTraversal to
delegate to po_begin & po_end to pick the right specialization, rather
than forcing using GraphTraits<GT::NodeRef>, by first getting the entry
node.

This makes `ReversePostOrderTraversal<Graph<6>> RPOT(G);` build and
work as expected in the test.

Reviewed By: dexonsmith

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

3 years ago[LoopUnroll] Regenerate test checks (NFC)
Nikita Popov [Sat, 17 Apr 2021 18:58:27 +0000 (20:58 +0200)]
[LoopUnroll] Regenerate test checks (NFC)

3 years ago[LoopUnroll] Make some tests more robust (NFC)
Nikita Popov [Sat, 17 Apr 2021 18:55:57 +0000 (20:55 +0200)]
[LoopUnroll] Make some tests more robust (NFC)

Replace branch on undef by branch on unknown condition.

3 years ago[JITLink] Add testcase that was accidentally left out of 19e402d2b34.
Lang Hames [Sat, 17 Apr 2021 18:55:14 +0000 (11:55 -0700)]
[JITLink] Add testcase that was accidentally left out of 19e402d2b34.

3 years ago[clang-scan-deps] Add support for clang-cl
Sylvain Audi [Sat, 17 Apr 2021 16:49:40 +0000 (12:49 -0400)]
[clang-scan-deps] Add support for clang-cl

clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

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

3 years ago[clang-scan-deps] Support double-dashes in clang command lines
Sylvain Audi [Sat, 17 Apr 2021 01:45:42 +0000 (21:45 -0400)]
[clang-scan-deps] Support double-dashes in clang command lines

This fixes argument injection in clang command lines, by adding them before "--".

Previously, the arguments were injected at the end of the command line and could be added after "--", which would be wrongly interpreted as input file paths.

This fix is needed for a subsequent patch, see D92191.

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

3 years ago[Support] ThreadPool tests: silence warning unused variable 'It'
Alexandre Ganea [Sat, 17 Apr 2021 17:56:23 +0000 (13:56 -0400)]
[Support] ThreadPool tests: silence warning unused variable 'It'

3 years ago[AST] Enable AST node introspection on WIN32
Stephen Kelly [Sat, 17 Apr 2021 17:58:05 +0000 (18:58 +0100)]
[AST] Enable AST node introspection on WIN32

3 years ago[TableGen] Remove local SmallSet from TypeSetByHwMode::insert.
Craig Topper [Sat, 17 Apr 2021 17:47:04 +0000 (10:47 -0700)]
[TableGen] Remove local SmallSet from TypeSetByHwMode::insert.

This keeps track of which modes are in VVT so we can find out
if a mode is missing later. But we can just ask VVT whether it
has a particular mode.

3 years ago[NFC] Fixed Typos
Jennifer Chukwu [Sat, 17 Apr 2021 15:04:06 +0000 (20:34 +0530)]
[NFC] Fixed Typos

Reviewed By: xgupta

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

3 years ago[AST] Remove args from LocationCall
Stephen Kelly [Fri, 16 Apr 2021 21:29:06 +0000 (22:29 +0100)]
[AST] Remove args from LocationCall

This class initially had args to be generic to future needs. In
particular, I thought that source location introspection should show the
getBeginLoc of CallExpr args and the getArgLoc of
TemplateSpecializationLocInfo etc.  However, that is probably best left
out of source location introspection because it involves node traversal.

If something like this is needed in the future, it can be added in the
future.

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

3 years ago[ADT] Take graph as const & in some post-order iterators (NFC).
Florian Hahn [Sat, 17 Apr 2021 14:22:54 +0000 (15:22 +0100)]
[ADT] Take graph as const & in some post-order iterators (NFC).

This patch updates a couple of functions that unnecessarily took the
input graph by value, when it was not needed. They can take the graph by
const-reference instead, which does not require GraphT to provide a copy
constructor.

Split off from D100169.