platform/upstream/llvm.git
2 years ago[AArch64] validateTargetOperandClass - early out from MCK_MPR case. NFCI.
Simon Pilgrim [Sat, 9 Apr 2022 08:26:58 +0000 (09:26 +0100)]
[AArch64] validateTargetOperandClass - early out from MCK_MPR case. NFCI.

If it didn't match a za register, there's nothing we can do.

Fixes static analyzer uninitialized variable warning.

2 years ago[PowerPC] Generate tests for 16-byte atomic load/store. NFC.
Kai Luo [Sat, 9 Apr 2022 08:36:57 +0000 (16:36 +0800)]
[PowerPC] Generate tests for 16-byte atomic load/store. NFC.

2 years ago[sanitizer] Disable new test on Android to fix a bot
Vitaly Buka [Sat, 9 Apr 2022 07:57:16 +0000 (00:57 -0700)]
[sanitizer] Disable new test on Android to fix a bot

2 years ago[gn build] Port 889302292bf6
LLVM GN Syncbot [Sat, 9 Apr 2022 07:40:37 +0000 (07:40 +0000)]
[gn build] Port 889302292bf6

2 years ago[libc++][format][4/6] Improve formatted_size.
Mark de Wever [Sun, 26 Sep 2021 14:48:25 +0000 (16:48 +0200)]
[libc++][format][4/6] Improve formatted_size.

Use a specialized "buffer" to count the number of insertions instead of
using a `string` as storage type.

Depends on D110497.

Reviewed By: ldionne, #libc

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

2 years ago[libc++][format][3/6] Adds a __container_buffer.
Mark de Wever [Sun, 26 Sep 2021 13:47:42 +0000 (15:47 +0200)]
[libc++][format][3/6] Adds a __container_buffer.

Instead of writing every character directly into the container by using
a `back_insert_iterator` the data is buffered in an `array`. This buffer
is then inserted to the container by calling its `insert` member function.

Since there's no guarantee every container's `insert` behaves properly
containers need to opt-in to this behaviour. The appropriate standard
containers opt-in to this behaviour.

This change improves the performance of the format functions that use a
`back_insert_iterator`.

Depends on D110495

Reviewed By: ldionne, vitaut, #libc

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

2 years agoReland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""
Fangrui Song [Sat, 9 Apr 2022 06:40:18 +0000 (23:40 -0700)]
Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""

(With C++ exceptions, `clang++ --target=mips64{,el}-linux-gnu -fpie -pie
-fuse-ld=lld` has link errors (lld does not implement some strange R_MIPS_64
.eh_frame handling in GNU ld). However, sanitizer-x86_64-linux-qemu used this to
build ScudoUnitTests. Pined ScudoUnitTests to -no-pie.)

Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX may be removed in the future.

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

2 years ago[scudo][test] Link with -no-pie to be agnostic of CLANG_DEFAULT_PIE_ON_LINUX
Fangrui Song [Sat, 9 Apr 2022 06:30:07 +0000 (23:30 -0700)]
[scudo][test] Link with -no-pie to be agnostic of CLANG_DEFAULT_PIE_ON_LINUX

This keeps the test behavior unchanged when CLANG_DEFAULT_PIE_ON_LINUX switches
to ON by default.

Note: current clang --target=mips64el-linux-gnu -fpie -pie -fuse-ld=lld
does not link with C++ exceptions, using -pie would lead to

```
ld.lld: error: cannot preempt symbol: DW.ref.__gxx_personality_v0
...
ld.lld: error: relocation R_MIPS_64 cannot be used against local symbol; recompile with -fPIC
...
```

when linking `ScudoUnitTests`: https://lab.llvm.org/buildbot/#/builders/169/builds/7311/steps/18/logs/stdio

2 years ago[flang] Support export/import OpenMP Threadprivate Flag
Peixin-Qiao [Sat, 9 Apr 2022 05:52:31 +0000 (13:52 +0800)]
[flang] Support export/import OpenMP Threadprivate Flag

The information about OpenMP/OpenACC declarative directives in modules
should be carried in export mod files. This supports export OpenMP
Threadprivate directive and import OpenMP declarative directives.

Reviewed By: kiranchandramohan

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

2 years ago[clang][OpenMP5.1] Initial parsing/sema for has_device_addr
Jennifer Yu [Thu, 7 Apr 2022 03:30:44 +0000 (20:30 -0700)]
[clang][OpenMP5.1] Initial parsing/sema for has_device_addr

Added basic parsing/sema/ support for the 'has_device_addr' clause.

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

2 years ago[BOLT] Check MCContext errors
Amir Ayupov [Sat, 9 Apr 2022 04:07:27 +0000 (21:07 -0700)]
[BOLT] Check MCContext errors

Abort on emission errors to prevent a malformed binary being written.
Example:
```
<unknown>:0: error: Undefined temporary symbol .Ltmp26310
<unknown>:0: error: Undefined temporary symbol .Ltmp26311
<unknown>:0: error: Undefined temporary symbol .Ltmp26312
<unknown>:0: error: Undefined temporary symbol .Ltmp26313
<unknown>:0: error: Undefined temporary symbol .Ltmp26314
<unknown>:0: error: Undefined temporary symbol .Ltmp26315
BOLT-ERROR: Emission failed.
```

Reviewed By: yota9

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

2 years ago[lld-macho] Use fewer indirections in UnwindInfo implementation
Jez Ng [Sat, 9 Apr 2022 02:33:00 +0000 (22:33 -0400)]
[lld-macho] Use fewer indirections in UnwindInfo implementation

