platform/upstream/llvm.git
2 years ago[JITLink] Add RISCV label subtraction and addition relocations
luxufan [Fri, 7 Jan 2022 07:49:03 +0000 (15:49 +0800)]
[JITLink] Add RISCV label subtraction and addition relocations

This patch add RISCV label subtraction and addition relocations in JITLink

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

2 years ago[AArch64][SVE][VLS] Move extends into arguments of comparisons
David Truby [Tue, 16 Nov 2021 11:33:12 +0000 (11:33 +0000)]
[AArch64][SVE][VLS] Move extends into arguments of comparisons

When a comparison is extended and it would be free to extend the
arguments to that comparison, we can propagate the extend into those arguments.
This prevents extra instructions being generated to extend the result of the
comparison, which is not free to extend.

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

2 years ago[flang][NFC] Fix indentation
Valentin Clement [Wed, 19 Jan 2022 14:08:40 +0000 (15:08 +0100)]
[flang][NFC] Fix indentation

2 years ago[flang][NFC] Remove number of inlined elements
Valentin Clement [Wed, 19 Jan 2022 13:51:07 +0000 (14:51 +0100)]
[flang][NFC] Remove number of inlined elements

Following the recommendation just remove the specified number of
inlined elements since it is not well-motivated choice here.

2 years ago[flang][NFC] Fix includes order
Valentin Clement [Wed, 19 Jan 2022 13:32:48 +0000 (14:32 +0100)]
[flang][NFC] Fix includes order

2 years ago[mlir][linalg][bufferize][NFC] Move analysis-related code to Comprehensive Bufferize
Matthias Springer [Wed, 19 Jan 2022 13:19:31 +0000 (22:19 +0900)]
[mlir][linalg][bufferize][NFC] Move analysis-related code to Comprehensive Bufferize

The code in `BufferizableOpInterface`'s header/source no longer contains any analysis code. This makes it easier to run the bufferization with a different analysis or without any analysis.

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

2 years ago[clang-format] [docs] Fix link to avoid redirection. NFC.
Marek Kurdej [Wed, 19 Jan 2022 13:16:14 +0000 (14:16 +0100)]
[clang-format] [docs] Fix link to avoid redirection. NFC.

2 years ago[AVR] Do not clear r0 at interrupt entry
Ayke van Laethem [Thu, 6 Jan 2022 17:22:06 +0000 (18:22 +0100)]
[AVR] Do not clear r0 at interrupt entry

There is no reason to do this: it's a scratch register and can therefore
hold any arbitrary value. And because it is in an interrupt, this code
is performance critical so it should be as short as possible.

I believe r0 was cleared because of the following:

 1. There used to be a bug that the cleared register was r0, not r1 as
    it should have been.
 2. This was fixed in https://reviews.llvm.org/D99467, but left the code
    to clear r0.

This patch completes D99467 by removing the `clr r0` instruction.

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

2 years ago[AVR] Mark call-clobbered registers as clobbered in interrupt handlers
Ayke van Laethem [Mon, 3 Jan 2022 19:29:27 +0000 (20:29 +0100)]
[AVR] Mark call-clobbered registers as clobbered in interrupt handlers

I have matched the RISCV backend, which only uses the interrupt save
list in getCalleeSavedRegs, _not_ in getCallPreservedMask. I don't know
the details of these two methods, but with it, the correct amount of
registers is saved and restored.

Without this patch, practically all interrupt handlers that call a
function will miscompile.

I have added a test to verify this behavior. I've also added a very
simple test to verify that more normal interrupt operations (in this
case, incrementing a global value) behave as expected.

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

2 years ago[AVR] Remove redundant dynalloca SP save/restore pass
Ayke van Laethem [Tue, 2 Mar 2021 23:45:15 +0000 (00:45 +0100)]
[AVR] Remove redundant dynalloca SP save/restore pass

I think this pass was previously used under the assumption that most
functions would not need a frame pointer and it would be more efficient
to store the old stack pointer in a regular register pair.

Unfortunately, right now we're forced to always reserve the Y register
as a frame pointer: whether or not this is needed is only known after
regsiter allocation at which point it doesn't make sense anymore to mark
it as non-reserved. Therefore, it makes sense to use the Y register to
store the old stack pointer in functions with dynamic allocas (with a
variable size or not in the entry block). Knowing this can make the code
around dynamic allocas a lot simpler: simply save/restore the frame
pointer.

This is especially relevant in functions that have a frame pointer
anyway (for example, because they have stack spills). The stack restore
in the epilogue will implicitly restore the old stack pointer, so there
is no need to store the old stack pointer separately. It even reduces
register pressure as a side effect.

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

2 years ago[LLD][COFF] Support GNU style == aliases
Ayke van Laethem [Sun, 7 Nov 2021 15:46:29 +0000 (16:46 +0100)]
[LLD][COFF] Support GNU style == aliases

D46245 added support for this in llvm-libtool, but while lld-link can
also create .lib files from .def files it didn't support aliases.

I compared the Inputs/library.def test against the output from
llvm-libtool and it matches, except for the fact that lld-link reorders
functions for some reason.

I have also verified that this fixes a bug I was running into while
trying to compile .def files to .lib files in MinGW-w64 (using lld-link
instead of llvm-libtool).

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

2 years ago[bazel] Fix the python bindings for 7ceffae18c43
Benjamin Kramer [Wed, 19 Jan 2022 13:20:55 +0000 (14:20 +0100)]
[bazel] Fix the python bindings for 7ceffae18c43

Also run buildifier.

2 years ago[AST] Fix the incorrect auto-keyword loc for constrained auto type loc.
Haojian Wu [Wed, 19 Jan 2022 12:55:07 +0000 (13:55 +0100)]
[AST] Fix the incorrect auto-keyword loc for constrained auto type loc.

E.g.  `Concept auto Func();`

