platform/upstream/llvm.git
2 years ago[lldb] Add a C language REPL to test LLDB's REPL infrastructure
Raphael Isemann [Thu, 23 Sep 2021 17:13:50 +0000 (19:13 +0200)]
[lldb] Add a C language REPL to test LLDB's REPL infrastructure

LLDB has a bunch of code that implements REPL support, but all that code is
unreachable as no language in master currently has an implemented REPL backend.
The only REPL that exists is in the downstream Swift fork. All patches for this
generic REPL code therefore also only have tests downstream which is clearly not
a good situation.

This patch implements a basic C language REPL on top of LLDB's REPL framework.
Beside implementing the REPL interface and hooking it up into the plugin
manager, the only other small part of this patch is making the `--language` flag
of the expression command compatible with the `--repl` flag. The `--repl` flag
uses the value of `--language` to see which REPL should be started, but right
now the `--language` flag is only available in OptionGroups 1 and 2, but not in
OptionGroup 3 where the `--repl` flag is declared.

The REPL currently can currently only start if a running target exists. I'll add
the 'create and run a dummy executable' logic from Swift (which is requires when
doing `lldb --repl`) when I have time to translate all this logic to something
that will work with Clang.

I should point out that the REPL currently uses the C expression parser's
approach to persistent variables where only result variables and the ones
starting with a '$' are transferred between expressions. I'll fix that in a
follow up patch. Also the REPL currently doesn't work in a non-interactive
terminal. This seems to be fixed in the Swift fork, so I assume one of our many
REPL downstream changes addresses the issue.

Reviewed By: JDevlieghere

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

2 years ago[compiler-rt][profile] Add padding after binary IDs
Leonard Chan [Thu, 23 Sep 2021 17:29:24 +0000 (10:29 -0700)]
[compiler-rt][profile] Add padding after binary IDs

Some tests with binary IDs would fail with error: no profile can be merged.
This is because raw profiles could have unaligned headers when emitting binary
IDs. This means padding should be emitted after binary IDs are emitted to
ensure everything else is aligned. This patch accounts for that padding in
__llvm_write_binary_ids.

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

2 years ago[flang] Implement READ(SIZE=) and INQUIRE(IOLENGTH=) in runtime
peter klausler [Mon, 20 Sep 2021 17:52:39 +0000 (10:52 -0700)]
[flang] Implement READ(SIZE=) and INQUIRE(IOLENGTH=) in runtime

Count input characters corresponding to formatted edit descriptors
for READ(SIZE=); count output bytes for INQUIRE(IOLENGTH=).

The I/O APIs GetSize() and GetLength() were adjusted to return
std::size_t as function results.

Basic unit tests were added (and others fixed).

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

2 years ago[libc++] Remove unused macro in __config
Louis Dionne [Wed, 22 Sep 2021 20:50:46 +0000 (16:50 -0400)]
[libc++] Remove unused macro in __config

That macro was being defined but not used anywhere in libc++, so it
must be safe to remove it.

As a fly-by fix, also remove mentions of this macro in other places
in LLVM, to make sure they were not depending on the value defined in
libc++.

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

2 years ago[ARM] Extra tests for unpredicated qr MVE intrinsics.
David Green [Thu, 23 Sep 2021 17:07:08 +0000 (18:07 +0100)]
[ARM] Extra tests for unpredicated qr MVE intrinsics.

2 years ago[fir][NFC] Remove fir.cmpf replaced by mlir.cmpf
Valentin Clement [Thu, 23 Sep 2021 17:04:39 +0000 (19:04 +0200)]
[fir][NFC] Remove fir.cmpf replaced by mlir.cmpf

fir.cmpf op is not necessary anymore as it is replaced by mlir.cmpf.
This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: schweitzpgi
Co-authored-by: jeanPerier
2 years agoRevert "[LiveIntervals] Fix repairOldRegInRange for simple def cases"
Jay Foad [Thu, 23 Sep 2021 16:55:05 +0000 (17:55 +0100)]
Revert "[LiveIntervals] Fix repairOldRegInRange for simple def cases"

This reverts commit 8229cb74125322ff337cfe316ab35c6ebf412bde.

It was failing on buildbots with expensive checks enabled.

2 years ago[fir][NFC] rename canBePointerOrHeapElementType to cannotBePointerOrHeapElementType
Valentin Clement [Thu, 23 Sep 2021 16:49:10 +0000 (18:49 +0200)]
[fir][NFC] rename canBePointerOrHeapElementType to cannotBePointerOrHeapElementType

This patch is part of the upstreaming effort from fir-dev branch.
Rename the function so the name conveys better what it does.

Reviewed By: jeanPerier

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

Co-authored-by: schweitz
Co-authored-by: jeanPerier
2 years ago[JumpThreading] Ignore free instructions
Nikita Popov [Wed, 22 Sep 2021 19:34:24 +0000 (21:34 +0200)]
[JumpThreading] Ignore free instructions

This is basically D108837 but for jump threading. Free instructions
should be ignored for the threading decision. JumpThreading already
skips some free instructions (like pointer bitcasts), but does not
skip various free intrinsics -- in fact, it currently gives them a
fairly large cost of 2.

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

2 years agoResolve {GlobalValue,GloalIndirectSymol}::getBaseObject confusion
Fangrui Song [Thu, 23 Sep 2021 16:23:35 +0000 (09:23 -0700)]
Resolve {GlobalValue,GloalIndirectSymol}::getBaseObject confusion

While both GlobalAlias and GlobalIFunc are GlobalIndirectSymbol, their
`getIndirectSymbol()` usage is quite different (GlobalIFunc's resolver
is an entity different from GlobalIFunc itself).

As discussed on https://lists.llvm.org/pipermail/llvm-dev/2020-September/144904.html
("[IR] Modelling of GlobalIFunc"), the name `getBaseObject` is confusing when
used with GlobalIFunc.

