Commit Graph

414756 Commits

Author SHA1 Message Date
Joe Loser 8f0b2ac140
[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
2022-02-11 18:37:32 -05:00
Jonas Devlieghere af969141fa [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
2022-02-11 15:26:33 -08:00
Fangrui Song da2a16f702 [tsan] Make __fxstat code path glibc only
This fixes Linux musl build after D118423.
2022-02-11 15:23:18 -08:00
Konstantin Varlamov e1e17a6489 [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
2022-02-11 15:15:51 -08:00
Michael Gottesman 19279ffc77 [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
2022-02-11 15:15:13 -08:00
Nico Weber 0574b5fc65 try to fix windows build after 73e585e44d 2022-02-11 18:04:15 -05:00
Paul Kirth e5739368b3 [sanitizers] Fix missing header for mac builds
Differential Revision: https://reviews.llvm.org/D119598
2022-02-11 23:02:47 +00:00
Alex Lorenz 0d9b91524e [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
2022-02-11 15:01:10 -08:00
Evgenii Stepanov a730b6a41a [NFC] clang-format one function.
fix code formatting

Differential Revision: https://reviews.llvm.org/D119299
2022-02-11 15:00:29 -08:00
Michael Jones 7eb5cb7f9e [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
2022-02-11 14:58:21 -08:00
Michael Forney d75a5650db [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
2022-02-11 14:49:25 -08:00
Martin Storsjö 415d676296 [libcxx] Fix a missed instance of _LIBCPP_NO_UNIQUE_ADDRESS
This was missed in 8a0a706f09 (added
after that patch was made originally).
2022-02-12 00:44:37 +02:00
Florian Mayer 26dbc47468 Revert "[hwasan] keep debug intrinsicts in AllocaInfo."
This reverts commit 19fdf85f58.
2022-02-11 14:41:24 -08:00
Florian Mayer b1bd64aeee Revert "[NFC] [MTE] Use helpers for stack tagging."
This reverts commit 8f0e5b4e26.
2022-02-11 14:41:24 -08:00
Fangrui Song 633e797d59 [Bazel] Add WindowsDriver after 73e585e44d 2022-02-11 14:32:23 -08:00
Conrad Poelman fc5bf040d8 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
2022-02-11 15:23:51 -07:00
Annika 43a1756a5d 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
2022-02-12 06:11:49 +08:00
Nico Weber 73e585e44d Reland "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:"
This relands commit b3b2538df1, except that the new files in Support
are instead in a new library WindowsDriver.
2022-02-11 17:07:33 -05:00
Shubham Sandeep Rastogi d76da6c7e4 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
2022-02-11 14:05:26 -08:00
Paul Kirth 45bddf54e2 [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
2022-02-11 21:58:02 +00:00
Philip Reames 7a04526117 Autogen a couple of predicated SCEV tests 2022-02-11 13:56:35 -08:00
Arthur Eubanks a3fa1d5071 [NFC] Remove check for callee parameter elementtype
elementtype is only allowed on caller arguments.
2022-02-11 13:43:51 -08:00
Björn Schäpers 9aab0db13f [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
2022-02-11 22:42:37 +01:00
Nikolas Klauser ccc740353d [libc++] Prepare string.ops for constexpr
Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D119490
2022-02-11 22:31:32 +01:00
Nico Weber 6f1147f825 [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
2022-02-11 16:16:02 -05:00
Dimitry Andric a9f1a9c00a [compiler-rt] Force ABI to libcxxabi when building cxustom libc++
Follow-up to 458ead66dc, 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
2022-02-11 22:12:54 +01:00
Adrian Prantl baac665adf Revert "[lld/coff] Make lld-link work in a non-MSVC shell, add /winsysroot:"
This reverts commit b3b2538df1,
it introduced a cycklic module depenency that broke the -DLLVM_ENABLE_MODULES=1 build.
2022-02-11 13:07:23 -08:00
Weverything d5c314cdf4 [Clang][OpaquePtr] Remove deprecated Address constructor calls
Remove most calls to deprcated Address constructor in CGExpr.cpp

Differential Revision: https://reviews.llvm.org/D119496
2022-02-11 13:02:09 -08:00
Florian Mayer d49aaaf44f [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
2022-02-11 13:01:14 -08:00
Louis Dionne c74b192404 [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
2022-02-11 15:54:02 -05:00
Louis Dionne 7338227882 [libc++] Disable local submodule visibility in the modules build
Differential Revision: https://reviews.llvm.org/D119468
2022-02-11 15:52:55 -05:00
Florian Hahn 66400fc2dd
[ConstraintElimination] Support add with precondition.
If we can prove that an addition without wrap flags won't wrap, decompse
the operation.

Issue #48253
2022-02-11 20:26:25 +00:00
YASHASVI KHATAVKAR f9f78a2c40 Fix build broken by missing empty line in SourceLevelDebugging.rst 2022-02-11 15:19:07 -05:00
Martin Storsjö 8a0a706f09 [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
2022-02-11 22:02:32 +02:00
Sanjay Patel 99ed84242f [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
2022-02-11 15:00:10 -05:00
Sanjay Patel bce7f942bc [x86] scrub less memory ops in test; NFC
The addresses matter - we want to verify the splitting
and order of the memops.
2022-02-11 15:00:09 -05:00
Konstantin Varlamov 10953974ed [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
2022-02-11 11:56:51 -08:00
Arthur Eubanks b59a402237 [MSan][OpaquePtr] Use inline asm elementtype instead of getPointerElementType() 2022-02-11 11:50:35 -08:00
Florian Mayer 11b0506c08 [Sanitizers] Fix build broken by missing import. 2022-02-11 11:43:00 -08:00
Dmitry Vyukov 54e96ac835 hwasan: fix up includes
Fix up includes after 595d340dce
("sanitizer_common: make internal/external headers compatible").

Differential Revision: https://reviews.llvm.org/D119570
2022-02-11 20:41:37 +01:00
YASHASVI KHATAVKAR 70fdbf35de Adding DiBuilder interface for assumed length strings 2022-02-11 14:40:02 -05:00
Philip Reames c02deae18c [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.
2022-02-11 11:35:58 -08:00
Arthur Eubanks c0281c7607 [OpaquePtr][SPARC] Remove getPointerElementType() call in SparcISelLowering
Requires keeping better track of sret types.
2022-02-11 11:31:19 -08:00
Eric Schweitz c45bd4b9e5 [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
2022-02-11 11:12:49 -08:00
Florian Mayer 8f0e5b4e26 [NFC] [MTE] Use helpers for stack tagging.
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D119503
2022-02-11 10:59:09 -08:00
Roman Lebedev 97484f46eb
[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.
2022-02-11 21:58:19 +03:00
Roman Lebedev 65715ac72a
[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.
2022-02-11 21:58:19 +03:00
Roman Lebedev c234809ff8
[SCEV] Recognize `x == 0 ? 0 : umin_seq(..., x, ...) -> umin_seq(x, umin_seq(...))` 2022-02-11 21:58:19 +03:00
Roman Lebedev 281421693b
[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.
2022-02-11 21:58:19 +03:00
Roman Lebedev 4d0c0e6cc2
[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.
2022-02-11 21:58:19 +03:00