platform/upstream/llvm.git
2 years ago[GlobalOpt] Don't replace alias with aliasee if either alias/aliasee may be preemptible
Fangrui Song [Tue, 1 Feb 2022 18:41:16 +0000 (10:41 -0800)]
[GlobalOpt] Don't replace alias with aliasee if either alias/aliasee may be preemptible

Generalize D99629 for ELF. A default visibility non-local symbol is preemptible
in a -shared link. `isInterposable` is an insufficient condition.

Moreover, a non-preemptible alias may be referenced in a sub constant expression
which intends to lower to a PC-relative relocation. Replacing the alias with a
preemptible aliasee may introduce a linker error.

Respect dso_preemptable and suppress optimization to fix the abose issues. With
the change, `alias = 345` will not be rewritten to use aliasee in a `-fpic`
compile.
```
int aliasee;
extern int alias __attribute__((alias("aliasee"), visibility("hidden")));
void foo() { alias = 345; } // intended to access the local copy
```

While here, refine the condition for the alias as well.

For some binary formats like COFF, `isInterposable` is a sufficient condition.
But I think canonicalization for the changed case has little advantage, so I
don't bother to add the `Triple(M.getTargetTriple()).isOSBinFormatELF()` or
`getPICLevel/getPIELevel` complexity.

For instrumentations, it's recommended not to create aliases that refer to
globals that have a weak linkage or is preemptible. However, the following is
supported and the IR needs to handle such cases.
```
int aliasee __attribute__((weak));
extern int alias __attribute__((alias("aliasee")));
```

There are other places where GlobalAlias isInterposable usage may need to be
fixed.

Reviewed By: rnk

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

2 years ago[NewPM] Don't skip SCCs not in current RefSCC
Arthur Eubanks [Wed, 16 Mar 2022 21:57:36 +0000 (14:57 -0700)]
[NewPM] Don't skip SCCs not in current RefSCC

With D107249 I saw huge compile time regressions on a module (150s ->
5700s). This turned out to be due to a huge RefSCC in
the module. As we ran the function simplification pipeline on functions
in the SCCs in the RefSCC, some of those SCCs would be split out to
their RefSCC, a child of the current RefSCC. We'd skip the remaining
SCCs in the huge RefSCC because the current RefSCC is now the RefSCC
just split out, then revisit the original huge RefSCC from the
beginning.  This happened many times because many functions in the
RefSCC were optimizable to the point of becoming their own RefSCC.

This patch makes it so we don't skip SCCs not in the current RefSCC so
that we split out all the child RefSCCs on the first iteration of
RefSCC. When we split out a RefSCC, we invalidate the original RefSCC
and add the remainder of the SCCs into a new RefSCC in
RCWorklist. This happens repeatedly until we finish visiting all
SCCs, at which point there is only one valid RefSCC in
RCWorklist from the original RefSCC containing all the SCCs that
were not split out, and we visit that.

For example, in the newly added test cgscc-refscc-mutation-order.ll,
we'd previously run instcombine in this order:
f1, f2, f1, f3, f1, f4, f1

Now it's:
f1, f2, f3, f4, f1

This can cause more passes to be run in some specific cases,
e.g. if f1<->f2 gets optimized to f1<-f2, we'd previously run f1, f2;
now we run f1, f2, f2.

This improves kimwitu++ compile times by a lot (12-15% for various -O3 configs):
https://llvm-compile-time-tracker.com/compare.php?from=2371c5a0e06d22b48da0427cebaf53a5e5c54635&to=00908f1d67400cab1ad7bcd7cacc7558d1672e97&stat=instructions

Reviewed By: asbirlea

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

2 years ago[RGT] StencilTest: Fix an assertion
Paul Robinson [Fri, 18 Mar 2022 20:40:02 +0000 (13:40 -0700)]
[RGT] StencilTest: Fix an assertion

ASSERT_THAT_EXPECTED implicitly calls takeError(), and calling
takeError() a second time returns nothing, so the check for the
content of the error text wasn't being executed.
Fixes Issue #48901

Found by the Rotten Green Tests project.

2 years ago[OpenMP] Initial parsing/sema for the 'omp target teams loop' construct
Mike Rice [Fri, 18 Mar 2022 18:02:02 +0000 (11:02 -0700)]
[OpenMP] Initial parsing/sema for the 'omp target teams loop' construct

 Adds basic parsing/sema/serialization support for the
 #pragma omp target teams loop directive.

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

2 years agoFix computation of MadeChange bit in AtomicExpandPass.
Eli Friedman [Fri, 18 Mar 2022 20:26:37 +0000 (13:26 -0700)]
Fix computation of MadeChange bit in AtomicExpandPass.

Fixes llvm-clang-x86_64-expensive-checks-debian failure with 2f497ec3.

expandAtomicStore always modifies the function, so make sure we set
MadeChange unconditionally. Not sure how nobody else has stumbled over
this before.

2 years agoDriver: Make macOS the default target OS for -arch arm64
Duncan P. N. Exon Smith [Fri, 18 Mar 2022 20:08:26 +0000 (13:08 -0700)]
Driver: Make macOS the default target OS for -arch arm64

This is a follow up to 565603cc94d79a8d0de6df840fd53714899fb890,
which made macOS the default target OS for `-arch arm64` when
running on an Apple Silicon Mac. Now it'll be the default when
running on an Intel Mac too.

clang/test/Driver/apple-arm64-arch.c was a bit odd before: it was added
for the above commit, but tested the inverse behaviour and XFAIL'ed on
Apple Silicon. This inverts it to the (new) behaviour (that's now
correct regardless) and removes the XFAIL.

