platform/upstream/llvm.git
2 years ago[ELF] Move Symbol::needsTlsLd to config->needsTlsLd. NFC
Fangrui Song [Sat, 5 Feb 2022 22:40:15 +0000 (14:40 -0800)]
[ELF] Move Symbol::needsTlsLd to config->needsTlsLd. NFC

to decrease sizeof(SymbolUnion) from 72 to 64 on ELF64 platforms.

2 years agoSimplify mask creation with llvm::seq. NFCI.
Benjamin Kramer [Sat, 5 Feb 2022 22:33:06 +0000 (23:33 +0100)]
Simplify mask creation with llvm::seq. NFCI.

2 years ago[HIPSPV] Fix literals are mapped to Generic address space
Yaxun (Sam) Liu [Fri, 4 Feb 2022 23:18:14 +0000 (18:18 -0500)]
[HIPSPV] Fix literals are mapped to Generic address space

This issue is an oversight in D108621.

Literals in HIP are emitted as global constant variables with default
address space which maps to Generic address space for HIPSPV. In
SPIR-V such variables translate to OpVariable instructions with
Generic storage class which are not legal. Fix by mapping literals
to CrossWorkGroup address space.

The literals are not mapped to UniformConstant because the “flat”
pointers in HIP may reference them and “flat” pointers are modeled
as Generic pointers in SPIR-V. In SPIR-V/OpenCL UniformConstant
pointers may not be casted to Generic.

Patch by: Henry Linjamäki

Reviewed by: Yaxun Liu

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

2 years ago[ELF] Reorder Symbol members to improve access locality. NFC
Fangrui Song [Sat, 5 Feb 2022 22:11:37 +0000 (14:11 -0800)]
[ELF] Reorder Symbol members to improve access locality. NFC

* partition and isPreemptible are frequently used. Move it to the front
* move used beside isUsedInRegularObj. They are similar and accessed together in .symtab finalizing
* move auxIdx/dynsymIndex/verdefIndex to the end.

This decreases code size.

2 years ago[libunwind] [sparc] Add SPARCv9 support
Koakuma [Sat, 5 Feb 2022 21:08:26 +0000 (13:08 -0800)]
[libunwind] [sparc] Add SPARCv9 support

Adds libunwind support for SPARCv9 (aka sparc64). This is a rebase of @kettenis' patch D32450, which I created (with his permission) because the original review has become inactive.
The changes are of a cosmetic nature to make it fit better with the new code style, and to reuse the existing SPARCv8 code, whenever possible.

Please let me know if I posted this on the wrong place. Also, the summary of the original review is reproduced below:

> This adds unwinder support for 64-bit SPARC (aka SPARCv9). The implementation was done on OpenBSD/sparc64, so it takes StackGhost into account:
>
> https://www.usenix.org/legacy/publications/library/proceedings/sec01/full_papers/frantzen/frantzen_html/index.html
>
> Since StackGhost xor's return addresses with a random cookie before storing them on the stack, the unwinder has to do some extra work to recover those. This is done by introducing a new kRegisterInCFADecrypt "location" type that is used to implement the DW_CFA_GNU_window_save opcode. That implementation is SPARC-specific, but should work for 32-bit SPARC as well. DW_CFA_GNU_window_save is only ever generated on SPARC as far as I know.

Co-authored-by: Mark Kettenis
Reviewed By: #libunwind, thesamesam, MaskRay, Arfrever

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

2 years ago[libunwind] Attempt to fix broken sphinx doc link
Simon Pilgrim [Sat, 5 Feb 2022 21:03:51 +0000 (21:03 +0000)]
[libunwind] Attempt to fix broken sphinx doc link

bbce75e352be0637305a1b59ac5eca7175bceece replaced `LLVM Bugzilla` with `LLVM bug tracker`

2 years agoRevert "[RISCV] Fold (sext_inreg (fmv_x_anyexth X), i16) -> (fmv_x_signexth X)."
Craig Topper [Sat, 5 Feb 2022 20:51:01 +0000 (12:51 -0800)]
Revert "[RISCV] Fold (sext_inreg (fmv_x_anyexth X), i16) -> (fmv_x_signexth X)."

This reverts commit 673d68cd923a9daa5065b929453bf4a4b8d39650.

This hadn't been reviewed yet.

2 years ago[RISCV] Add more tests for rotate idioms. Add more RUN lines. NFC
Craig Topper [Sat, 5 Feb 2022 20:39:23 +0000 (12:39 -0800)]
[RISCV] Add more tests for rotate idioms. Add more RUN lines. NFC

We were only testing rotate idioms on rv32i. DAGCombiner won't
form ISD::ROTL/ROTR unless those operations are Legal or Custom.
They aren't for rv32 so we were only testing shift lowering.

This commit adds i64 idioms and the idioms that mask the shift
amount to avoid UB for a rotate of 0. I've added riscv64 and Zbb
RUN lines to show that we do match rotate for XLen types when
available. We currently miss i32 on rv64izbb.

2 years ago[RISCV] Fold (sext_inreg (fmv_x_anyexth X), i16) -> (fmv_x_signexth X).
Craig Topper [Fri, 4 Feb 2022 07:28:47 +0000 (23:28 -0800)]
[RISCV] Fold (sext_inreg (fmv_x_anyexth X), i16) -> (fmv_x_signexth X).

Add a new ISD opcode to represent the sign extending behavior of
vmv.x.h. Keep the previous anyext opcode to allow the existing
(fmv_x_anyexth (fmv_h_x X)) combine to keep working without needing
to generate a sign extend.

