platform/upstream/llvm.git
2 years ago[lld-macho] Unset ExportDynamic where possible for LTO
Jez Ng [Sat, 12 Feb 2022 03:24:09 +0000 (22:24 -0500)]
[lld-macho] Unset ExportDynamic where possible for LTO

By unsetting this property, we are now able to internalize more symbols
during LTO. I compared the output of `-save-temps` for both LLD and
ld64, and we now match ld64's behavior as far as `lto-internalize.ll` is
concerned.

(Thanks @smeenai for working on an initial version of this diff!)

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

Reviewed By: #lld-macho, thakis

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

2 years ago[AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt.
Micah Weston [Sat, 12 Feb 2022 03:11:50 +0000 (03:11 +0000)]
[AArch64] Adds SUBS and ADDS instructions to the MIPeepholeOpt.

Implements ADDS/SUBS 24-bit immediate optimization using the
MIPeepholeOpt pass. This follows the pattern:

Optimize ([adds|subs] r, imm) -> ([ADDS|SUBS] ([ADD|SUB] r, #imm0, lsl #12), #imm1),
if imm == (imm0<<12)+imm1. and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

Optimize ([adds|subs] r, imm) -> ([SUBS|ADDS] ([SUB|ADD] r, #imm0, lsl #12), #imm1),
if imm == -(imm0<<12)-imm1, and both imm0 and imm1 are non-zero 12-bit unsigned
integers.

The SplitAndOpcFunc type had to change the return type to an Opcode pair so that
the first add/sub is the regular instruction and the second is the flag setting
instruction. This required updating the code in the AND case.

Testing:

I ran a two stage bootstrap with this code.
Using the second stage compiler, I verified that the negation of an ADDS to SUBS
or vice versa is a valid optimization. Example V == -0x111111.

Reviewed By: dmgreen

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

2 years ago[RISCV][NFC] Move some combine patterns to DAG combine.
Chenbing.Zheng [Sat, 12 Feb 2022 02:52:12 +0000 (02:52 +0000)]
[RISCV][NFC] Move some combine patterns to DAG combine.

Move some combine patterns to DAG combine,and
it dealt with fixme left in RISCVInstrInfoZb.td.

Reviewed By: craig.topper

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

2 years ago[HWASAN] regression test we do not instrument dynamic allocas
Florian Mayer [Sat, 12 Feb 2022 00:33:01 +0000 (16:33 -0800)]
[HWASAN] regression test we do not instrument dynamic allocas

Reviewed By: browneee

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

2 years ago[flang] Fix edge case in USE-associated generics
Peter Klausler [Tue, 8 Feb 2022 21:39:59 +0000 (13:39 -0800)]
[flang] Fix edge case in USE-associated generics

It is generally an error when a USE-associated name clashes
with a name defined locally, but not in all cases; a generic
interface can be both USE-associated and locally defined.
This works, but not when there is also a local subprogram
with the same name, which is valid when that subprogram is
a specific of the local generic.  A bogus error issues at
the point of the USE because name resolution will have already
defined a symbol for the local subprogram.

The solution is to collect the names of local generics when
creating the program tree, and then create their symbols as
well if their names are also local subprograms, prior to any
USE association processing.

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

2 years ago[Mach-O][NFC] Reorder map file tests
Roger Kim [Sat, 12 Feb 2022 00:40:53 +0000 (19:40 -0500)]
[Mach-O][NFC] Reorder map file tests

We are just grouping the files and the tests together.

Reviewed By: int3, #lld-macho

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

2 years agoPrint C-string literals in mapfile
Roger Kim [Sat, 12 Feb 2022 00:33:23 +0000 (19:33 -0500)]
Print C-string literals in mapfile

This diff has the C-string literals printed into the mapfile in the symbol table like how ld64 does.

Here is what ld64's mapfile looks like with C-string literals:
```
# Path: out
# Arch: x86_64
# Object files:
[  0] linker synthesized
[  1] foo.o
# Sections:
# Address       Size            Segment Section
0x100003F7D     0x0000001D      __TEXT  __text
0x100003F9A     0x0000001E      __TEXT  __cstring
0x100003FB8     0x00000048      __TEXT  __unwind_info
# Symbols:
# Address       Size            File  Name
0x100003F7D     0x0000001D      [  1] _main
0x100003F9A     0x0000000E      [  1] literal string: Hello world!\n
0x100003FA8     0x00000010      [  1] literal string: Hello, it's me\n
0x100003FB8     0x00000048      [  0] compact unwind info
```

Here is what the new lld's Mach-O mapfile looks like:
```
# Path: /Users/rgr/local/llvm-project/build/Debug/tools/lld/test/MachO/Output/map-file.s.tmp/c-string-liter
al-out
# Arch: x86_64
# Object files:
[  0] linker synthesized
[  1] /Users/rgr/local/llvm-project/build/Debug/tools/lld/test/MachO/Output/map-file.s.tmp/c-string-literal
.o
# Sections:
# Address       Size            Segment Section
0x1000002E0     0x0000001D      __TEXT  __text
0x1000002FD     0x0000001D      __TEXT  __cstring
# Symbols:
# Address           File  Name
0x1000002E0     [  1] _main
0x1000002FD     [  1] literal string: Hello world!\n
0x10000030B     [  1] literal string: Hello, it's me\n
```

Reviewed By: #lld-macho, int3

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

2 years ago[NFC] [MTE] Use helpers for stack tagging.
Florian Mayer [Sat, 12 Feb 2022 00:01:37 +0000 (16:01 -0800)]
[NFC] [MTE] Use helpers for stack tagging.

Reviewed By: eugenis

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

2 years ago[hwasan] keep debug intrinsicts in AllocaInfo.
Florian Mayer [Fri, 11 Feb 2022 23:46:37 +0000 (15:46 -0800)]
[hwasan] keep debug intrinsicts in AllocaInfo.

Reviewed By: eugenis

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

2 years ago[OpenMP] libomp: fix UB when LIBOMP_NUM_HIDDEN_HELPER_THREADS=1.
AndreyChurbanov [Sat, 12 Feb 2022 00:00:38 +0000 (03:00 +0300)]
[OpenMP] libomp: fix UB when LIBOMP_NUM_HIDDEN_HELPER_THREADS=1.

The __kmp_hidden_helper_threads_num set to N+1 if user requested N threads.
Thus number of worker hidden helper threads corresponds to user request,
main thread of helper team excluded as it does not participate in actual work.
This also fixes divide-by-0 issue in the code.

Fixes #48656

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

2 years ago[flang] Avoid bogus error for specification expression
Peter Klausler [Tue, 8 Feb 2022 18:08:23 +0000 (10:08 -0800)]
[flang] Avoid bogus error for specification expression

When a scope's symbol has characteriztics whose specification
expressions depend on other non-constant symbols in the same scope,
f18 rightfully emits an error.  However, in the case of usage in
specification expressions involving host association, the program is not
invalid.  This can arise, for example, in the case of an internal
function whose result's attributes use host-associated variables.

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

2 years agoRevert "[Preprocessor] Reduce the memory overhead of `#define` directives"
Alex Lorenz [Fri, 11 Feb 2022 23:53:09 +0000 (15:53 -0800)]
Revert "[Preprocessor] Reduce the memory overhead of `#define` directives"

This reverts commit 0d9b91524ea4db3760791bba15773c386a26d8ec.

This change broke LLDB's build. I will need to recommit after fixing LLDB.

2 years ago[flang] Change internal errors in RESHAPE runtime routine to user errors
Peter Steinfeld [Fri, 11 Feb 2022 22:44:42 +0000 (14:44 -0800)]
[flang] Change internal errors in RESHAPE runtime routine to user errors

There are several checks in the runtime routine for the RESHAPE
intrinsic.  Some checks verify things that should have been checked at
compile time while others represent user errors.

This update changes the checks for user errors into calls to "Crash"
which include information about the failing check.  This identifies them
as user errors rather than compiler errors.

I also verified that the checks that remain as internal errors are also
checked by the front end.  I added a test to the front end's RESHAPE
test to complete the checks.

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

2 years ago[libc++] Use _LIBCPP_NO_UNIQUE_ADDRESS for base in join_view
Joe Loser [Tue, 8 Feb 2022 02:33:11 +0000 (21:33 -0500)]
[libc++] Use _LIBCPP_NO_UNIQUE_ADDRESS for base in join_view

Despite the comment saying `[[no_unique_address]]` on the `__base_` data member
makes clang crash, this does not seem to be true on CI. So, mark `__base_` with
`_LIBCPP_NO_UNIQUE_ADDRESS`.

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

2 years ago[lldb] Pin the shared cache when iterating over its images
Jonas Devlieghere [Fri, 11 Feb 2022 23:25:12 +0000 (15:25 -0800)]
[lldb] Pin the shared cache when iterating over its images

Use the dyld_shared_cache_(un)pin_mapping SPI to map the whole shared
cache in memory (if possible) to avoid repeated calls to mmap.

rdar://81189015

2 years ago[tsan] Make __fxstat code path glibc only
Fangrui Song [Fri, 11 Feb 2022 23:23:18 +0000 (15:23 -0800)]
[tsan] Make __fxstat code path glibc only

This fixes Linux musl build after D118423.

2 years ago[libc++][ranges][NFC] Refactor tests for `ranges::{begin,end}`.
Konstantin Varlamov [Fri, 11 Feb 2022 23:15:10 +0000 (15:15 -0800)]
[libc++][ranges][NFC] Refactor tests for `ranges::{begin,end}`.

- add some test cases for `cbegin`/`cend`;
- make class definitions generally follow the order in which they are
  used;
- add a missing include.

Reviewed By: philnik

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

2 years ago[debug-info] If one sees a spill with a dbg.addr use, salvageDebugInfo upon it and...
Michael Gottesman [Mon, 7 Feb 2022 21:05:30 +0000 (13:05 -0800)]
[debug-info] If one sees a spill with a dbg.addr use, salvageDebugInfo upon it and don't hoist it.

This ensures that if we have a dbg.addr in a coroutine funclet that is on one of
our function arguments, that the dbg.addr is not mapped to undef and also that
later it isn't hoisted to the front of the basic block. Instead it remains at
its original cloned location.

rdar://83957028

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

2 years agotry to fix windows build after 73e585e44d
Nico Weber [Fri, 11 Feb 2022 23:04:10 +0000 (18:04 -0500)]
try to fix windows build after 73e585e44d

2 years ago[sanitizers] Fix missing header for mac builds
Paul Kirth [Fri, 11 Feb 2022 22:53:19 +0000 (22:53 +0000)]
[sanitizers] Fix missing header for mac builds

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

2 years ago[Preprocessor] Reduce the memory overhead of `#define` directives
Alex Lorenz [Fri, 11 Feb 2022 21:50:30 +0000 (13:50 -0800)]
[Preprocessor] Reduce the memory overhead of `#define` directives

Recently we observed high memory pressure caused by clang during some parallel builds.
We discovered that we have several projects that have a large number of #define directives
in their TUs (on the order of millions), which caused huge memory consumption in clang due
to a lot of allocations for MacroInfo. We would like to reduce the memory overhead of
clang for a single #define to reduce the memory overhead for these files, to allow us to
reduce the memory pressure on the system during highly parallel builds. This change achieves
that by removing the SmallVector in MacroInfo and instead storing the tokens in an array
allocated using the bump pointer allocator, after all tokens are lexed.

The added unit test with 1000000 #define directives illustrates the problem. Prior to this
change, on arm64 macOS, clang's PP bump pointer allocator allocated 272007616 bytes, and
used roughly 272 bytes per #define. After this change, clang's PP bump pointer allocator
allocates 120002016 bytes, and uses only roughly 120 bytes per #define.

For an example test file that we have internally with 7.8 million #define directives, this
change produces the following improvement on arm64 macOS: Persistent allocation footprint for
this test case file as it's being compiled to LLVM IR went down 22% from 5.28 GB to 4.07 GB
and the total allocations went down 14% from 8.26 GB to 7.05 GB. Furthermore, this change
reduced the total number of allocations made by the system for this clang invocation from
1454853 to 133663, an order of magnitude improvement.

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

2 years ago[NFC] clang-format one function.
Evgenii Stepanov [Tue, 8 Feb 2022 23:28:06 +0000 (15:28 -0800)]
[NFC] clang-format one function.

fix code formatting

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

2 years ago[libc] Fix allocator inclusion
Michael Jones [Fri, 11 Feb 2022 21:17:55 +0000 (13:17 -0800)]
[libc] Fix allocator inclusion

Previously, allocator functions were only available if they were included
from scudo or by using the system libc headers (i.e. by turning off the
full build). This patch changes the logic to include the prototypes for
the allocator functitons in all cases, which allows the linker to link
in the system's allocator.

Reviewed By: sivachandra, abrachet

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

2 years ago[asan] Always skip first object from dl_iterate_phdr
Michael Forney [Fri, 11 Feb 2022 22:49:25 +0000 (14:49 -0800)]
[asan] Always skip first object from dl_iterate_phdr

All platforms return the main executable as the first dl_phdr_info.
FreeBSD, NetBSD, Solaris, and Linux-musl place the executable name
in the dlpi_name field of this entry. It appears that only Linux-glibc
uses the empty string.

To make this work generically on all platforms, unconditionally skip the first
object (like is currently done for FreeBSD and NetBSD). This fixes first DSO
detection on Linux-musl with clang -shared-libsan/-shared-libasan and GCC's
default. It also would likely fix detection on Solaris/Illumos if it were to
gain PIE support (since dlpi_addr would not be NULL).

Additionally, only skip the Linux VDSO on linux.

Finally, use the empty string as the "seen first dl_phdr_info"
marker rather than (char *)-1. If there was no other object, we
would try to dereference it for a string comparison.

Reviewed By: MaskRay, vitalybuka

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

2 years ago[libcxx] Fix a missed instance of _LIBCPP_NO_UNIQUE_ADDRESS
Martin Storsjö [Fri, 11 Feb 2022 22:41:28 +0000 (00:41 +0200)]
[libcxx] Fix a missed instance of _LIBCPP_NO_UNIQUE_ADDRESS

This was missed in 8a0a706f096bf380d81b615c67ab1e1af1c377d3 (added
after that patch was made originally).

2 years agoRevert "[hwasan] keep debug intrinsicts in AllocaInfo."
Florian Mayer [Fri, 11 Feb 2022 22:41:11 +0000 (14:41 -0800)]
Revert "[hwasan] keep debug intrinsicts in AllocaInfo."

This reverts commit 19fdf85f5858fa0aaae5f28f7140fbf12643993c.

2 years agoRevert "[NFC] [MTE] Use helpers for stack tagging."
Florian Mayer [Fri, 11 Feb 2022 22:41:03 +0000 (14:41 -0800)]
Revert "[NFC] [MTE] Use helpers for stack tagging."

This reverts commit 8f0e5b4e26a54a3ec347d6499cbb43b15ad6352c.

2 years ago[Bazel] Add WindowsDriver after 73e585e44d68cf77e2e3274e98c9615156a7d909
Fangrui Song [Fri, 11 Feb 2022 22:32:23 +0000 (14:32 -0800)]
[Bazel] Add WindowsDriver after 73e585e44d68cf77e2e3274e98c9615156a7d909

2 years agofix check-clang-tools tests that fail due to Windows CRLF line endings
Conrad Poelman [Fri, 11 Feb 2022 22:19:01 +0000 (15:19 -0700)]
fix check-clang-tools tests that fail due to Windows CRLF line endings

Running check-clang-tools on Windows produces 5 test failures:

Failed Tests (5):
  Clang Tools :: clang-apply-replacements/ClangRenameClassReplacements.cpp
  Clang Tools :: clang-apply-replacements/basic.cpp
  Clang Tools :: clang-apply-replacements/format.cpp
  Clang Tools :: clang-move/move-used-helper-decls.cpp
  Clang Tools :: clang-tidy/infrastructure/export-diagnostics.cpp

Four of these failures are simply due to fixed character position
offsets differing on Windows versus Linux, since Windows line endings
take up two characters instead of one:

clang-apply-replacements/ClangRenameClassReplacements.cpp runs clang-rename -offset=254
clang-apply-replacements/Inputs/basic/file[12].yaml specify e.g.  FileOffset: 148 and Offset: 298
clang-apply-replacements/Inputs/format/{no,yes}.yaml specify e.g.  FileOffset: 94 and Offset: 94
clang-tidy/infrastructure/export-diagnostics.cpp specifies e.g.  CHECK-YAML-NEXT: FileOffset: 30

(The move-used-helper-decls.cpp failure seems more complex; clang-move
adds a blank line after void HelperFun1() {} when
clang-move/Inputs/helper_decls_test.cpp has LF line endings, but does
not add a blank line when the input files has CRLF line endings. That
difference in behavior seems like it may be an actual bug, but I have
yet to track it down.)

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

2 years agom68k: Support bit shifts on 64-bit integers
Annika [Fri, 11 Feb 2022 22:11:27 +0000 (06:11 +0800)]
m68k: Support bit shifts on 64-bit integers

As per https://bugs.llvm.org/show_bug.cgi?id=52119.

Reviewed By: myhsu

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

2 years agoReland "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:"
Nico Weber [Fri, 11 Feb 2022 21:26:12 +0000 (16:26 -0500)]
Reland "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:"

This relands commit b3b2538df100ec, except that the new files in Support
are instead in a new library WindowsDriver.

2 years agoAdd support for the swift5 reflection section acfuncs
Shubham Sandeep Rastogi [Fri, 11 Feb 2022 19:19:36 +0000 (11:19 -0800)]
Add support for the swift5 reflection section acfuncs

With bc013b3e4e862da8d0c2d91cf99dcbebf124e4ac a new section called accessible functions was added to swift/include/swift/ABI/ObjectFile.h so this change adds support for dumping it out into the dSYM bundle

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

2 years ago[sanitizers] Add missing header to fix Fuchsia builds
Paul Kirth [Fri, 11 Feb 2022 21:51:34 +0000 (21:51 +0000)]
[sanitizers] Add missing header to fix Fuchsia builds

Adds missing header to fix sanitizer builds for Fuchsia.

Reviewed By: abrachet

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

2 years agoAutogen a couple of predicated SCEV tests
Philip Reames [Fri, 11 Feb 2022 21:56:27 +0000 (13:56 -0800)]
Autogen a couple of predicated SCEV tests

2 years ago[NFC] Remove check for callee parameter elementtype
Arthur Eubanks [Fri, 11 Feb 2022 21:43:09 +0000 (13:43 -0800)]
[NFC] Remove check for callee parameter elementtype

elementtype is only allowed on caller arguments.

2 years ago[clang-format] Improve require and concept handling
Björn Schäpers [Fri, 5 Nov 2021 20:10:09 +0000 (21:10 +0100)]
[clang-format] Improve require and concept handling

- Added an option where to put the requires clauses.
- Renamed IndentRequires to IndentRequiresClause.
- Changed BreakBeforeConceptDeclaration from bool to an enum.

Fixes https://llvm.org/PR32165, and https://llvm.org/PR52401.

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

2 years ago[libc++] Prepare string.ops for constexpr
Nikolas Klauser [Thu, 10 Feb 2022 23:11:31 +0000 (00:11 +0100)]
[libc++] Prepare string.ops for constexpr

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[clang] Expose -fprofile-use in clang-cl
Nico Weber [Fri, 11 Feb 2022 20:09:20 +0000 (15:09 -0500)]
[clang] Expose -fprofile-use in clang-cl

Less typing than `-fprofile-instr-use`, and means the same thing.

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

2 years ago[compiler-rt] Force ABI to libcxxabi when building cxustom libc++
Dimitry Andric [Fri, 11 Feb 2022 17:07:20 +0000 (18:07 +0100)]
[compiler-rt] Force ABI to libcxxabi when building cxustom libc++

Follow-up to 458ead66dc37, which replaced the bespoke CMakeLists.txt
file for building a custom instrumented libc++ with an invocation of the
runtimes build.

In the the bespoke CMakeLists.txt, the LIBCXX_CXX_ABI setting was forced
to libcxxabi, but this was not done for the CMake invocation for the
runtimes build. This would cause CMake configuration issues on platforms
where the default LIBCXX_CXX_ABI setting is not libcxxabi, such as
FreeBSD.

Add `-DLIBCXX_CXX_ABI=libcxxabi` to that invocation, to make sure the
custom instrumented libc++ always uses the expected ABI.

Reviewed By: phosek

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

2 years agoRevert "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:"
Adrian Prantl [Fri, 11 Feb 2022 21:02:28 +0000 (13:02 -0800)]
Revert "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:"

This reverts commit b3b2538df100ec7f6587b0ee70819a3c8ee2c27e,
it introduced a cycklic module depenency that broke the -DLLVM_ENABLE_MODULES=1 build.

2 years ago[Clang][OpaquePtr] Remove deprecated Address constructor calls
Weverything [Thu, 10 Feb 2022 23:23:43 +0000 (15:23 -0800)]
[Clang][OpaquePtr] Remove deprecated Address constructor calls

Remove most calls to deprcated Address constructor in CGExpr.cpp

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

2 years ago[memprof] Fix UB.
Florian Mayer [Fri, 11 Feb 2022 20:21:19 +0000 (12:21 -0800)]
[memprof] Fix UB.

An infinite loop without any effects is illegal C++ and can be optimized
away by the compiler.

Reviewed By: vitalybuka

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

2 years ago[libc++] Revert the addition of _LIBCPP_HIDE_FROM_ABI and inline in __threading_support
Louis Dionne [Thu, 10 Feb 2022 22:10:12 +0000 (17:10 -0500)]
[libc++] Revert the addition of _LIBCPP_HIDE_FROM_ABI and inline in __threading_support

This reverts commit 2722ac65. As explained in D115906, this was actually
unnecessary and it broke the external threading configuration.

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

2 years ago[libc++] Disable local submodule visibility in the modules build
Louis Dionne [Thu, 10 Feb 2022 20:06:50 +0000 (15:06 -0500)]
[libc++] Disable local submodule visibility in the modules build

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

2 years ago[ConstraintElimination] Support add with precondition.
Florian Hahn [Fri, 11 Feb 2022 20:26:25 +0000 (20:26 +0000)]
[ConstraintElimination] Support add with precondition.

If we can prove that an addition without wrap flags won't wrap, decompse
the operation.

Issue #48253

2 years agoFix build broken by missing empty line in SourceLevelDebugging.rst
YASHASVI KHATAVKAR [Fri, 11 Feb 2022 20:18:57 +0000 (15:18 -0500)]
Fix build broken by missing empty line in SourceLevelDebugging.rst

2 years ago[libcxx] Wrap [[no_unique_address]] in a macro, for clang-cl
Martin Storsjö [Thu, 10 Feb 2022 11:23:40 +0000 (13:23 +0200)]
[libcxx] Wrap [[no_unique_address]] in a macro, for clang-cl

This should silence all remaining clang-cl build warnings.

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

2 years ago[x86] add test for load ordering; NFC
Sanjay Patel [Fri, 11 Feb 2022 17:05:58 +0000 (12:05 -0500)]
[x86] add test for load ordering; NFC

This is reduced from a test that failed with D118376.
The C source is posted in issue #53695

2 years ago[x86] scrub less memory ops in test; NFC
Sanjay Patel [Thu, 10 Feb 2022 20:18:46 +0000 (15:18 -0500)]
[x86] scrub less memory ops in test; NFC

The addresses matter - we want to verify the splitting
and order of the memops.

2 years ago[libc++][NFC] Work around false positive ODR violations from ASan.
Konstantin Varlamov [Fri, 11 Feb 2022 19:56:29 +0000 (11:56 -0800)]
[libc++][NFC] Work around false positive ODR violations from ASan.

This works around a known issue in ASan. ASan doesn't instrument weak
symbols. Because instrumentation increases object size, the binary can
end up with two versions of the same object, one instrumented and one
not instrumented, with different sizes, which ASan will report as an ODR
violation. In libc++, this affects typeinfo for `std::bad_function_call`
which is emitted as a weak symbol in the test executable and as a strong
symbol in the shared library.

The main open issue for ASan appears to be
https://github.com/google/sanitizers/issues/1017.

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

2 years ago[MSan][OpaquePtr] Use inline asm elementtype instead of getPointerElementType()
Arthur Eubanks [Fri, 11 Feb 2022 19:50:11 +0000 (11:50 -0800)]
[MSan][OpaquePtr] Use inline asm elementtype instead of getPointerElementType()

2 years ago[Sanitizers] Fix build broken by missing import.
Florian Mayer [Fri, 11 Feb 2022 19:27:24 +0000 (11:27 -0800)]
[Sanitizers] Fix build broken by missing import.

2 years agohwasan: fix up includes
Dmitry Vyukov [Fri, 11 Feb 2022 19:35:17 +0000 (20:35 +0100)]
hwasan: fix up includes

Fix up includes after 595d340dceca
("sanitizer_common: make internal/external headers compatible").

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

2 years agoAdding DiBuilder interface for assumed length strings
YASHASVI KHATAVKAR [Fri, 11 Feb 2022 19:38:50 +0000 (14:38 -0500)]
Adding DiBuilder interface for assumed length strings

2 years ago[SCEVPredicate] Remove getExpr mechanism [NFC]
Philip Reames [Fri, 11 Feb 2022 19:34:30 +0000 (11:34 -0800)]
[SCEVPredicate] Remove getExpr mechanism [NFC]

This mechanism was used for a couple of purposes, but the primary one was keeping track of which predicates in a union might apply to an expression.  As these sets are small and agressively deduped, this has little value.

2 years ago[OpaquePtr][SPARC] Remove getPointerElementType() call in SparcISelLowering
Arthur Eubanks [Fri, 11 Feb 2022 19:30:42 +0000 (11:30 -0800)]
[OpaquePtr][SPARC] Remove getPointerElementType() call in SparcISelLowering

Requires keeping better track of sret types.

2 years ago[flang] Upstream fix to allocmem codegen to deal with missing dimensions
Eric Schweitz [Fri, 11 Feb 2022 02:40:13 +0000 (18:40 -0800)]
[flang] Upstream fix to allocmem codegen to deal with missing dimensions
for sequence of character types.

Upstream type test. Upstream test. Fix tests.

Do not run on windows, as that is not an implemented target.

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

2 years ago[NFC] [MTE] Use helpers for stack tagging.
Florian Mayer [Fri, 11 Feb 2022 00:15:59 +0000 (16:15 -0800)]
[NFC] [MTE] Use helpers for stack tagging.

Reviewed By: eugenis

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

2 years ago[NFCI][SCEV] `SCEVTraversal`: if search terminated, don't push further ops of nary
Roman Lebedev [Fri, 11 Feb 2022 18:25:06 +0000 (21:25 +0300)]
[NFCI][SCEV] `SCEVTraversal`: if search terminated, don't push further ops of nary

Even if the search is marked as terminated after only looking at
the first operand, we'd still look at the remaining operands
before actually ending the search.

This seems pointless and wasteful, let's not do that.

2 years ago[SCEV] Generalize umin_seq matching
Roman Lebedev [Fri, 11 Feb 2022 17:34:46 +0000 (20:34 +0300)]
[SCEV] Generalize umin_seq matching

Since we don't greedily flatten `umin_seq(a, umin(b, c))` into `umin_seq(a, b, c)`,
just looking at the operands of the outer-level `umin` is not sufficient,
and we need to recurse into all same-typed `umin`'s.

2 years ago[SCEV] Recognize `x == 0 ? 0 : umin_seq(..., x, ...) -> umin_seq(x, umin_seq(....
Roman Lebedev [Fri, 11 Feb 2022 14:59:09 +0000 (17:59 +0300)]
[SCEV] Recognize `x == 0 ? 0 : umin_seq(..., x, ...)  ->  umin_seq(x, umin_seq(...))`

2 years ago[SCEV] Recognize `x == 0 ? 0 : umin(..., x, ...) -> umin_seq(x, umin(...))`
Roman Lebedev [Fri, 11 Feb 2022 14:52:11 +0000 (17:52 +0300)]
[SCEV] Recognize `x == 0 ? 0 : umin(..., x, ...)  ->  umin_seq(x, umin(...))`

That is the canonical expansion for umin_seq,
so we really should roundtrip it.

2 years ago[SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: generalize eq handling
Roman Lebedev [Fri, 11 Feb 2022 12:48:36 +0000 (15:48 +0300)]
[SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: generalize eq handling

The current logic was: https://alive2.llvm.org/ce/z/j8muXk
but in reality the offset to the Y in the 'true' hand
does not need to exist: https://alive2.llvm.org/ce/z/MNQ7DZ
https://alive2.llvm.org/ce/z/S2pMQD

To catch that, instead of computing the Y's in both
hands and checking their equality, compute Y and C,
and check that C is 0 or 1.

2 years ago[NFC][SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: dedup eq/ne pred handling
Roman Lebedev [Fri, 11 Feb 2022 12:25:47 +0000 (15:25 +0300)]
[NFC][SCEV] `createNodeForSelectOrPHIInstWithICmpInstCond()`: dedup eq/ne pred handling

2 years ago[NFC][SCEV] Add test more tests for umin_seq recognition
Roman Lebedev [Fri, 11 Feb 2022 15:02:47 +0000 (18:02 +0300)]
[NFC][SCEV] Add test more tests for umin_seq recognition

2 years ago[NFC][SCEV] Add some tests for select->umax recognition
Roman Lebedev [Fri, 11 Feb 2022 12:22:12 +0000 (15:22 +0300)]
[NFC][SCEV] Add some tests for select->umax recognition

Apparently we didn't have any tests for that codepath?

2 years ago[X86] Replace X86ISD::AVG with generic ISD::AVGCEILU
David Green [Fri, 11 Feb 2022 18:57:18 +0000 (18:57 +0000)]
[X86] Replace X86ISD::AVG with generic ISD::AVGCEILU

Pulled out of D106237, this replaces the X86ISD::AVG DAG node with the
generic ISD::AVGCEILU. It doesn't remove the detectAVGPattern method,
but the extra generic ISel matching does alter the existing test.

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

2 years ago[hwasan] keep debug intrinsicts in AllocaInfo.
Florian Mayer [Thu, 10 Feb 2022 23:57:47 +0000 (15:57 -0800)]
[hwasan] keep debug intrinsicts in AllocaInfo.

Reviewed By: eugenis

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

2 years ago[flang] Allow mixed association of procedure pointers and targets
Peter Steinfeld [Thu, 10 Feb 2022 03:46:34 +0000 (19:46 -0800)]
[flang] Allow mixed association of procedure pointers and targets

Section 10.2.2.4, paragraph 3 states that a procedure pointer with an explicit
interface must have the same characteristics as its target.  Previously, we
interpreted this as disallowing such pointers to point to procedures with
implicit interfaces.  But several other compilers allow this.

We make an exception for the case where the explicit interface cannot be
called via an implicit interface.

This change makes us allow this, also

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

2 years ago[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:
Peter Kasting [Fri, 11 Feb 2022 18:45:58 +0000 (13:45 -0500)]
[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:

Makes lld-link work in a non-MSVC shell by autodetecting MSVC toolchain. Also
adds support for /winsysroot and a few other switches.

All this is done by refactoring to share code with clang-cl's existing support
for the same.

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

2 years ago[gn build] Manually port c7eb84634519e6497
Arthur Eubanks [Fri, 11 Feb 2022 18:51:52 +0000 (10:51 -0800)]
[gn build] Manually port c7eb84634519e6497

Since the bot is broken due to hwasan issues, it's not auto updating the file lists.

2 years ago[nfc] [hwasan] factor out logic to collect info about stack
Florian Mayer [Thu, 3 Feb 2022 19:56:42 +0000 (11:56 -0800)]
[nfc] [hwasan] factor out logic to collect info about stack

this is the first step in unifying some of the logic between hwasan and
mte stack tagging. this only moves around code, changes to converge
different implementations of the same logic follow later.

Reviewed By: eugenis

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

2 years ago[RGT] Refactor environment-specific checks to use GTEST_SKIP()
Paul Robinson [Fri, 11 Feb 2022 18:43:22 +0000 (10:43 -0800)]
[RGT] Refactor environment-specific checks to use GTEST_SKIP()

This allows using GTEST_SKIP() to identify un-executed tests.

Found by the Rotten Green Tests project.

2 years ago[RGT] Refactor Windows-specific checks into their own test
Paul Robinson [Fri, 11 Feb 2022 18:42:38 +0000 (10:42 -0800)]
[RGT] Refactor Windows-specific checks into their own test

This allows using GTEST_SKIP() to identify un-executed tests.

Found by the Rotten Green Tests project.

2 years ago[RGT] Exercise both paths through a test
Paul Robinson [Fri, 11 Feb 2022 18:41:24 +0000 (10:41 -0800)]
[RGT] Exercise both paths through a test

BitcastToGEP had an opaque/typed pointer decision point, make sure it
exercises both sides.

Found by the Rotten Green Tests project.

2 years ago[OpenMP][FIX] The `llvm.amdgcn.s.barrier` is actually not aligned
Johannes Doerfert [Fri, 11 Feb 2022 18:22:51 +0000 (12:22 -0600)]
[OpenMP][FIX] The `llvm.amdgcn.s.barrier` is actually not aligned

If we assume `llvm.amdgcn.s.barrier` is aligned we may remove it and
cause OpenMP GPU applications on the AMD GPU to be stuck or wrongly
synchronized.

Reported by Carlo Bertolli.

2 years ago[clang][OpaquePtr] Remove call to getPointerElementType() in CodeGenModule::GetAddrOf...
Arthur Eubanks [Fri, 11 Feb 2022 18:39:26 +0000 (10:39 -0800)]
[clang][OpaquePtr] Remove call to getPointerElementType() in CodeGenModule::GetAddrOfGlobalTemporary()

2 years agosanitizer_common: make internal/external headers compatible
Dmitry Vyukov [Fri, 11 Feb 2022 15:11:23 +0000 (16:11 +0100)]
sanitizer_common: make internal/external headers compatible

This is a follow up to 4f3f4d672254
("sanitizer_common: fix __sanitizer_get_module_and_offset_for_pc signature mismatch")
which fixes a similar problem for msan build.

I am getting the following error compiling a unit test for code that
uses sanitizer_common headers and googletest transitively includes
sanitizer interface headers:

In file included from third_party/gwp_sanitizers/singlestep_test.cpp:3:
In file included from sanitizer_common/sanitizer_common.h:19:
sanitizer_interface_internal.h:41:5: error: typedef redefinition with different types
('struct __sanitizer_sandbox_arguments' vs 'struct __sanitizer_sandbox_arguments')
  } __sanitizer_sandbox_arguments;
common_interface_defs.h:39:3: note: previous definition is here
} __sanitizer_sandbox_arguments;

Reviewed By: melver

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

2 years ago[PSE] Allow duplicate predicates in debug output
Philip Reames [Fri, 11 Feb 2022 18:37:39 +0000 (10:37 -0800)]
[PSE] Allow duplicate predicates in debug output

This lets us avoid redundant implication work in the constructor of SCEVUnionPredicate which simplifies an upcoming change.  If we're actually building a predicate via PSE, that goes through addPredicate which does include the implication check.

2 years ago[X86] combineVSelectToBLENDV - handle vselect(vXi1,A,B) -> blendv(sext(vXi1),A,B)
Simon Pilgrim [Fri, 11 Feb 2022 18:38:07 +0000 (18:38 +0000)]
[X86] combineVSelectToBLENDV - handle vselect(vXi1,A,B) -> blendv(sext(vXi1),A,B)

For pre-AVX512 targets, attempt to sign-extend a vXi1 condition mask to pass to a X86ISD::BLENDV node

Fixes Issue #53760

2 years ago[AMDGPU] Merge AMDGPULDSUtils into AMDGPUMemoryUtils
Stanislav Mekhanoshin [Fri, 11 Feb 2022 00:30:10 +0000 (16:30 -0800)]
[AMDGPU] Merge AMDGPULDSUtils into AMDGPUMemoryUtils

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

2 years ago[ISel] Port AArch64 HADD and RHADD to ISel
David Green [Fri, 11 Feb 2022 18:28:56 +0000 (18:28 +0000)]
[ISel] Port AArch64 HADD and RHADD to ISel

This ports the aarch64 combines for HADD and RHADD over to DAG combine,
so that they can be used in more architectures (notably MVE in a
followup patch). They are renamed to AVGFLOOR and AVGCEIL in the
process, to avoid confusion with instructions such as X86 hadd. The code
was also rewritten slightly to remove the AArch64 idiosyncrasies.

The general pattern for a AVGFLOORS is
  %xe = sext i8 %x to i32
  %ye = sext i8 %y to i32
  %a = add i32 %xe, %ye
  %r = lshr i32 %a, 1
  %t = trunc i32 %r to i8

An AVGFLOORU is equivalent with zext. Because of the truncate
lshr==ashr, as the top bits are not demanded. An AVGCEIL also includes
an extra rounding, so includes an extra add of 1.

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

2 years ago[AlwaysInliner] Respect noinline call site attribute
Dávid Bolvanský [Fri, 11 Feb 2022 18:22:51 +0000 (19:22 +0100)]
[AlwaysInliner] Respect noinline call site attribute

```
always_inline foo() { }

bar () {

noinline foo();
}
```

We should prefer call site attribute over attribute on decl. This is fix for AlwaysInliner, similar fix is needed for normal Inliner (follow up).

Related to https://reviews.llvm.org/D119061

Reviewed By: aeubanks

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

2 years ago[CodeView] Match any backend version in the new test
Reid Kleckner [Fri, 11 Feb 2022 18:20:10 +0000 (10:20 -0800)]
[CodeView] Match any backend version in the new test

This makes the test pass for any LLVM_VERSION_MAJOR/MINOR value. Vendors
override these, and they change every six months.

2 years ago[libc++] Remove __functional_base
Nikolas Klauser [Fri, 11 Feb 2022 18:15:18 +0000 (19:15 +0100)]
[libc++] Remove __functional_base

Reviewed By: ldionne, Quuxplusone, #libc

Spies: Mordante, mgorny, libcxx-commits, arichardson, llvm-commits, arphaman

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

2 years agoRevert "StackProtector: ignore debug insts when splitting blocks."
Tim Northover [Fri, 11 Feb 2022 18:06:28 +0000 (18:06 +0000)]
Revert "StackProtector: ignore debug insts when splitting blocks."

This reverts commit 7605ca85f1a8e4e61e7de98856630d67da11aaae.

It caused an assertion failure in Fuschia.

2 years ago[InferAddressSpaces] Fix assert on invalid cast ordering
Austin Kerbow [Fri, 11 Feb 2022 06:43:45 +0000 (22:43 -0800)]
[InferAddressSpaces] Fix assert on invalid cast ordering

If a cast is needed when replacing uses with newly created values, the
cast must be inserted after the instruction that defines the new value.

Fixes: SWDEV-321215

Reviewed By: arsenm

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

2 years ago[CoroFrame][OpaquePtr] Remove getPointerElementType() call
Arthur Eubanks [Fri, 11 Feb 2022 17:52:44 +0000 (09:52 -0800)]
[CoroFrame][OpaquePtr] Remove getPointerElementType() call

Get it from the byval type instead.

2 years ago[Hexagon] Add patterns for select(i1, Q, Q)
Krzysztof Parzyszek [Fri, 11 Feb 2022 17:19:00 +0000 (09:19 -0800)]
[Hexagon] Add patterns for select(i1, Q, Q)

2 years ago[gn build] Port 31f9519d48c2
LLVM GN Syncbot [Fri, 11 Feb 2022 17:36:54 +0000 (17:36 +0000)]
[gn build] Port 31f9519d48c2

2 years ago[mlir][bufferize] Use rewriter instead of replacing all uses directly
Matthias Springer [Fri, 11 Feb 2022 17:31:00 +0000 (02:31 +0900)]
[mlir][bufferize] Use rewriter instead of replacing all uses directly

This is important for compatibility with DialectConversion.

2 years ago[RISCV] Insert VSETVLI at the end of a basic block if we didn't produce BlockInfo...
Craig Topper [Fri, 11 Feb 2022 05:33:08 +0000 (21:33 -0800)]
[RISCV] Insert VSETVLI at the end of a basic block if we didn't produce BlockInfo.Exit.

This is an alternative to D118667 that instead of fixing the store
to match phase 1, it tries to detect the mismatch with the expected
value at the end of the block. This inserts a vsetvli after the vse
to satisfy the requirement of the other basic block.

We still have serious design issues in the pass, that is going to
require some rethinking.

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

2 years agoRevert "[RISCV] Fix a vsetvli insertion bug involving loads/stores." and "[RISCC...
Craig Topper [Fri, 11 Feb 2022 05:03:12 +0000 (21:03 -0800)]
Revert "[RISCV] Fix a vsetvli insertion bug involving loads/stores." and "[RISCC] Add missing words to comment. NFC"

This reverts commit f943c58cae2480755cecdac5be832274f238df93.
and commit 7eb781072744b31a60e82b5a5903471032d4845f.

This introduced a new bug that appears to be easier to hit.

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

2 years ago[RISCV] Add test case for a vsetvli insertion bug found after D118667.
Craig Topper [Thu, 10 Feb 2022 21:55:29 +0000 (13:55 -0800)]
[RISCV] Add test case for a vsetvli insertion bug found after D118667.

We're missing a vsetvli before a vse after a redsum in this test.

This appears to be because the vmv.s.x has a VL of 1, but did not
trigger a vsetvli because it is a scalar move op and any non-zero
VL would work. So it looked at it the predecessors and decided it was
that they all had a non-zero vl. Then the redsum was visited, it
also took the VL from the predecessors since the vmv.s.x and the 4
was found compatible.

Finally we visit the vse and it looks at the BBLocalInfo and sees
that is compatible because it contains a VL of 1 from the vmv.s.x,
the first instruction in the block. BBLocalInfo was not updated
when the vredsum was visited because BBLocalInfo was valid and no
vsetvli was generated.

I think fundamentally the vmv.s.x optimization has the same first
phase and third phase not matching problem that D118667 was trying
to fix for stores.

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

2 years ago[M68k] Adopt the new VarLenCodeEmitterGen for arithmetic instructions
Min-Yih Hsu [Mon, 6 Dec 2021 03:36:10 +0000 (11:36 +0800)]
[M68k] Adopt the new VarLenCodeEmitterGen for arithmetic instructions

This patch refactors all the existing M68k arithmetic instructions
to use the new VarLenCodeEmitterGen infrastructure.

This patch is tested by the existing MC test cases.

Note that one of the codegen tests needed to be updated because the
ordering of two equivalent instructions were switched.

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

2 years ago[TableGen][CodeEmitter] Introducing the VarLenCodeEmitterGen infrastructure
Min-Yih Hsu [Mon, 6 Dec 2021 03:01:17 +0000 (11:01 +0800)]
[TableGen][CodeEmitter] Introducing the VarLenCodeEmitterGen infrastructure

Full write up:
https://gist.github.com/mshockwave/66e98d099256deefc062633909bb7b5b

The existing CodeEmitterGen infrastructure is unable to generate encoder
function for ISAs with variable-length instructions. This patch
introduces a new infrastructure to support variable-length instruction
encoding, including a new TableGen syntax for writing instruction
encoding directives and a new TableGen backend component,
VarLenCodeEmitterGen, built on top of CodeEmitterGen.

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

2 years ago[TableGen][AMDGPU] Allow empty register classes
Jay Foad [Fri, 11 Feb 2022 14:07:15 +0000 (14:07 +0000)]
[TableGen][AMDGPU] Allow empty register classes

Remove ARTIFICIAL_VGPR which only existed to make VReg_1 not empty.

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

2 years ago[libc++] Remove unused include from ranges_swap_ranges.h
Joe Loser [Thu, 10 Feb 2022 23:11:39 +0000 (18:11 -0500)]
[libc++] Remove unused include from ranges_swap_ranges.h

`ranges_swap_ranges.h` includes `<type_traits>` but does not use anything from
it. So, remove the include.

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

2 years ago[AMDGPU] Make enable-flat-scratch a subtarget feature
Sebastian Neubauer [Fri, 11 Feb 2022 17:18:25 +0000 (18:18 +0100)]
[AMDGPU] Make enable-flat-scratch a subtarget feature

Use a subtarget feature instead of a command line argument to reduce
global state.
We want to enable flat scratch for graphics in some cases and this
doesn't work well with command line options.

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

2 years ago[AMDGPU] replace hostcall module flag with function attribute
Sameer Sahasrabuddhe [Fri, 11 Feb 2022 05:13:41 +0000 (10:43 +0530)]
[AMDGPU] replace hostcall module flag with function attribute

The module flag to indicate use of hostcall is insufficient to catch
all cases where hostcall might be in use by a kernel. This is now
replaced by a function attribute that gets propagated to top-level
kernel functions via their respective call-graph.

If the attribute "amdgpu-no-hostcall-ptr" is absent on a kernel, the
default behaviour is to emit kernel metadata indicating that the
kernel uses the hostcall buffer pointer passed as an implicit
argument.

The attribute may be placed explicitly by the user, or inferred by the
AMDGPU attributor by examining the call-graph. The attribute is
inferred only if the function is not being sanitized, and the
implictarg_ptr does not result in a load of any byte in the hostcall
pointer argument.

Reviewed By: jdoerfert, arsenm, kpyzhov

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