Radar-Id: rdar://90500294

2 years ago[AMDGPU] Added gfx940 mfma dst constraint test. NFC.
Stanislav Mekhanoshin [Fri, 18 Mar 2022 20:34:35 +0000 (13:34 -0700)]
[AMDGPU] Added gfx940 mfma dst constraint test. NFC.

2 years ago[AMDGPU] gfx940 basic speed model
Stanislav Mekhanoshin [Thu, 17 Mar 2022 22:24:00 +0000 (15:24 -0700)]
[AMDGPU] gfx940 basic speed model

This is incomplete and will handle more instructions as they are added.

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

2 years ago[AMDGPU] Disable some MFMA instructions on gfx940
Stanislav Mekhanoshin [Thu, 17 Mar 2022 21:14:47 +0000 (14:14 -0700)]
[AMDGPU] Disable some MFMA instructions on gfx940

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

2 years agoUpdate llvm-config.h.cmake for 7b983917d4
Sterling Augustine [Fri, 18 Mar 2022 19:58:14 +0000 (12:58 -0700)]
Update llvm-config.h.cmake for 7b983917d4

2 years ago[AMDGPU] reuse blgp as neg in 2 mfma operations on gfx940
Stanislav Mekhanoshin [Mon, 14 Mar 2022 20:32:56 +0000 (13:32 -0700)]
[AMDGPU] reuse blgp as neg in 2 mfma operations on gfx940

GFX940 repurposes BLGP as NEG only in DGEMM MFMA.

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

2 years ago[scudo] Fix static and unused function type annotations
Dominic Chen [Wed, 16 Mar 2022 20:46:23 +0000 (13:46 -0700)]
[scudo] Fix static and unused function type annotations

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

2 years ago[scudo] Don't assume preprocessor macro is defined
Dominic Chen [Wed, 16 Mar 2022 20:50:07 +0000 (13:50 -0700)]
[scudo] Don't assume preprocessor macro is defined

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

2 years ago[ARM] Fix ARM backend to correctly use atomic expansion routines.
Eli Friedman [Thu, 17 Feb 2022 09:24:16 +0000 (01:24 -0800)]
[ARM] Fix ARM backend to correctly use atomic expansion routines.

Without this patch, clang would generate calls to __sync_* routines on
targets where it does not make sense; we can't assume the routines exist
on unknown targets. Linux has special implementations of the routines
that work on old ARM targets; other targets have no such routines. In
general, atomics operations which aren't natively supported should go
through libatomic (__atomic_*) APIs, which can support arbitrary atomics
through locks.

ARM targets older than v6, where this patch makes a difference, are rare
in practice, but not completely extinct. See, for example, discussion on
D116088.

This also affects Cortex-M0, but I don't think __sync_* routines
actually exist in any Cortex-M0 libraries. So in practice this just
leads to a slightly different linker error for those cases, I think.

Mechanically, this patch does the following:

- Ensures we run atomic expansion unconditionally; it never makes sense to
completely skip it.
- Fixes getMaxAtomicSizeInBitsSupported() so it returns an appropriate
number on all ARM subtargets.
- Fixes shouldExpandAtomicRMWInIR() and shouldExpandAtomicCmpXchgInIR() to
correctly handle subtargets that don't have atomic instructions.

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

2 years agoReland "[gn build] (manually) port 6316129e066e"
Nico Weber [Fri, 18 Mar 2022 19:43:02 +0000 (15:43 -0400)]
Reland "[gn build] (manually) port 6316129e066e"

This reverts commit 21b97df74c15aa29a9d5ca54e3033eae6c97362d.
6316129e066e relanded in 7b983917d455.

2 years ago[libc++] Enable modernize-loop-convert
Nikolas Klauser [Tue, 8 Mar 2022 15:27:22 +0000 (16:27 +0100)]
[libc++] Enable modernize-loop-convert

Reviewed By: ldionne, Mordante, #libc

Spies: var-const, aheejin, libcxx-commits

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

2 years ago[polly] Fix NPM unittests after D121566.
Michael Kruse [Fri, 18 Mar 2022 19:21:18 +0000 (14:21 -0500)]
[polly] Fix NPM unittests after D121566.

2 years agoAdd a cmake flag to turn `llvm_unreachable()` into builtin_trap() when assertions...
Mehdi Amini [Thu, 17 Mar 2022 22:19:33 +0000 (22:19 +0000)]
Add a cmake flag to turn `llvm_unreachable()` into builtin_trap() when assertions are disabled

This re-lands 6316129e066e after fixing the condition logic.

The new flag seems to not be working yet on Windows, where the builtin
trap isn't "no return".

Reviewed By: dexonsmith

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

2 years agoUse llvm::append_range where applicable
Benjamin Kramer [Fri, 18 Mar 2022 19:05:12 +0000 (20:05 +0100)]
Use llvm::append_range where applicable

It knows the size, so no need to call reserve beforehand. NFCI.

2 years ago[CostModel][X86] Reduce cost of extracting bool vector elements
Simon Pilgrim [Fri, 18 Mar 2022 19:02:42 +0000 (19:02 +0000)]
[CostModel][X86] Reduce cost of extracting bool vector elements

For constant indices, these are now just a MOVMSK+TEST/BT

2 years ago[SLP] Add comment clarifying assumption that tripped me up [NFC]
Philip Reames [Fri, 18 Mar 2022 18:34:22 +0000 (11:34 -0700)]
[SLP] Add comment clarifying assumption that tripped me up [NFC]