To resolve the confusion:

* Move GloalIndirectSymol::getBaseObject to GlobalAlias:: (GlobalIFunc should use `getResolver` instead)
* Change GlobalValue::getBaseObject not to inspect GlobalIFunc. Note: the function has 7 references.
* Add GlobalIFunc::getResolverFunction to peel off potential ConstantExpr indirection
  (`strlen` in `test/LTO/Resolution/X86/ifunc.ll`)

Note: GlobalIFunc::getResolver (like GlobalAlias::getAliasee which does not peel
off ConstantExpr indirection) is kept to be used by ValueEnumerator.

Reviewed By: ibookstein

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

2 years agoRevert "[lldb] [gdb-remote] Refactor getting remote regs to use local vector"
Michał Górny [Thu, 23 Sep 2021 16:16:51 +0000 (18:16 +0200)]
Revert "[lldb] [gdb-remote] Refactor getting remote regs to use local vector"

This reverts commit b03e701c145365ba339657ead54a2e0cc5c02776.  This is
causing regressions when XML support is disabled.

2 years agoRevert "[lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs"
Michał Górny [Thu, 23 Sep 2021 16:16:33 +0000 (18:16 +0200)]
Revert "[lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs"

This reverts commit 6fbed33d4a7de2229c40e6318f223092d3a23848.
The prerequisite commit is causing regressions.

2 years ago[LiveIntervals] Fix repairOldRegInRange for simple def cases
Jay Foad [Wed, 22 Sep 2021 11:14:18 +0000 (12:14 +0100)]
[LiveIntervals] Fix repairOldRegInRange for simple def cases

The fix applied in D23303 "LiveIntervalAnalysis: fix a crash in repairOldRegInRange"
was over-zealous. It would bail out when the end of the range to be
repaired was in the middle of the first segment of the live range of
Reg, which was always the case when the range contained a single def of
Reg.

This patch fixes it as suggested by Matthias Braun in post-commit review
on the original patch, and tests it by adding -early-live-intervals to
a selection of existing lit tests that now pass.

(Note that D23303 was originally applied to fix a crash in
SILoadStoreOptimizer, but that is now moot since D23814 updated
SILoadStoreOptimizer to run before scheduling so it no longer has to
update live intervals.)

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

2 years ago[libc++] Use CMake interface targets to setup benchmark flags
Louis Dionne [Wed, 12 Aug 2020 21:56:16 +0000 (17:56 -0400)]
[libc++] Use CMake interface targets to setup benchmark flags

This is a re-application of da0592e4c8df which was reverted in
1454018dc1d9 because it was incompatible with older CMakes.
Instead, disable the benchmarks when CMake is too old to
support those idioms.

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

2 years ago[PowerPC] Add range checks for P10 Vector Builtins
Quinn Pham [Mon, 13 Sep 2021 17:30:25 +0000 (12:30 -0500)]
[PowerPC] Add range checks for P10 Vector Builtins

This patch adds range checking for some Power10 altivec builtins and
changes the signature of a builtin to match documentation. For `vec_cntm`,
range checking is done via SemaChecking. For `vec_splati_ins`, the second
argument is masked to extract the 0th bit so that we always receive either a `0`
or a `1`.

Reviewed By: lei, amyk

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

2 years ago[SampleFDO] Remove redundant declarations (NFC)
Kazu Hirata [Thu, 23 Sep 2021 15:58:08 +0000 (08:58 -0700)]
[SampleFDO] Remove redundant declarations (NFC)

Note that these are declared in SampleProfileLoaderBaseUtil.h, which
SampleProfileLoaderBaseImpl.h includes.

2 years ago[RegAlloc] Cast uint8_t to unsigned before printing it.
Craig Topper [Thu, 23 Sep 2021 15:48:23 +0000 (08:48 -0700)]
[RegAlloc] Cast uint8_t to unsigned before printing it.

raw_ostream interprets uint8_t as wanting to print a character
with that ASCII value. In this case the uint8_t is an integer
that we want to print.

2 years ago[clang] Use portable "#!/usr/bin/env bash" shebang for tools and utils.
Frederic Cambus [Thu, 23 Sep 2021 15:46:11 +0000 (21:16 +0530)]
[clang] Use portable "#!/usr/bin/env bash" shebang for tools and utils.

Reviewed By: JDevlieghere

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