The previous implementation of UnwindInfoSection materialized
all the compact unwind entries & applied their relocations, then parsed
the resulting data to generate the final unwind info. This design had
some unfortunate conseqeuences: since relocations can only be applied
after their referents have had addresses assigned, operations that need
to happen before address assignment must contort themselves. (See
{D113582} and observe how this diff greatly simplifies it.)

Moreover, it made synthesizing new compact unwind entries awkward.
Handling PR50956 will require us to do this synthesis, and is the main
motivation behind this diff.

Previously, instead of generating a new CompactUnwindEntry directly, we
would have had to generate a ConcatInputSection with a number of
`Reloc`s that would then get "flattened" into a CompactUnwindEntry.

This diff introduces an internal representation of `CompactUnwindEntry`
(the former `CompactUnwindEntry` has been renamed to
`CompactUnwindLayout`). The new CompactUnwindEntry stores references to
its personality symbol and LSDA section directly, without the use of
`Reloc` structs.

In addition to being easier to work with, this diff also allows us to
handle unwind info whose personality symbols are located in sections
placed after the `__unwind_info`.

Reviewed By: #lld-macho, oontvoo

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

2 years agoRevert D121556 "[randstruct] Add randomize structure layout support"
Fangrui Song [Sat, 9 Apr 2022 01:37:26 +0000 (18:37 -0700)]
Revert D121556 "[randstruct] Add randomize structure layout support"

This reverts commit 3f0587d0c668202bb89d29a25432aa290e551a31.

Not all tests pass after a few rounds of fixes.

I spot one failure that std::shuffle (potentially different results with
different STL implementations) was misused and replaced it with llvm::shuffle,
but there appears to be another failure in a Windows build.

The latest failure is reported on https://reviews.llvm.org/D121556#3440383

2 years ago[gn build] Port 46b2a463bdef
LLVM GN Syncbot [Sat, 9 Apr 2022 01:14:57 +0000 (01:14 +0000)]
[gn build] Port 46b2a463bdef

2 years ago[randstruct] Use llvm::shuffle to avoid STL impl difference after D121556
Fangrui Song [Sat, 9 Apr 2022 01:14:21 +0000 (18:14 -0700)]
[randstruct] Use llvm::shuffle to avoid STL impl difference after D121556

This reverts commit 2a2149c754f96376ddf8fed248102dd8e6092a22.
This reverts commit 8d7595be1dd41d7f7470ec90867936ca5e4e0d82.
This reverts commit e2e6899452998932b37f0fa9e66d104a02abe3e5.

If this doesn't work, I'll revert the whole thing.

2 years ago[gn build] Port 2a2149c754f9
LLVM GN Syncbot [Sat, 9 Apr 2022 00:50:44 +0000 (00:50 +0000)]
[gn build] Port 2a2149c754f9

2 years ago[AMDGPU] Fix regression with vectorization limiting
Stanislav Mekhanoshin [Thu, 31 Mar 2022 23:17:01 +0000 (16:17 -0700)]
[AMDGPU] Fix regression with vectorization limiting

D67148 has removed TTI::getNumberOfRegisters(bool Vector) and
started to call TTI::getNumberOfRegisters(unsigned ClassID) from
the LoopVectorize. This has resulted in an unrestricted vectorization
on AMDGPU blowing up register pressure.

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

2 years agoAdapt the ObjC stepping algorithm to deal with "selector-stubs" in clang.
Jim Ingham [Fri, 8 Apr 2022 19:25:53 +0000 (12:25 -0700)]
Adapt the ObjC stepping algorithm to deal with "selector-stubs" in clang.

Clang is adding a feature to ObjC code generation, where instead of calling
objc_msgSend directly with an object & selector, it generates a stub that
gets passed only the object and the stub figures out the selector.

This patch adds support for following that dispatch method into the implementation
function.

2 years ago[randstruct] Remove RandstructTest.cpp from list
Bill Wendling [Sat, 9 Apr 2022 00:41:36 +0000 (17:41 -0700)]
[randstruct] Remove RandstructTest.cpp from list

2 years ago[randstruct] temporarily remove test that's failing
Bill Wendling [Sat, 9 Apr 2022 00:04:22 +0000 (17:04 -0700)]
[randstruct] temporarily remove test that's failing

2 years ago[PowerPC] Adjust `MaxAtomicSizeInBitsSupported` on PPC64
Kai Luo [Fri, 8 Apr 2022 23:42:06 +0000 (23:42 +0000)]
[PowerPC] Adjust `MaxAtomicSizeInBitsSupported` on PPC64

AtomicExpandPass uses this variable to determine emitting libcalls or not. The default value is 1024 and if we don't specify it for PPC64 explicitly, AtomicExpandPass won't emit `__atomic_*` libcalls for those target unable to inline atomic ops and finally the backend emits `__sync_*` libcalls. Thanks @efriedma for pointing it out.

Reviewed By: efriedma

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

2 years agoAdd some function prototypes; NFC
Aaron Ballman [Fri, 8 Apr 2022 23:54:35 +0000 (19:54 -0400)]
Add some function prototypes; NFC

(This file is compiled with -pedantic enabled in some two-stage builds)

2 years agounbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV after fa34951fbc9bde75
Nico Weber [Fri, 8 Apr 2022 23:43:37 +0000 (19:43 -0400)]
unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV after fa34951fbc9bde75

See revision b8b7a9dcdcbc for prior art.

2 years agoFix bazel rule for __support_fputil_fma when using header modules.
Jorge Gorbe Moya [Fri, 8 Apr 2022 23:26:21 +0000 (16:26 -0700)]
Fix bazel rule for __support_fputil_fma when using header modules.