I keep thinking this assumption is probably exploitable for a bug in the existing implementation, but all of my attempts at writing a test case have failed.  So for the moment, just document this very subtle assumption.

2 years ago[Vectorize] Fix an 'unused function' warning
Kazu Hirata [Fri, 18 Mar 2022 18:24:57 +0000 (11:24 -0700)]
[Vectorize] Fix an 'unused function' warning

This patch fixes:

  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3917:13: error:
  unused function 'needToScheduleSingleInstruction'
  [-Werror,-Wunused-function]

2 years ago[VE] Fix an 'unused variable' warning
Kazu Hirata [Fri, 18 Mar 2022 18:24:56 +0000 (11:24 -0700)]
[VE] Fix an 'unused variable' warning

This patch fixes:

  llvm/lib/Target/VE/VVPISelLowering.cpp:186:11: error: unused
  variable 'PassThru' [-Werror,-Wunused-variable]

2 years ago[Vectorize] Fix an 'unused variable' warning
Kazu Hirata [Fri, 18 Mar 2022 18:24:54 +0000 (11:24 -0700)]
[Vectorize] Fix an 'unused variable' warning

This patch fixes:

  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:8148:18: error:
  unused variable 'SDTE' [-Werror,-Wunused-variable]

2 years ago[SCCP] do not clean up dead blocks that have their address taken
Nick Desaulniers [Fri, 18 Mar 2022 17:48:28 +0000 (10:48 -0700)]
[SCCP] do not clean up dead blocks that have their address taken

[SCCP] do not clean up dead blocks that have their address taken

Fixes a crash observed in IPSCCP.

Because the SCCPSolver has already internalized BlockAddresses as
Constants or ConstantExprs, we don't want to try to update their Values
in the ValueLatticeElement. Instead, continue to propagate these
BlockAddress Constants, continue converting BasicBlocks to unreachable,
but don't delete the "dead" BasicBlocks which happen to have their
address taken.  Leave replacing the BlockAddresses to another pass.

Fixes: https://github.com/llvm/llvm-project/issues/54238
Fixes: https://github.com/llvm/llvm-project/issues/54251

Reviewed By: nikic

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

2 years ago[libc++] Make shared_ptr move unique_ptr's deleter
Asher Mancinelli [Fri, 18 Mar 2022 17:36:25 +0000 (11:36 -0600)]
[libc++] Make shared_ptr move unique_ptr's deleter

Addresses LWG 3548 which mandates that when shared_ptr is being constructed from a unique_ptr, the unique_ptr's deleter should be moved and not copied.

Reviewed By: #libc, philnik, EricWF

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

2 years agoRevert "[SLP] Optionally preserve MemorySSA"
Philip Reames [Fri, 18 Mar 2022 17:28:21 +0000 (10:28 -0700)]
Revert "[SLP] Optionally preserve MemorySSA"

This reverts commit 1cfa986d68e2f04854ef30c432b8aa28e13a9706.  See https://github.com/llvm/llvm-project/issues/54256 for why I'm discontinuing the project.

Seperately, it turns out that while this patch does correctly preserve MSSA, it's correct only at the end of the pass; not between vectorization attempts.  Even if we decide to resurrect this, we'll need to fix that before reapplying.

2 years ago[HWASan] do not replace lifetime intrinsics with tagged address.
Florian Mayer [Fri, 18 Mar 2022 17:06:04 +0000 (10:06 -0700)]
[HWASan] do not replace lifetime intrinsics with tagged address.

Quote from the LLVM Language Reference
  If ptr is a stack-allocated object and it points to the first byte of the
  object, the object is initially marked as dead. ptr is conservatively
  considered as a non-stack-allocated object if the stack coloring algorithm
  that is used in the optimization pipeline cannot conclude that ptr is a
  stack-allocated object.

By replacing the alloca pointer with the tagged address before this change,
we confused the stack coloring algorithm.

Reviewed By: eugenis

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

2 years ago[trace][intelpt] fix some test failures
Walter Erquinigo [Fri, 18 Mar 2022 16:22:27 +0000 (09:22 -0700)]
[trace][intelpt] fix some test failures

Minor fixes needed and now `./bin/lldb-dotest -p TestTrace` passes
correctly.

- There was an incorrect iteration.
- Some error messages changed.
- The way repeat commands are handled changed a bit, so I had to create
a new --continue arg in "thread trace dump instructions" to handle this
correctly.

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

2 years agoRevert "[pseudo] Split greatergreater token."
Zequan Wu [Fri, 18 Mar 2022 17:15:05 +0000 (10:15 -0700)]
Revert "[pseudo] Split greatergreater token."

This reverts commit f66d3758bda99e9f57bfdad168212feda18792ae.

It breaks windows bot.

2 years agoImplement __cpuid and __cpuidex as Clang builtins
Alan Zhao [Fri, 18 Mar 2022 17:08:04 +0000 (18:08 +0100)]
Implement __cpuid and __cpuidex as Clang builtins

https://reviews.llvm.org/D23944 implemented the #pragma intrinsic from
MSVC. This causes the statement #pragma intrinsic(cpuid) to fail [0]
on Clang because cpuid is currently implemented in intrin.h instead
of a Clang builtin. Reimplementing cpuid (as well as it's releated
function, cpuidex) should resolve this.

[0]: https://crbug.com/1279344

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