2 years ago[lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs
Michał Górny [Mon, 20 Sep 2021 10:20:17 +0000 (12:20 +0200)]
[lldb] [gdb-remote] Use local regnos for value_regs/invalidate_regs

Switch the gdb-remote client logic to use local (LLDB) register numbers
in value_regs/invalidate_regs rather than remote regnos. This involves
translating regnos received from lldb-server.

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

2 years ago[lldb] [gdb-remote] Refactor getting remote regs to use local vector
Michał Górny [Sat, 18 Sep 2021 18:00:40 +0000 (20:00 +0200)]
[lldb] [gdb-remote] Refactor getting remote regs to use local vector

Refactor remote register getters to collect them into a local
std::vector rather than adding them straight into DynamicRegisterInfo.
The purpose of this change is to lay groundwork for switching value_regs
and invalidate_regs to use local LLDB register numbers rather than
remote numbers.

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

2 years ago[x86] add AVX run to tests of fcmp logic; NFC
Sanjay Patel [Thu, 23 Sep 2021 13:59:47 +0000 (09:59 -0400)]
[x86] add AVX run to tests of fcmp logic; NFC

The ISA before AVX has predicate gaps for both fcmp
codegen alternatives, so that requires a more
complicated fix to get ideal asm in all cases.

2 years agoSupport: Fix missing whitespace in comment for inconvertibleErrorCode(), NFC
Duncan P. N. Exon Smith [Thu, 23 Sep 2021 15:09:26 +0000 (11:09 -0400)]
Support: Fix missing whitespace in comment for inconvertibleErrorCode(), NFC

2 years agoFix buildbot error.
Haojian Wu [Thu, 23 Sep 2021 15:03:40 +0000 (17:03 +0200)]
Fix buildbot error.

-frounding-math is not available for all targets.

2 years agoPass some DataLayout arguments by const-ref
Simon Pilgrim [Thu, 23 Sep 2021 14:35:22 +0000 (15:35 +0100)]
Pass some DataLayout arguments by const-ref

Avoid unnecessary copies, reported by MSVC static analyzer.

2 years ago[AMDGPU] Avoid processing functions in amdgpu-propagate-attributes pass for shaders
Piotr Sobczak [Fri, 17 Sep 2021 12:12:23 +0000 (14:12 +0200)]
[AMDGPU] Avoid processing functions in amdgpu-propagate-attributes pass for shaders

The pass amdgpu-propagate-attributes ("Early/Late propagate attributes
from kernels to functions") is currently run also for shaders, where
it does nothing. Modify the check so the pass only processes functions
for kernels.

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

2 years ago[Sema] Fix a null pointer reference crash.
Haojian Wu [Thu, 23 Sep 2021 09:01:37 +0000 (11:01 +0200)]
[Sema] Fix a null pointer reference crash.

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

2 years ago[ORC][examples] Fix segfault in LLJITWithTargetProcessControl
Stefan Gränitz [Thu, 23 Sep 2021 14:30:05 +0000 (16:30 +0200)]
[ORC][examples] Fix segfault in LLJITWithTargetProcessControl

Issue reported during review D110260

2 years agoclangd: Do not report inline overrides twice
Christian Kandeler [Thu, 23 Sep 2021 13:45:01 +0000 (15:45 +0200)]
clangd: Do not report inline overrides twice

... in textDocument/references.

Reviewed By: sammccall

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

2 years ago[CostModel][X86] Increase i64 mul cost from 1 to 2
Simon Pilgrim [Thu, 23 Sep 2021 13:48:08 +0000 (14:48 +0100)]
[CostModel][X86] Increase i64 mul cost from 1 to 2

Only the most recent cpus support really 1cy 64-bit multiplies, and the X64 cost table represents a realistic worst case. The 1cy value was also discouraging vectorization when most vXi64 PMULDQ expansions aren't actually slower than scalarization.

Noticed while investigating PR51436.

2 years ago[InstCombine] fold cast of right-shift if high bits are not demanded (2nd try)
Sanjay Patel [Thu, 23 Sep 2021 13:40:01 +0000 (09:40 -0400)]
[InstCombine] fold cast of right-shift if high bits are not demanded (2nd try)

The 1st try at this was reverted because it caused an infinite loop in instcombine.
That should be fixed after:
1cd6b44f267b

(masked) trunc (lshr X, C) --> (masked) lshr (trunc X), C

Narrowing the shift should be better for analysis and can lead
to follow-on transforms as shown.

Attempt at a general proof in Alive2:
https://alive2.llvm.org/ce/z/tRnnSF

Here are a couple of the specific tests:
https://alive2.llvm.org/ce/z/bCnTp-
https://alive2.llvm.org/ce/z/TfaHnb

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

2 years ago[gn build] Port f4abdb0c074b
LLVM GN Syncbot [Thu, 23 Sep 2021 13:34:40 +0000 (13:34 +0000)]
[gn build] Port f4abdb0c074b

2 years ago[gn build] (manually) port ac191bcc99e2f
Nico Weber [Thu, 23 Sep 2021 13:34:24 +0000 (09:34 -0400)]
[gn build] (manually) port ac191bcc99e2f

2 years ago[gn build] (semi-manually) port 702cb7afe9de
Nico Weber [Thu, 23 Sep 2021 13:26:18 +0000 (09:26 -0400)]
[gn build] (semi-manually) port 702cb7afe9de

2 years ago[CodeGen] update test file to not run the entire LLVM optimizer; NFC
Sanjay Patel [Thu, 23 Sep 2021 12:53:28 +0000 (08:53 -0400)]
[CodeGen] update test file to not run the entire LLVM optimizer; NFC

Clang regression tests should not break when changes are made to
the LLVM optimizer. This file broke on the 1st attempt at D110170,
so I'm trying to prevent that on another try.

Similar to other files in this directory, we make a compromise and
run -mem2reg to reduce noise by about 1000 lines out of 5000+ CHECK lines.

2 years ago[libc++] Remove uses of _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
Louis Dionne [Wed, 22 Sep 2021 13:46:19 +0000 (09:46 -0400)]
[libc++] Remove uses of _LIBCPP_HAS_NO_VARIABLE_TEMPLATES

All supported compilers provide support for variable templates now.

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

2 years agotsan: remove expected race leftover
Dmitry Vyukov [Thu, 23 Sep 2021 11:52:49 +0000 (13:52 +0200)]
tsan: remove expected race leftover

Remove nmissed_expected variable.
It's a leftover from removed "expected race" feature and is never incremented.

Reviewed By: melver

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

2 years ago[DSE] Track earliest escape, use for loads in isReadClobber.
Florian Hahn [Thu, 23 Sep 2021 07:54:46 +0000 (08:54 +0100)]
[DSE] Track earliest escape, use for loads in isReadClobber.

At the moment, DSE only considers whether a pointer may be captured at
all in a function. This leads to cases where we fail to remove stores to
local objects because we do not check if they escape before potential
read-clobbers or after.

Doing context-sensitive escape queries in isReadClobber has been removed
a while ago in d1a1cce5b130 to save compile-time. See PR50220 for more
context.

This patch introduces a new capture tracker, which keeps track of the
'earliest' capture. An instruction A is considered earlier than instruction
B, if A dominates B. If 2 escapes do not dominate each other, the
terminator of the common dominator is chosen. If not all uses cannot be
analyzed, the earliest escape is set to the first instruction in the
function entry block.

If the query instruction dominates the earliest escape and is not in a
cycle, then pointer does not escape before the query instruction.

This patch uses this information when checking if a load of a loaded
underlying object may alias a write to a stack object. If the stack
object does not escape before the load, they do not alias.

I will share a follow-up patch to also use the information for call
instructions to fix PR50220.

In terms of compile-time, the impact is low in general,
    NewPM-O3: +0.05%
    NewPM-ReleaseThinLTO: +0.05%
    NewPM-ReleaseLTO-g: +0.03

with the largest change being tramp3d-v4 (+0.30%)
http://llvm-compile-time-tracker.com/compare.php?from=1a3b3301d7aa9ab25a8bdf045c77298b087e3930&to=bc6c6899cae757c3480f4ad4874a76fc1eafb0be&stat=instructions

Compared to always computing the capture information on demand, we get
the following benefits from the caching:
NewPM-O3: -0.03%
NewPM-ReleaseThinLTO: -0.08%
NewPM-ReleaseLTO-g: -0.04%

The biggest speedup is tramp3d-v4 (-0.21%).
http://llvm-compile-time-tracker.com/compare.php?from=0b0c99177d1511469c633282ef67f20c851f58b1&to=bc6c6899cae757c3480f4ad4874a76fc1eafb0be&stat=instructions

Overall there is a small, but noticeable benefit from caching. I am not
entirely sure if the speedups warrant the extra complexity of caching.
The way the caching works also means that we might miss a few cases, as
it is less precise. Also, there may be a better way to cache things.

Reviewed By: nikic

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

2 years ago[RISCV] Add missing op type OPERAND_UIMM2, OPERAND_UIMM3 and OPERAND_UIMM7 for verify...
Jim Lin [Thu, 23 Sep 2021 11:23:00 +0000 (19:23 +0800)]
[RISCV] Add missing op type OPERAND_UIMM2, OPERAND_UIMM3 and OPERAND_UIMM7 for verifyInstruction

Reviewed By: craig.topper

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

2 years ago[CodeGen] ProcessSDDbgValues - use const-ref value in for-range loop. NFCI.
Simon Pilgrim [Wed, 22 Sep 2021 17:40:22 +0000 (18:40 +0100)]
[CodeGen] ProcessSDDbgValues - use const-ref value in for-range loop. NFCI.

Avoid unnecessary copies, reported by MSVC static analyzer.

2 years ago[CodeGen] RegisterCoalescer::buildVRegToDbgValueMap - use const-ref value in for...
Simon Pilgrim [Wed, 22 Sep 2021 17:38:10 +0000 (18:38 +0100)]
[CodeGen] RegisterCoalescer::buildVRegToDbgValueMap - use const-ref value in for-range loop. NFCI.

Avoid unnecessary copies, reported by MSVC static analyzer.

2 years ago[BasicBlockUtils] Fixup of an assumed typo in MergeBlockIntoPredecessor
Bjorn Pettersson [Thu, 23 Sep 2021 10:13:28 +0000 (12:13 +0200)]
[BasicBlockUtils] Fixup of an assumed typo in MergeBlockIntoPredecessor

The NFC commit e5692a564a73ef63b7b changed the logic for
DomTreeUpdates to use the range [succ_begin, succ_begin) when
looking for SuccsOfPredBB rather than using [succ_begin, succ_end).

As the commit was NFC this is identified as a typo (it has been
discussed briefly in phabricator).

The typo was found when inspecting the code, so I've got no idea if
changing back to the old range has any significant impact (such as
solving any PR:s or causing some new problems). But at least this
restores the code to the originally indented behavior.

2 years ago[lldb] Fix DomainSocket::GetSocketName for unnamed sockets
Pavel Labath [Thu, 23 Sep 2021 09:31:33 +0000 (11:31 +0200)]
[lldb] Fix DomainSocket::GetSocketName for unnamed sockets

getpeername will return addrlen = 2 (sizeof sa_family_t) for unnamed
sockets (those not assigned a name with bind(2)). This is typically true
for client sockets as well as those created by socketpair(2).

This GetSocketName used to crash for sockets which were connected to
these kinds of sockets. Now it returns an empty string.

2 years ago[RISCV][VP] Add support for VP_REDUCE_* operations
Fraser Cormack [Thu, 5 Aug 2021 12:54:37 +0000 (13:54 +0100)]
[RISCV][VP] Add support for VP_REDUCE_* operations

This patch adds codegen support for lowering the vector-predicated
reduction intrinsics to RVV instructions. The process is similar to that
of the other reduction intrinsics, save for the fact that every VP
reduction has a start value. We reuse the existing custom "VL" nodes,
adding extra patterns where required to handle non-true masks.

To support these nodes, the `RISCVISD::VECREDUCE_*_VL` nodes have been
given an explicit "merge" operand. This is to faciliate the VP
reductions, where we must be careful to ensure that even if no operation
is performed (when VL=0) we still produce the start value. The RVV
reductions don't update the destination register under these conditions,
so we tie the splatted start value to the output register.

Reviewed By: craig.topper

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

2 years ago[fir][NFC] inline trival isa_<type> functions
Valentin Clement [Thu, 23 Sep 2021 09:08:26 +0000 (11:08 +0200)]
[fir][NFC] inline trival isa_<type> functions

This patch is part of the upstreaming effort from fir-dev branch and sync changes. Inline trival `isa_<type>` functions.

Co-authored-by: schweitzpgi
Reviewed By: kiranchandramohan

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

2 years agotsan: move shadow declaration into a separate header file (NFC)
Dmitry Vyukov [Wed, 22 Sep 2021 17:25:28 +0000 (19:25 +0200)]
tsan: move shadow declaration into a separate header file (NFC)

tsan_rtl.h is very huge and contains too many things.
Move FastState and Shadow types into a new tsan_shadow.h file.
This also allows to use FastState/Shadow in other header files
without creating circular dependencies (which most likely will
happen today).

Reviewed By: melver

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

2 years agotsan: use RawShadow instead of u64 more
Dmitry Vyukov [Wed, 22 Sep 2021 16:41:03 +0000 (18:41 +0200)]
tsan: use RawShadow instead of u64 more

Fix few remaining cases where we use u64 instead of the new RawShadow type.

Depends on D110265.

Reviewed By: melver

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

2 years agotsan: add another deep stack test
Dmitry Vyukov [Wed, 22 Sep 2021 15:56:52 +0000 (17:56 +0200)]
tsan: add another deep stack test

Add a test for a trace corner case that lead to a bug
in experimental runtime replacement.
Since it passes with the current runtime it makes sense
to submit it on its own.

Depends on D110264.

Reviewed By: melver

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

2 years agotsan: remove DontDumpShadow from Go build
Dmitry Vyukov [Wed, 22 Sep 2021 15:50:54 +0000 (17:50 +0200)]
tsan: remove DontDumpShadow from Go build

DontDumpShadow is used only in InitializeShadowMemory which is Go-only.

Depends on D110263.

Reviewed By: melver

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

2 years agotsan: remove unnecessary enum values (NFC)
Dmitry Vyukov [Wed, 22 Sep 2021 15:48:11 +0000 (17:48 +0200)]
tsan: remove unnecessary enum values (NFC)

Remove unnecessary enum values in the memory profiler.
There is no point in spelling them, it can only lead to bugs
and larger diffs when values are added/removed.

Reviewed By: melver

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

2 years ago[InstSimplify] Don't lose inbounds when simplifying a GEP
Alex Richardson [Thu, 23 Sep 2021 08:02:23 +0000 (09:02 +0100)]
[InstSimplify] Don't lose inbounds when simplifying a GEP

I noticed this while working on a (ptrtoint (gep null, x)) -> x fold.

Reviewed By: nikic

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

2 years ago[libc] Add optimized memset for AArch64
Andre Vieira [Thu, 23 Sep 2021 08:19:47 +0000 (09:19 +0100)]
[libc] Add optimized memset for AArch64

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

2 years agoRevert "[Driver] Correctly handle static C++ standard library"
Petr Hosek [Thu, 23 Sep 2021 08:13:10 +0000 (01:13 -0700)]
Revert "[Driver] Correctly handle static C++ standard library"

This reverts commit 5e28c892d06f95600f8b6290ad4de38bfe142637 as
the linker on the clang-ppc64le-rhel bot doesn't seem to support
--push-state/--pop-state.

2 years ago[Driver] Correctly handle static C++ standard library
Petr Hosek [Tue, 21 Sep 2021 06:25:21 +0000 (23:25 -0700)]
[Driver] Correctly handle static C++ standard library

When statically linking C++ standard library, we shouldn't add -Bdynamic
after including the library on the link line because that might override
user settings like -static and -static-pie. Rather, we should surround
the library with --push-state/--pop-state to make sure that -Bstatic
only applies to C++ standard library and nothing else. This has been
supported since GNU ld 2.25 (2014) so backwards compatibility should
no longer be a concern.

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

2 years ago[TII] Remove the MFI argument to convertToThreeAddress. NFC.
Jay Foad [Wed, 22 Sep 2021 09:24:56 +0000 (10:24 +0100)]
[TII] Remove the MFI argument to convertToThreeAddress. NFC.

This simplifies the API and addresses a FIXME in
TwoAddressInstructionPass::convertInstTo3Addr.

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

2 years ago[DAGCombiner] Rename isAlias as mayAlias. NFC
Bjorn Pettersson [Fri, 17 Sep 2021 17:48:20 +0000 (19:48 +0200)]
[DAGCombiner] Rename isAlias as mayAlias. NFC

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

2 years ago[ModuleInlinerWrapperPass] Do some naive printing of wrapped pipeline with -print...
Bjorn Pettersson [Thu, 16 Sep 2021 11:38:50 +0000 (13:38 +0200)]
[ModuleInlinerWrapperPass] Do some naive printing of wrapped pipeline with -print-pipeline-passes

Bisecting and reducing opt pipelines that includes the
ModuleInlinerWrapperPass has turned out to be a bit problematic.
This is far from perfect (it still lacks information about inline
advisor params etc.), but it should give some kind of hint to what
the wrapped pipeline looks like when using -print-pipeline-passes.

Reviewed By: aeubanks, mtrofin

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

2 years ago[clangd] Ensure lambda init-capture gets semantic token
Nathan Ridge [Tue, 21 Sep 2021 07:44:31 +0000 (03:44 -0400)]
[clangd] Ensure lambda init-capture gets semantic token

Prior to this patch, CollectExtraHighlightings would incorrectly produce
a token for the init-capture's type which overlapped the name and
resulted in both being dropped.

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

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

2 years ago[NFC] Wrap MLIR addAffineForOpDomain warning with LLVM_DEBUG
Tharindu Rusira [Thu, 23 Sep 2021 07:24:24 +0000 (12:54 +0530)]
[NFC] Wrap MLIR addAffineForOpDomain warning with LLVM_DEBUG

Current warning message in method `addAffineForOpDomain` of mlir/lib/Analysis/AffineStructures.cpp is being printed to the stdout/stderr.
This patch redirects the warning with LLVM_DEBUG following standard llvm practice.

Reviewed By: bondhugula

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

2 years agoWrap xar/xar.h include in extern "C" block
Mike Hommey [Thu, 23 Sep 2021 07:25:36 +0000 (09:25 +0200)]
Wrap xar/xar.h include in extern "C" block

Without such wrapping, linking lld fails with missing symbols because of
C++ symbol mangling with older versions of the MacOSX SDK, in which
xar.h doesn't have an extern "C" block itself.

Reviewed By: #lld-macho, thakis

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

2 years ago[X86][FP16] Combine the FADD(A, FMA(B, C, 0)) to FMA(B, C, A)
Liu, Chen3 [Fri, 17 Sep 2021 07:11:20 +0000 (15:11 +0800)]
[X86][FP16] Combine the FADD(A, FMA(B, C, 0)) to FMA(B, C, A)

This patch is to support transform something like
_mm512_add_ph(acc, _mm512_fmadd_pch(a, b, _mm512_setzero_ph()))
to _mm512_fmadd_pch(a, b, acc).

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

2 years ago[clang][tooling] NFC: Refactor command-line diagnostic tests
Jan Svoboda [Tue, 21 Sep 2021 11:52:17 +0000 (13:52 +0200)]
[clang][tooling] NFC: Refactor command-line diagnostic tests

This patch uses a different command-line arguments to test `clang::tooling::ToolInvocation` that are not specific to Darwin.

Reviewed By: dexonsmith

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

2 years ago[mlir] Fix build on Windows on Arm
Diana Picus [Wed, 22 Sep 2021 07:07:33 +0000 (09:07 +0200)]
[mlir] Fix build on Windows on Arm

clang-cl errors out while handling the templated version of tgfmt. This
patch works around the issue by explicitly choosing the non-templated
version of tgfmt, which takes an ArrayRef<std::string>.

More details in this thread:
https://lists.llvm.org/pipermail/cfe-dev/2021-September/068936.html

Thanks @Mehdi Amini for suggesting the fix :)

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

2 years ago[AMDGPU] Fix gcc warnings about unused variables [NFC]
Mikael Holmen [Thu, 23 Sep 2021 06:07:45 +0000 (08:07 +0200)]
[AMDGPU] Fix gcc warnings about unused variables [NFC]

2 years ago[libc++][spaceship] Implement std::pair::operator<=>
Kent Ross [Thu, 23 Sep 2021 05:36:23 +0000 (22:36 -0700)]
[libc++][spaceship] Implement std::pair::operator<=>

Implements parts of P1614, including synth-three-way and three way comparison for std::pair.

Reviewed By: #libc, Quuxplusone, Mordante

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

2 years ago[OpenMP][FIX] Be more deliberate about invalidating the AAKernelInfo state
Johannes Doerfert [Wed, 8 Sep 2021 20:54:27 +0000 (15:54 -0500)]
[OpenMP][FIX] Be more deliberate about invalidating the AAKernelInfo state

This patch fixes a problem when the AAKernelInfo state was invalidated,
e.g., due to `optnone` for a kernel, but not all parts indicated the
invalidation properly. We further eliminate most full state
invalidations as they should never be necessary.

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

2 years ago[OpenMP][NFC] Repair test that contained nested kernels
Johannes Doerfert [Wed, 8 Sep 2021 20:55:57 +0000 (15:55 -0500)]
[OpenMP][NFC] Repair test that contained nested kernels

The benchmark contained (partially) nested kernels, something we do not
generate nor support.

2 years ago[OpenMP][NFC] Rerun the test check update script on all OpenMP-Opt tests
Johannes Doerfert [Wed, 8 Sep 2021 21:00:06 +0000 (16:00 -0500)]
[OpenMP][NFC] Rerun the test check update script on all OpenMP-Opt tests

2 years ago[OpenMP][NFC] Precommit test that exposes a bug in our optnone handling
Johannes Doerfert [Wed, 8 Sep 2021 17:59:44 +0000 (12:59 -0500)]
[OpenMP][NFC] Precommit test that exposes a bug in our optnone handling

2 years ago[OpenMP][NFC] Improve debug output
Johannes Doerfert [Wed, 8 Sep 2021 16:56:51 +0000 (11:56 -0500)]
[OpenMP][NFC] Improve debug output

2 years ago[OpenMP][NFC] Clang format OMPIRBuilder
Johannes Doerfert [Thu, 2 Sep 2021 16:12:36 +0000 (11:12 -0500)]
[OpenMP][NFC] Clang format OMPIRBuilder

These files should be kept clang-formatted but diverge sometimes.

2 years ago[AArch64][SVE][InstCombine] Eliminate redundant chains of tuple get/set
Usman Nadeem [Tue, 14 Sep 2021 04:32:19 +0000 (21:32 -0700)]
[AArch64][SVE][InstCombine] Eliminate redundant chains of tuple get/set

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

Change-Id: I06a3c28e3658ecda109a3a1b73265828274ab2ea

2 years ago[demangle] Support for ISO/IEC TS 18661 binary floating point type
Pengfei Wang [Thu, 23 Sep 2021 03:02:25 +0000 (11:02 +0800)]
[demangle] Support for ISO/IEC TS 18661 binary floating point type

Reviewed By: #libc_abi, ldionne

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

2 years ago[X86][FP16] Change the order of the operands in complex FMA intrinsics to allow swap...
Wang, Pengfei [Thu, 23 Sep 2021 02:13:52 +0000 (10:13 +0800)]
[X86][FP16] Change the order of the operands in complex FMA intrinsics to allow swap between the mul operands.

Reviewed By: craig.topper

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

2 years ago[MLIR] [Python] Make Attribute and Type hashable
John Demme [Thu, 23 Sep 2021 02:50:22 +0000 (19:50 -0700)]
[MLIR] [Python] Make Attribute and Type hashable

Enables putting types and attributes in sets and in dicts as keys.

Reviewed By: stellaraccident

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

2 years ago[NFC] Remove redundant setOperationAction.
Freddy Ye [Thu, 23 Sep 2021 02:27:45 +0000 (10:27 +0800)]
[NFC] Remove redundant setOperationAction.

[FROUND,FROUNDEVEN][f32, f64, f128] are set Expand twice.

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

2 years ago[RISCV] Update mir tests.
Hsiangkai Wang [Wed, 22 Sep 2021 23:47:50 +0000 (07:47 +0800)]
[RISCV] Update mir tests.

2 years ago[llvm-profgen] Fix a dangling vector reference in CS line number based generator
wlei [Wed, 22 Sep 2021 18:14:46 +0000 (11:14 -0700)]
[llvm-profgen] Fix a dangling vector reference in CS line number based generator

It seems we missed one spot to persist `SampleContextFrameVector` into the global table (CSProfileGenerator::populateFunctionBoundarySamples:340) which causes a crash.

This change tried to fix it in a centralized way i. e. where we generate the `FunctionSamples`.

Reviewed By: hoy, wenlei

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

2 years ago[llvm-profgen] Fix an out-of-range error during unwinding
wlei [Wed, 22 Sep 2021 17:24:54 +0000 (10:24 -0700)]
[llvm-profgen] Fix an out-of-range error during unwinding

It happened that the LBR entry target can be the first address of text section which causes an out-of-range crash. So here add a boundary check.

Reviewed By: hoy, wenlei

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

2 years ago[llvm-profgen] Fix a bug of assertion
wlei [Wed, 22 Sep 2021 17:13:42 +0000 (10:13 -0700)]
[llvm-profgen] Fix a bug of assertion

The assertion should work on the entire context.

Reviewed By: hoy, wenlei

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

2 years ago[NFC][InstCombine] Fix inconsistent comments
hyeongyu kim [Thu, 23 Sep 2021 00:31:39 +0000 (09:31 +0900)]
[NFC][InstCombine] Fix inconsistent comments

2 years ago[libc++] Fix __wrap_iter to be a proper contiguous iterator.
Arthur O'Dwyer [Tue, 21 Sep 2021 20:35:16 +0000 (16:35 -0400)]
[libc++] Fix __wrap_iter to be a proper contiguous iterator.

Instead of overloading `__to_address`, let's specialize `pointer_traits`.
Function overloads need to be in scope at the point where they're called,
whereas template specializations do not. (User code can provide pointer_traits
specializations to be used by already-included library code, so obviously
`__wrap_iter` can do the same.)

`pointer_traits<__wrap_iter<It>>` cannot provide `pointer_to`, because
you generally cannot create a `__wrap_iter` without also knowing the
identity of the container into which you're trying to create an iterator.
I believe this is OK; contiguous iterators are required to provide
`to_address` but *not* necessarily `pointer_to`.

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

2 years ago[Polly] Dissolve Isl test directory. NFC.
Michael Kruse [Wed, 22 Sep 2021 22:45:07 +0000 (17:45 -0500)]
[Polly] Dissolve Isl test directory. NFC.

All tests use ISL, integrate its subfolder into the components they
belong to.

2 years ago[Polly] Implement user-directed loop distribution/fission.
Michael Kruse [Wed, 22 Sep 2021 22:27:16 +0000 (17:27 -0500)]
[Polly] Implement user-directed loop distribution/fission.

This is a simple version without the possibility to define distribute
points or followup-transformations. However, it is the first
transformation that has to check whether the transformation is correct.

It interprets the same metadata as the LoopDistribute pass.

2 years ago[compiler-rt][test] Add REQUIRES for checking static libc++abi
Leonard Chan [Wed, 22 Sep 2021 22:25:05 +0000 (15:25 -0700)]
[compiler-rt][test] Add REQUIRES for checking static libc++abi

intercept-rethrow-exception.cc fails when running runtimes tests if linking in
a hermetic libc++abi. This is because if libc++abi is used, then asan expects
to intercept __cxa_rethrow_primary_exception on linux, which should unpoison the
stack. If we statically link in libc++abi though, it will contain a strong
definition for __cxa_rethrow_primary_exception which wins over the weakly
defined interceptor provided by asan, causing the test to fail by not unpoisoning
the stack on the exception being thrown.

It's likely no one has encountered this before and possible that upstream tests
opt for dynamically linking where the interceptor can work properly. An ideal
long term solution would be to update the interceptor and libc++[abi] APIs to
work for this case, but that will likely take a long time to work out. In the
meantime, since the test isn't necessarily broken, we can just add another
REQUIRES check to make sure that it's only run if we aren't statically linking
in libc++abi.

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

2 years ago[NFC] Remove trailing spaces from some files
Shilei Tian [Wed, 22 Sep 2021 22:16:56 +0000 (18:16 -0400)]
[NFC] Remove trailing spaces from some files

2 years ago[llvm-profgen] Use hot threshold for context merging and trimming
Wenlei He [Wed, 22 Sep 2021 01:17:49 +0000 (18:17 -0700)]
[llvm-profgen] Use hot threshold for context merging and trimming

Without preinliner, we need to tune down the cold count cutoff to merge/trim more context to limit profile size for large components. However it doesn't make sense for cold threshold to be higher than hot threshold, so we now change to use hot threshold as merging/trimming cut off instead.

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

2 years ago[mlir][sparse] add sparse kernels test to sparse compiler test suite
Aart Bik [Mon, 20 Sep 2021 18:15:13 +0000 (11:15 -0700)]
[mlir][sparse] add sparse kernels test to sparse compiler test suite

This test makes sure kernels map to efficient sparse code, i.e. all
compressed for-loops, no co-iterating while loops.  In addition, this
revision removes the special constant folding inside the sparse
compiler in favor of Mahesh' new generic linalg folding. Thanks!

NOTE: relies on Mahesh fix, which needs to be rebased first

Reviewed By: bixia

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

2 years ago[WebAssembly] Add relaxed-simd feature
Zhi An Ng [Wed, 22 Sep 2021 21:52:50 +0000 (14:52 -0700)]
[WebAssembly] Add relaxed-simd feature

This currently only defines a constant, but it the future will be used
to gate builtins for experimenting and prototyping relaxed-simd proposal
(https://github.com/WebAssembly/relaxed-simd/).

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

2 years ago[flang] Catch error: base of DATA statement object can't be a pointer
peter klausler [Tue, 14 Sep 2021 20:37:11 +0000 (13:37 -0700)]
[flang] Catch error: base of DATA statement object can't be a pointer

A pointer with subscripts, substring indices, or components cannot
be initialized by a DATA statement (although of course a whole pointer
can be so).  Catch the missing cases.

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

2 years agoDiagnose -Wunused-value based on CFG reachability
Yuanfang Chen [Thu, 24 Jun 2021 06:46:42 +0000 (23:46 -0700)]
Diagnose -Wunused-value based on CFG reachability

While at it, add the diagnosis message "left operand of comma operator has no effect" (used by GCC) for comma operator.

This also makes Clang diagnose in the constant evaluation context which aligns with GCC/MSVC behavior. (https://godbolt.org/z/7zxb8Tx96)

Reviewed By: aaron.ballman

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

2 years ago[RISCV] Remove stale FIXMEs from float-convert.ll and double-convert.ll. NFC
Craig Topper [Wed, 22 Sep 2021 21:25:40 +0000 (14:25 -0700)]
[RISCV] Remove stale FIXMEs from float-convert.ll and double-convert.ll. NFC

2 years ago[RISCV] Add fcvt.s.w(u)/fcvt.d.w(u)/fcvt.h.w(u) to hasAllNBitUsers
Craig Topper [Wed, 22 Sep 2021 21:21:03 +0000 (14:21 -0700)]
[RISCV] Add fcvt.s.w(u)/fcvt.d.w(u)/fcvt.h.w(u) to hasAllNBitUsers

These instructions only read the lower 32 bits of their input.

2 years ago[RISCV] Add test cases showing failure to use ADDIW before fcvt.s.w/fcvt.d.w/fcvt...
Craig Topper [Wed, 22 Sep 2021 21:16:30 +0000 (14:16 -0700)]
[RISCV] Add test cases showing failure to use ADDIW before fcvt.s.w/fcvt.d.w/fcvt.h.w. NFC

By not using ADDIW we can cause both an ADDIW and ADDI to be emitted
when the add has multiple users.

These instructions needed be added to the list of instructions that
only use the lower 32 bits of input.

I've also added tests for the wu versions, but I'm having trouble
showing bad codegen from it.

2 years agoFix bug for Ops with default valued attributes and successors/variadic regions.
Tyler Augustine [Wed, 22 Sep 2021 20:44:02 +0000 (20:44 +0000)]
Fix bug for Ops with default valued attributes and successors/variadic regions.

When both a DefaultValuedAttr and a successor or variadic region was specified, this would generate invalid C++ declaration. There would be the parameter with a default value, followed by the successors/regions, which don't have a default, which is invalid.

Reviewed By: mehdi_amini

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

2 years ago[OpenMP][Offloading] Change `bool IsSPMD` to `int8_t Mode` in `__kmpc_target_init...
Shilei Tian [Wed, 22 Sep 2021 21:16:28 +0000 (17:16 -0400)]
[OpenMP][Offloading] Change `bool IsSPMD` to `int8_t Mode` in `__kmpc_target_init` and `__kmpc_target_deinit`

This is a follow-up of D110029, which uses bitset to indicate execution mode. This patches makes the changes in the function call.

Reviewed By: jdoerfert

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

2 years ago[Clang] Ignore BTFTag attr if used as a type attribute
Yonghong Song [Mon, 20 Sep 2021 23:23:46 +0000 (16:23 -0700)]
[Clang] Ignore BTFTag attr if used as a type attribute

Currently, linux kernel has a __user attribute ([1]) defined as
   __attribute__((noderef, address_space(__user)))
which is used by sparse tool ([2]) to do some
type checking of pointers to user space memory.
During normal compilation, __user will be defined
to nothing so it won't have an impact on compilation.

The btf_tag attribute, which is motivated by
carrying linux kernel annotations into dwarf/BTF,
is introduced in [3]. We intended to define __user as
   __attribute__((btf_tag("user")))
so such information will be encoded in dwarf/BTF
and can be used later by bpf verification or other
tracing tools.

But linux kernel __user attribute is also used during
type conversion which btf_tag doesn't support ([4]) since
such type conversion is only used for compiler analysis
and not encoded in dwarf/btf. Theoretically, it is
possible for clang to understand these tags and
do a sparse-like type checking work. But I would like
to leave that to future work and for now suggest simply
ignore these btf_tag attributes if they are used
as type attributes.

  [1] https://github.com/torvalds/linux/blob/master/include/linux/compiler_types.h#L10
  [2] https://sparse.docs.kernel.org/en/latest/
  [3] https://reviews.llvm.org/D106614
  [4] https://github.com/torvalds/linux/blob/master/fs/binfmt_flat.c#L135

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

2 years ago[mlir][Linalg] Teach constant -> generic op fusion to handle scalar constants.
MaheshRavishankar [Wed, 22 Sep 2021 18:14:19 +0000 (11:14 -0700)]
[mlir][Linalg] Teach constant -> generic op fusion to handle scalar constants.

The current folder of constant -> generic op only handles splat
constants. The same logic holds for scalar constants. Teach the
pattern to handle such cases.

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

2 years ago[libc++][NFC] Add missing whitespace in <compare>
Louis Dionne [Wed, 22 Sep 2021 20:41:11 +0000 (16:41 -0400)]
[libc++][NFC] Add missing whitespace in <compare>

2 years ago[InstCombine] add one-use check to shift-shift transform
Sanjay Patel [Wed, 22 Sep 2021 20:16:49 +0000 (16:16 -0400)]
[InstCombine] add one-use check to shift-shift transform

We don't want to create extra instructions, and this
could infinite loop with the proposed transform in D110170.

2 years ago[InstCombine] add test for shift-shift with extra use; NFC
Sanjay Patel [Wed, 22 Sep 2021 20:15:47 +0000 (16:15 -0400)]
[InstCombine] add test for shift-shift with extra use; NFC