500358 Commits

Author SHA1 Message Date
David Blaikie
6e975ecf5c Reapply "[DebugInfo] Add flag to only emit referenced member functions" (#93767)
This reverts commit 02c6845c762dfd0a19d4a2f997990e160f392dae,
reapplying bfabc958c7c0d7ddc15f23383d9da836e8c6093f.

The patch was reverted due to the test failing on MacOS and Windows
where type units aren't supported. This is addressed by limiting type
unit flag/test coverage to Linux.

Complete C++ type information can be quite expensive - and there's
limited value in representing every member function, even those that
can't be called (we don't do similarly for every non-member function
anyway). So add a flag to opt out of this behavior for experimenting
with this more terse behavior.

I think Sony already does this by default, so perhaps with a change to
the defaults, Sony can migrate to this rather than a downstream patch.

This breaks current debuggers in some expected ways - but those
breakages are visible without this feature too. Consider member function
template instantiations - they can't be consistently enumerated in every
translation unit:

a.h:
```
struct t1 {
  template <int i>
  static int f1() {
    return i;
  }
};
namespace ns {
template <int i>
int f1() {
  return i;
}
}  // namespace ns
```
a.cpp:
```
void f1() {
  t1::f1<0>();
  ns::f1<0>();
}
```
b.cpp:
```
void f1();
int main() {
  f1();
  t1::f1<1>();
  ns::f1<1>();
}
```
```
(gdb) p ns::f1<0>()
$1 = 0
(gdb) p ns::f1<1>()
$2 = 1
(gdb) p t1::f1<0>()
Couldn't find method t1::f1<0>
(gdb) p t1::f1<1>()
$3 = 1
(gdb) s
f1 () at a.cpp:3
3         t1::f1<0>();
(gdb) p t1::f1<0>()
$4 = 0
(gdb) p t1::f1<1>()
Couldn't find method t1::f1<1>
(gdb)
```

(other similar non-canonical features are implicit special members
(copy/move ctor/assignment operator, default ctor) and nested types (eg:
pimpl idiom, where the nested type is declared-but-not-defined in one
TU, and defined in another TU))

lldb can't parse the template expressions above, so I'm not sure how to
test it there, but I'd guess it has similar problems. (

https://stackoverflow.com/questions/64602475/how-to-print-value-returned-by-template-member-function-in-gdb-lldb-debugging
so... I guess that's just totally not supported in lldb, how
unfortunate. And implicit special members are instantiated implicitly by
lldb, so missing those doesn't tickle the same issue)

Some very rudimentary numbers for a clang debug build:
.debug_info section size:
-g: 476MiB
-g -fdebug-types-section: 357MiB
-g -gomit-unreferenced-members: 340MiB

Though it also means a major reduction in .debug_str size,
-fdebug-types-section doesn't reduce string usage (so the first two
examples have the same .debug_str size, 247MiB), down to 175MiB.