2 years ago[CMake][Fuchsia] Drop Darwin architectures
Petr Hosek [Fri, 18 Mar 2022 17:02:46 +0000 (10:02 -0700)]
[CMake][Fuchsia] Drop Darwin architectures

We want to build all available ones.

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

2 years ago[CMake][Fuchsia] Include llvm-undname
Petr Hosek [Fri, 18 Mar 2022 17:04:33 +0000 (10:04 -0700)]
[CMake][Fuchsia] Include llvm-undname

This is useful when developing on Windows.

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

2 years agoRevert "[HWASan] do not replace lifetime intrinsics with tagged address."
Florian Mayer [Fri, 18 Mar 2022 17:04:19 +0000 (10:04 -0700)]
Revert "[HWASan] do not replace lifetime intrinsics with tagged address."

Failed on buildbot:

/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/llc: error: : error: unable to get target for 'aarch64-unknown-linux-android29', see --version and --triple.
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck /home/buildbot/buildbot-root/llvm-project/llvm/test/Instrumentation/HWAddressSanitizer/stack-coloring.ll --check-prefix=COLOR

This reverts commit 208b923e74feeb986fe5114ca39a74b1d2032ed7.

2 years ago[MLIR][MemRef] Nested allocation scope inlining
William S. Moses [Fri, 18 Mar 2022 06:53:55 +0000 (02:53 -0400)]
[MLIR][MemRef] Nested allocation scope inlining

If a stack allocation is within a nested allocation scope
don't count that as an allocation of the outer allocation scope
that would prevent inlining.

Reviewed By: ftynse

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

2 years ago[runtimes] Detect changes to Tests.cmake
Petr Hosek [Mon, 14 Mar 2022 21:21:26 +0000 (14:21 -0700)]
[runtimes] Detect changes to Tests.cmake

This ensures that Tests.cmake is tracked by Ninja and any changes to
this file from the subbuilds are correctly detected.

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

2 years ago[MLIR][SCF] Combine nested ifs with yields
William S. Moses [Thu, 17 Mar 2022 17:01:33 +0000 (13:01 -0400)]
[MLIR][SCF] Combine nested ifs with yields

This patch extends the existing combine nested if
combination canonicalization to also handle ifs which
yield values

Reviewed By: ftynse

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

2 years ago[LICM] Add allowspeculation pass options.
Florian Hahn [Fri, 18 Mar 2022 16:51:56 +0000 (16:51 +0000)]
[LICM] Add allowspeculation pass options.

This adds a new option to control AllowSpeculation added in D119965 when
using `-passes=...`.

This allows reproducing #54023 using opt.

Reviewed By: aeubanks

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

2 years ago[HWASan] do not replace lifetime intrinsics with tagged address.
Florian Mayer [Thu, 10 Mar 2022 23:17:26 +0000 (15:17 -0800)]
[HWASan] do not replace lifetime intrinsics with tagged address.

Quote from the LLVM Language Reference
  If ptr is a stack-allocated object and it points to the first byte of the
  object, the object is initially marked as dead. ptr is conservatively
  considered as a non-stack-allocated object if the stack coloring algorithm
  that is used in the optimization pipeline cannot conclude that ptr is a
  stack-allocated object.

By replacing the alloca pointer with the tagged address before this change,
we confused the stack coloring algorithm.

Reviewed By: eugenis

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

2 years ago[RISCV][NFC] Add tests to address invalid arch dependencies.
Zakk Chen [Fri, 18 Mar 2022 08:46:11 +0000 (01:46 -0700)]
[RISCV][NFC] Add tests to address invalid arch dependencies.

Improve test converage.

Reviewed By: asb

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

2 years ago[flang][Parser] Add a node for individual sections in sections construct
Shraiysh Vaishay [Fri, 18 Mar 2022 15:07:25 +0000 (20:37 +0530)]
[flang][Parser] Add a node for individual sections in sections construct

This patch adds parser nodes for each indivudual section in sections
construct. This should help with the translation to FIR. `!$omp section`
was not recognized as a construct and hence needed special handling.

`OpenMPSectionsConstruct` contains a list of `OpenMPConstruct`. Each
such `OpenMPConstruct` wraps an `OpenMPSectionConstruct`
(section, not sections). An `OpenMPSectionConstruct` is a wrapper around
a `Block`.

Reviewed By: kiranchandramohan, peixin

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

2 years ago[ARM][AArch64] generate subtarget feature flags
Tomas Matheson [Wed, 23 Feb 2022 11:34:41 +0000 (11:34 +0000)]
[ARM][AArch64] generate subtarget feature flags

Reland of D120906 after sanitizer failures.

This patch aims to reduce a lot of the boilerplate around adding new subtarget
features. From the SubtargetFeatures tablegen definitions, a series of calls to
the macro GET_SUBTARGETINFO_MACRO are generated in
ARM/AArch64GenSubtargetInfo.inc.  ARMSubtarget/AArch64Subtarget can then use
this macro to define bool members and the corresponding getter methods.

Some naming inconsistencies have been fixed to allow this, and one unused
member removed.

This implementation only applies to boolean members; in future both BitVector
and enum members could also be generated.

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

2 years ago[lldb] Remove lldb/lldb subdir created by wrong patch level
Jonas Devlieghere [Fri, 18 Mar 2022 16:06:11 +0000 (09:06 -0700)]
[lldb] Remove lldb/lldb subdir created by wrong patch level

Bad application of patch -p<level>.

