521744 Commits

Author SHA1 Message Date
Tristan Ross
7477b61b24
[libc] Add unistd overlay (#119312)
Reverts the revert #119295 of #118882 by expanding #118882 with
additional fixes which made CI unhappy.
2024-12-17 10:40:22 -08:00
Nick Desaulniers
4c5ddc9ed4
[libc][docs] add redirect for math/index.html (#120274)
commit a9aff440d9dd ("[libc][docs] reorganize documentation (#118836)")

moved https://libc.llvm.org/math/index.html to
https://libc.llvm.org/headers/math/index.html which makes links from
various slide decks stale.

There's an extension for sphinx that can generate redirects. Add a dependency
on that, then use it to create a redirect so that those older links still work.

I was able to install this sphinx extension via:

    $ sudo apt install python3-sphinx-reredirects

We may need to install this on whatever server generates the llvm
documentation.
2024-12-17 10:37:21 -08:00
Nick Sarnie
1c16807d0d
[LLVM] Add Intel vendor in Triple (#120250)
We plan to make use of this in SPIR-V-based OpenMP offloading, for which
there is already an initial patch in review.

Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2024-12-17 12:30:21 -06:00
Brox Chen
b26f534980
[AMDGPU][True16][MC] test update for v_and/or/xor_b16 in true16 (#119489)
This is a NFC change. Update mc test for v_and/or/xor_b16 in true16
format.

MC source change was done by previous patch and automatically enabled by
t16 pesudo
2024-12-17 13:26:59 -05:00
Jacek Caban
9c8214ff31
[LLD][COFF] Create COFFObjectFile instance when constructing ObjFile (NFC) (#120144)
This change moves the creation of COFFObjectFile to the construction of
ObjFile, instead of delaying it until parsing.
2024-12-17 19:26:13 +01:00
Craig Topper
659dbb6329 [RISCV] Remove unnecessary patterns from RISCVInstrInfoA.td. NFC
Looks like they got left behind in the Zalasr patch after I removed
i32 patterns for RV64.
2024-12-17 10:24:50 -08:00
Brox Chen
f9a9173b6c
[AMDGPU][True16][MC] test update for v_mul_f16 in true16 (#119314)
This is a NFC change. Update mc test for v_mul_f16 in true16 format.

MC source change was done by previous patch and automatically enabled by
t16 pesudo
2024-12-17 13:24:32 -05:00
Simon Pilgrim
2a922903bf [X86] vector-shift tests - regenerate VPTERNLOG comments 2024-12-17 18:19:15 +00:00
Brox Chen
8bbbcaddbb
[AMDGPU][True16][MC] test update for v_max_f16/v_min_f16 in true16 (#119291)
This is a NFC change. Update mc test for v_max/min_f16 in true16 format.

MC source change was done by previous patch and automatically enabled by
t16 pesudo
2024-12-17 13:12:39 -05:00
Simon Pilgrim
5287299f88
[VectorCombine] foldShuffleOfBinops - prefer same cost fold if it reduces instruction count (#120216)
We don't fold "shuffle (binop), (binop)" -> "binop (shuffle), (shuffle)" if the old/new costs are equal, but we can relax this if either new shuffle will constant fold as it will reduce instruction count.
2024-12-17 18:10:20 +00:00
Michael Maitland
904849f297
[RISCV][VLOPT] Add support for more instructions in vl-opt-op-info.mir (#119416)
Specifically, some more where EMUL=LMUL and EEW=SEW.
2024-12-17 12:57:29 -05:00
Guray Ozen
90c7600f25
[MLIR][NVVM] Add exit (#120251)
PR adds `exit` instruction to nvvm dialect.
2024-12-17 18:38:39 +01:00
lntue
a57f4c7009
[compiler-rt] Fix a bug in fp_div_impl when an intermediate result is out of expected range. (#119449)
Before this fix, `1.0L / (1.0L - 0x1.0p-113L)` will return `2 * (1 +
eps(1))`.
2024-12-17 12:24:57 -05:00
Thurston Dang
e8a6563768
Fix-forward 'RegAllocFast: Avoid using temporary DiagnosticInfo #120184' (#120268)
There was a buildbot breakage

(https://lab.llvm.org/buildbot/#/builders/24/builds/3329/steps/11/logs/stdio):


/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/test/CodeGen/AMDGPU/ran-out-of-registers-error-all-regs-reserved.ll:9:10:
error: CHECK: expected string not found in input
; CHECK: error: <unknown>:0:0: no registers from class available to
allocate in function 'no_registers_from_class_available_to_allocate'

2: ==75198==ERROR: AddressSanitizer: stack-use-after-scope on address
0xfa23f9f1c270 at pc 0xb2660dda9340 bp 0xfffffe8ab340 sp 0xfffffe8ab338

caused by https://github.com/llvm/llvm-project/pull/120184, which made a
partial fix but also renabled the tests. This patch attempts to fix
forward by applying the same fix to the error message highlighted in the
buildbot.
2024-12-17 09:09:13 -08:00
Kazu Hirata
30916b6942
[MemRef] Migrate away from PointerUnion::{is,get} (NFC) (#120202)
Note that PointerUnion::{is,get} have been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

I'm not touching PointerUnion::dyn_cast for now because it's a bit
complicated; we could blindly migrate it to dyn_cast_if_present, but
we should probably use dyn_cast when the operand is known to be
non-null.
2024-12-17 09:07:47 -08:00
Michael Maitland
345a35259c
[RISCV][VLOPT] Avoid crash when user produces scalar def (#120255)
I found this crash when trying to enable the VLOptimizer pass. We need
this patch before we can enable by default. The old assert was not
checking that USE and DEF were vector registers. The correct condition
is guarded at the callsite of tryReduceVL.
2024-12-17 12:07:29 -05:00
Timothy Hoffman
fbbbd65b25
[MLIR] correct return type of parse() functions (#120180)
The `parseX()` functions that are defined to support `custom<X>` in
`assemblyFormat` should return `ParseResult` rather than
`LogicalResult`. The `ParseResult` type is necessary due to tablegen
generating code that expects this type within an Op `parseX()` function.
2024-12-17 09:06:55 -08:00
Slava Zakharin
9d33874936
[flang] Support -f[no-]realloc-lhs. (#120165)
-frealloc-lhs is the default.
If -fno-realloc-lhs is specified, then an allocatable on the left
side of an intrinsic assignment is not implicitly (re)allocated
to conform with the right hand side. Fortran runtime will issue
an error if there is a mismatch in shape/type/allocation-status.
2024-12-17 09:06:05 -08:00
Mikhail Goncharov
525c818f08 [bazel] port 6a7d6c5f69dda254ec92f982985fd10fa51c63ef 2024-12-17 17:56:43 +01:00
alx32
558de0e1f9
[llvm-gsymutil] Add option to load callsites from DWARF (#119913)
This change adds support for loading gSYM callsite information from
DWARF. Previously the only support was for loading callsites info from
YAML.

For testing, we add a pass where `macho-gsym-merged-callsites-dsym`
loads callsite info from DWARF rather than YAML.
2024-12-17 08:51:30 -08:00
Kazu Hirata
8bb1bdf919 [X86] Fix warnings
This patch fixes:

  llvm/lib/Target/X86/X86ISelLowering.cpp:30127:23: error: comparison
  of integers of different signs: 'int' and 'unsigned int'
  [-Werror,-Wsign-compare]

  llvm/lib/Target/X86/X86ISelLowering.cpp:30205:35: error: comparison
  of integers of different signs: 'int' and 'unsigned int'
  [-Werror,-Wsign-compare]

  llvm/lib/Target/X86/X86ISelLowering.cpp:30453:23: error: comparison
  of integers of different signs: 'int' and 'unsigned int'
  [-Werror,-Wsign-compare]
2024-12-17 08:48:23 -08:00
Michael Buch
9fc54c0e80
[clang][DebugInfo][gmodules] Set runtimeLang on ObjC forward declarations (#120154)
In Objective-C, forward declarations are currently represented as:
```
DW_TAG_structure_type
  DW_AT_name                ("Foo")
  DW_AT_declaration         (true)
  DW_AT_APPLE_runtime_class (DW_LANG_ObjC)
```
However, when compiling with `-gmodules`, when a class definition is
turned into a forward declaration within a `DW_TAG_module`, the DIE for
the forward declaration looks as follows:
```
DW_TAG_structure_type
  DW_AT_name                ("Foo")
  DW_AT_declaration         (true)
```

Note the absence of `DW_AT_APPLE_runtime_class`. With recent changes in
LLDB, not being able to differentiate between C++ and Objective-C
forward declarations has become problematic (see attached test-case and
explanation in https://github.com/llvm/llvm-project/pull/119860).
2024-12-17 16:40:10 +00:00
Nico Weber
34a44b2088
[lld/COFF] Handle -start-lib / -end-lib better in /reproduce: output (#119752)
Previously, we'd collect all input files in Driver::filePaths, and then
write filePaths after all other flags in
createResponseFile(). This meant that `-start-lib foo.obj -end-lib`
would be written as `-start-lib -end-lib foo.obj`, changing semantics.

Instead, remove Driver::filePaths, and handle things that fed into it
directly:

* OPT_INPUT is now handled in the same way as other flags, so that we
now get `-start-lib foo.obj -end-lib` in response.txt as desired. Add a
test for -start-lib / -end-lib and /reproduce:.

* OPT_wholearchive_file needs explicit handling now -- but before, this
was buggy as well: We'd put the flag without a rewritten path in
response.txt, but also the rewritten input file without wholearchive
semantics via filePaths. So this commit makes --whole-archive work with
/reproduce: too, and adds test coverage.

* /defaultlib:foo is now written as /defaultlib:foo into response.txt,
instead of writing the resolved path previously. While response.txt
looks slightly differently, both should have the same semantics, and
this should be mostly a no-op. (It does require updating a test.)

* /defaultlib: from .drectve sections are no longer recorded in
response.txt. This seems like a progression -- in the non-repro case
they come from .obj files, so they should come (only) from there in the
repro case too. This adds test coverage for this case.

Makes createResponseFile() look more like the versions in the ELF and
MachO ports too.
2024-12-17 11:30:13 -05:00
Simon Pilgrim
7ab8dd7c31
[X86] LowerShift - pull out repeated getVectorNumElements calls. NFC. (#120241) 2024-12-17 16:27:11 +00:00
Petr Hosek
edf9439e00
[libcxx] Support for using timespec_get (#117362)
clock_gettime is a POSIX API that may not be available on platforms like
baremetal; timespec_get is the C11 equivalent. This change adds support
for using timespec_get instead of clock_gettime to improve compatibility
with non-POSIX platforms. For now, this is only enabled with LLVM libc
which implemented timespec_get in #116102, but in the future this can be
expanded to other platforms.

Related to #84879.
2024-12-17 08:16:55 -08:00
Petr Hosek
62bd10f7d1
[libcxx] Use alias for detecting overriden function (#114961)
This mechanism is preferable in environments like embedded since it
doesn't require special handling of the custom section.
2024-12-17 08:16:26 -08:00
Gedare Bloom
57c161a647
[clang-format] Detect nesting in template strings (#119989)
The helper to check if a token is in a template string scans too far
backward. It should stop if a different scope is found.

Fixes #107571
2024-12-17 08:05:01 -08:00
Simon Pilgrim
146240ef1c Fix MSVC " 32-bit shift implicitly converted to 64 bits" warnings. NFC. 2024-12-17 16:01:19 +00:00
Maksim Levental
f539e00c70
[mlir] add option to print SSA IDs using NameLocs as prefixes (#119996)
This PR adds an `AsmPrinter` option `-mlir-use-nameloc-as-prefix` which
uses trailing `NameLoc`s, if the source IR provides them, as prefixes
when printing SSA IDs.
2024-12-17 07:59:11 -08:00
Mehdi Amini
6a7d6c5f69
[MLIR] Add a MLIR_NVVM_EMBED_LIBDEVICE CMake option that embeds libdevice in the binary (#120238)
This removes a runtime dependency on the CUDA Toolkit path, instead of
looking up the filesystem we use a version of libdevice embedded in the
binary at build time.
2024-12-17 16:53:38 +01:00
Louis Dionne
d8a0709b10
[libc++] Bump the version of CMake built in the CI Docker image (#120240)
This will allow using the $<LINK_LIBRARY> generator expression in some
of our configurations. We should separately pursue officially bumping
the minimum CMake version across all LLVM so we can use this feature
more widely.
2024-12-17 10:29:18 -05:00
Florian Hahn
c135f6ffe2
[TySan] Add initial Type Sanitizer support to Clang) (#76260)
This patch introduces the Clang components of type sanitizer: a
sanitizer for type-based aliasing violations.

It is based on Hal Finkel's https://reviews.llvm.org/D32198.

The Clang changes are mostly formulaic, the one specific change being
that when the TBAA sanitizer is enabled, TBAA is always generated, even
at -O0.

It goes together with the corresponding LLVM changes
(https://github.com/llvm/llvm-project/pull/76259) and compiler-rt
changes (https://github.com/llvm/llvm-project/pull/76261)

PR: https://github.com/llvm/llvm-project/pull/76260
2024-12-17 15:13:42 +00:00
Sergei Barannikov
cf4375d107
[TableGen][GISel] Extract common function for determining MI's regclass (#120135)
Add some comments that hopefully clarify a few things.

This was supposed to be NFC, but there is a difference in the inferred
register class for EXTRACT_SUBREG.

Pull Request: https://github.com/llvm/llvm-project/pull/120135
2024-12-17 18:03:22 +03:00
Louis Dionne
ce4ac99452
[libc++] Remove explicit mentions of __need_FOO macros (#119025)
This change has a long history. It was first attempted naively in
https://reviews.llvm.org/D131425, which didn't work because we broke the
ability for code to include e.g. <stdio.h> multiple times and get
different definitions based on the pre-defined macros.

However, in #86843 we managed to simplify <stddef.h> by including the
underlying system header outside of any include guards, which worked.

This patch applies the same simplification we did to <stddef.h> to the
other headers that currently mention __need_FOO macros explicitly.
2024-12-17 09:52:34 -05:00
Mikhail Goncharov
17b3dd03a0 [NVPTX][test] fix CodeGen/NVPTX/surf-write.ll
ptxas needs a proper triplet

for 133352feb30605ec51b15f77826ed3a2fbf8db56
2024-12-17 15:45:06 +01:00
LLVM GN Syncbot
70c5887958 [gn build] Port a487b792e2da 2024-12-17 14:10:29 +00:00
Ivan G.
e6ced4da44
Typo fix in large_sections.rst (#120101)
Remove duplicate word.
2024-12-17 14:01:03 +00:00
Florian Hahn
a487b792e2
[TySan] Add initial Type Sanitizer (LLVM) (#76259)
This patch introduces the LLVM components of a type sanitizer: a
sanitizer for type-based aliasing violations.

It is based on Hal Finkel's https://reviews.llvm.org/D32198.

C/C++ have type-based aliasing rules, and LLVM's optimizer can exploit
these given TBAA metadata added by Clang. Roughly, a pointer of given
type cannot be used to access an object of a different type (with, of
course, certain exceptions). Unfortunately, there's a lot of code in the
wild that violates these rules (e.g. for type punning), and such code
often must be built with -fno-strict-aliasing. Performance is often
sacrificed as a result. Part of the problem is the difficulty of finding
TBAA violations. Hopefully, this sanitizer will help.

For each TBAA type-access descriptor, encoded in LLVM's IR using
metadata, the corresponding instrumentation pass generates descriptor
tables. Thus, for each type (and access descriptor), we have a unique
pointer representation. Excepting anonymous-namespace types, these
tables are comdat, so the pointer values should be unique across the
program. The descriptors refer to other descriptors to form a type
aliasing tree (just like LLVM's TBAA metadata does). The instrumentation
handles the "fast path" (where the types match exactly and no
partial-overlaps are detected), and defers to the runtime to handle all
of the more-complicated cases. The runtime, of course, is also
responsible for reporting errors when those are detected.

The runtime uses essentially the same shadow memory region as tsan, and
we use 8 bytes of shadow memory, the size of the pointer to the type
descriptor, for every byte of accessed data in the program. The value 0
is used to represent an unknown type. The value -1 is used to represent
an interior byte (a byte that is part of a type, but not the first
byte). The instrumentation first checks for an exact match between the
type of the current access and the type for that address recorded in the
shadow memory. If it matches, it then checks the shadow for the
remainder of the bytes in the type to make sure that they're all -1. If
not, we call the runtime. If the exact match fails, we next check if the
value is 0 (i.e. unknown). If it is, then we check the shadow for the
remainder of the byes in the type (to make sure they're all 0). If
they're not, we call the runtime. We then set the shadow for the access
address and set the shadow for the remaining bytes in the type to -1
(i.e. marking them as interior bytes). If the type indicated by the
shadow memory for the access address is neither an exact match nor 0, we
call the runtime.

The instrumentation pass inserts calls to the memset intrinsic to set
the memory updated by memset, memcpy, and memmove, as well as
allocas/byval (and for lifetime.start/end) to reset the shadow memory to
reflect that the type is now unknown. The runtime intercepts memset,
memcpy, etc. to perform the same function for the library calls.

The runtime essentially repeats these checks, but uses the full TBAA
algorithm, just as the compiler does, to determine when two types are
permitted to alias. In a situation where access overlap has occurred and
aliasing is not permitted, an error is generated.

Clang's TBAA representation currently has a problem representing unions,
as demonstrated by the one XFAIL'd test in the runtime patch. We'll
update the TBAA representation to fix this, and at the same time, update
the sanitizer.

When the sanitizer is active, we disable actually using the TBAA
metadata for AA. This way we're less likely to use TBAA to remove memory
accesses that we'd like to verify.

As a note, this implementation does not use the compressed shadow-memory
scheme discussed previously
(http://lists.llvm.org/pipermail/llvm-dev/2017-April/111766.html). That
scheme would not handle the struct-path (i.e. structure offset)
information that our TBAA represents. I expect we'll want to further
work on compressing the shadow-memory representation, but I think it
makes sense to do that as follow-up work.

It goes together with the corresponding clang changes
(https://github.com/llvm/llvm-project/pull/76260) and compiler-rt
changes (https://github.com/llvm/llvm-project/pull/76261)

PR: https://github.com/llvm/llvm-project/pull/76259
2024-12-17 13:57:34 +00:00
Joseph Huber
f6f4744176
[libc] Install RPC server to shared/rpc.h (#120170)
Summary:
This installs the shared header to the users installation. I couldn't
decide if this should be a standalone thing or use the existing support
in `include/` mostly because this is completely separate from hdrgen
stuff and it's C++.
2024-12-17 07:45:13 -06:00
Joseph Huber
2072ec1ff9 [LLVM] Remove warning print when merging fails
Summary:
This message is only confusing and shouldn't have been added in the
first place.
2024-12-17 07:44:17 -06:00
Youngsuk Kim
b4c1ded7d5
[clang] Recover necessary AddrSpaceCast (#119246)
A necessary AddrSpaceCast was wrongfully deleted in
5c91b2886f6bf400b60ca7839069839ac3980f8f . Recover the AddrSpaceCast.

This fixes #86791 .
2024-12-17 08:38:31 -05:00
Mariya Podchishchaeva
fbbf1bed74
[HLSL][NFC] Fix static analyzer concerns (#120090)
Class BuiltinTypeMethodBuilder has a user-defined destructor so likely
compiler generated special functions may behave incorrectly. Delete
explicitly copy constructor and copy assignment operator to avoid
potential errors.
2024-12-17 14:37:48 +01:00
Michael Buch
f1763888bb
[lldb][DWARF] Remove obsolete calls to Supports_DW_AT_APPLE_objc_complete_type and DW_AT_decl_file_attributes_are_invalid (#120226)
Depends on https://github.com/llvm/llvm-project/pull/120225

With `llvm-gcc` support being removed from LLDB, these APIs
are now trivial and can be removed too.
2024-12-17 13:32:25 +00:00
Michael Buch
e0a79eeca2
[lldb] Remove references to llvm-gcc (#120225)
The `llvm-gcc` front-end has been EOL'd at least since 2011 (based on
some `git` archeology). And Clang/LLVM has been removing references to
it ever since.

This patch removes the remaining references to it from LLDB. One benefit
of this is that it will allow us to remove the code checking for
`DW_AT_decl_file_attributes_are_invalid` and
`Supports_DW_AT_APPLE_objc_complete_type`.
2024-12-17 13:23:13 +00:00
Nikita Popov
1157187496
[VPlan] Propagate all GEP flags (#119899)
Store GEPNoWrapFlags instead of only InBounds and propagate them.
2024-12-17 13:48:50 +01:00
Mikhail Goncharov
34c4f6f937 [MLIR][bazel] port 0693b9e9ccdec5f09a3080b1bec73f5004a8dfa3 2024-12-17 13:41:38 +01:00
Michael Buch
794cd814ee
[lldb][DWARFASTParserClang][ObjC] Remove workaround for old ObjC DWARF (#120218)
With all the recent versions of Clang that I tested, ObjC forward
declarations like
```
@class ForwardObjcClass;
```
don't emit the kind of DWARF that this workaround was put in place for.

Also, zero-sized structures are valid in C (and thus Objective-C), so
this workaround makes things confusing to reason about when mixing the
two languages.

This workaround has been in place for at least a decade, and given that
recent compilers don't produce this anymore, we think it's a good time
to remove it.
2024-12-17 12:35:28 +00:00
Nathan Gauër
52b07d971c
[HLSL] Fix call convention mismatch for ctor/dtor (#118651)
Before this patch, there was a calling-convention mismatch between the
constructors and the actual call emitted for the entrypoint wrapper.

Such mismatch causes the InstCombine pass to replace this call with an
`unreachable`, breaking the whole function.

Signed-off-by: Nathan Gauër <brioche@google.com>
2024-12-17 13:26:03 +01:00
Timm Baeder
56fd46edb3
[clang][bytecode] Remove a bitcast nullptr_t special case (#120188)
We still need to check the input pointer, so let this go through
BitCastPrim.
2024-12-17 13:23:14 +01:00
Florian Hahn
8ea9576d94
[SCEV] Add initial matchers for SCEV expressions. (NFC) (#119390)
This patch adds initial matchers for unary and binary SCEV expressions 
and specializes it for SExt, ZExt and binary add expressions.

Also adds matchers for SCEVConstant and SCEVUnknown.

This patch only converts a few instances to use the new matchers to make
sure everything builds as expected for now.

The goal of the matchers is to hopefully make it slightly easier to
write code matching SCEV patterns.

Depends on https://github.com/llvm/llvm-project/pull/119389

PR: https://github.com/llvm/llvm-project/pull/119390
2024-12-17 12:12:56 +00:00