For fmv.x.w we are able to match the sext_inreg in an isel pattern,
but a 16-bit sext_inreg is lowered to a shift pair before isel. This
seemed like a larger match than we should do in isel.

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

2 years ago[ELF] Merge canInline into scriptDefined
Fangrui Song [Sat, 5 Feb 2022 20:00:34 +0000 (12:00 -0800)]
[ELF] Merge canInline into scriptDefined

They perform similar tasks and are essentially the same after
d28c26bbdd9e6e55cc0a6156e9879f7e0ca36329.

2 years ago[llvm-remark-size-diff] Don't use enum name as auto variable name
Simon Pilgrim [Sat, 5 Feb 2022 19:30:03 +0000 (19:30 +0000)]
[llvm-remark-size-diff] Don't use enum name as auto variable name

This was confusing the clang-cmake-x86_64-avx2-linux buildbot (gcc version 5.4.0).

2 years ago[ELF] Simplify shouldKeepInSymtab after Symbol::used is false by default. NFC
Fangrui Song [Sat, 5 Feb 2022 19:21:44 +0000 (11:21 -0800)]
[ELF] Simplify shouldKeepInSymtab after Symbol::used is false by default. NFC

2 years ago[ELF] Simplify includeInSymtab. NFC
Fangrui Song [Sat, 5 Feb 2022 19:18:08 +0000 (11:18 -0800)]
[ELF] Simplify includeInSymtab. NFC

2 years ago[ELF] Refactor how Symbol::used is set. NFC
Fangrui Song [Sat, 5 Feb 2022 19:09:39 +0000 (11:09 -0800)]
[ELF] Refactor how Symbol::used is set. NFC

2 years ago[X86] Add some better common check-prefixes to slow-pmulld.ll
Simon Pilgrim [Sat, 5 Feb 2022 18:56:38 +0000 (18:56 +0000)]
[X86] Add some better common check-prefixes to slow-pmulld.ll

Try to reduce at least some of the duplication

2 years ago[ELF] Refactor how exportDynamic is set. NFC
Fangrui Song [Sat, 5 Feb 2022 18:25:25 +0000 (10:25 -0800)]
[ELF] Refactor how exportDynamic is set. NFC

2 years ago[ELF] --wrap: don't copy exportDynamic
Fangrui Song [Sat, 5 Feb 2022 17:56:29 +0000 (09:56 -0800)]
[ELF] --wrap: don't copy exportDynamic

For -no-pie/-pie, when `__real_foo` is interposable in a shared object, `foo` is
exported. This rule does not match GNU ld and is unneeded because:

* the exported `foo` does not interpose `__real_foo` at run-time
* the similar `__wrap_foo` <-> `foo` relation does not have the rule

2 years ago[lldb] Use mangled symbol name to look for __asan::AsanDie()
Jonas Devlieghere [Sat, 5 Feb 2022 17:48:14 +0000 (09:48 -0800)]
[lldb] Use mangled symbol name to look for __asan::AsanDie()

After aed965d we no longer demangle full symbol names while indexing the
symbol table which means we have to use the mangled name instead of the
demangled name to find the symbol for __asan::AsanDie().

This fixes the following two tests:

  lldb-api :: functionalities/asan/TestMemoryHistory.py
  lldb-api :: functionalities/asan/TestReportData.py

2 years ago[PowerPC] Fix SSE translation on FreeBSD
Piotr Kubaj [Sat, 5 Feb 2022 17:13:42 +0000 (01:13 +0800)]
[PowerPC] Fix SSE translation on FreeBSD

This patch drops throws specifier in posix_memalign declaration because
that's different between glibc and other libc, and Clang has a hack.

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

2 years ago[InstCombine] Add PR34063 test coverage
Simon Pilgrim [Sat, 5 Feb 2022 15:21:51 +0000 (15:21 +0000)]
[InstCombine] Add PR34063 test coverage

2 years ago[InstCombine] SimplifyDemandedBits - mul(x,x) - if only demand bit[1] then fold to...
Sanjay Patel [Sat, 5 Feb 2022 14:05:21 +0000 (09:05 -0500)]
[InstCombine] SimplifyDemandedBits - mul(x,x) - if only demand bit[1] then fold to zero

This is a translation of the fold added to codegen with:
2d1390efbe61

Part of solving issue #48027

2 years ago[libc++] Add Unstable ABI CI run
Nikolas Klauser [Sat, 5 Feb 2022 13:09:45 +0000 (14:09 +0100)]
[libc++] Add Unstable ABI CI run

Reviewed By: ldionne, #libc, Mordante

Spies: mgorny, Mordante, libcxx-commits, arichardson

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

2 years ago[DAGCombiner] Fold vecreduce_or/and if operand is insert_subvector.
Sander de Smalen [Sat, 5 Feb 2022 14:07:44 +0000 (14:07 +0000)]
[DAGCombiner] Fold vecreduce_or/and if operand is insert_subvector.

Fold:
  vecreduce_or(insert_subvec(zeroinitializer, vec))
  -> vecreduce_or(vec)

  vecreduce_and(insert_subvec(allones, vec))
  -> vecreduce_and(vec)

  vecreduce_and/or(insert_subvec(undef, vec))
  -> vecreduce_and/or(vec)

This is useful for SVE which uses insert/extract subvector
to convert fixed-width to/from scalable vectors.

Reviewed By: bsmith

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

2 years ago[ConstraintElimination] Add test with trivially false condition in and.
Florian Hahn [Sat, 5 Feb 2022 14:17:07 +0000 (14:17 +0000)]
[ConstraintElimination] Add test with trivially false condition in and.