2 years ago[OpenMP][FIX] Make test check lines less strict
Johannes Doerfert [Fri, 18 Mar 2022 15:51:33 +0000 (10:51 -0500)]
[OpenMP][FIX] Make test check lines less strict

The ppc64be bot emits the dtor metadata first for some reason. We should
investigate this or make the _cc_ update script able to use variables
instead of fixed numbers (e.g., !1). The IR update script does that
already.

2 years ago[MLIR][SCF] Create selects from if yield results which are not defined in the body
William S. Moses [Thu, 17 Mar 2022 19:31:05 +0000 (15:31 -0400)]
[MLIR][SCF] Create selects from if yield results which are not defined in the body

Previously, the canonicalizer to create ifs from selects would only work
if the if did not have a body other than yielding. This patch upgrade the functionality
to be able to create selects from any if result whose operands are not defined
within the body.

Reviewed By: ftynse

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

2 years ago[InstCombine] add tests for bswap with shifted operand; NFC
Sanjay Patel [Fri, 18 Mar 2022 14:33:11 +0000 (10:33 -0400)]
[InstCombine] add tests for bswap with shifted operand; NFC

2 years ago[NFC][mlir] Run clang-format on file.
Eric Schweitz [Fri, 18 Mar 2022 15:19:37 +0000 (08:19 -0700)]
[NFC][mlir] Run clang-format on file.

2 years ago[mlir] Add support for the nest attribute to the LLVM-IR dialect conversion.
Eric Schweitz [Thu, 17 Mar 2022 20:22:36 +0000 (13:22 -0700)]
[mlir] Add support for the nest attribute to the LLVM-IR dialect conversion.

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

2 years agotsan: print signal num in errno spoiling reports
Dmitry Vyukov [Fri, 18 Mar 2022 06:24:00 +0000 (07:24 +0100)]
tsan: print signal num in errno spoiling reports

For errno spoiling reports we only print the stack
where the signal handler is invoked. And the top
frame is the signal handler function, which is supposed
to give the info for debugging.
But in same cases the top frame can be some common thunk,
which does not give much info. E.g. for Go/cgo it's always
runtime.cgoSigtramp.

Print the signal number.
This is what we can easily gather and it may give at least
some hints regarding the issue.

Reviewed By: melver, vitalybuka

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

2 years ago[gn build] Port a36c2dd6d54c
LLVM GN Syncbot [Fri, 18 Mar 2022 14:44:37 +0000 (14:44 +0000)]
[gn build] Port a36c2dd6d54c

2 years ago[flang] Lower select case statement
Valentin Clement [Fri, 18 Mar 2022 14:39:57 +0000 (15:39 +0100)]
[flang] Lower select case statement

This patch adds lowering for the `select case`
statement.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: jeanPerier

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years ago[BasicAA] Account for wrapping when using abs(VarIndex) >= abs(Scale).
Florian Hahn [Fri, 18 Mar 2022 14:41:15 +0000 (14:41 +0000)]
[BasicAA] Account for wrapping when using abs(VarIndex) >= abs(Scale).

The patch adds an extra check to only set MinAbsVarIndex if
abs(V * Scale) won't wrap. In the absence of IsNSW, try to use the
bitwidths of the original V and Scale to rule out wrapping.

Attempt to model https://alive2.llvm.org/ce/z/HE8ZKj

The code in the else if below probably needs the same treatment, but I
need to come up with a test first.

Reviewed By: asbirlea

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

2 years ago[clang][dataflow] Add modeling of Chromium's CHECK functionality
Yitzhak Mandelbaum [Wed, 9 Mar 2022 20:14:43 +0000 (20:14 +0000)]
[clang][dataflow] Add modeling of Chromium's CHECK functionality

Chromium's implementation of assertions (`CHECK`, `DCHECK`, etc.) are not
annotated with "noreturn", by default. This patch adds a model of the logical
implications of successfully executing one of these assertions.

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

2 years ago[SLP][X86] Add baseline SSE2 test run to lookahead.ll
Simon Pilgrim [Fri, 18 Mar 2022 14:26:54 +0000 (14:26 +0000)]
[SLP][X86] Add baseline SSE2 test run to lookahead.ll

2 years ago[FPEnv][InstSimplify] Teach CannotBeNegativeZero() about constrained intrinsics.
Kevin P. Neal [Fri, 18 Mar 2022 14:22:15 +0000 (10:22 -0400)]
[FPEnv][InstSimplify] Teach CannotBeNegativeZero() about constrained intrinsics.

Currently some optimizations are disabled because llvm::CannotBeNegativeZero()
does not know how to deal with the constrained intrinsics. This patch fixes
that by extending the existing implementation.

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

2 years ago[clang-format] Refactor ShouldBreakBeforeBrace to use switch. NFC.
Marek Kurdej [Fri, 18 Mar 2022 14:07:55 +0000 (15:07 +0100)]
[clang-format] Refactor ShouldBreakBeforeBrace to use switch. NFC.

2 years ago[clang][SVE] Add support for bitwise operators on SVE types
David Truby [Mon, 7 Mar 2022 15:09:46 +0000 (15:09 +0000)]
[clang][SVE] Add support for bitwise operators on SVE types

This patch implements support for the &, |, ^, and ~ operators on sizeless SVE
types.

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

2 years agoAdd validation for number of arguments of __builtin_memcpy_inline
Roy Jacobson [Fri, 18 Mar 2022 13:20:49 +0000 (13:20 +0000)]
Add validation for number of arguments of __builtin_memcpy_inline

__builtin_memcpy_inline doesn't use the usual builtin argument validation code,
so it crashed when receiving wrong number of argument. Add the missing validation
check.