Putting __support/FPUtil/x86_64/FMA.h in `hdrs` will trigger a
compilation action for that header, and it will always `#error` out for
non-FMA targets. Move these platform-specific headers that are
conditionally included to `textual_hdrs` instead.

2 years ago[PowerPC] Support 16-byte lock free atomics on pwr8 and up
Kai Luo [Fri, 8 Apr 2022 22:50:45 +0000 (22:50 +0000)]
[PowerPC] Support 16-byte lock free atomics on pwr8 and up

Make 16-byte atomic type aligned to 16-byte on PPC64, thus consistent with GCC. Also enable inlining 16-byte atomics on non-AIX targets on PPC64.

Reviewed By: hubert.reinterpretcast

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

2 years agoTransforms: Fix code duplication between LowerAtomic and AtomicExpand
Matt Arsenault [Wed, 6 Apr 2022 00:22:12 +0000 (20:22 -0400)]
Transforms: Fix code duplication between LowerAtomic and AtomicExpand

2 years ago[randstruct] disable test for Windows for now.
Bill Wendling [Fri, 8 Apr 2022 23:00:15 +0000 (16:00 -0700)]
[randstruct] disable test for Windows for now.

2 years agoNo reason for these not to have prototypes; NFC
Aaron Ballman [Fri, 8 Apr 2022 22:52:06 +0000 (18:52 -0400)]
No reason for these not to have prototypes; NFC

This should speculatively fix build bots:

https://lab.llvm.org/buildbot#builders/19/builds/10294
https://lab.llvm.org/buildbot#builders/37/builds/12289

2 years agoSkip test on earlier clang versions
Adrian Prantl [Fri, 8 Apr 2022 22:40:57 +0000 (15:40 -0700)]
Skip test on earlier clang versions

2 years ago[MSAN] add __b64_pton and __b64_ntop intercepts
Kevin Athey [Fri, 8 Apr 2022 22:00:09 +0000 (15:00 -0700)]
[MSAN] add __b64_pton and __b64_ntop intercepts

Reviewed By: vitalybuka

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

2 years ago[RGT] Use GTEST_SKIP() in more places where we skip a test
Paul Robinson [Fri, 8 Apr 2022 22:18:50 +0000 (15:18 -0700)]
[RGT] Use GTEST_SKIP() in more places where we skip a test

Simply returning will report the test as PASSED when it didn't
really do anything. SKIPPED is the correct result for these.

Found by the Rotten Green Tests project.

2 years ago[clang-tidy] Deal with keyword tokens in preprocessor conditions
Richard [Fri, 8 Apr 2022 00:58:36 +0000 (18:58 -0600)]
[clang-tidy] Deal with keyword tokens in preprocessor conditions

When a "keyword" token like __restrict was present in a macro condition,
modernize-macro-to-enum would assert in non-release builds.  However,
even for a "keyword" token, calling getIdentifierInfo()->getName() would
retrieve the text of the token, which is what we want.  Our intention is
to scan names that appear in conditional expressions in potential enum
clusters and invalidate those clusters if they contain the name.

Also, guard against "raw identifiers" appearing as potential enums.
This shouldn't happen, but it doesn't hurt to generalize the code.

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

Fixes #54775

2 years ago[lldb] XFAIL tests that aren't passing remotely
Jonas Devlieghere [Fri, 8 Apr 2022 20:07:29 +0000 (13:07 -0700)]
[lldb] XFAIL tests that aren't passing remotely

XFAIL a series of tests that are failing remotely.

2 years ago[lldb] Skip more tests that don't make sense to run remotely
Jonas Devlieghere [Fri, 8 Apr 2022 20:07:08 +0000 (13:07 -0700)]
[lldb] Skip more tests that don't make sense to run remotely

Skip another batch of tests that don't really make sense to run
remotely.

2 years ago[randstruct] add expected output for WIN64
Bill Wendling [Fri, 8 Apr 2022 21:41:44 +0000 (14:41 -0700)]
[randstruct] add expected output for WIN64

This is an attempt to fix a test failure on one of the buildbot Windows
machines. It also turns all of the "ASSERT_" macros into "EXPECT_" to
catch all other failures.

Link: https://lab.llvm.org/buildbot/#/builders/216/builds/2647
2 years agoReland "[MTE] Add -fsanitize=memtag* and friends."
Mitch Phillips [Fri, 8 Apr 2022 20:22:27 +0000 (13:22 -0700)]
Reland "[MTE] Add -fsanitize=memtag* and friends."

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

2 years ago[libc][NFC] implement printf parser
Michael Jones [Mon, 4 Apr 2022 18:46:30 +0000 (11:46 -0700)]
[libc][NFC] implement printf parser

This patch adds the sequential mode implementation of the printf parser,
as well as unit tests for it. In addition it adjusts the surrounding
files to accomodate changes in the design found in the implementation
process.

Reviewed By: sivachandra

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

2 years ago[libc++] Add missing 'return 0;' to main() in test
Louis Dionne [Fri, 8 Apr 2022 21:10:58 +0000 (17:10 -0400)]
[libc++] Add missing 'return 0;' to main() in test

2 years ago[libcxx][NFC] Format sort.h
Nilay Vaish [Fri, 8 Apr 2022 21:02:25 +0000 (17:02 -0400)]
[libcxx][NFC] Format sort.h

This is to simplify the changes made in D122780.  This diff was generated using the command:

```
clang-format include/__algorithm/sort.h  -i
```

Reviewed By: #libc, ldionne

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

2 years ago[libc++] Rename PS() macro to avoid clashing with Xtensa register name
Gustavo Henrique Nihei [Fri, 8 Apr 2022 20:58:56 +0000 (16:58 -0400)]
[libc++] Rename PS() macro to avoid clashing with Xtensa register name