2 years ago[MLIR][Presburger] MaybeLocalRepr: add explicit bool() for convenience
Arjun P [Wed, 2 Feb 2022 15:01:22 +0000 (20:31 +0530)]
[MLIR][Presburger] MaybeLocalRepr: add explicit bool() for convenience

This also slightly simplifies some code.

Reviewed By: Groverkss

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

2 years ago[clang] added allocsize attribute to allocation functions
Dávid Bolvanský [Sat, 5 Feb 2022 13:26:17 +0000 (14:26 +0100)]
[clang] added allocsize attribute to allocation functions

2 years ago[MLIR][Presburger][NFC] Use getters for IntegerPolyhedron members
Groverkss [Sat, 5 Feb 2022 12:38:08 +0000 (18:08 +0530)]
[MLIR][Presburger][NFC] Use getters for IntegerPolyhedron members

This patch makes IntegerPolyhedron and derived classes use of getters to access
IntegerPolyhedron space information (`numIds, numDims, numSymbols`) instead of
directly accessing them.

This patch makes it easier to change the underlying implementation of the way
identifiers are stored, making it easier to extend/modify existing implementation.

Reviewed By: arjunp

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

2 years ago[AIX][PowerPC][PGO] Generate .ref for some PGO sections
Wael Yehia [Sat, 5 Feb 2022 05:08:21 +0000 (00:08 -0500)]
[AIX][PowerPC][PGO] Generate .ref for some PGO sections

For PGO on AIX, when we switch to the linux-style PGO variable access
(via _start and _stop labels), we need the compiler to generate a .ref
assembly for each of the three csects:

 -   __llvm_prf_data[RW]
 -   __llvm_prf_names[RO]
 -   __llvm_prf_vnds[RW]

We insert the .ref inside the __llvm_prf_cnts[RW] csect so that if it's
live then the 3 csects are live.

For example, for a testcase with at least one function definition, when
compiled with -fprofile-generate we should generate:

        .csect __llvm_prf_cnts[RW],3
        .ref __llvm_prf_data[RW]   <<============ needs to be inserted
        .ref __llvm_prf_names[RO]  <<===========

the __llvm_prf_vnds is not always present, so we reference it only when
it's present.

Reviewed By: sfertile, daltenty

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

2 years ago[libc++] __config cleanup; _LIBCPP_ABI_UNSTABLE should set _LIBCPP_ABI_VERSION
Nikolas Klauser [Fri, 4 Feb 2022 13:28:19 +0000 (14:28 +0100)]
[libc++] __config cleanup; _LIBCPP_ABI_UNSTABLE should set _LIBCPP_ABI_VERSION

Some `__config` cleanup and `_LIBCPP_ABI_UNSTABLE` should set `_LIBCPP_ABI_VERSION`, since the latest ABI version //is// the unstable ABI.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[clang] added alloc allign attr to memalign
Dávid Bolvanský [Sat, 5 Feb 2022 10:44:32 +0000 (11:44 +0100)]
[clang] added alloc allign attr to memalign

2 years ago[ELF] Allow STV_PROTECTED shared definition to set exportDynamic
Fangrui Song [Sat, 5 Feb 2022 09:10:43 +0000 (01:10 -0800)]
[ELF] Allow STV_PROTECTED shared definition to set exportDynamic

A STV_PROTECTED shared definition does not set exportDynamic of a defined
symbol. This is on the basis that a protected definition cannot be preempted so
the export is unnecessary. However, the condition is imperfect because we don't
know whether the shared object was built with a symbolic option. Since dropping
the condition simplifies code and matches GNU ld, let's do it.

2 years agoIncrease memory buffer for scanning objc classes on darwin systems
Jason Molenda [Sat, 5 Feb 2022 07:53:27 +0000 (23:53 -0800)]
Increase memory buffer for scanning objc classes on darwin systems

iOS systems are getting near this limit; double itfrom a 150kb
buffer to a 300kb buffer, which is freed after processing the
list of classes.

rdar://88454594
Differential Revision: https://reviews.llvm.org/D118972

2 years ago[RISCV] Remove a ComputeNumSignBits call from an isel special case.
Craig Topper [Sat, 5 Feb 2022 07:16:36 +0000 (23:16 -0800)]
[RISCV] Remove a ComputeNumSignBits call from an isel special case.

Only isel (and (srl (sexti32 Y), c2), c1) -> (srliw (sraiw Y, 31), c3 - 32)
when there is a sext_inreg present. Don't both checking for Y
having 32 sign bits.

2 years ago[MLIR][Presburger][NFC] Fix clang-tidy warnings
Groverkss [Sat, 5 Feb 2022 06:25:09 +0000 (11:55 +0530)]
[MLIR][Presburger][NFC] Fix clang-tidy warnings

This patch changes variable naming to lowerCamelCase to remove
clang-tidy warning in Presburger/Utils.cpp.

2 years agogithub: Fix automated PR creation for backports
Tom Stellard [Sat, 5 Feb 2022 06:22:01 +0000 (22:22 -0800)]
github: Fix automated PR creation for backports

GitHub Actions stores the token used for checking out a git repo in
the git configuration and then uses that token for pushes from that
repo too.  We need to use a different token for push because we
are pushing to the llvmbot/llvm-project repo and not the upstream repo,
so we need to disable persist-credentials when checking out the source.