Open issue: https://github.com/llvm/llvm-project/issues/52949

Reviewed By: gchatelet

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

Committed by gchatelet on behalf of "Roy Jacobson <roi.jacobson1@gmail.com>"

2 years ago[clang-format] Expect instead of setting the same value in tests. NFC.
Marek Kurdej [Fri, 18 Mar 2022 14:01:18 +0000 (15:01 +0100)]
[clang-format] Expect instead of setting the same value in tests. NFC.

2 years ago[clang-format] Use range-for loop. NFC.
Marek Kurdej [Fri, 18 Mar 2022 14:01:07 +0000 (15:01 +0100)]
[clang-format] Use range-for loop. NFC.

2 years ago[clang-format] Refactor BreakableBlockComment constructor. NFC.
Marek Kurdej [Fri, 18 Mar 2022 14:00:35 +0000 (15:00 +0100)]
[clang-format] Refactor BreakableBlockComment constructor. NFC.

2 years ago[LowerConstantIntrinsics] Make TLI a required dependency
Nikita Popov [Fri, 18 Mar 2022 13:47:22 +0000 (14:47 +0100)]
[LowerConstantIntrinsics] Make TLI a required dependency

The way the pass is actually used in the optimization pipeline,
TLI will be available, but this is not the case when running just
-lower-constant-intrinsics in tests, which ends up being quite
confusing.

Require TLI unconditionally, as we usually do.

2 years ago[flang] Lower length on character storage
Valentin Clement [Fri, 18 Mar 2022 13:49:34 +0000 (14:49 +0100)]
[flang] Lower length on character storage

This patch adds lowering for SetLength used to set
different length on character storage around calls where
the dummy and actual length differ.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[LowerConstantIntrinsics] Add test for objectsize of malloc (NFC)
Nikita Popov [Fri, 18 Mar 2022 13:49:42 +0000 (14:49 +0100)]
[LowerConstantIntrinsics] Add test for objectsize of malloc (NFC)

This is currently not folded with a plain -lower-constant-intrinsics
invocation, because TLI is an optional dependency.

2 years ago[flang][NFC] Add lowering tests
Valentin Clement [Fri, 18 Mar 2022 13:47:42 +0000 (14:47 +0100)]
[flang][NFC] Add lowering tests

Add couple of tests for the lowering.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
2 years ago[flang] Lower statement function
Valentin Clement [Fri, 18 Mar 2022 13:46:10 +0000 (14:46 +0100)]
[flang] Lower statement function

This patch adds lowering to suppoert statement functions

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[OpenMPRuntime] Specify correct pointer type
Nikita Popov [Fri, 18 Mar 2022 13:24:19 +0000 (14:24 +0100)]
[OpenMPRuntime] Specify correct pointer type

Rather than specifying a dummy type in EmitLoadOfPointer() and
then casting it to the correct one, we should instead specify the
correct type and cast beforehand. Otherwise the computed alignment
will be incorrect.

2 years ago[BOLT] LongJmp speedup refactoring
Vladislav Khmelevsky [Wed, 16 Mar 2022 16:45:38 +0000 (19:45 +0300)]
[BOLT] LongJmp speedup refactoring

Run tentativeLayoutRelocMode twice only if UseOldText option was passed.
Refactor BF loop to break on condtition met.

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

2 years ago[gn build] Port f83d833e41d7
LLVM GN Syncbot [Fri, 18 Mar 2022 12:43:27 +0000 (12:43 +0000)]
[gn build] Port f83d833e41d7

2 years ago[gn build] (manually) port a954ade8ed4 (gen X86GenMnemonicTables.inc)
Nico Weber [Fri, 18 Mar 2022 12:42:36 +0000 (08:42 -0400)]
[gn build] (manually) port a954ade8ed4 (gen X86GenMnemonicTables.inc)

2 years ago[gn build] (semiautomatically) port fdcb256f9796
Nico Weber [Fri, 18 Mar 2022 12:39:12 +0000 (08:39 -0400)]
[gn build] (semiautomatically) port fdcb256f9796

2 years ago[lldb] Require x86 target for NativePDB test
David Spickett [Fri, 18 Mar 2022 12:29:50 +0000 (12:29 +0000)]
[lldb] Require x86 target for NativePDB test

This test would fail if you only build for example,
just the AArch64 backend, due to the x86 triple.

2 years agoRevert "[gn build] (manually) port 6316129e066e"
Nico Weber [Fri, 18 Mar 2022 12:26:46 +0000 (08:26 -0400)]
Revert "[gn build] (manually) port 6316129e066e"

This reverts commit 5f4a334ded90f80ca16ceb2bf784c62806ee23d1.
6316129e066e was reverted in 112aafcaf425.

2 years ago[Clang] Support multiple attributes in a single pragma
Egor Zhdan [Tue, 8 Mar 2022 22:45:28 +0000 (22:45 +0000)]
[Clang] Support multiple attributes in a single pragma

This adds support for multiple attributes in `#pragma clang attribute push`, for example:

```
```
or
```
```

Related attributes can now be applied with a single pragma, which makes it harder for developers to make an accidental error later when editing the code.

rdar://78269653

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

2 years agoRevert "[ARM][AArch64] generate subtarget feature flags"
Tomas Matheson [Fri, 18 Mar 2022 11:58:02 +0000 (11:58 +0000)]
Revert "[ARM][AArch64] generate subtarget feature flags"