The nameLoc for the constained auto type loc pointed to the concept name
loc, it should be the auto token loc. This patch fixes it, and remove
a relevant hack in clang-tidy check.

Reviewed By: sammccall

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

2 years ago[bazel] Port 7ceffae18c43
Benjamin Kramer [Wed, 19 Jan 2022 13:14:36 +0000 (14:14 +0100)]
[bazel] Port 7ceffae18c43

2 years ago[clangd] Sort targets before printing for tests
Kadir Cetinkaya [Tue, 18 Jan 2022 10:03:20 +0000 (11:03 +0100)]
[clangd] Sort targets before printing for tests

Targets are not necessarily inserted in the order they appear in source
code. For example we could traverse overload sets, or selectively insert
template patterns after all other decls.
So order the targets before printing to make sure tests are not dependent on
such implementation details. We can also do it in production, but that might be
wasteful as we haven't seen any complaints in the wild around these orderings
yet.

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

2 years ago[mlir][linalg][bufferize][NFC] Split analysis-related code from BufferizationState...
Matthias Springer [Wed, 19 Jan 2022 09:58:36 +0000 (18:58 +0900)]
[mlir][linalg][bufferize][NFC] Split analysis-related code from BufferizationState/Options

This separates the analysis (and its helpers/data structures) more clearly from the rest of the bufferization.

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

2 years ago[mlir] Fix PDL python bindings build
Denys Shabalin [Wed, 19 Jan 2022 12:42:14 +0000 (13:42 +0100)]
[mlir] Fix PDL python bindings build

Fixes incorrect build definition for the bindings for the PDL dialect.

Reviewed By: ftynse

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

2 years ago[AMDGPU] Tweak some compares in wqm.ll test
Jay Foad [Wed, 19 Jan 2022 12:42:56 +0000 (12:42 +0000)]
[AMDGPU] Tweak some compares in wqm.ll test

This prevents the compares from being optimized away when D86578 lands,
which seems unintended. Also fixed some unused results.

2 years ago[NFC] Use Register instead of unsigned
Jim Lin [Wed, 19 Jan 2022 09:25:52 +0000 (17:25 +0800)]
[NFC] Use Register instead of unsigned

2 years ago[BuildLibCalls] Mark calloc as inaccessiblememonly
Nikita Popov [Wed, 19 Jan 2022 11:52:02 +0000 (12:52 +0100)]
[BuildLibCalls] Mark calloc as inaccessiblememonly

Now that DSE handles inaccessiblememonly calloc, mark it as such,
as we do with other memory allocation functions.

2 years ago[DSE] Handle inaccessiblememonly calloc
Nikita Popov [Tue, 18 Jan 2022 08:04:12 +0000 (09:04 +0100)]
[DSE] Handle inaccessiblememonly calloc

Change the DSE calloc handling to assume that it is
inaccessiblememonly, i.e. the defining access is liveOnEntry.

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

2 years ago[lldb] Introduce SBPlatform::SetSDKRoot
Pavel Labath [Tue, 18 Jan 2022 10:26:07 +0000 (11:26 +0100)]
[lldb] Introduce SBPlatform::SetSDKRoot

It complements the existing SBDebugger::SetCurrentPlatformSDKRoot and
allows one to set the sysroot of a platform without making it current.

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

2 years ago[lldb] Remove the requirement for windows clients to specify -DIMPORT_LIBLLDB
Pavel Labath [Tue, 18 Jan 2022 15:15:10 +0000 (16:15 +0100)]
[lldb] Remove the requirement for windows clients to specify -DIMPORT_LIBLLDB

This macro was being used to select the proper import/export annotations
on SB classes. Non-windows clients do not have such requirements.

Instead introduce a new macro (LLDB_IN_LIBLLDB), which signals that
we're compiling liblldb itself (and should use dllexport). The default
(no macro) is to use dllimport. I've moved the macro definition to
SBDefines.h, since it only makes sense when building the API library.

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

2 years ago[lldb] Fix NativeThreadLinux to build with older compilers
Pavel Labath [Wed, 19 Jan 2022 10:58:40 +0000 (11:58 +0100)]
[lldb] Fix NativeThreadLinux to build with older compilers

2 years ago[lldb] Fix D114722 for python<=3.6
Pavel Labath [Wed, 19 Jan 2022 10:59:19 +0000 (11:59 +0100)]
[lldb] Fix D114722 for python<=3.6

_Py_IsFinalizing was called _Py_Finalizing back then (and it was a
variable instead of a function).

2 years ago[X86] Add some missing dependency-breaking zero idiom patterns to scheduler models
Simon Pilgrim [Wed, 19 Jan 2022 11:29:07 +0000 (11:29 +0000)]
[X86] Add some missing dependency-breaking zero idiom patterns to scheduler models

Many of the x86 scheduler models are not accounting for their microarch's ability to handle dependency-breaking zero idioms (pxor xmm0,xmm0 etc.), which is causing some notable differences when comparing llvm-mca reports to iaca, uops.info etc.

These are based on the Intel AoMs and Agner's docs which list the instructions handled on each cpu model - there may be more, although tbh the xor/pxor/xorps/xorpd are by far the most commonly encountered.

Once this is in place we also need to review missing support for 'allones' idioms and reg-reg move elimination, but this needs fixing first.

@lebedev.ri The Barcelona test changes are due to the cpu still being tagged as using the SandyBridge model, if/when you get back to D63628 these will need to be addressed.

Based on an original patch by @andreadb (Andrea Di Biagio)

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

2 years ago[AttrBuilder] Change storage to sorted vector (NFC)
Nikita Popov [Sat, 15 Jan 2022 09:05:22 +0000 (10:05 +0100)]
[AttrBuilder] Change storage to sorted vector (NFC)

This follows up on the work in D116599, which changed AttrBuilder
to store string attributes as SmallVector<Attribute>. This patch
changes the implementation to store *all* attributes as a sorted
vector.