So for total clang binary size (I don't have a quick "debug section size
reduction" on-hand): 1.45 (no type units) GiB -> 1.34 -> 1.22, so it
saves about 120MiB of binary size.

Original Differential Revision: https://reviews.llvm.org/D152017
2024-05-30 20:36:47 +00:00
Keith Smiley
d471860f2d
[bazel] Port #92983 (#93874) 2024-05-30 13:35:03 -07:00
Nick Desaulniers (paternity leave)
6f576d957e
[libc] android atest compat (#93852)
These changes slighly modify the output of the unittests so that they better
match GTest, so that utilities that parse the expected output from GTest (such
as Android's unit test harness) can read the output from our unit tests.

This allows our unit tests to be run on Android devices.

Add very primitive command line parsing to:
- support --gtest_color=no to disable printing terminal colors.
- recognize --gtest_print_time and print the test time in milliseconds.
  - most of our unit tests run on the order of microseconds, so its useful to
    preserve the existing behavior.  But upsteram GTest ONLY prints time tests
    in milliseconds, and Android's atest expects to be able to parse exactly
    that. Atest always passes --gtest_print_time. The word `took` is removed as
    that also differs from upstream GTest, tripping up parsers.
- ignore other --gtest_* flags

Do so so that atest can parse the output correctly.

Print the test number count before
each run, so that atest can parse this value correctly.

Link: https://android-review.googlesource.com/c/platform/external/llvm-libc/+/3107252
Link: https://google.github.io/googletest/advanced.html#colored-terminal-output
Link: https://google.github.io/googletest/advanced.html#suppressing-the-elapsed-time
2024-05-30 13:28:11 -07:00
Adrian Prantl
22ada554d5
[dsymutil] Also detect external downloadable toolchains (#93872)
and reject them when copying Swift interface files, since they can live
outside of DEVELOPER_DIR.
2024-05-30 13:20:57 -07:00
Kazu Hirata
224581cf3c [flang] Fix a warning
This patch fixes:

  flang/lib/Semantics/check-do-forall.cpp:731:9: error: default label
  in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]
2024-05-30 13:19:04 -07:00
Artem Yurchenko
7b80489390
[clang][AST] fix ast-print of extern <lang> with >=2 declarators (#93131)
Problem: the printer used to ignore all but the first declarator for
unbraced language linkage declarators. Furthemore, that one would be
printed without the final semicolon.

Solution: when there is more than one declarator, we print them in a
braced `extern <lang>` block. If the original declaration was unbraced
and there is one or less declarator, we omit the braces, but add the
semicolon.

**N.B.** We are printing braces which were, in some cases, absent from
the original CST. If that's an issue, I'll work on it. See the tests for
the examples.
2024-05-30 13:18:47 -07:00
Teresa Johnson
61afebdacc
[MemProf][NFC] Switch to DenseMaps (#93868)
Change a couple of maps from std::map to DenseMap, which showed
a modest (3.6%) reduction in peak RSS.
2024-05-30 12:57:14 -07:00
Krzysztof Parzyszek
ce7b670912
[clang][OpenMP] Simplify check for repeated clauses (#93611)
The `FirstClauses` is a vector of pointer-bool pairs, and the pointer
part of the pair is never used. Replace the vector with std::bitset, and
rename it to `SeenClauses` to make the purpose of it a bit clearer.
2024-05-30 14:49:13 -05:00
Martin Storsjö
9faa623d96
[compiler-rt] [test] Work around MS CRT stdio format quirks on mingw too (#93787)
So far, these tests have been disabled in mingw build configurations
(built as asan-dynamic), but these were enabled in
246234ac70faa1e3281a2bb83dfc4dd206a7d59c, exposing the issue.

(That commit is currently reverted, but will probably be relanded in
some form soon.)
2024-05-30 22:46:37 +03:00
Mingming Liu
c803c29039
[nfc][InstrProf]Remove 'offsetOf' when parsing indexed profiles (#93346)
- In `Header::readFromBuffer`, read the buffer in the forward direction by using `readNext`.
- When compute the header size, spell out the constant.

With the changes above, we can remove `offsetOf` in InstrProf.cpp

---------

Co-authored-by: Kazu Hirata <kazu@google.com>
2024-05-30 12:44:29 -07:00
Florian Mayer
973821cb44 [MTE] rename RecordStackHistoryMode
We used the same name in the global name space for HWASan, so we got
a collision.
2024-05-30 12:39:39 -07:00
Vlad Serebrennikov
baabaa4ce9
[clang][NFC] Move PDiag into SemaBase (#93849)
This patch moves `PDiag` into `SemaBase`, making it readily available
everywhere across `Sema` without `SemaRef`, like the regular `Diag`.
2024-05-30 23:38:46 +04:00
OverMighty
0eb9e021b1
[libc][math][c23] Add fabsf16 C23 math function (#93567)
cc @lntue
2024-05-30 15:37:15 -04:00
Mircea Trofin
7cfffe74ee
Unittests and usability for BitstreamWriter incremental flushing (#92983)
- added unittests for the raw_fd_stream output case.

- the `BitstreamWriter` ctor was confusing, the relationship between the buffer and the file stream wasn't clear and in fact there was a potential bug in `BitcodeWriter` in the mach-o case, because that code assumed in-buffer only serialization. The incremental flushing behavior of flushing at end of block boundaries was an implementation detail that meant serializers not using blocks (for example) would need to know to check the buffer and flush. The bug was latent - in the sense that, today, because the stream being passed was not a `raw_fd_stream`, incremental buffering never kicked in.

The new design moves the responsibility of flushing to the `BitstreamWriter`, and makes it work with any `raw_ostream` (but incrementally flush only in the `raw_fd_stream` case). If the `raw_ostream` is over a buffer - i.e. a `raw_svector_stream` - then it's equivalent to today's buffer case. For all other `raw_ostream` cases, buffering is an implementation detail. In all cases, the buffer is flushed (well, in the buffer case, that's a moot statement).

This simplifies the state and state transitions the user has to track: you have a raw_ostream -> BitstreamWrite in it -> destroy the writer => the bitstream is completely written in your raw_ostream. The "buffer" case and the "raw_fd_stream" case become optimizations rather than imposing state transition concerns to the user.
2024-05-30 12:25:59 -07:00
Adrian Prantl
f8cc183ea2
Fix the dsymutil heuristic for excluding system interfaces. (#93745)
The function was meant to find the Developer/ dir, but it found a
Developer directory nested deep inside the top-level Developer dir.

The new implementation rejects everything in Xcode.app/Developer in
broad strokes.

rdar://128571037
2024-05-30 12:23:20 -07:00
Charlie Barto
0a93e9f2e2 Revert "[asan][windows] Eliminate the static asan runtime on windows (#93770)"
This reverts commit 8fa66c6ca7272268747835a0e86805307b62399c.
2024-05-30 11:41:44 -07:00
khaki3
3af717d661
[flang] Add parsing of DO CONCURRENT REDUCE clause (#92518)
Derived from #92480. This PR supports parsing of the DO CONCURRENT
REDUCE clause in Fortran 2023. Following the style of the OpenMP parser
in MLIR, the front end accepts both arbitrary operations and procedures
for the REDUCE clause. But later Semantics can notify type errors and
resolve procedure names.
2024-05-30 11:34:19 -07:00
Hendrik Hübner
485f9f5895
Reland: [libc][POSIX][pthreads] implemented missing pthread_rwlockattr functions (#93622)
New pull request for https://github.com/llvm/llvm-project/issues/89443

The previous PR was reverted after breaking fullbuild due to a missing
struct declaration, which I forgot to commit.

Reverts revert and adds the missing pthread_rwlockattr_getkind_np /
pthread_rwlockattr_setkind_np functions and tests respecitvely.
2024-05-30 11:27:50 -07:00
Florian Hahn
5785048321
[VPlan] Add VPIRBasicBlock, use to model pre-preheader. (#93398)
This patch adds a new special type of VPBasicBlock that wraps an
existing IR basic block. Recipes of the block get added before the
terminator of the wrapped IR basic block. Making it a subclass of
VPBasicBlock avoids duplicating various APIs to manage recipes in a
block, as well as makes sure the traversals filtering VPBasicBlocks
automatically apply as well.

Initially VPIRBasicBlock are only used for the pre-preheader (wrapping
the original preheader of the scalar loop).

As follow-up, this will be used to move more parts of the skeleton
inside VPlan, starting with the branch and condition in the middle
block.

Separated out of https://github.com/llvm/llvm-project/pull/92651

PR: https://github.com/llvm/llvm-project/pull/93398
2024-05-30 11:23:32 -07:00
Charlie Barto
8fa66c6ca7
[asan][windows] Eliminate the static asan runtime on windows (#93770)
Re-Apply: 246234ac70faa1e3281a2bb83dfc4dd206a7d59c
Originally #81677

The static asan runtime on windows had various buggy hacks to ensure loaded dlls got the executable's copy of asan, these never worked all that well, so we have eliminated the static runtime altogether and made the dynamic runtime work for applications linking any flavor of the CRT.

Among other things this allows non-asan-instrumented applications to load asan-instrumented dlls that link against the static CRT.

Co-authored-by: Amy Wishnousky <amyw@microsoft.com>
2024-05-30 11:22:26 -07:00
Fangrui Song
747d670bae [ELF] Make .interp/SHT_NOTE not special
Follow-up to a previous simplification
2473b1af085ad54e89666cedf684fdf10a84f058.

The xor difference between a SHT_NOTE and a read-only SHT_PROGBITS
(previously >=NOT_SPECIAL) should be smaller than RF_EXEC. Otherwise,
for the following section layout, `findOrphanPos` would place .text
before note.

```
// simplified from linkerscript/custom-section-type.s
non orphans:
progbits 0x8060c00 NOT_SPECIAL
note     0x8040003

orphan:
.text    0x8061000 NOT_SPECIAL
```

rw-text.lds in orphan.s (added by
73e07e924470ebab76a634e41fadf425a859e0ea) demonstrates a similar case.
The new behavior is more similar to GNU ld.

#93763 fixed BOLT's brittle reliance on the previous .interp behavior.
2024-05-30 11:18:03 -07:00
Fangrui Song
73e07e9244 [ELF] Add RW then text test
Currently, lld assigns RF_NOT_SPECIAL so that orphan .interp and
SHT_NOTE are always before other sections. GNU ld doesn't do so. The
next change will remove RF_NOT_SPECIAL.
2024-05-30 11:12:55 -07:00
Jeremy Kun
692ae5443b
[mlir][polynomial] verify from_tensor coeff type (#93243)
Rebased over https://github.com/llvm/llvm-project/pull/93227

---------

Co-authored-by: Jeremy Kun <j2kun@users.noreply.github.com>
2024-05-30 11:03:36 -07:00
Fangrui Song
270d95bfed [ELF] Improve orphan placement tests
Merge orphan-align.test (which introduced `shouldSkip`) into orphan.s.
2024-05-30 10:59:22 -07:00
LLVM GN Syncbot
ded04bf5d3 [gn build] Port 48175a5d9f62 2024-05-30 17:38:53 +00:00
Miro Bucko
48175a5d9f
[lldb] Add SBAddressRange and SBAddressRangeList to SB API (#93836)
This adds new SB API calls and classes to allow a user of the SB API to obtain an address range from SBFunction and SBBlock. This is a second attempt to land the reverted PR #92014.
2024-05-30 10:38:21 -07:00
Matt Arsenault
5f243b3fff
AMDGPU: Generalize instruction shrinking code (#93810)
Try to avoid referring to specific operand names, except in the special
case. The special case for hasNamedOperand(Op32, sdst) seems to have
been dead code.
2024-05-30 19:25:04 +02:00
Fangrui Song
ce5b371606
[BOLT,test] Make linker scripts less sensitive to lld's orphan placement (#93763)
Then two tests rely on .interp being the first section.
llvm-bolt would crash if lld places .interp after .got
(f639b57f7993cadb82ee9c36f04703ae4430ed85).

For best portability, when a linker scripts specifies a SECTIONS
command, the first section for each PT_LOAD segment should be specified
with a MAXPAGESIZE alignment. Otherwise, linkers have freedom to decide
how to place orphan sections, which might break intention.
2024-05-30 10:12:41 -07:00
Andrzej Warzyński
435114f9fe
[mlir][test] Rename Vector integration tests for CPU (nfc) (#93521)
To keep the test filenames consistent, this patch:
  * removes "test-" from  file names (there used to be a mix of
    "test-feature-1.mlir" and "feature-2.mlir"),
  * replaces "_" with "-" (there used to be a mix of "feature-3.mlir"
    and "feature_4.mlir").

Only files under test/Integration/Dialect/Vector/CPU are updated.
2024-05-30 18:06:43 +01:00
Zequan Wu
3d9d485239
[lldb][DWARF] Fix adding children to clang type that hasn't started definition. (#93839)
This fixes
https://github.com/llvm/llvm-project/pull/92328#issuecomment-2139339444
by not differentiating `DW_TAG_class_type` and `DW_TAG_structure_type`
in `UniqueDWARFASTTypeList`, because it's possible that DIE for a type
is `DW_TAG_class_type` in one CU but is `DW_TAG_structure_type` in a
different CU.

---------

Co-authored-by: Michael Buch <michaelbuch12@gmail.com>
2024-05-30 13:05:29 -04:00
Jay Foad
f6c8e7dc3e
[MLIR][AMDGPU] Remove support for old llvm.amdgcn.buffer.* intrinsics (#93838)
They have been superseded by llvm.amdgcn.raw.buffer.* and
llvm.amdgcn.struct.buffer.*.
2024-05-30 17:58:11 +01:00
Poseydon42
cc2fafa178
[InstSimplify] Add constant folding support for ucmp/scmp intrinsics (#93730)
This PR adds support for folding calls to `ucmp`/`scmp` intrinsics with
constant arguments.
2024-05-30 18:31:03 +02:00
Stephen Tozer
a8e03aed6a
[DebugInfo][RemoveDIs] Add documentation for updating code to handle debug records (#93562)
Although the patch that enables debug records by default has been
temporarily reverted, it will (eventually) be reverted and everyone's
code will be subjected to the new debug info format. Although this is
broadly a good thing, it is important that the documentation has enough
information to guide users through the update; this patch adds what
should hopefully be enough detail for most users to either find the
answers, or find out how to find those answers.
2024-05-30 17:25:51 +01:00
LLVM GN Syncbot
32546bd2ff [gn build] Port ed35a92c4046 2024-05-30 16:08:16 +00:00
Brendan Dahl
8aa8019975
[WebAssembly] Implement all f16x8 relation instructions. (#93751)
All of these instructions can be generated using regular LL
instructions.

Specified at:

29a9b9462c/proposals/half-precision/Overview.md
2024-05-30 09:02:17 -07:00
Vlad Serebrennikov
ed35a92c40
[clang] Introduce target-specific Sema components (#93179)
This patch introduces `SemaAMDGPU`, `SemaARM`, `SemaBPF`, `SemaHexagon`,
`SemaLoongArch`, `SemaMIPS`, `SemaNVPTX`, `SemaPPC`, `SemaSystemZ`,
`SemaWasm`. This continues previous efforts to split Sema up. Additional
context can be found in #84184 and #92682.

I decided to bundle target-specific components together because of their
low impact on `Sema`. That said, their impact on `SemaChecking.cpp` is
far from low, and I consider it a success.

Somewhat accidentally, I also moved Wasm- and AMDGPU-specific function
from `SemaDeclAttr.cpp`, because they were exposed in `Sema`. That went
well, and I consider it a success, too. I'd like to move the rest of
static target-specific functions out of `SemaDeclAttr.cpp` like we're
doing with built-ins in `SemaChecking.cpp` .
2024-05-30 19:59:59 +04:00
Dmitry Vasilyev
b62ba7f5b1
[lldb] Fixed the TestGdbRemotePlatformFile test running on a remote target (#93832)
Skip checking of few stat fields like st_dev (ID of device containing
file) in case of a remote target.
2024-05-30 19:57:16 +04:00
Dmitry Vasilyev
59e2a6b08f
[lldb] Fixed the TestDebuggerAPI test running on a remote target (#93829)
Recently we have disabled this test for Windows host and Linux target.
Now we faced the same issue #92419 in case of Linux x86_64 host and
Linux Aarch64 target.
2024-05-30 19:56:46 +04:00
Dmitry Vasilyev
facb767e5b
[lldb] Fixed the TestGdbRemoteLibrariesSvr4Support test running on a remote target (#93825)
The TestGdbRemoteLibrariesSvr4Support test failed in case of Linux
x86_64 host and Linux Aarch64 target. Installing libraries to the remote
target is not enough. This test actively uses self.getBuildDir() and
os.path.realpath() which does not work in case of the remote target. So,
disable this test for remote target now.
2024-05-30 19:56:04 +04:00
Min-Yih Hsu
6147a7b5f9
[RISCV] Adjust FP load latencies from 6 to 5 in SiFiveP400/P600 scheduling models (#93735)
According to our performance measurements, FLH/W/D have load latencies
closer to 5 rather than 6 in these two models.
2024-05-30 08:47:27 -07:00
Pavel Labath
a2bcb932f3 [lldb] Attempt to fix TestCompletion on macos
Macos will automatically load dependent modules when creating a target,
resulting in more modules than the test expects.
2024-05-30 15:28:13 +00:00
cor3ntin
1ee02f9b60
[Clang] Fix overloading for constrained variadic functions (#93817)
Found by #93667
2024-05-30 17:22:07 +02:00
Stefan Gränitz
647d2728c4 [clang-repl] Fix SetUp in CodeCompletionTest fixture (#93816)
And sort out some unused headers
2024-05-30 17:03:21 +02:00
Christudasan Devadasan
e8de977716
[AMDGPU] Fixed subtarget name in the lit test check-prefix string (NFC). (#93780) 2024-05-30 20:27:24 +05:30
Valentin Clement (バレンタイン クレメン)
f55622f0ff
[flang] Lower non optional inquired argument in custom intrinsic lowering (#93592)
Handle lowering of non optional inquired argument in custom lowering.
Also fix an issue in the lowering of associated optional argument where
a box was emboxed again which led to weird result.
2024-05-30 07:52:08 -07:00
Ryan Holt
1159e7645b
[mlir][linalg] Add folder for transpose(transpose) -> transpose (#93606)
Back to back `linalg.transpose` can be rewritten to a single transpose
2024-05-30 10:41:29 -04:00
Krzysztof Parzyszek
adc4e45f2e [Offload] Update test to use target parallel for reduction
Re-enable test disabled in 1bf1f93d with a fix.
2024-05-30 09:17:17 -05:00
Stefan Gränitz
a871470a0d
[clang-repl] Introduce common fixture class in unittests (NFC) (#93816)
Reduce code bloat by checking test requirements in a common test fixture
2024-05-30 16:15:12 +02:00
Jeremy Kun
1f46729a18
[polynomial] Move primitive root attribute to ntt/intt ops. (#93227)
Better design to put semantics on the ops, and in this case the ntt/intt
op can lower in multiple ways depending on the polynomial ring modulus
(it can need an nth root of unity for cyclic polymul -> ntt, or a 2nth
root for negacyclic polymul -> ntt)

---------

Co-authored-by: Jeremy Kun <j2kun@users.noreply.github.com>
2024-05-30 07:09:18 -07:00
David Green
b5db2e1969 [MCP] Remove unused TII argument. NFC
Last used in e35fbf5c04f4719db8ff7c7a993cbf96bb706903.
2024-05-30 15:01:02 +01:00