This reverts commit dd8b0fecb95df7689aac26c2ef9ebd1f527f9f46.

2 years ago[AArch64] Custom lower concat(v4i8 load, ...)
David Green [Fri, 18 Mar 2022 11:58:02 +0000 (11:58 +0000)]
[AArch64] Custom lower concat(v4i8 load, ...)

We already have custom lowering for v4i8 load, which loads as a f32,
converts to a vector and bitcasts and extends the result to a v4i16.
This adds some custom lowering of concat(v4i8 load, ...) to keep the
result as an f32 and create a buildvector of the resulting f32 loads.
This helps not create all the extends and bitcasts, which are often
difficult to fully clean up.

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

2 years ago[libc++][ranges] Implement ranges::min
Nikolas Klauser [Fri, 18 Mar 2022 01:57:08 +0000 (02:57 +0100)]
[libc++][ranges] Implement ranges::min

Reviewed By: var-const, Mordante, #libc

Spies: jwakely, ldionne, libcxx-commits, mgorny

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

2 years ago[ARM][AArch64] generate subtarget feature flags
Tomas Matheson [Wed, 23 Feb 2022 11:34:41 +0000 (11:34 +0000)]
[ARM][AArch64] generate subtarget feature flags

This patch aims to reduce a lot of the boilerplate around adding new subtarget
features. From the SubtargetFeatures tablegen definitions, a series of calls to
the macro GET_SUBTARGETINFO_MACRO are generated in
ARM/AArch64GenSubtargetInfo.inc.  ARMSubtarget/AArch64Subtarget can then use
this macro to define bool members and the corresponding getter methods.

Some naming inconsistencies have been fixed to allow this, and one unused
member removed.

This implementation only applies to boolean members; in future both BitVector
and enum members could also be generated.

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

2 years ago[CostModel][X86] Update RUN -passes=* to double quotes to appease update scripts...
Simon Pilgrim [Fri, 18 Mar 2022 11:44:07 +0000 (11:44 +0000)]
[CostModel][X86] Update RUN -passes=* to double quotes to appease update scripts on windows

2 years ago[lldb] Increase timeout in TestProcessIOHandlerInterrupt
Pavel Labath [Fri, 18 Mar 2022 11:14:10 +0000 (12:14 +0100)]
[lldb] Increase timeout in TestProcessIOHandlerInterrupt

The small value was not meant to be checked in.

2 years ago[SCEV] Use constant ranges when determining reachable blocks (PR54434)
Nikita Popov [Fri, 18 Mar 2022 11:01:05 +0000 (12:01 +0100)]
[SCEV] Use constant ranges when determining reachable blocks (PR54434)

This avoids false positive verification failures if the condition
is not literally true/false, but SCEV still makes use of the fact
that a loop is not reachable through more complex reasoning.

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

2 years ago[lldb] Fix TestProcessIOHandlerInterrupt.py for macos
Pavel Labath [Fri, 18 Mar 2022 10:47:47 +0000 (11:47 +0100)]
[lldb] Fix TestProcessIOHandlerInterrupt.py for macos

On darwin, we don't completely suppress the signal used to interrupt the
inferior. The underlying read syscall returns EINTR, which causes premature
termination of the input loop.

Work around that by hand-rolling an EINTR-resistant version of getline.

2 years ago[clang-format] Copy help options to the doc directory.
sstwcw [Fri, 18 Mar 2022 10:51:36 +0000 (10:51 +0000)]
[clang-format] Copy help options to the doc directory.

The options listed in ClangFormat.rst lag behind those output by the
-help command line option.  Specifically, these are missing.

--files
--qualifier-alignment

Fixes #54418

Reviewed By: MyDeveloperDay, HazardyKnusperkeks

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

2 years ago[flang][lowering] Add support for lowering of the `ior` intrinsic
Andrzej Warzynski [Thu, 17 Mar 2022 17:22:46 +0000 (17:22 +0000)]
[flang][lowering] Add support for lowering of the `ior` intrinsic

This patch adds support for lowering of the `ior` intrinsic from
Fortran to the FIR dialect of MLIR.

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[RISCV] Add more sign-extending ops to MIR sext.w pass.
Mohammed Nurul Hoque [Fri, 18 Mar 2022 09:26:10 +0000 (17:26 +0800)]
[RISCV] Add more sign-extending ops to MIR sext.w pass.

This patch adds single-bit and bit-counting ops to list of sign-extending ops.

A single-bit write propagates sign-extendedness if it's not in the sign-bits.

Bit extraction and bit counting always outputs a small number, so sign-extended.

Reviewed By: craig.topper

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

2 years ago[AMDGPU][DOC][NFC] Added links to MI200 documentation
Dmitry Preobrazhensky [Fri, 18 Mar 2022 10:16:27 +0000 (13:16 +0300)]
[AMDGPU][DOC][NFC] Added links to MI200 documentation

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

2 years ago[flang][lowering] Add support for lowering of the `{l|u}bound` intrinsics
Andrzej Warzynski [Thu, 17 Mar 2022 17:11:35 +0000 (17:11 +0000)]
[flang][lowering] Add support for lowering of the `{l|u}bound` intrinsics

This patch adds support for lowering of the `{l|u}bound` intrinsics from
Fortran to the FIR dialect of MLIR. Note that `ubound` is already
supported, but the test was missing (added here).

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
2 years ago[CodeGen] Store element type in DominatingValue<RValue>
Nikita Popov [Fri, 18 Mar 2022 10:11:00 +0000 (11:11 +0100)]
[CodeGen] Store element type in DominatingValue<RValue>