This both makes the implementation simpler and improves compile-time.
We get a -0.5% geomean compile-time improvement on CTMark at O0.

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

2 years ago[NFC] Add missing <map> includes
Nikita Popov [Wed, 19 Jan 2022 11:19:03 +0000 (12:19 +0100)]
[NFC] Add missing <map> includes

These were relying on a transitive include.

2 years ago[clang][AVR] Implement '__flashN' for variables on different flash banks
Ben Shi [Sat, 18 Dec 2021 05:51:45 +0000 (05:51 +0000)]
[clang][AVR] Implement '__flashN' for variables on different flash banks

Reviewed By: aykevl

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

2 years ago[Doc] Fix wrong indentation
Saiyedul Islam [Wed, 19 Jan 2022 11:13:46 +0000 (11:13 +0000)]
[Doc] Fix wrong indentation

Handle Sphinx's warning at line 218.

2 years ago[Attributes] Make attribute addition behavior consistent
Nikita Popov [Tue, 18 Jan 2022 10:55:28 +0000 (11:55 +0100)]
[Attributes] Make attribute addition behavior consistent

Currently, the behavior when adding an attribute with the same key
as an existing attribute is inconsistent, depending on the type of
the attribute and the method used to add it. When going through
AttrBuilder::addAttribute(), the new attribute always overwrites
the old one. When going through AttrBuilder::merge() the new
attribute overwrites the existing one if it is a string attribute,
but keeps the existing one for int and type attributes. One
particular API also asserts that you can't overwrite an align
attribute, but does not handle any of the other int, type or string
attributes.

This patch makes the behavior consistent by always overwriting with
the new attribute, which is the behavior I would intuitively expect.
Two tests are affected, which now make a different (but equally
valid) choice. Those tests could be improved by taking the maximum
deref bytes, but I haven't bothered with that, since this is testing
a degenerate case -- the important bit is that it doesn't crash.

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

2 years ago[LoopFlatten] Update MemorySSA state
Sjoerd Meijer [Wed, 5 Jan 2022 13:48:57 +0000 (13:48 +0000)]
[LoopFlatten] Update MemorySSA state

I would like to move LoopFlatten from LoopPass Manager LPM2 to LPM1 (D116612),
but that is a LPM that is using MemorySSA and so LoopFlatten needs to preserve
MemorySSA and this adds that. More specifically, LoopFlatten restructures the
CFG and with this change the MSSA state is updated accordingly, where we also
update the DomTree. LoopFlatten doesn't rewrite/optimise/delete load or store
instructions, so I have not added any MSSA updates for that.

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

2 years ago[IR] Remove NumElements tracking from GEP type iterator
Nikita Popov [Wed, 19 Jan 2022 10:47:27 +0000 (11:47 +0100)]
[IR] Remove NumElements tracking from GEP type iterator

After ed0cdb29397ecd7d03579b846360906081d80aea, this is no longer
used by anything, and shouldn't be used by anything.

2 years ago[Doc] Add documentation for the clang-offload-wrapper tool (NFC)
Saiyedul Islam [Wed, 12 Jan 2022 15:44:10 +0000 (15:44 +0000)]
[Doc] Add documentation for the clang-offload-wrapper tool (NFC)

Add the missing documentation for this tool.

Reviewed By: sdmitriev

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

2 years ago[Constants] Remove unused isGEPWithNoNotionalOverIndexing() method
Nikita Popov [Wed, 19 Jan 2022 10:36:40 +0000 (11:36 +0100)]
[Constants] Remove unused isGEPWithNoNotionalOverIndexing() method

Since d56b0ad441a34ae6c353c823969397b451f053a6, this method is
no longer used -- and shouldn't be used.

2 years ago[ConstantHoist] Remove check for notional overindexing
Nikita Popov [Thu, 13 Jan 2022 09:07:33 +0000 (10:07 +0100)]
[ConstantHoist] Remove check for notional overindexing

ConstantHoist currently only hoists GEPs if there is no notional
overindexing. As this transform only hoists address arithmetic,
it shouldn't care about whether any overindexing occurs or not.

There is one caveat: If the hoisted base GEP is inbounds, and a
later non-inbounds GEP is rewritten in terms of it, the value
may be incorrectly poisoned. To avoid this, restrict the transform
to inbounds GEPs for now, as the notional overindexing check
effectively did that as well. The inbounds restriction could be
dropped by dropping inbounds from the base GEP expression.

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

2 years ago[Attributor] Remove notional overindexing check
Nikita Popov [Thu, 13 Jan 2022 09:49:36 +0000 (10:49 +0100)]
[Attributor] Remove notional overindexing check

AAPointerInfo currently bails on constant expression GEPs with
notional overindexing. I don't think this is necessary, as the
following code handling GEPOperator will deal with arbitrary
indices appropriately.

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

2 years ago[mlir] Introduce Python bindings for the PDL dialect
Denys Shabalin [Thu, 13 Jan 2022 09:53:21 +0000 (10:53 +0100)]
[mlir] Introduce Python bindings for the PDL dialect

This change adds full python bindings for PDL, including types and operations
with additional mixins to make operation construction more similar to the PDL
syntax.

Reviewed By: ftynse

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

2 years ago[X86][AVX] LowerFunnelShift - improve FSHL/FSHR per-element lowering
Simon Pilgrim [Tue, 18 Jan 2022 20:48:54 +0000 (20:48 +0000)]
[X86][AVX] LowerFunnelShift - improve FSHL/FSHR per-element lowering

Similar to LowerRotate, see if we can either unpack or extend to a wider type and use that type's per-element shift instruction

2 years ago[libc++] Fix GDB pretty printers when GDB uses Python 2.7
Alex Richardson [Wed, 19 Jan 2022 09:53:41 +0000 (09:53 +0000)]
[libc++] Fix GDB pretty printers when GDB uses Python 2.7