2 years ago[NFC] Remove unnecessary #includes
Bill Wendling [Sat, 5 Feb 2022 05:16:20 +0000 (21:16 -0800)]
[NFC] Remove unnecessary #includes

An attempt to reduce the number of files that are recompiled due to a change.

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

2 years agoDon't assume that a new cleanup was added to InnermostEHScope.
James Y Knight [Sat, 5 Feb 2022 04:39:18 +0000 (23:39 -0500)]
Don't assume that a new cleanup was added to InnermostEHScope.

After fa87fa97fb79, this was no longer guaranteed to be the cleanup
just added by this code, if IsEHCleanup got disabled. Instead, use
stable_begin(), which _is_ guaranteed to be the cleanup just added.

This caused a crash when a object that is callee destroyed (e.g. with the MS ABI) was passed in a call from a noexcept function.

Added a test to verify.

Fixes: fa87fa97fb79

2 years ago[CSSPGO] Turn on ext-tsp by default for CSSPGO.
Hongtao Yu [Sat, 5 Feb 2022 01:17:35 +0000 (17:17 -0800)]
[CSSPGO] Turn on ext-tsp by default for CSSPGO.

I'm seeing ext-tsp helps CSSPGO for our intern large benchmarks so I'm turning on it for CSSPGO. For non-CS AutoFDO, ext-tsp doesn't seem to help, probably because of lower profile counts quality.

Reviewed By: wenlei

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

2 years ago[Driver] Default to -fno-math-errno for musl
Alex Xu (Hello71) [Sat, 5 Feb 2022 03:20:30 +0000 (19:20 -0800)]
[Driver] Default to -fno-math-errno for musl

musl does not set errno in math functions: https://wiki.musl-libc.org/mathematical-library.html, https://git.musl-libc.org/cgit/musl/tree/include/math.h?id=cfdfd5ea3ce14c6abf7fb22a531f3d99518b5a1b#n26.

Reviewed By: srhines, MaskRay

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

2 years ago[OpenMP] Add search path for llvm-strip
Kelvin Li [Sat, 5 Feb 2022 03:15:14 +0000 (22:15 -0500)]
[OpenMP] Add search path for llvm-strip

Add the build directory to the search path for llvm-strip instead
of solely relying on the PATH environment variable setting.

Reviewed By: jhuber6

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

2 years ago[X86] Introduce more common modern tunings into `generic`
Phoebe Wang [Sat, 5 Feb 2022 01:49:54 +0000 (09:49 +0800)]
[X86] Introduce more common modern tunings into `generic`

GCC has updated its generic `-mtune` to haswell. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81616
Update it to match with GCC.

Reviewed By: spatel

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

2 years ago[ELF] Avoid wrapping unreferenced lazy symbols
Shoaib Meenai [Wed, 2 Feb 2022 07:59:50 +0000 (23:59 -0800)]
[ELF] Avoid wrapping unreferenced lazy symbols

There's a couple of motivations here:
* LLD 12 (which I was originally testing with) was adding an undefined
  symbol to the symbol table if you attempted to wrap an unreferenced
  lazy symbol, which would later break `--no-allow-shlib-undefined`. LLD
  on main actually produces a weak undefined symbol, so this doesn't
  break anyway, but it's cleaner to not have the weak undefined symbol
  as well. The new behavior also matches bfd and gold.
* PROVIDE in a linker script referencing a wrapped symbol would think
  that an otherwise-unreferenced lazy symbol which was wrapped was
  actually referenced, and therefore proceed with the definition, which
  goes against expectations. The new behavior also matches bfd and gold.

Reviewed By: MaskRay

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

2 years ago[test] Remove unnecessary require<> in LoopAccessAnalysis tests
Arthur Eubanks [Sat, 5 Feb 2022 02:02:48 +0000 (18:02 -0800)]
[test] Remove unnecessary require<> in LoopAccessAnalysis tests

These function analyses are always available in loop passes.

2 years ago[BOLT] Add nfc-check-setup script
Amir Ayupov [Sat, 5 Feb 2022 02:02:50 +0000 (18:02 -0800)]
[BOLT] Add nfc-check-setup script

Add the script to set up llvm-bolt-wrapper. The intended use is to run NFC
checks manually and automatically on a buildbot.

Reviewed By: rafauler

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

2 years ago[flang] Debugging of ACCESS='STREAM' I/O (take 2)
Peter Klausler [Fri, 28 Jan 2022 23:34:28 +0000 (15:34 -0800)]
[flang] Debugging of ACCESS='STREAM' I/O (take 2)

Corrects the runtime implementation of I/O on files with
the access mode ACCESS='STREAM'.  This is a collection
of edge-case tweaks to ensure that the distinctions between
stream and direct/sequential files, unformatted or formatted,
are respected where appropriate.

Moves NextInField() from io-stmt.h to io-stmt.cpp --
it was getting too big to keep in a header.

This patch exposed a problem with the I/O runtime
on Windows and it was reverted.  This version also
fixes that problem; files are now opened on Windows
in binary mode to prevent inadvertent insertions of
carriage returns before line feeds, and those line
endings (CR+LF) are now explicitly generated.

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

2 years ago[BOLT-UnitTests] Fix shared libraries build
Amir Ayupov [Fri, 4 Feb 2022 23:04:01 +0000 (15:04 -0800)]
[BOLT-UnitTests] Fix shared libraries build

Fix build with `-DBUILD_SHARED_LIBS=ON` (add explicit deps).

Reviewed By: yota9

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

2 years ago[gn build] Port 679f8a885b65
LLVM GN Syncbot [Sat, 5 Feb 2022 01:52:05 +0000 (01:52 +0000)]
[gn build] Port 679f8a885b65