For aggregate rvalues, we need to store the element type in the
dominating value, so we can recover the element type for the
address.

2 years ago[flang][lowering] Add support for lowering of the `merge` intrinsics
Andrzej Warzynski [Thu, 17 Mar 2022 16:58:40 +0000 (16:58 +0000)]
[flang][lowering] Add support for lowering of the `merge` intrinsics

This patch adds support for lowering of the `merge` intrinsics from
Fortran to the FIR dialect of MLIR.

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

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

Co-authored-by: Valentin Clement <clementval@gmail.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Mark Leair <leairmark@gmail.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[CodeGen] Remove some uses of deprecated Address constructor
Nikita Popov [Fri, 18 Mar 2022 09:47:24 +0000 (10:47 +0100)]
[CodeGen] Remove some uses of deprecated Address constructor

2 years ago[bazel] Port a954ade8ed41
Benjamin Kramer [Fri, 18 Mar 2022 09:50:55 +0000 (10:50 +0100)]
[bazel] Port a954ade8ed41

2 years ago[bazel] Sync llvm-config.h after 112aafcaf425dca901690ca823d25607e5795263
Benjamin Kramer [Fri, 18 Mar 2022 09:45:54 +0000 (10:45 +0100)]
[bazel] Sync llvm-config.h after 112aafcaf425dca901690ca823d25607e5795263

2 years ago[InstCombine] Remove integer SPF of SPF folds (NFCI)
Nikita Popov [Thu, 24 Feb 2022 13:33:57 +0000 (14:33 +0100)]
[InstCombine] Remove integer SPF of SPF folds (NFCI)

Now that we canonicalize to intrinsics, these folds should no
longer be needed. Only one fold that also applies to floating-point
min/max is retained.

2 years ago[Flang] Lower the spacing, rrspacing intrinsics
Kiran Chandramohan [Thu, 17 Mar 2022 13:47:28 +0000 (13:47 +0000)]
[Flang] Lower the spacing, rrspacing intrinsics

These intrinsics returns the distance to the nearest real number and
their reciprocal. They are lowered to flang runtime calls.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: clementval

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

Co-authored-by: Mark Leair <leairmark@gmail.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
2 years ago[MemorySSA] Don't optimize uses during construction
Nikita Popov [Wed, 9 Mar 2022 15:34:55 +0000 (16:34 +0100)]
[MemorySSA] Don't optimize uses during construction

This changes MemorySSA to be constructed in unoptimized form.
MemorySSA::ensureOptimizedUses() can be called to optimize all
uses (once). This should be done by passes where having optimized
uses is beneficial, either because we're going to query all uses
anyway, or because we're doing def-use walks.

This should help reduce the compile-time impact of MemorySSA for
some use cases (the reason why I started looking into this is
D117926), which can avoid optimizing all uses upfront, and instead
only optimize those that are actually queried.

Actually, we have an existing use-case for this, which is EarlyCSE.
Disabling eager use optimization there gives a significant
compile-time improvement, because EarlyCSE will generally only query
clobbers for a subset of all uses (this change is not included in
this patch).

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

2 years ago[LoopSimplifyCFG] Check predecessors of exits before marking them dead.
Florian Hahn [Fri, 18 Mar 2022 08:54:44 +0000 (08:54 +0000)]
[LoopSimplifyCFG] Check predecessors of exits before marking them dead.

LoopSimplifyCFG may process loops that are not in
loop-simplify/canonical form. For loops not in canonical form, exit
blocks may be reachable from non-loop blocks and we cannot consider them
as dead if they only are not reachable from the loop itself.

Unfortunately the smallest test I could come up with requires running
multiple passes:
    -passes='loop-mssa(loop-instsimplify,loop-simplifycfg,simple-loop-unswitch)'

The reason is that loops are canonicalized at the beginning of loop
pipelines, so a later transform has to break canonical form in a way
that breaks LoopSimplifyCFG's dead-exit analysis.

Alternatively we could try to require all loop passes to maintain
canonical form. That in turn would also require additional verification.

Fixes #54023, #49931.

Reviewed By: nikic

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

2 years ago[BOLT][NFC] Use X86 mnemonic tables
Amir Ayupov [Fri, 18 Mar 2022 08:48:00 +0000 (01:48 -0700)]
[BOLT][NFC] Use X86 mnemonic tables

Remove tables from X86MCPlusBuilder, make use of llvm::X86 mnemonic tables.

Reviewed By: rafauler

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

2 years ago[X86][NFC] Generate mnemonic tables
Amir Ayupov [Fri, 18 Mar 2022 08:45:23 +0000 (01:45 -0700)]
[X86][NFC] Generate mnemonic tables

Produce mnemonic tables, adding the functions to llvm::X86 namespace.

Reviewed By: MaskRay, skan

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

2 years ago[TableGen] X86 mnemonic tables backend
Amir Ayupov [Fri, 18 Mar 2022 08:41:10 +0000 (01:41 -0700)]
[TableGen] X86 mnemonic tables backend

Add tablegen backend that generates X86 mnemonic-based opcode groupings, e.g.
`isADD`, `isTEST`, etc.

Addresses https://lists.llvm.org/pipermail/llvm-dev/2022-January/154526.html

Reviewed By: skan

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

2 years ago[flang][NFC] Move random test in Instriscs folder
Valentin Clement [Fri, 18 Mar 2022 08:25:14 +0000 (09:25 +0100)]
[flang][NFC] Move random test in Instriscs folder