The gdb_pretty_printer_test.sh fails if GDB was built against Python 2.7
since Python 2 expects iterators to have a next() method rather than
using __next__. To make the pretty printers work with both Python 2 and 3
we can simply set next to __next__ in the iterator classes.

Python 2.7 support was removed in f46f93b4786377dd7ee704ef2beedadfe4f05adf,
so this partially reverts that commit. While Python 2.7 is EOL, it
appears there are still many GDB installations that are linked against
Python 2.7, so we may want to keep this tiny amount of compat code
around for a while longer.

Without this commit the tests fails with errors such as:
```
GDB printed:
   u"std::tuple containingTypeError: iter() returned non-iterator of type '_Children'\n"
Value should match:
   u'std::tuple containing = {[1] = 2, [2] = 3, [3] = 4}'
```

Reviewed By: #libc, ldionne

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

2 years ago[VPlan] Assert can IV is only used by increments during epilogue vec.
Florian Hahn [Wed, 19 Jan 2022 10:09:46 +0000 (10:09 +0000)]
[VPlan] Assert can IV is only used by increments during epilogue vec.

After resetting the start value of the canonical IV, it might not be
canonical any more. Add an assertion to make sure it is only used by its
increment, to avoid potential mis-use. Suggested in D117140.

2 years agoRevert "Revert "[clang][dataflow] Add a test to justify skipping past references...
Stanislav Gatev [Wed, 19 Jan 2022 09:28:02 +0000 (09:28 +0000)]
Revert "Revert "[clang][dataflow] Add a test to justify skipping past references in UO_Deref""

This reverts commit a0262043bb87fdef68c817722de320a5dd9eb9c9.

Add the -fno-delayed-template-parsing arg to fix the failing test on Windows.

2 years ago[AMDGPU] Fix missing waitcnt issue
Piotr Sobczak [Mon, 17 Jan 2022 16:51:23 +0000 (17:51 +0100)]
[AMDGPU] Fix missing waitcnt issue

Ignore out of order counters when merging brackets. The fact that
there was a pending event in the old state does not guarantee that
the waitcnt was generated, so we still need to conservatively re-process
the block.

The patch fixes a correctness issue where the block was not re-processed
and the waitcnt not inserted in consequence.

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

2 years ago[mlir][linalg][bufferize][NFC] Merge AllocationCallbacks into BufferizationOptions
Matthias Springer [Wed, 19 Jan 2022 09:34:48 +0000 (18:34 +0900)]
[mlir][linalg][bufferize][NFC] Merge AllocationCallbacks into BufferizationOptions

Also move `createAlloc` and related helper functions out of BufferizationState. The goal is to make BufferizationState as small as possible. (Code cleanup)

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

2 years ago[mlir][linalg][bufferize] Generalize destination-passing style detection
Matthias Springer [Wed, 19 Jan 2022 07:46:24 +0000 (16:46 +0900)]
[mlir][linalg][bufferize] Generalize destination-passing style detection

If not allow-return-memref, raise an error if a new memory allocation is returned/yielded from a block. We do not check for new allocations directly, but for ops that yield/return values that are not equivalent to values that are defined outside of the current of the block.

Note: We still need to check that scf.for yield values and bbArgs are aliasing to ensure that getAliasingOpOperand/getAliasingOpResult is correct.

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

2 years ago[clang-format] Fix incorrect alignment of operator= overloads.
Elliott Maguire [Wed, 19 Jan 2022 08:31:21 +0000 (09:31 +0100)]
[clang-format] Fix incorrect alignment of operator= overloads.

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

Added a check for operator keyword tokens.

Reviewed By: MyDeveloperDay, curdeius, owenpan, HazardyKnusperkeks

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

2 years ago[mlir][linalg][bufferize] Support scf.execute_region bufferization
Matthias Springer [Wed, 19 Jan 2022 07:45:54 +0000 (16:45 +0900)]
[mlir][linalg][bufferize] Support scf.execute_region bufferization