This patch addresses a clash with the PS register from Xtensa
defined in the <specreg.h> header file, which is commonly included in
OS implementation.

Issue identified while building libc++ port for Apache NuttX, targeting
Xtensa-based chips (e.g. Espressif's ESP32).

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
Differential Revision: https://reviews.llvm.org/D122479

2 years ago[gn build] Port 3f0587d0c668
LLVM GN Syncbot [Fri, 8 Apr 2022 20:26:24 +0000 (20:26 +0000)]
[gn build] Port 3f0587d0c668

2 years ago[gn build] Port 2aa575fd7f4b
LLVM GN Syncbot [Fri, 8 Apr 2022 20:26:23 +0000 (20:26 +0000)]
[gn build] Port 2aa575fd7f4b

2 years ago[C89/C2x] Improve diagnostics around strict prototypes in C
Aaron Ballman [Fri, 8 Apr 2022 20:19:58 +0000 (16:19 -0400)]
[C89/C2x] Improve diagnostics around strict prototypes in C

Functions without prototypes in C (also known as K&R C functions) were
introduced into C89 as a deprecated feature and C2x is now reclaiming
that syntax space with different semantics. However, Clang's
-Wstrict-prototypes diagnostic is off-by-default (even in pedantic
mode) and does not suffice to warn users about issues in their code.

This patch changes the behavior of -Wstrict-prototypes to only diagnose
declarations and definitions which are not going to change behavior in
C2x mode, and enables the diagnostic in -pedantic mode. The diagnostic
is now specifically about the fact that the feature is deprecated.

It also adds -Wdeprecated-non-prototype, which is grouped under
-Wstrict-prototypes and diagnoses declarations or definitions which
will change behavior in C2x mode. This diagnostic is enabled by default
because the risk is higher for the user to continue to use the
deprecated feature.

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

2 years agoRevert "[MTE] Add -fsanitize=memtag* and friends."
Aaron Ballman [Fri, 8 Apr 2022 20:15:58 +0000 (16:15 -0400)]
Revert "[MTE] Add -fsanitize=memtag* and friends."

This reverts commit 8aa1490513f111afd407d87c3f07d26f65c8a686.

Broke testing: https://lab.llvm.org/buildbot/#/builders/109/builds/36233

2 years ago[libc++] Avoid using anonymous struct with base classes (fixes GCC 12)
Azat Khuzhin [Fri, 8 Apr 2022 20:13:46 +0000 (16:13 -0400)]
[libc++] Avoid using anonymous struct with base classes (fixes GCC 12)

GCC 12 reports:

     libcxx/include/string:727:13: error: anonymous struct with base classes
     727 |             : __padding<value_type>

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

2 years ago[AMDGPU] Enable PreRARematerialize scheduling pass with multiple high RP regions
Vang Thao [Fri, 25 Mar 2022 18:36:34 +0000 (11:36 -0700)]
[AMDGPU] Enable PreRARematerialize scheduling pass with multiple high RP regions

Enable the PreRARematerialize pass when there are multiple high RP scheduling
regions present. Require the occupancy in all high RP regions be improved
before finalizing sinking. If any high RP region did not improve in occupancy
then un-do all sinking and restore the state to before the pass.

Reviewed By: rampitec

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

2 years agoAMDGPU: Add codegen test for ctpop(ballot(x))
Nicolai Hähnle [Fri, 8 Apr 2022 19:30:20 +0000 (14:30 -0500)]
AMDGPU: Add codegen test for ctpop(ballot(x))

Highlights a gap in DAG-based ISel where we unnecessarily choose vector
instructions. GlobalISel already looks good.

2 years ago[randstruct] Add randomize structure layout support
Connor Kuehl [Fri, 8 Apr 2022 19:47:11 +0000 (12:47 -0700)]
[randstruct] Add randomize structure layout support

The Randstruct feature is a compile-time hardening technique that
randomizes the field layout for designated structures of a code base.
Admittedly, this is mostly useful for closed-source releases of code,
since the randomization seed would need to be available for public and
open source applications.

Why implement it? This patch set enhances Clang’s feature parity with
that of GCC which already has the Randstruct feature. It's used by the
Linux kernel in certain structures to help thwart attacks that depend on
structure layouts in memory.

This patch set is a from-scratch reimplementation of the Randstruct
feature that was originally ported to GCC. The patches for the GCC
implementation can be found here:

  https://www.openwall.com/lists/kernel-hardening/2017/04/06/14

Link: https://lists.llvm.org/pipermail/cfe-dev/2019-March/061607.html
Co-authored-by: Cole Nixon <nixontcole@gmail.com>
Co-authored-by: Connor Kuehl <cipkuehl@gmail.com>
Co-authored-by: James Foster <jafosterja@gmail.com>
Co-authored-by: Jeff Takahashi <jeffrey.takahashi@gmail.com>
Co-authored-by: Jordan Cantrell <jordan.cantrell@mail.com>
Co-authored-by: Nikk Forbus <nicholas.forbus@gmail.com>
Co-authored-by: Tim Pugh <nwtpugh@gmail.com>
Co-authored-by: Bill Wendling <isanbard@gmail.com>
Signed-off-by: Bill Wendling <isanbard@gmail.com>
Reviewed By: aaron.ballman

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

2 years agoRevert D120327 "compiler-rt: Add udivmodei5 to builtins and add bitint library"
Fangrui Song [Fri, 8 Apr 2022 19:39:42 +0000 (12:39 -0700)]
Revert D120327 "compiler-rt: Add udivmodei5 to builtins and add bitint library"

It has several problems like not-compilable weak attribute with MSVC
(and the usage needs further scrutiny), and " different types for formal and actual parameter"
https://lab.llvm.org/buildbot/#/builders/127/builds/27760/steps/7/logs/stdio

This reverts commit 8843245ddd2daf8d6cecc94667c2af83a82284fa492c5c05e111b81e2e7f1faa69756082fb826085bf2dc4b37623e1b4f7d39570e1b5a6f3ef5db107.

2 years ago[RGT] Use GTEST_SKIP instead of just returning
Paul Robinson [Fri, 8 Apr 2022 19:19:51 +0000 (12:19 -0700)]
[RGT] Use GTEST_SKIP instead of just returning

2 years ago[flang] Do not fold fir.box_addr when it has a slice
Valentin Clement [Fri, 8 Apr 2022 19:16:08 +0000 (21:16 +0200)]
[flang] Do not fold fir.box_addr when it has a slice

This patch avoids to fold `fir.box_addr` when the defining `fir.embox` op
has a slice. If the op is folded the slice information are lost.

This kind of problem occurred with code like:

```
call check(y(half+1:))
```

where `y` is an array.

Reviewed By: jeanPerier

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

2 years ago[MTE] Add -fsanitize=memtag* and friends.
Mitch Phillips [Fri, 1 Apr 2022 21:24:15 +0000 (14:24 -0700)]
[MTE] Add -fsanitize=memtag* and friends.

Currently, enablement of heap MTE on Android is specified by an ELF note, which
signals to the linker to enable heap MTE. This change allows
-fsanitize=memtag-heap to synthesize these notes, rather than adding them
through the build system. We need to extend this feature to also signal the
linker to do special work for MTE globals (in future) and MTE stack (currently
implemented in the toolchain, but not implemented in the loader).

Current Android uses a non-backwards-compatible ELF note, called
".note.android.memtag". Stack MTE is an ABI break anyway, so we don't mind that
we won't be able to run executables with stack MTE on Android 11/12 devices.

The current expectation is to support the verbiage used by Android, in
that "SYNC" means MTE Synchronous mode, and "ASYNC" effectively means
"fast", using the Kernel auto-upgrade feature that allows
hardware-specific and core-specific configuration as to whether "ASYNC"
would end up being Asynchronous, Asymmetric, or Synchronous on that
particular core, whichever has a reasonable performance delta. Of
course, this is platform and loader-specific.

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

2 years ago[mlir][sparse] Moving <P,I,V>-invariant parts of SparseTensorStorage to base
wren romano [Thu, 7 Apr 2022 01:08:02 +0000 (18:08 -0700)]
[mlir][sparse] Moving <P,I,V>-invariant parts of SparseTensorStorage to base

This reorganization helps to clean up the changes needed for D122060.

Work towards fixing: https://github.com/llvm/llvm-project/issues/51652

Depends On D122625

Reviewed By: aartbik

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

2 years ago[LV] Set debug loc after setting insert point.
Florian Hahn [Fri, 8 Apr 2022 18:34:40 +0000 (20:34 +0200)]
[LV] Set debug loc after setting insert point.

This fixes the code to actually use the location of the instruction, if
available. Previously, SetInsertPoint would overwrite the insert point
set from the instruction.

2 years ago[LV] Add test case for wrong debug location with replicate recipe.
Florian Hahn [Fri, 8 Apr 2022 18:34:16 +0000 (20:34 +0200)]
[LV] Add test case for wrong debug location with replicate recipe.

2 years agolld/AMDGPU: Fix asserts if no object files are involved in link
Matt Arsenault [Fri, 8 Apr 2022 17:22:23 +0000 (13:22 -0400)]
lld/AMDGPU: Fix asserts if no object files are involved in link

Fixes issue 47690. The reproduction steps produced a shared object
from clang directly, and then fed the shared object back into
lld. With no regular object files, this assert was hit. I'm not sure
if we need to or should be looking for equivalent fields in shared
objects.

2 years ago[libc] Add support for x86-64 targets that do not have FMA instructions.
Tue Ly [Thu, 7 Apr 2022 20:02:10 +0000 (16:02 -0400)]
[libc] Add support for x86-64 targets that do not have FMA instructions.

Make FMA flag checks more accurate for x86-64 targets, and refactor
polyeval to use multiply and add instead when FMA instructions are not
available.

Reviewed By: michaelrj, sivachandra

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

2 years ago[libc++][test] Use the Japanese locale.
Mark de Wever [Wed, 30 Mar 2022 15:34:17 +0000 (17:34 +0200)]
[libc++][test] Use the Japanese locale.

This change is done to see whether all platforms have a CI with the
Japanese locale installed.

This wires in the locale in the tests and uses it in one test. This is
a preparation for the tests of the chrono formatters.

Reviewed By: ldionne, #libc

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

2 years agoUse writable temporary file for test compiler output instead of hardcoded name. NFCI.
Jorge Gorbe Moya [Fri, 8 Apr 2022 17:57:20 +0000 (10:57 -0700)]
Use writable temporary file for test compiler output instead of hardcoded name. NFCI.

2 years ago[lldb] Skip a bunch of tests that shouldn't run remotely
Jonas Devlieghere [Fri, 8 Apr 2022 17:36:16 +0000 (10:36 -0700)]
[lldb] Skip a bunch of tests that shouldn't run remotely

Skip a bunch of tests that don't really make sense to run remotely.

2 years ago[lldb] Fix TestQuoting when run remotely
Jonas Devlieghere [Fri, 8 Apr 2022 17:10:17 +0000 (10:10 -0700)]
[lldb] Fix TestQuoting when run remotely

2 years ago[lldb] Import Foundation in TestConflictingDefinition.py
Jonas Devlieghere [Fri, 8 Apr 2022 17:04:15 +0000 (10:04 -0700)]
[lldb] Import Foundation in TestConflictingDefinition.py

We need to import foundation to get a 'NSLog' declaration when building
against the iOS SDK. This doesn't appear necessary when building against
the macOS SDK, presumable because it gets transitively imported by
objc/NSObject.h

2 years agoUse portable formatting specified in test. NFCI.
Jorge Gorbe Moya [Fri, 8 Apr 2022 17:43:20 +0000 (10:43 -0700)]
Use portable formatting specified in test. NFCI.

2 years ago[Clang] [Docs] Add HLSLSupport page
Chris Bieneman [Thu, 7 Apr 2022 04:13:56 +0000 (23:13 -0500)]
[Clang] [Docs] Add HLSLSupport page

This document is a first-stab at addressing some of the questions about
HLSL support in Clang.

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

2 years ago[clang-offload-bundler] fix "no output file" issue with -outputs
Siu Chi Chan [Fri, 8 Apr 2022 17:09:31 +0000 (17:09 +0000)]
[clang-offload-bundler] fix "no output file" issue with -outputs

Fix backward compatibility issue due to D120662.

Change-Id: I7cd0f704aabbaac7dcf59fd4b73b4f0e0cdfa69f

Reviewed By: yaxunl, saiislam

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

2 years ago[CaptureTracking] Ignore ephemeral values in EarliestEscapeInfo
Arthur Eubanks [Thu, 7 Apr 2022 22:39:53 +0000 (15:39 -0700)]
[CaptureTracking] Ignore ephemeral values in EarliestEscapeInfo

And thread DSE's ephemeral values to EarliestEscapeInfo.

This allows more precise analysis in DSEState::isReadClobber() via BatchAA.

Followup to D123162.

Reviewed By: nikic

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

2 years ago[MC][ELF] Improve st_size propagation rule
Fangrui Song [Fri, 8 Apr 2022 17:06:43 +0000 (10:06 -0700)]
[MC][ELF] Improve st_size propagation rule

`.symver foo, foo@ver` creates the MCSymbolELF `foo@ver` whose almost all
attributes (including st_size) should inherit from `foo` (GNU as behavior).

a041ef1bd8905f0d58e301c6830b183002ff1847 added st_size propagation which works
for many cases but fails for the following one:

```
.set __GLIBC_2_12_sys_errlist, _sys_errlist_internal
.type   __GLIBC_2_12_sys_errlist,@object
.size   __GLIBC_2_12_sys_errlist, 1080
.symver __GLIBC_2_12_sys_errlist, sys_errlist@GLIBC_2.12
...
_sys_errlist_internal:
.size   _sys_errlist_internal, 1072
```

`sys_errlist@GLIBC_2.12`'s st_size is 1072 (incorrect), which does not match
`__GLIBC_2_12_sys_errlist`'s st_size: 1080.

The problem is that `Base` is (the final) `_sys_errlist_internal` while we want
to respect (the intermediate) `__GLIBC_2_12_sys_errlist`'s st_size.
Fix this by following the MCSymbolRefExpr assignment chain and finding
the closest non-null `getSize()`, which covers most needs. Notably MCBinaryExpr
is not handled, but it is rare enough to matter.

Reviewed By: peter.smith

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

2 years ago[MC][test] Improve offset.s
Fangrui Song [Fri, 8 Apr 2022 16:58:04 +0000 (09:58 -0700)]
[MC][test] Improve offset.s

2 years agoAdd one more definition for symbols in prctl unit test.
Kevin Athey [Fri, 8 Apr 2022 16:44:27 +0000 (09:44 -0700)]
Add one more definition for symbols in prctl unit test.

one more follow up to: https://reviews.llvm.org/D122851

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

2 years ago[clang][extract-api] Emit "navigator" property of "name" in SymbolGraph
Daniel Grumberg [Fri, 8 Apr 2022 14:58:14 +0000 (15:58 +0100)]
[clang][extract-api] Emit "navigator" property of "name" in SymbolGraph

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

2 years ago[flang] Fix semantic analysis for "forall" targeted by "label"
PeixinQiao [Fri, 8 Apr 2022 16:27:53 +0000 (00:27 +0800)]
[flang] Fix semantic analysis for "forall" targeted by "label"

As Fortran 2018 3.18 states, the branch target statement can be
`forall-construct-stmt`, but cannot be `forall-stmt`. `forall-stmt` is
wrapped by `Statement` in `action-stmt` and `action-stmt` can be one
branch target statement. Fix the semantic analysis and add two
regression test cases in lowering.

Reviewed By: Jean Perier

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

2 years ago[RISCV] Select unmasked FP setcc insts via ISel post-process
Fraser Cormack [Thu, 7 Apr 2022 08:32:32 +0000 (09:32 +0100)]
[RISCV] Select unmasked FP setcc insts via ISel post-process

Similar to D123217 but for the floating-point patterns. No change in
generated output, while reducing the generated table size.

Reviewed By: arcbbb

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

2 years ago[AMDGPU] Fix inline asm causing assert during PreRARematerialize stage in scheduler...
Vang Thao [Fri, 8 Apr 2022 00:51:47 +0000 (17:51 -0700)]
[AMDGPU] Fix inline asm causing assert during PreRARematerialize stage in scheduler pass

Reviewed By: foad

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

2 years ago[memprof] Deduplicate and outline frame storage in the memprof profile.
Snehasish Kumar [Tue, 22 Mar 2022 02:39:24 +0000 (19:39 -0700)]
[memprof] Deduplicate and outline frame storage in the memprof profile.

The current implementation of memprof information in the indexed profile
format stores the representation of each calling context fram inline.
This patch uses an interned representation where the frame contents are
stored in a separate on-disk hash table. The table is indexed via a hash
of the contents of the frame. With this patch, the compressed size of a
large memprof profile reduces by ~22%.

Reviewed By: tejohnson

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

2 years agoNFC: Avoid unused variable warning in UnwindLevel1.c
kristina [Fri, 8 Apr 2022 16:04:35 +0000 (17:04 +0100)]
NFC: Avoid unused variable warning in UnwindLevel1.c

2 years ago[RISCV] Always select (and (srl X, C), Mask) as (srli (slli X, C2), C3).
Craig Topper [Thu, 7 Apr 2022 23:10:30 +0000 (16:10 -0700)]
[RISCV] Always select (and (srl X, C), Mask) as (srli (slli X, C2), C3).

SLLI is always compressible to C.SLLI as long as the source and dest
register is the same.

ANDI and SRLI are only compressible if the register is x8-x15. By
using SLLI we have a better chance of generating shorter code.

I had to exclude one exclusion for the BEXTI case so that it's
pattern match could still fire.

Reviewed By: luismarques

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

2 years ago[InstCombine] Add sub(add(x,y),minmax(x,y)) -> maxmin(x,y) tests
Simon Pilgrim [Fri, 8 Apr 2022 15:55:44 +0000 (16:55 +0100)]
[InstCombine] Add sub(add(x,y),minmax(x,y)) -> maxmin(x,y) tests

Based on Issue #37628

2 years agoAdd definitions for symbols in unit test for prctl.
Kevin Athey [Fri, 8 Apr 2022 15:49:25 +0000 (08:49 -0700)]
Add definitions for symbols in unit test for prctl.

Follow up to: https://reviews.llvm.org/D122851

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

2 years ago[Loads] Check type size in bits during store to load forwarding
Nikita Popov [Fri, 8 Apr 2022 15:26:29 +0000 (17:26 +0200)]
[Loads] Check type size in bits during store to load forwarding

Rather than checking the rounded type store size, check the type
size in bits. We don't want to forward a store of i1 to a load
of i8 for example, even though they have the same type store size.
The padding bits have unspecified contents.

This is a partial fix for the issue reported at
https://reviews.llvm.org/D115924#inline-1179482,
the problem also needs to be addressed more generally in the
constant folding code.

2 years ago[VPlan] Preserve debug location when creating branch.
Florian Hahn [Fri, 8 Apr 2022 15:22:38 +0000 (17:22 +0200)]
[VPlan] Preserve debug location when creating branch.

Update createEmptyBasicBlock to preserve the debug location of the
previous terminator.

2 years ago[LV] Add test for missing debug info on branch in vector loop.
Florian Hahn [Fri, 8 Apr 2022 15:20:59 +0000 (17:20 +0200)]
[LV] Add test for missing debug info on branch in vector loop.

Adds a test case where currently no debug location is added to branches
in the vector body.

2 years ago[LSR] Optimize unused IVs to final values in the exit block
Zaara Syeda [Thu, 7 Apr 2022 16:27:05 +0000 (12:27 -0400)]
[LSR] Optimize unused IVs to final values in the exit block

Loop Strength Reduce sometimes optimizes away all uses of an induction variable
from a loop but leaves the IV increments. When the only remaining use of the IV
is the PHI in the exit block, this patch will call rewriteLoopExitValues to
replace the exit block PHI with the final value of the IV to skip the updates
in each loop iteration.

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

2 years ago[libc++] Adds back_insert_iterator::__get_container.
Mark de Wever [Mon, 27 Sep 2021 18:53:59 +0000 (20:53 +0200)]
[libc++] Adds back_insert_iterator::__get_container.

Adds a `__get_container` member as suggested by @Quuxplusone in D110497.

Includes  s/_LIBCPP_INLINE_VISIBILITY/_LIBCPP_HIDE_FROM_ABI/.

Reviewed By: Quuxplusone, #libc, ldionne

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

2 years ago[NFC][libc++][format] Prepare unit tests.
Mark de Wever [Sat, 2 Oct 2021 10:38:46 +0000 (12:38 +0200)]
[NFC][libc++][format] Prepare unit tests.

Before implementing P2216's format-string adjust the unit tests.
After P2216 the format* functions require a compile-time string literal.
This changes prepares the tests.

Reviewed By: #libc, ldionne

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

2 years ago[Support][unittests] Silence warning when building with Clang 13 on
Alexandre Ganea [Fri, 8 Apr 2022 15:07:14 +0000 (11:07 -0400)]
[Support][unittests] Silence warning when building with Clang 13 on
Windows.

2 years ago[OpenMP] Fix linker error when building info tool
Joseph Huber [Fri, 8 Apr 2022 14:50:31 +0000 (10:50 -0400)]
[OpenMP] Fix linker error when building info tool

Summary:
The changes made in D123177 added new targets to the
`LIBOMPTARGET_TESTED_PLUGINS` variable which was linked against when
building the `llvm-omp-target-info` tool. This caused linker errors on
the export scripts. This patch removes that dependency, it still builds
and runs as expected so I will assume it's correct.

2 years ago[ConstantFold] Add test for load of i8 from i1 (NFC)
Nikita Popov [Fri, 8 Apr 2022 14:31:40 +0000 (16:31 +0200)]
[ConstantFold] Add test for load of i8 from i1 (NFC)

Semantics here are a bit unclear, but the store-to-load forwarding
case at least should be a miscompile.

2 years ago[flang][OpenMP] Added allocate clause translation for OpenMP block constructs
Shraiysh Vaishay [Fri, 8 Apr 2022 14:11:15 +0000 (19:41 +0530)]
[flang][OpenMP] Added allocate clause translation for OpenMP block constructs

This patch adds translation for allocate clause for parallel and single
constructs.

Also added tests for block constructs.

This patch also adds tests for parallel construct which were not added earlier.

Reviewed By: NimishMishra, peixin

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

Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
2 years agoClarify language option default value behavior; NFC
Aaron Ballman [Fri, 8 Apr 2022 14:22:09 +0000 (10:22 -0400)]
Clarify language option default value behavior; NFC

The LANGOPT macro allows you to specify a default value for the
langauge option. However, it's expected that these values be constant
rather than depending on other language options (because the
constructor setting the default values does not know the language mode
at the time it's being constructed).

Some of our language options were abusing this and passing in other
language mode options which were then set correctly by other parts of
frontend initialization. This removes the default values for the
language options, and then ensures they're consistently set from the
same place when setting language standard defaults.

2 years ago[OpenMP] Remove help and documentation for old flag
Joseph Huber [Fri, 8 Apr 2022 14:15:15 +0000 (10:15 -0400)]
[OpenMP] Remove help and documentation for old flag

Summary:
The `-fopenmp-target-new-runtime` flag has not been used for awhile. It
was present in a previous release so we shouldn't remove it for
backwards compatibility, but we shouldn't have documentation or a help
message for it.

2 years ago[AMDGPU][SIMachineFunctionInfo] Code cleanup (NFC).
Christudasan Devadasan [Fri, 8 Apr 2022 13:59:54 +0000 (19:29 +0530)]
[AMDGPU][SIMachineFunctionInfo] Code cleanup (NFC).

2 years ago[X86][FastISel] Fix with.overflow + select eflags clobber (PR54369)
Nikita Popov [Thu, 31 Mar 2022 15:02:38 +0000 (17:02 +0200)]
[X86][FastISel] Fix with.overflow + select eflags clobber (PR54369)

Don't try to directly use the with.overflow flag result in a cmov
if we need to materialize constants between the instruction
producing the overflow flag and the cmov. The current code is
careful to check that there are no other instructions in between,
but misses the constant materialization case (which may clobber
eflags via xor or constant expression evaluation).

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

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

2 years ago[llvm-pdbutil] Move global state (Filters) inside LinePrinter class.
Carlos Alberto Enciso [Fri, 8 Apr 2022 13:18:13 +0000 (14:18 +0100)]
[llvm-pdbutil] Move global state (Filters) inside LinePrinter class.

The changes described by:

https://reviews.llvm.org/D121801
https://reviews.llvm.org/D122226

Moved some llvm-pdbutil functionality to the debug PDB library.

This patch addresses one outstanding issue concerning the global
state (Filters) created in the PDB library.

- Move 'Filters' inside the 'LinePrinter' class.
- Omit 'Optional' and just pass 'PrintScope &HeaderScope' everywhere.

Reviewed By: aganea

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

2 years agoFix another g++ incompatibility. Same issue as 932f27dc1f03.
Benjamin Kramer [Fri, 8 Apr 2022 13:52:56 +0000 (15:52 +0200)]
Fix another g++ incompatibility. Same issue as 932f27dc1f03.

2 years ago[flang] Handle dynamically optional argument in EXIT
Jean Perier [Fri, 8 Apr 2022 13:51:32 +0000 (15:51 +0200)]
[flang] Handle dynamically optional argument in EXIT

The actual argument passed to STATUS may be a dummy OPTIONAL or a
disassociated POINTER/unallocated ALLOCATABLE.

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

2 years ago[Sanitizer] Add -no-opaque-pointers to IR test (NFC)
Nikita Popov [Fri, 8 Apr 2022 13:40:02 +0000 (15:40 +0200)]
[Sanitizer] Add -no-opaque-pointers to IR test (NFC)

This test is currently looking for specific typed-pointer IR,
so explicitly disable opaque pointers.

2 years ago[Profile] Add -no-opaque-pointers to IR tests (NFC)
Nikita Popov [Fri, 8 Apr 2022 13:35:18 +0000 (15:35 +0200)]
[Profile] Add -no-opaque-pointers to IR tests (NFC)

The output differs slightly with opaque pointers (no GEP constexpr),
add -no-opaque-pointers for now.

2 years ago[CGCall] Make findDominatingStoreToReturnValue() more robust
Nikita Popov [Fri, 8 Apr 2022 13:16:03 +0000 (15:16 +0200)]
[CGCall] Make findDominatingStoreToReturnValue() more robust

This was skipping specific lifetime + bitcast patterns, but with
opaque pointers the bitcast will not be present, and we did not
perform this fold.

Instead skip over lifetime.end and bitcasts generally, without
trying to correlate them.

2 years ago[clang-tidy] Make performance-inefficient-vector-operation work on members
Nathan James [Fri, 8 Apr 2022 13:17:37 +0000 (14:17 +0100)]
[clang-tidy] Make performance-inefficient-vector-operation work on members

Fixes https://llvm.org/PR50157

Adds support for when the container being read from in a range-for is a member of a struct.

Reviewed By: aaron.ballman

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

2 years ago[mlir][Linalg] Add pooling_nchw_sum op.
Vivek Khandelwal [Fri, 8 Apr 2022 12:26:26 +0000 (17:56 +0530)]
[mlir][Linalg] Add pooling_nchw_sum op.

This commit adds pooling_nchw_sum as a yaml op.

Reviewed By: cathyzhyi, gysit

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