2 years ago[OpenMP] Change amdgcn to amdgpu in device library handling
Joseph Huber [Sat, 5 Feb 2022 01:44:06 +0000 (20:44 -0500)]
[OpenMP] Change amdgcn to amdgpu in device library handling

Summary:
The name of the AMDGPU device library was changes. Previously it was
called 'libomptarget-amdgcn'. This patch changes fixes the tests to use
the new name of the library and adds a new flag with the same name.

2 years ago[Debuginfod][test] Fix debuginfod.test to use %python instead of python after D112759
Fangrui Song [Sat, 5 Feb 2022 01:32:00 +0000 (17:32 -0800)]
[Debuginfod][test] Fix debuginfod.test to use %python instead of python after D112759

2 years ago[Debuginfod] Fix curl_easy_init in -DLLVM_ENABLE_ASSERTIONS=off build after D112753
Fangrui Song [Sat, 5 Feb 2022 01:29:19 +0000 (17:29 -0800)]
[Debuginfod] Fix curl_easy_init in -DLLVM_ENABLE_ASSERTIONS=off build after D112753

2 years ago[RISCV] Remove exclusions for zext.h/zext.w from our (and (srl X, C1), C2) selection...
Craig Topper [Sat, 5 Feb 2022 01:10:43 +0000 (17:10 -0800)]
[RISCV] Remove exclusions for zext.h/zext.w from our (and (srl X, C1), C2) selection code.

This code tries to replace the pattern with a pair of shifts, but
we were excluding if the And could be a zext.h or zext.w. The SLLI/SRL
pair is more compressible and doesn't come with much down side.

We do regress one test case in rv64i-exhaustive-w-insts.ll but we
can probably add a narrower exclusion for that case.

2 years agoReland [SimplifyCFG] `markAliveBlocks()`: recognize that normal dest of `invoke`d...
Roman Lebedev [Fri, 4 Feb 2022 23:39:22 +0000 (02:39 +0300)]
Reland [SimplifyCFG] `markAliveBlocks()`: recognize that normal dest of `invoke`d `noreturn` function is `unreachable`

As per LangRef's definition of `noreturn` attribute:
```
noreturn
  This function attribute indicates that the function never returns
  normally, hence through a return instruction.
  This produces undefined behavior at runtime if the function
  ever does dynamically return. nnotated functions may still
  raise an exception, i.a., nounwind is not implied.
```

So if we `invoke` a `noreturn` function, and the normal destination
of an invoke is not an `unreachable`, point it at the new `unreachable`
block.

The change/fix from the original commit is that we now actually create
the new block, and don't just repurpose the original block,
because said normal destination block could have other users.

This reverts commit db1176ce66cf276b45ac3b90ea6b5ce62de56be7,
relanding commit 598833c987593ce192fa827f162cae8c867c9d43.

2 years ago[NFC][SimplifyCFG] Add test w/ shared normal dest of a `noreturn` `invoke`d function
Roman Lebedev [Fri, 4 Feb 2022 23:38:48 +0000 (02:38 +0300)]
[NFC][SimplifyCFG] Add test w/ shared normal dest of a `noreturn` `invoke`d function

2 years ago[BOLT][NFC] Fix compiler warnings
Amir Ayupov [Tue, 1 Feb 2022 06:07:46 +0000 (22:07 -0800)]
[BOLT][NFC] Fix compiler warnings

Summary:
- variable 'TotalSize' set but not used
- variable 'TotalCallsTopN' set but not used
- use of bitwise '|' with boolean operands

Reviewed By: maksfb

FBD33911129

2 years ago[mlir][NFC] Fully qualify call to `mlir::success` in auto generated C++
Markus Böck [Fri, 4 Feb 2022 23:40:04 +0000 (00:40 +0100)]
[mlir][NFC] Fully qualify call to `mlir::success` in auto generated C++

2 years agoRevert "[SimplifyCFG] `markAliveBlocks()`: recognize that normal dest of `invoke...
Roman Lebedev [Fri, 4 Feb 2022 23:29:28 +0000 (02:29 +0300)]
Revert "[SimplifyCFG] `markAliveBlocks()`: recognize that normal dest of `invoke`d `noreturn` function is `unreachable`"

The normal destination may have other uses.

This reverts commit 598833c987593ce192fa827f162cae8c867c9d43.

2 years ago[mlir] Add canonicalizer to merge shape.assuming_all ops
Eugene Zhulenev [Fri, 4 Feb 2022 19:31:59 +0000 (11:31 -0800)]
[mlir] Add canonicalizer to merge shape.assuming_all ops

Depends On D119021

Reviewed By: frgossen

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

2 years ago[SimplifyCFG] `markAliveBlocks()`: recognize that normal dest of `invoke`d `noreturn...
Roman Lebedev [Fri, 4 Feb 2022 22:28:24 +0000 (01:28 +0300)]
[SimplifyCFG] `markAliveBlocks()`: recognize that normal dest of `invoke`d `noreturn` function is `unreachable`

As per LangRef's definition of `noreturn` attribute:
```
noreturn
  This function attribute indicates that the function never returns
  normally, hence through a return instruction.
  This produces undefined behavior at runtime if the function
  ever does dynamically return. nnotated functions may still
  raise an exception, i.a., nounwind is not implied.