This op is needed for unit testing in a subsequent revision. (This is the first op that has a block that yields equivalent values via the op's results.)

Note: Bufferization of scf.execute_region ops with multiple blocks is not yet supported.

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

2 years ago[NFC][XCOFF] remove the tool name `yaml2obj` in the test.
esmeyi [Wed, 19 Jan 2022 09:11:21 +0000 (04:11 -0500)]
[NFC][XCOFF] remove the tool name `yaml2obj` in the test.

2 years ago[NFC][XCOFF] commit tests for D113552.
esmeyi [Wed, 19 Jan 2022 09:06:37 +0000 (04:06 -0500)]
[NFC][XCOFF] commit tests for D113552.

The code part of D113552 was committed at
817936408bad, where the test was left because
it depended on another patch.
There are no dependencies now.

2 years ago[AMDGPU] Tweak some compares in wave32.ll test
Jay Foad [Wed, 19 Jan 2022 08:13:46 +0000 (08:13 +0000)]
[AMDGPU] Tweak some compares in wave32.ll test

This prevents the compares from being optimized away when D86578 lands,
which seems unintended.

2 years ago[llvm-objcopy] Preserve ARM and AArch64 mapping symbols
Igor Kudrin [Wed, 19 Jan 2022 07:41:21 +0000 (14:41 +0700)]
[llvm-objcopy] Preserve ARM and AArch64 mapping symbols

Mapping symbols are required by ARM/AArch64 ELF ABI. They help to
disassemble files correctly and are also used in linkers. Nonetheless,
for executable files, the symbols can be stripped to better resemble
the behavior of GNU's objcopy.

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

2 years ago[ELF] Move SHT_REL/SHT_RELA handling from createInputSection to initializeSections
Fangrui Song [Wed, 19 Jan 2022 07:31:51 +0000 (23:31 -0800)]
[ELF] Move SHT_REL/SHT_RELA handling from createInputSection to initializeSections

This simplifies the code a bit. While here,

* change the `multiple relocation sections` diagnostic from `fatal` to `error` and include the relocated section name.
* drop less useful name from `getRelocTarget`. Without -r/--emit-relocs we don't need to get SHT_REL/SHT_RELA names.

2 years ago[mlir][tosa] Add tosa.clamp as no-op canonicalization
not-jenni [Wed, 19 Jan 2022 07:02:51 +0000 (23:02 -0800)]
[mlir][tosa] Add tosa.clamp as no-op canonicalization

When the min/max are the total range of the value, it is a no-op as the values
are already restricted to that range.

Reviewed By: rsuderman

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

2 years agoRevert "[clang][dataflow] Add a test to justify skipping past references in UO_Deref"
Stanislav Gatev [Wed, 19 Jan 2022 06:44:33 +0000 (06:44 +0000)]
Revert "[clang][dataflow] Add a test to justify skipping past references in UO_Deref"

This reverts commit 68226e572f41105446413b12ee95ab5540b2b6ac.

2 years ago[ELF] Simplify ObjFile<ELFT>::initializeSections. NFC
Fangrui Song [Wed, 19 Jan 2022 06:45:04 +0000 (22:45 -0800)]
[ELF] Simplify ObjFile<ELFT>::initializeSections. NFC

2 years agoFix GCC 5 MLIR Build (NFC)
Mehdi Amini [Wed, 19 Jan 2022 06:43:57 +0000 (06:43 +0000)]
Fix GCC 5 MLIR Build (NFC)

Try to fix the error:

mlir/lib/Parser/Parser.cpp:553:14: error: cannot call member function 'mlir::InFlightDiagnostic mlir::detail::Parser::emitError(llvm::SMLoc, const llvm::Twine&)' without object
              << "operation location alias was never defined";

2 years ago[RISCV] Add patterns for vector narrowing integer right shift instructions
eopXD [Mon, 17 Jan 2022 07:40:00 +0000 (23:40 -0800)]
[RISCV] Add patterns for vector narrowing integer right shift instructions

Reviewed By: craig.topper

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

2 years ago[libc][Obvious] Add -Wno-c++17-extensions to sinf, cosf and sincosf targets.
Siva Chandra Reddy [Wed, 19 Jan 2022 06:22:17 +0000 (06:22 +0000)]
[libc][Obvious] Add -Wno-c++17-extensions to sinf, cosf and sincosf targets.

2 years ago[BOLT][CMAKE] Use BOLT_CLANG_EXE and BOLT_LLD_EXE as is
Amir Ayupov [Wed, 19 Jan 2022 05:13:25 +0000 (21:13 -0800)]
[BOLT][CMAKE] Use BOLT_CLANG_EXE and BOLT_LLD_EXE as is

Add an ability to provide paths that don't match tool name exactly:
e.g. clang-13.
Remove use_lld call that sets up unused extra tools.

Test plan:
```
cmake -G Ninja ../llvm-project/llvm -DLLVM_TARGETS_TO_BUILD="X86;AArch64" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="bolt" -DBOLT_CLANG_EXE=/usr/bin/clang-13 -DBOLT_LLD_EXE=/usr/bin/lld-13
...
llvm-lit: /data/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using clang: /usr/bin/clang-13
llvm-lit: /data/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using lld: /usr/bin/lld-13

cmake -G Ninja ../llvm-project/llvm -DLLVM_TARGETS_TO_BUILD="X86;AArch64" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="bolt;lld" -DBOLT_CLANG_EXE=/usr/bin/clang-13
...
llvm-lit: /data/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using clang: /usr/bin/clang-13
llvm-lit: /data/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using lld: /data/llvm-build2/bin/lld

cmake -G Ninja ../llvm-project/llvm -DLLVM_TARGETS_TO_BUILD="X86;AArch64" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="bolt;clang;lld"
...
llvm-lit: /data/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using clang: /data/llvm-build3/bin/clang
llvm-lit: /data/llvm-project/llvm/utils/lit/lit/llvm/config.py:436: note: using lld: /data/llvm-build3/bin/lld
```

Reviewed By: maksfb

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

2 years ago[mlir] Convert OpTrait::FunctionLike to FunctionOpInterface
River Riddle [Fri, 14 Jan 2022 04:51:38 +0000 (20:51 -0800)]
[mlir] Convert OpTrait::FunctionLike to FunctionOpInterface

This commit refactors the FunctionLike trait into an interface (FunctionOpInterface).
FunctionLike as it is today is already a pseudo-interface, with many users checking the
presence of the trait and then manually into functionality implemented in the
function_like_impl namespace. By transitioning to an interface, these accesses are much
cleaner (ideally with no direct calls to the impl namespace outside of the implementation
of the derived function operations, e.g. for parsing/printing utilities).

I've tried to maintain as much compatability with the current state as possible, while
also trying to clean up as much of the cruft as possible. The general migration plan for
current users of FunctionLike is as follows:

* function_like_impl -> function_interface_impl
Realistically most user calls should remove references to functions within this namespace
outside of a vary narrow set (e.g. parsing/printing utilities). Calls to the attribute name
accessors should be migrated to the `FunctionOpInterface::` equivalent, most everything
else should be updated to be driven through an instance of the interface.

* OpTrait::FunctionLike -> FunctionOpInterface
`hasTrait` checks will need to be moved to isa, along with the other various Trait vs
Interface API differences.

* populateFunctionLikeTypeConversionPattern -> populateFunctionOpInterfaceTypeConversionPattern

Fixes #52917

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

2 years ago[libc] Remove as_double usage as constant initializations in sincosf implementation.
Tue Ly [Wed, 19 Jan 2022 01:14:14 +0000 (20:14 -0500)]
[libc] Remove as_double usage as constant initializations in sincosf implementation.

Use hexadecimal floats with C++17 instead of as_double as floating point constant initializations.

Reviewed By: sivachandra

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

2 years ago[flang] Convert uses of FunctionPass to OperationPass<FuncOp>
River Riddle [Wed, 19 Jan 2022 04:46:34 +0000 (20:46 -0800)]
[flang] Convert uses of FunctionPass to OperationPass<FuncOp>

FunctionPass has been deprecated and is in the process of being removed.

2 years ago[MLIR][OpenMP] Support schedule chunk size with various bit width
Peixin-Qiao [Wed, 19 Jan 2022 04:36:14 +0000 (12:36 +0800)]
[MLIR][OpenMP] Support schedule chunk size with various bit width

The chunk size in schedule clause is one integer expression, which can
be either constant integer or integer variable. Fix schedule clause in
MLIR Op Def to support integer expression with different bit width.

Reviewed By: shraiysh

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

2 years ago[mlir] Mark FunctionPass as deprecated using the C++14 deprecated attribute
River Riddle [Wed, 19 Jan 2022 04:18:47 +0000 (20:18 -0800)]
[mlir] Mark FunctionPass as deprecated using the C++14 deprecated attribute

2 years ago[mlir][Pass] Deprecate FunctionPass in favor of OperationPass<FuncOp>
River Riddle [Tue, 4 Jan 2022 23:41:17 +0000 (15:41 -0800)]
[mlir][Pass] Deprecate FunctionPass in favor of OperationPass<FuncOp>

The only benefit of FunctionPass is that it filters out function
declarations. This isn't enough to justify carrying it around, as we can
simplify filter out declarations when necessary within the pass. We can
also explore with better scheduling primitives to filter out declarations
at the pipeline level in the future.

The definition of FunctionPass is left intact for now to allow time for downstream
users to migrate.

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

2 years ago[libcxx][test] test _LIBCPP_VERSION with #ifdef, not #if
Casey Carter [Thu, 30 Dec 2021 01:53:16 +0000 (17:53 -0800)]
[libcxx][test] test _LIBCPP_VERSION with #ifdef, not #if

2 years ago[mlir][textmate] Add support for function visibility
Jacques Pienaar [Wed, 19 Jan 2022 02:48:43 +0000 (18:48 -0800)]
[mlir][textmate] Add support for function visibility

Avoids functions with visibility not being marked as functions. Tested
via Lightshow.

2 years ago[libc++] Re-enable the _BitInt test for std::atomic on Clang 14
Louis Dionne [Tue, 7 Dec 2021 16:31:50 +0000 (11:31 -0500)]
[libc++] Re-enable the _BitInt test for std::atomic on Clang 14

It should now work since the Clang on CI nodes has been updated.

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

2 years ago[debug-info] Add support for llvm.dbg.addr in DIBuilder.
Michael Gottesman [Sun, 16 Jan 2022 20:44:52 +0000 (12:44 -0800)]
[debug-info] Add support for llvm.dbg.addr in DIBuilder.

I based this off of the API already create for llvm.dbg.value since both
intrinsics have the same arguments at the API level.

I added some tests exercising the API a little as well as an additional small
test that shows how one can use llvm.dbg.addr to limit the PC range where an
address value is available in the debugger. This is done by calling
llvm.dbg.value with undef and the same metadata info as one used to create the
llvm.dbg.addr.

rdar://83957028

Reviewed By: aprantl

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

2 years ago[CSSPGO] Print "context-nested" instead of "preilnined" for ProfileSummarySection.
Hongtao Yu [Wed, 12 Jan 2022 20:21:54 +0000 (12:21 -0800)]
[CSSPGO] Print "context-nested" instead of "preilnined" for ProfileSummarySection.

Reviewed By: wenlei

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

2 years ago[NFC] Test commit to verify commit access.
Daniel Thornburgh [Wed, 19 Jan 2022 02:03:26 +0000 (18:03 -0800)]
[NFC] Test commit to verify commit access.

2 years ago[Coroutines] Offering llvm.coro.align intrinsic
Chuanqi Xu [Tue, 18 Jan 2022 07:19:50 +0000 (15:19 +0800)]
[Coroutines] Offering llvm.coro.align intrinsic

It is a known problem that we can't align the switch-based coroutine
frame if the alignment exceeds std::max_align_t (which is 16 usually).

We could solve the problem on the middle-end by dynamically transforming
or in the frontend by emitting aligned allocation function.

If we need to solve it in the frontend, the middle end need to offer an
intrinsic to tell the alignment at least. This patch tries to offer such
an intrinsic called llvm.coro.align.

Reviewed By: https://reviews.llvm.org/D117542

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

2 years agoUpdate bitcode format doc to mention that a multi-module bitcode file is
minglotus-6 [Wed, 12 Jan 2022 00:57:01 +0000 (16:57 -0800)]
Update bitcode format doc to mention that a multi-module bitcode file is
valid.

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

2 years ago[ELF] De-template InputSectionBase::getLocation. NFC
Fangrui Song [Wed, 19 Jan 2022 01:33:58 +0000 (17:33 -0800)]
[ELF] De-template InputSectionBase::getLocation. NFC

2 years ago[lldb] Print an error message when we're reading libobjc.A.dylib from memory
Jonas Devlieghere [Wed, 19 Jan 2022 00:37:30 +0000 (16:37 -0800)]
[lldb] Print an error message when we're reading libobjc.A.dylib from memory

Use libobjc.A.dylib as a sentinel to detect situations where we're
reading libraries from process memory instead of the shared cache.

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

2 years ago[ELF] Simplify/optimize EhInputSection::split
Fangrui Song [Wed, 19 Jan 2022 01:03:23 +0000 (17:03 -0800)]
[ELF] Simplify/optimize EhInputSection::split

and change some `fatal` to `errorOrWarn`.

EhFrame.cpp is a helper file. We don't place all .eh_frame implementation there,
so the code move is fine.

2 years ago[NFC][libunwind] Fix uintptr_t vs size_t confusion for lengths
Jessica Clarke [Tue, 18 Jan 2022 23:50:05 +0000 (23:50 +0000)]
[NFC][libunwind] Fix uintptr_t vs size_t confusion for lengths

These two are not conceptually the same; the former is a pointer shoved
in an integer, the latter is an offset or length. On the architectures
supported by libunwind, these two have the same underlying type, namely
unsigned int on ILP32, unsigned long on LP64 and unsigned long long on
LLP64. However, on CHERI, and thus Arm's Morello, they are not the same,
as pointers are hardware capabilities that carry additional metadata
including bounds and permissions, which is preserved in uintptr_t but
not in size_t. Thus, fix all length variables to be of type size_t not
uintptr_t, as we have done downstream for a while in CHERI LLVM but did
not get round to upstreaming.

Note that dyld_unwind_sections is currently defined in Apple's headers
as genuinely using uintptr_t to represent lengths. This is a bad API and
should be fixed, which would be totally API and ABI compatible due to
size_t and uintptr_t being the same type on all supported Apple systems,
but our definition is left matching theirs until such a time as they fix
their bogus types.

This is intended to be an NFC change on all architectures supported by
LLVM upstream, only being a functional change for CHERI downstream in
CHERI LLVM.

2 years agoAMDGPU: Fix using deprecated buffer intrinsics in test
Matt Arsenault [Tue, 18 Jan 2022 23:41:44 +0000 (18:41 -0500)]
AMDGPU: Fix using deprecated buffer intrinsics in test

2 years ago[llvm-jitlink] Prevent dead-stripping of test callback
Ben Langmuir [Tue, 18 Jan 2022 22:26:30 +0000 (14:26 -0800)]
[llvm-jitlink] Prevent dead-stripping of test callback

`llvm_jitlink_setTestResultOverride` is used via runtime lookup by
tests, so make sure it is not dead-stripped from llvm-jitlink in release
builds.

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

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

2 years ago[bazel] Port 755dc07d69ed
Benjamin Kramer [Tue, 18 Jan 2022 23:55:56 +0000 (00:55 +0100)]
[bazel] Port 755dc07d69ed

Still a fair bit of spaghetti in the unittest rules

2 years ago[lld-macho] Allow deduplicate-literals to be overridden
Vincent Lee [Sat, 15 Jan 2022 07:06:13 +0000 (23:06 -0800)]
[lld-macho] Allow deduplicate-literals to be overridden

It's still uncertain but whether we want to have `deduplicate-literals` be the
default flag for LLD out of the box or not. If `deduplicate-literals` is the default
behavior, then we will need a way override it and not deduplicate. Luckily, we
have `no_deduplicate` to fill this gap. For now, I've set the default to be false
which aligns with the existing behavior. That can only always be changed after
discussions on D117250.

Reviewed By: #lld-macho, int3

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

2 years ago[flang] Better messages for function vs. array errors
Peter Klausler [Sat, 8 Jan 2022 21:08:08 +0000 (13:08 -0800)]
[flang] Better messages for function vs. array errors

When a scalar-valued function with no distinct RESULT
is being called recursively in its own executable part,
emit a better message about the error.  Clean up the
code that resolves function vs. array ambiguities in
expression semantics.

Update to address review comment

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

2 years ago[MemoryBuiltins] Demote isMallocLikeFn to implementation routine since last use has...
Philip Reames [Tue, 18 Jan 2022 23:16:47 +0000 (15:16 -0800)]
[MemoryBuiltins] Demote isMallocLikeFn to implementation routine since last use has been removed

Try 2, this time including the test.

2 years ago[Libomptarget] Fix external visibility for internal variables
Joseph Huber [Tue, 18 Jan 2022 00:55:03 +0000 (19:55 -0500)]
[Libomptarget] Fix external visibility for internal variables

After the changes in D117362 made variables declared inside of a target
declare directive visible outside the plugin, some variables inside the
runtime were given visiblity that conflicted with their address space
type. This caused problems when shared or local memory was made
externally visible. This patch fixes this issue by making these
varialbes static within the module, therefore limiting their visibility
to being internal.

Reviewed By: jdoerfert

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

2 years ago[OpenMP] Remove hidden visibility for declare target variables
Joseph Huber [Fri, 14 Jan 2022 22:21:46 +0000 (17:21 -0500)]
[OpenMP] Remove hidden visibility for declare target variables

This patch changes the visiblity of variables declared within a declare
target directive. Variable declarations within a declare target
directive need to be externally visible to the plugin for initialization
or reading. Previously this would cause runtime errors where the named
global could not be found because it was not included in the symbol
table.

Reviewed By: jdoerfert

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

2 years agoRevert "[MemoryBuiltins] Demote isMallocLikeFn to implementation routine since last...
Philip Reames [Tue, 18 Jan 2022 23:16:12 +0000 (15:16 -0800)]
Revert "[MemoryBuiltins] Demote isMallocLikeFn to implementation routine since last use has been removed"

This reverts commit 167af7bbfe2d6e969c409b0cbe1af560b2b39e8f. Buildbot breaks since I forgot to remove a unit test.

2 years ago[MemoryBuiltins] Demote isMallocLikeFn to implementation routine since last use has...
Philip Reames [Tue, 18 Jan 2022 23:12:00 +0000 (15:12 -0800)]
[MemoryBuiltins] Demote isMallocLikeFn to implementation routine since last use has been removed

2 years ago[flang] runtime: catch OPEN(ACCESS='DIRECT',POSITION=)
Peter Klausler [Mon, 10 Jan 2022 20:34:51 +0000 (12:34 -0800)]
[flang] runtime: catch OPEN(ACCESS='DIRECT',POSITION=)

A POSITION= specifier may not be used on a direct access file.

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

2 years ago[flang] runtime error on inappropriate OPEN(UNIT=extant,RECL=n)
Peter Klausler [Mon, 10 Jan 2022 20:04:30 +0000 (12:04 -0800)]
[flang] runtime error on inappropriate OPEN(UNIT=extant,RECL=n)

Don't let a program set a fixed RECL= on a connected unit unless
it already had one with the same value.

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

2 years ago[LangRef] Clarify that inaccessiblememonly functions are allowed noalias returns
Philip Reames [Tue, 18 Jan 2022 22:46:58 +0000 (14:46 -0800)]
[LangRef] Clarify that inaccessiblememonly functions are allowed noalias returns

Confusion over this point came up in a couple of recent changes (D117180, e20b32ff3). Current tone of discussion seems to be that we think inaccessiblememonly was always legal on allocation functions, so this change takes the form of a clarification instead of a change.

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

2 years ago[linalg][fusion] Disallow fusion when it would create an invalid expand_shape
Benjamin Kramer [Tue, 4 Jan 2022 15:52:44 +0000 (16:52 +0100)]
[linalg][fusion] Disallow fusion when it would create an invalid expand_shape

The input type of a linalg.generic can be less dynamic than its output
type. If this is the case moving a reshape across the generic op would
create invalid IR, as expand_shape cannot expand arbitrary dynamic
dimensions.

Check that the reshape is actually valid before creating the
expand_shape. This exposes the existing verification logic in reshape
utils and removes the incomplete custom implementation in fusion.

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

2 years ago[mlir][linalg] Insert a cast for identity linalg.generics when the types don't match
Benjamin Kramer [Mon, 17 Jan 2022 16:38:07 +0000 (17:38 +0100)]
[mlir][linalg] Insert a cast for identity linalg.generics when the types don't match

This can happen when the result has different dynamic dimensions than
the input.

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

2 years ago[mlir] Fix bazel build of GPU dialect
Mogball [Tue, 18 Jan 2022 22:39:24 +0000 (22:39 +0000)]
[mlir] Fix bazel build of GPU dialect

2 years agoGlobalISel: Swap order of operand checks in ConstantFoldVectorBinop
Matt Arsenault [Tue, 18 Jan 2022 22:07:19 +0000 (17:07 -0500)]
GlobalISel: Swap order of operand checks in ConstantFoldVectorBinop

Since constants are canonicalized to the RHS, this is more likely to
exit early.

2 years agoGlobalISel: Fix CSEMIRBuilder mishandling constant folds of vectors
Matt Arsenault [Tue, 11 Jan 2022 14:46:18 +0000 (09:46 -0500)]
GlobalISel: Fix CSEMIRBuilder mishandling constant folds of vectors

This was ignoring the requested result register, resulting in a
missing def when this happened in the IRTranslator. Fixes some crashes
and verifier errors at -O0.

Alternatively we could pass DstOps to the constant fold functions.

2 years ago[lld][WebAssembly] Perform data relocations during start function
Sam Clegg [Sat, 15 Jan 2022 23:33:02 +0000 (15:33 -0800)]
[lld][WebAssembly] Perform data relocations during start function

We already perform memory initialization and apply global relocations
during start.  It makes sense to performs data relocations too.  I think
the reason we were not doing this already is solely historical.

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

2 years ago[sanitizer] Improve FreeBSD ASLR detection
Ed Maste [Mon, 17 Jan 2022 22:36:45 +0000 (17:36 -0500)]
[sanitizer] Improve FreeBSD ASLR detection

The kern.elf64.aslr.pie_enable and kern.elf32.aslr.pie_enable sysctls
control the default setting for PIE binary address randomization, but
it is possible to enable or disable ASLR on a per-process basis.  So,
use procctl(2) to query whether ASLR is enabled.

(Note that with ASLR enabled but sysctl kern.elf64.aslr.pie_enable=0
a PIE binary will in effect have randomization disabled, and would be
functional with msan.  This is not intended as as a user-facing control
though; proccontrol(1) should be used to disable aslr for the process.)

Reviewed By: devnexen

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

2 years agoGlobalISel: Fix legalization error where CSE leaves behind dead defs
Matt Arsenault [Fri, 7 Jan 2022 22:44:23 +0000 (17:44 -0500)]
GlobalISel: Fix legalization error where CSE leaves behind dead defs

If the conversion artifact introduced in the unmerge of cast of merge
combine already existed in the function, this would introduce dead
copies which kept the old casts around, neither of which were deleted,
and would fail legalization.

This would fail as follows:

The G_UNMERGE_VALUES of the G_SEXT of the G_BUILD_VECTOR would
introduce a G_SEXT for each of the scalars.

Some of the required G_SEXTs already existed in the function, so CSE
moves them up in the function and introduces a copy to the original
result register.

The introduced CSE copies are dead, since the originally G_SEXTs were
already directly used. These copies add a use to the illegal G_SEXTs,
so they are not deleted.

The artifact combiner does not see the defs that need to be updated,
since it was hidden inside the CSE builder.

I see 2 potential fixes, and opted for the mechanically simpler one,
which is to just not insert the cast if the result operand isn't
used. Alternatively, we could not insert the cast directly into the
result register, and use replaceRegOrBuildCopy similar to the case
where there is no conversion.

I suspect this is a wider problem in the artifact combiner.

2 years agoAllows deferred location attribute in `parseOptionalLocationSpecifier`
Mehdi Amini [Tue, 18 Jan 2022 20:55:35 +0000 (20:55 +0000)]
Allows deferred location attribute in `parseOptionalLocationSpecifier`

Before this patch, deferred location in operation like `test.pretty_printed_region` would
break the parser, and so the IR round-trip.

Depends On D117088

Reviewed By: rriddle

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

2 years agoAdding gitattributes for split-file tests
Chris Bieneman [Tue, 18 Jan 2022 21:37:10 +0000 (15:37 -0600)]
Adding gitattributes for split-file tests

This change gets the split-file tests passing on Windows when
autocrlf=true.