```

2 years ago[NFC][SimplifyCFG] Add test showing failure to drop normal dest of noreturn invoke
Roman Lebedev [Fri, 4 Feb 2022 22:27:05 +0000 (01:27 +0300)]
[NFC][SimplifyCFG] Add test showing failure to drop normal dest of noreturn invoke

2 years ago[NFC][InstCombine] `visitCallInst()`: make comment more understandable
Roman Lebedev [Fri, 4 Feb 2022 22:03:39 +0000 (01:03 +0300)]
[NFC][InstCombine] `visitCallInst()`: make comment more understandable

2 years ago[NFC][SimplifyCFG] 'merge compatible invokes': tests for non-`unreachable` normal...
Roman Lebedev [Fri, 4 Feb 2022 21:26:01 +0000 (00:26 +0300)]
[NFC][SimplifyCFG] 'merge compatible invokes': tests for non-`unreachable` normal destination

2 years ago[ELF] Support R_PPC_NONE/R_PPC64_NONE in getImplicitAddend
Fangrui Song [Fri, 4 Feb 2022 23:13:37 +0000 (15:13 -0800)]
[ELF] Support R_PPC_NONE/R_PPC64_NONE in getImplicitAddend

Similar to f457863ae345d2635026501f5383e0e625869639

2 years ago[yaml2obj] Support R_PPC_* relocation types
Fangrui Song [Fri, 4 Feb 2022 23:11:50 +0000 (15:11 -0800)]
[yaml2obj] Support R_PPC_* relocation types

2 years agoRevert "[clangd] Properly compute framework-style include spelling"
David Goldman [Fri, 4 Feb 2022 22:57:11 +0000 (17:57 -0500)]
Revert "[clangd] Properly compute framework-style include spelling"

This reverts commit 4dfd11324eb05d167392958c0f0f273cae6386c6
due to the failures on Linux CI:
https://lab.llvm.org/buildbot/#/builders/188/builds/9296

2 years ago[GlobalISel] Don't combine instructions which are fed by memory instructions using...
Róbert Ágoston [Fri, 4 Feb 2022 22:46:27 +0000 (14:46 -0800)]
[GlobalISel] Don't combine instructions which are fed by memory instructions using different size

Memory instructions like extending loads from the same address are not equal if
their size is not equal.

This fixes https://github.com/llvm/llvm-project/issues/53524.

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

2 years ago[OpenMP] Emit remark on the captured call instead of the variable
Joseph Huber [Fri, 4 Feb 2022 21:54:59 +0000 (16:54 -0500)]
[OpenMP] Emit remark on the captured call instead of the variable

Changes the remark to emit on the function call that captures the globalized
variable instead of the globalized variable itself. The user should be able to
see which variable it was in the argument list of the function.

Reviewed By: jdoerfert

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

2 years agoAttempt forward fix after 4dfd113
David Goldman [Fri, 4 Feb 2022 22:47:38 +0000 (17:47 -0500)]
Attempt forward fix after 4dfd113

If this doesn't work will just revert the change,
can't seem to repro on macOS.

2 years ago[mlir:NFC] Move BaseOpWithOffsetSizesAndStrides out of OpBase.td
River Riddle [Fri, 4 Feb 2022 20:57:28 +0000 (12:57 -0800)]
[mlir:NFC] Move BaseOpWithOffsetSizesAndStrides out of OpBase.td

This is not a general construct, and shouldn't have been defined in OpBase.
This moves a copy to both MemRefOps+TensorOps, which are the only
users.

2 years agoAMDGPU/GlobalISel: Fix assertions on invalid addrspacecasts
Matt Arsenault [Thu, 27 Jan 2022 01:20:29 +0000 (20:20 -0500)]
AMDGPU/GlobalISel: Fix assertions on invalid addrspacecasts

Fixes some assert on invalid situations and starts directly emitting
the error.

2 years ago[libc++][Docker] Don't actually start using a newer compiler in the CI
Louis Dionne [Fri, 4 Feb 2022 22:12:38 +0000 (17:12 -0500)]
[libc++][Docker] Don't actually start using a newer compiler in the CI

To ensure a smooth transition without breaking CI, we should use explicitly
versioned Clangs in the CI jobs definition instead, since that's a change
we can actually test in the CI.

So instead of bumping the compiler version from the Docker image, use
the same version as before by default, and we can bump it from the CI
job definition once all the nodes are running the new image.

2 years ago[libc++] Replace includes of <utility> with specific detail headers
Arthur O'Dwyer [Fri, 4 Feb 2022 18:09:30 +0000 (13:09 -0500)]
[libc++] Replace includes of <utility> with specific detail headers

Basically a rebase of D104980; most of that patch had already happened
via gradual drive-by changes, but this finishes it up.
Don't touch the inclusions from `<__functional_base>`, `<__hash_table>`,
or `<__locale>`; those could be removed if we propagated the
inclusions up to the includers of those files, but there are lots
of those includers.

`<algorithm>`, `<functional>`, and `<memory>` already include `<utility>`
at the top level. `<iterator>` did not, so I've added it there.

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

2 years ago[libc++] Bump the version of Clang we use in the CI
Louis Dionne [Wed, 2 Feb 2022 18:19:27 +0000 (13:19 -0500)]
[libc++] Bump the version of Clang we use in the CI

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

2 years ago[mlir][vector] Add constant folder for vector.shuffle ops
Lei Zhang [Fri, 4 Feb 2022 21:32:42 +0000 (16:32 -0500)]
[mlir][vector] Add constant folder for vector.shuffle ops

Reviewed By: ThomasRaoux

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

2 years ago[ELF][test] Test getImplicitAddend for R_ARM_NONE/R_RISCV_NONE/R_386_NONE/R_X86_64_NONE
Fangrui Song [Fri, 4 Feb 2022 21:59:18 +0000 (13:59 -0800)]
[ELF][test] Test getImplicitAddend for R_ARM_NONE/R_RISCV_NONE/R_386_NONE/R_X86_64_NONE

Similar to f457863ae345d2635026501f5383e0e625869639

2 years ago[OpenMP] Fix mismatched device runtime name
Joseph Huber [Fri, 4 Feb 2022 21:53:11 +0000 (16:53 -0500)]
[OpenMP] Fix mismatched device runtime name

Summary:
The new runtime was deleted. AMD's old runtime used the triple name
`amdgcn` while the new runtime used `amdgpu`. This was not updated when
the old runtime was removed causing the library to not be found on
AMDGPU.

2 years agoAMDGPU: Fix failing test
Matt Arsenault [Fri, 4 Feb 2022 21:53:55 +0000 (16:53 -0500)]
AMDGPU: Fix failing test

2 years ago[mlir][spirv] Fix missing dependencies in BUILD.bazel
Lei Zhang [Fri, 4 Feb 2022 21:51:05 +0000 (16:51 -0500)]
[mlir][spirv] Fix missing dependencies in BUILD.bazel

2 years ago[clangd] Properly compute framework-style include spelling
David Goldman [Thu, 20 Jan 2022 20:31:01 +0000 (15:31 -0500)]
[clangd] Properly compute framework-style include spelling

With this change, clangd now computes framework-style includes
for framework headers at indexing time.

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

2 years ago[lld][macho] Add more skip platform check for libSystem re-exports
Byoungchan Lee [Fri, 4 Feb 2022 19:03:11 +0000 (14:03 -0500)]
[lld][macho] Add more skip platform check for libSystem re-exports

Xcode 13 comes with a mismatched platform in libcompiler_rt.dylib,
so this creates a linker error on mac catalyst.
Fix it by adding it to the skip list.

Reviewed By: MaskRay, #lld-macho, int3

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

2 years ago[mlir][spirv] Add support for converting vector.shuffle
Lei Zhang [Fri, 4 Feb 2022 21:30:44 +0000 (16:30 -0500)]
[mlir][spirv] Add support for converting vector.shuffle

Reviewed By: ThomasRaoux

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

2 years ago[PowerPC] Option controling scalar MASS convertion
Masoud Ataei [Fri, 4 Feb 2022 21:24:22 +0000 (13:24 -0800)]
[PowerPC] Option controling scalar MASS convertion

differential: https://reviews.llvm.org/D119035

reviewer: bmahjour

2 years ago[ELF] Support REL-format R_AARCH64_NONE relocation
Fangrui Song [Fri, 4 Feb 2022 21:20:49 +0000 (13:20 -0800)]
[ELF] Support REL-format R_AARCH64_NONE relocation

-fprofile-use=/-fprofile-sample-use= compiles may produce REL-format
.rel.llvm.call-graph-profile even if the prevailing format is RELA on AArch64.
Add R_AARCH64_NONE to getImplicitAddend to fix this linker error:

```
ld.lld: error: internal linker error: cannot read addend for relocation R_AARCH64_NONE
PLEASE submit a bug report to https://crbug.com and run tools/clang/scripts/process_crashreports.py (only works inside Google) which will upload a report and include the crash backtrace.
```

2 years ago[bazel] Port dbed14d215fe
Benjamin Kramer [Fri, 4 Feb 2022 21:14:45 +0000 (22:14 +0100)]
[bazel] Port dbed14d215fe

2 years ago[libc++] No longer support ranges::begin(x) when x is an array of incomplete type.
Arthur O'Dwyer [Fri, 4 Feb 2022 02:41:30 +0000 (21:41 -0500)]
[libc++] No longer support ranges::begin(x) when x is an array of incomplete type.

var-const points out that `ranges::begin` is (non-normatively
but explicitly) always supposed to return a `std::input_or_output_iterator`,
and `Incomplete*` is not a `std::input_or_output_iterator` because it
has no `operator++`. Therefore, we should never return `Incomplete*`
from `ranges::begin(x)`, even when `x` is `Incomplete(&)[]`. Instead,
just SFINAE away.

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

2 years ago[WebAssembly] Refactor and fix emission of external IR global decls
Paulo Matos [Fri, 4 Feb 2022 21:01:41 +0000 (22:01 +0100)]
[WebAssembly] Refactor and fix emission of external IR global decls

Reland of 00bf4755.

This patches fixes the visibility and linkage information of symbols
referring to IR globals.

Emission of external declarations is now done in the first execution
of emitConstantPool rather than in emitLinkage (and a few other
places). This is the point where we have already gathered information
about used symbols (by running the MC Lower PrePass) and not yet
started emitting any functions so that any declarations that need to
be emitted are done so at the top of the file before any functions.

This changes the order of a few directives in the final asm file which
required an update to a few tests.

Reviewed By: sbc100

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

2 years agoRename this file to fix the typo in its name; NFC
Aaron Ballman [Fri, 4 Feb 2022 20:59:28 +0000 (15:59 -0500)]
Rename this file to fix the typo in its name; NFC

2 years agoAMDGPU: Convert AMDGPUResourceUsageAnalysis to a Module pass
Matt Arsenault [Mon, 17 Jan 2022 15:55:36 +0000 (10:55 -0500)]
AMDGPU: Convert AMDGPUResourceUsageAnalysis to a Module pass

This is more precise in the face of indirect calls and aliases, still
assuming the call target is defined somewhere in the current module.

This sometimes changes the order the functions are printed, and also
changes the point where context errors are printed relative to
stdout. This also likely has negative consequences for compile time
and memory usage.

2 years agoAMDGPU: Use module level register maximums for unknown callees
Matt Arsenault [Fri, 14 Jan 2022 01:13:29 +0000 (20:13 -0500)]
AMDGPU: Use module level register maximums for unknown callees

Compute the theoretical register budget based on the IR function
signature/attributes, and use the global maximum register budgets for
unknown callees.

This should fix the kernel reported register usage in the presence of
indirect calls. The previous fix in
2b08f6af62afbf32e89a6a392dbafa92c62f7bdf was incorrect becauset it was
only taking the maximum in the known call graph, and missing something
that was either outside of it or codegened later.

This fixes a second case I discovered where calls to aliases also did
not work as expected. CallGraphAnalysis misses these, so functions
called through aliases were not codegened ahead of callers as
expected. CallGraphAnalysis should probably be fixed to understand
this case, and there's likely a bug with IPRA here. This fixes
numerous failures in the conformance test at -O0.

2 years ago[libc++] Move fpos into its own header
Nikolas Klauser [Fri, 4 Feb 2022 12:04:33 +0000 (13:04 +0100)]
[libc++] Move fpos into its own header

For some reason `<string>` defines `std::fpos`, which should be defined in `<ios>`.

Reviewed By: Quuxplusone, Mordante, #libc

Spies: libcxx-commits, mgorny

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

2 years ago[gn build] Port dbed14d
Arthur Eubanks [Fri, 4 Feb 2022 20:51:53 +0000 (12:51 -0800)]
[gn build] Port dbed14d

2 years ago[libc++] Remove unused code paths for non-existent builtins
Louis Dionne [Thu, 3 Feb 2022 17:29:35 +0000 (12:29 -0500)]
[libc++] Remove unused code paths for non-existent builtins

It looks like we added some checks to try and use builtin type traits
in https://reviews.llvm.org/D67900, but some of those type traits are
never implemented as builtins, so this is essentially dead code.

Fixes llvm-project#53569

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

2 years agoClean up a test case.
minglotus-6 [Wed, 2 Feb 2022 21:30:22 +0000 (13:30 -0800)]
Clean up a test case.

The test case is added to demonstrate diff before and after patch D114832.

The solution is

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

2 years ago[APInt] Update APInt::isShiftedMask() description. NFC.
Simon Pilgrim [Fri, 4 Feb 2022 20:38:52 +0000 (20:38 +0000)]
[APInt] Update APInt::isShiftedMask() description. NFC.

Make it clear that it matches a non-empty sequence of ones, matches the descriptions for isShiftedMask_32/64 as suggested on D119019

2 years ago[IntrospectionTest] Replace "return" with "GTEST_SKIP"
Paul Robinson [Fri, 4 Feb 2022 20:33:21 +0000 (12:33 -0800)]
[IntrospectionTest] Replace "return" with "GTEST_SKIP"

If a test simply returns, it gets mis-reported as a pass; being
reported as SKIPPED is correct.

Found by the Rotten Green Tests project.

2 years ago[mte] [nfc] do not keep Tag in AllocaInfo
Florian Mayer [Fri, 4 Feb 2022 01:10:28 +0000 (17:10 -0800)]
[mte] [nfc] do not keep Tag in AllocaInfo

this is to get the implementation closer to HWASan

Reviewed By: eugenis

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

2 years ago[OpenMP] Completely remove old device runtime
Joseph Huber [Thu, 3 Feb 2022 19:43:40 +0000 (14:43 -0500)]
[OpenMP] Completely remove old device runtime

This patch completely removes the old OpenMP device runtime. Previously,
the old runtime had the prefix `libomptarget-new-` and the old runtime
was simply called `libomptarget-`. This patch makes the formerly new
runtime the only runtime available. The entire project has been deleted,
and all references to the `libomptarget-new` runtime has been replaced
with `libomptarget-`.

Reviewed By: JonChesterfield

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

2 years ago[SLP] Strengthen internal asserts about scheduled node state [NFC]
Philip Reames [Fri, 4 Feb 2022 20:21:53 +0000 (12:21 -0800)]
[SLP] Strengthen internal asserts about scheduled node state [NFC]

All members of a scheduled bundle must have valid dependencies, with no unscheduled ones, and only the lead element gets marked scheduled.

2 years agoUse functions with prototypes when appropriate; NFC
Aaron Ballman [Fri, 4 Feb 2022 20:19:56 +0000 (15:19 -0500)]
Use functions with prototypes when appropriate; NFC

A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the second batch of tests being updated (there are a significant
number of other tests left to be updated).

2 years ago[OpenMP] Add -Bsymbolic to arguments for GNU linker
Joseph Huber [Fri, 4 Feb 2022 17:51:10 +0000 (12:51 -0500)]
[OpenMP] Add -Bsymbolic to arguments for GNU linker

This patch adds the '-Bsymbolic' flag when we perform linking for the
offloading device. We already pass '-fvisibility=protected' but this is
not properly handled when using the bfd linker as is described in
https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic.
Previously this caused linker errors when creating the shared library.

Reviewed By: JonChesterfield

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

2 years ago[Clang][Sema][OpenMP] Fix uninitialized variable Op
Shilei Tian [Fri, 4 Feb 2022 20:00:36 +0000 (15:00 -0500)]
[Clang][Sema][OpenMP] Fix uninitialized variable Op

This can fix the case atomic_messages