477918 Commits

Author SHA1 Message Date
Kazu Hirata
3fb3df36ea [ModuleInliner] Use SmallVector::pop_back_val (NFC)
We can use std::pop_heap first and then retrieve the top priority item
with pop_back_val, saving one line of code.
2023-10-18 13:04:46 -07:00
Ivan Tadeu Ferreira Antunes Filho
400389db7d
Initialize sigset in asan_interceptors (#69502)
When compiling for Darwin, sigset is not initialized. 

When -Werror,-Wuninitialized-const-reference are enabled we see the
error:
asan_interceptors.cpp:260:38: error: variable 'sigset' is uninitialized
when passed as a const reference argument here
[-Werror,-Wuninitialized-const-reference]

This fixes the error
2023-10-18 13:01:36 -07:00
Aart Bik
306f4c306a
[mlir][sparse] implement non-permutation MapRef encoding (#69406)
This enables reading block sparse from file using libgen! (and soon also
direct IR codegen)
2023-10-18 13:01:12 -07:00
Kazu Hirata
781424c872 [compiler-rt] Fix a warning
This patch fixes:

  compiler-rt/lib/builtins/int_to_fp_impl.inc:36:10: error: expression
  is not an integer constant expression; folding it to a constant is a
  GNU extension [-Werror,-Wgnu-folding-constant]
2023-10-18 12:16:41 -07:00
Fangrui Song
e8fe4de64f
[CodeGen] -fsanitize=alignment: add cl::opt sanitize-alignment-builtin to disable memcpy instrumentation (#69240)
Deploying #67766 to a large internal codebase uncovers many bugs (many
are
probably benign but need cleaning up). There are also issues in
high-profile
open-source projects like v8. Add a cl::opt to disable builtin
instrumentation
for -fsanitize=alignment to help large codebase users.

In the long term, this cl::opt option may still be useful to debug
-fsanitize=alignment instrumentation on builtins, so we probably want to
keep it around.
2023-10-18 11:43:36 -07:00
David Green
8a701024f3 [ARM] Lower i1 concat via MVETRUNC
The MVETRUNC operation can perform the same truncate of two vectors, without
requiring lane inserts/extracts from every vector lane. This moves the concat
i1 lowering to use it for v8i1 and v16i1 result types, trading a bit of extra
stack space for less instructions.
2023-10-18 19:40:11 +01:00
Louis Dionne
e494a96a69
[libc++][NFC] Refactor the core logic of operator new into helper functions (#69407)
This will make it easier to implement new(nothrow) without calling the
throwing version of new when exceptions are disabled. See
https://llvm.org/D150610 for the full discussion.
2023-10-18 11:33:05 -07:00
Stanislav Mekhanoshin
84f398af74
[AMDGPU] Add missing test checks. NFC. (#69484) 2023-10-18 11:26:39 -07:00
Louis Dionne
f362be597a [libc++][NFC] Reformat new.cpp and stdlib_new_delete.cpp
This makes it a lot easier to make wide ranging changes like I am
about to do in https://llvm.org/D150610.
2023-10-18 11:23:32 -07:00
Luke Lau
3927b9ab11 [VectorCombine] Add tests for unspeculatable VP binops. NFC
The current test cases to guard against speculative execution can actually be
safely speculated because the denominator is known to be not 0 or -1, and
isSafeToSpeculativelyExecuteWithOpcode will account for this. This adds some
more test cases and rejigs some existing ones to use an unknown variable
instead.
2023-10-18 14:23:02 -04:00
Oskar Wirga
c9b7d21dc5
[CFI/MergeFunctions] Modify MergeFunctions to propagate type information (#68628)
When MergeFuncs creates a thunk, it does not modify the function in
place, but creates a new one altogether. If type metadata is not
properly forwarded to this new function, LowerTypeTests will be unable
to put this thunk into the dispatch table.

The fix here is to just forward the type metadata to the newly created
functions.
2023-10-18 11:22:35 -07:00
Yaxun (Sam) Liu
10079a23c5
[HIP] Document func ptr and virtual func (#68126)
Document clang support for function pointers and virtual functions with
HIP
2023-10-18 14:14:04 -04:00
Dominik Adamski
eee8dd9088
[CodeExtractor] Allow to use 0 addr space for aggregate arg (#66998)
The user of CodeExtractor should be able to specify that
the aggregate argument should be passed as a pointer in zero address
space.

CodeExtractor is used to generate outlined functions required by OpenMP
runtime. The arguments of the outlined functions for OpenMP GPU code
are in 0 address space. 0 address space does not need to be the default
address space for GPU device. That's why there is a need to allow
the user of CodeExtractor to specify, that the allocated aggregate parameter
is passed as pointer in zero address space.
2023-10-18 20:12:31 +02:00
Thurston Dang
ddf1de20a3
[hwasan] Fix rare false negative (zero tag) in stack-uar.c (#69374)
stack-uar.c is flaky (1 in 256 executions) because the random tag
may be zero (https://github.com/llvm/llvm-project/issues/69221).

This patch works around the issue in the same way as deep-recursion.c

(aa4dfd3736),
by falling back to a neighboring object, which must have a different
(non-zero) tag.

This patch also does a minor cleanup of the aforementioned
deep-recursion.c, for consistency with stack-uar.c.

Co-authored-by: Thurston Dang <thurston@google.com>
2023-10-18 10:43:53 -07:00
Guray Ozen
192d3320f0
[mlir][nvgpu] Add predicate argument to NVGPU Ops (#69322) 2023-10-18 19:41:51 +02:00
Piotr Zegar
fea55db233 [clang-tidy][DOC] Fix syntax in coroutine-hostile-raii.rst
Fix 'Bullet list ends without a blank line; unexpected unindent.
2023-10-18 17:34:40 +00:00
Chengji Yao
1a21196b9a
[MLIR] reverse int8 type's printing logic (#69361)
Specializing for 8-bit integers to ensure values are printed as integers

Fixes #69310
2023-10-18 10:30:13 -07:00
Kai Nacke
a587f42953
[TableGen] SubtargetEmitter must use std::nullopt (#69475)
Use of llvm::Optional was migrated to std::optional. This included a
change in the constructor of ArrayRef.
However, there are still 2 places in the SubtargetEmitter which uses
llvm::None, causing a compile error when emitted.
2023-10-18 13:11:23 -04:00
Ilya Leoshkevich
8e810dc7d9
[SystemZ] Support builtin_{frame,return}_address() with non-zero argument (#69405)
When the code is built with -mbackchain, it is possible to retrieve the
caller's frame and return addresses. GCC already can do this, add this
support to Clang as well. Use RISCVTargetLowering and GCC's
s390_return_addr_rtx() as inspiration. Add tests based on what GCC is
emitting.
2023-10-18 19:05:31 +02:00
Joseph Huber
b69081e324
Attributes (#69358)
- [Libomptarget] Make the references to 'malloc' and 'free' weak.
- [Libomptarget][NFC] Use C++ style attributes instead
2023-10-18 12:52:43 -04:00
Joseph Huber
1e5fe67e70
[Libomptarget] Make the references to 'malloc' and 'free' weak. (#69356)
Summary:
We use `malloc` internally in the DeviceRTL to handle data
globalization. If this is undefined it will map to the Nvidia
implementation of `malloc` for NVPTX and return `nullptr` for AMDGPU.
This is somewhat problematic, because when using this as a shared
library it causes us to always extract the GPU libc implementation,
which uses RPC and thus requires an RPC server. Making this `weak`
allows us to implement this internally without worrying about binding to
the GPU `libc` implementation.
2023-10-18 12:50:23 -04:00
Alexey Bataev
3ef271c3d6 [SLP][NFC]Use MutableArrayRef instead of SmallVectorImpl& in param, NFC. 2023-10-18 09:47:07 -07:00
vabridgers
708808e853
[Sema] Add check for bitfield assignments to integral types (#69049)
This change introduces the bitfield conversion check after fixes to the
test case. The original submission unfortunately did not comprehend
differences in architecture for the diagnostic messages, leading to
unanticipated failures in the arm build bots.

Original PR: https://github.com/llvm/llvm-project/pull/68276

Clang does not check for bitfield assignment widths, while gcc checks
this.

gcc produced a warning like so for it's -Wconversion flag:
```
$ gcc -Wconversion -c test.c
test.c: In function 'foo':
test.c:10:15: warning: conversion from 'int' to 'signed char:7' may
change value [-Wconversion]
   10 |      vxx.bf = x; // no warning
      |               ^
```

This change simply adds this check for integral types under the
-Wbitfield-conversion compiler option.
2023-10-18 11:40:07 -05:00
Adrian Prantl
410f41300a Add missing include breaking the modules build 2023-10-18 09:30:33 -07:00
Piotr Zegar
1891d21312 [clang-tidy][DOC] Fix syntax in coroutine-hostile-raii.rst
Fix ':4:Title underline too short.'
2023-10-18 16:30:18 +00:00
Emilio Cota
ecd3934432
[mlir] ADTExtras: include mlir/Support/LLVM.h (#69479)
To forward-declare LLVM's support types.
2023-10-18 12:28:55 -04:00
Piotr Zegar
598712315b [clang-tidy][DOC] Fix list.rst
Fix micro bug in list.rst.
2023-10-18 16:26:08 +00:00
Logikable
7b94744e77
[Kaleidoscope] Switch to the new PassManager. (#69032)
Using the new pass manager is more verbose; let me know if the tutorial
doesn't flow well with all the additions.
2023-10-18 09:25:50 -07:00
Stanislav Mekhanoshin
47ed921985
[AMDGPU] Add legality check when folding short 64-bit literals (#69391)
We can only fold it if it can fit into 32-bit. I believe it did not
trigger yet because we do not select 64-bit literals generally.
2023-10-18 09:22:23 -07:00
Arjun P
bf7a826e71 [Presburger] Fraction: resolve ambiguous overload in some cases 2023-10-18 17:18:42 +01:00
Aaron Ballman
e7b827e11b Add a FIXME comment; NFC
The constant expression engines use a list of note diagnostics to
report back whether an evaluation is a valid constant expression or
not. This requires the engines to generate those note diagnostics, and
that can be expensive in cases where we're converting an APValue to a
string as a streamed argument to the note. If we're going to display
the note, then that expense is warranted. However, there are operations
looking for a yes/no answer to whether something is a constant
expression and won't display the diagnostics at all. Those uses are
paying an expense they shouldn't have to.
2023-10-18 12:16:33 -04:00
Erich Keane
98191d7c16
[CONCEPTS]Corrected comparison of constraints with out of line CTD (#69244)
Out of line class template declaration specializations aren't created at
the time they have their template arguments checked, so we previously
weren't doing any amount of work to substitute the constraints before
comparison. This resulted in the out of line definition's difference in
'depth' causing the constraints to compare differently.

This patch corrects that. Additionally, it handles ClassTemplateDecl
when collecting template arguments.

Fixes: #61763
2023-10-18 09:10:30 -07:00
Alex Langford
814a79aea6
[DebugInfo] Separate error generation from reporting in DWARFHeaderUnit::extract (#68242)
Instead of reporting the error directly through the DWARFContext passed
in as an argument, it would be more flexible to have extract return the
error and allow the caller to react appropriately.

This will be useful for using llvm's DWARFHeaderUnit from lldb which may
report header extraction errors through a different mechanism.
2023-10-18 09:06:39 -07:00
Valery Dmitriev
c80b503496
[SLP] Improve gather tree nodes matching when users are PHIs. (#69392) 2023-10-18 09:05:11 -07:00
Eric Kilmer
e3ae2a52d2
[llvm][CMake] Check dependency cxx source compiles (#68549)
If a CMake project doesn't enable the C language, then the CMake FFI and
Terminfo find modules will fail their checks for compilation and
linking.

This commit allows projects to enable only C++ by first checking if a C
compiler is set before testing C source compilation; if not, it checks
whether C++ compilation succeeds.

Fixes #53950
2023-10-18 09:03:04 -07:00
Mehdi Amini
cba4e7e9e6 [MLIR][Doc] Clarify the cf.asssert doc that this is a runtime assertion 2023-10-18 08:57:22 -07:00
Fangrui Song
ec0e556e67
[ELF] Merge copyLocalSymbols and demoteLocalSymbolsInDiscardedSections (#69425)
Follow-up to #69295: In `Writer<ELFT>::run`, the symbol passes are
flexible:
they can be placed almost everywhere before `scanRelocations`, with a
constraint
that the `computeIsPreemptible` pass must be invoked for linker-defined
non-local symbols.

Merge copyLocalSymbols and demoteLocalSymbolsInDiscardedSections to
simplify
code:

* Demoting local symbols can be made unconditional, not constrainted to
/DISCARD/ uses due to performance concerns
* `includeInSymtab` can be made faster
* Make symbol passes close to each other
* Decrease data cache misses due to saving an iteration over local
symbols

There is no speedup, likely due to the unconditional `dr->section`
access in `demoteAndCopyLocalSymbols`.

`gc-sections-tls.s` no longer reports an error because the TLS symbol is
converted to an Undefined.
2023-10-18 08:56:17 -07:00
NatashaKnk
9f4950983e
[mlir] Add ContractionOpInterface utility functions for vector matrix multiplication (#68945) 2023-10-18 08:55:51 -07:00
Stephen Tozer
df3478e480
[LLVM] Add new attribute optdebug to optimize for debugging (#66632)
This patch adds a new fn attribute, `optdebug`, that specifies that
optimizations should make decisions that prioritize debug info quality,
potentially at the cost of runtime performance.

This patch does not add any functional changes triggered by this
attribute, only the attribute itself. A subsequent patch will use this
flag to disable the post-RA scheduler.
2023-10-18 16:32:06 +01:00
Slava Zakharin
d0e8f3321e
[flang][openacc] Fixed private/reduction for combined constructs. (#69417)
According to OpenACC 3.2 2.11, private or reduction clause
on the combined construct is treated as if it appeared
on the loop construct.
2023-10-18 08:10:50 -07:00
Florian Hahn
e7432bc343
[InstCombine] Add aligned_alloc with pointer icmp as only use. 2023-10-18 16:09:47 +01:00
Harmen Stoppels
0a9bdc276d
[lldb] Fix linking to libtinfo (#69458)
LLVM detects when ncurses has a separate terminfo library, but linking to it
was broken in lldb since b66339575a9b541e67ce5ad2ba7e88da07cf9305 (LLVM14)
due to a change of variables. This commit fixes that oversight.
2023-10-18 16:06:50 +01:00
Caroline Concatto
1b93e15bcd [Clang][SVE2p1] Add svpsel builtins
As described in: https://github.com/ARM-software/acle/pull/257

Patch by : Sander de Smalen<sander.desmalen@arm.com>

Reviewed By: kmclaughlin

Differential Revision: https://reviews.llvm.org/D151197
2023-10-18 15:05:26 +00:00
Tomás Longeri
5a600c23f9
[mlir][python] Expose PyInsertionPoint's reference operation (#69082)
The reason I want this is that I am writing my own Python bindings and
would like to use the insertion point from
`PyThreadContextEntry::getDefaultInsertionPoint()` to call C++ functions
that take an `OpBuilder` (I don't need to expose it in Python but it
also seems appropriate). AFAICT, there is currently no way to translate
a `PyInsertionPoint` into an `OpBuilder` because the operation is
inaccessible.
2023-10-18 16:53:18 +02:00
Dmitry Chernenkov
a3a0f59a1e Revert "Correctly compute conversion seq for args to fn with reversed param order (#68999)"
This reverts commit e6d0b126c824222fca2f31a2ba571c2ee2bb4760.

See PR for reason

https://github.com/llvm/llvm-project/pull/68999#issuecomment-1768541660
2023-10-18 14:13:48 +00:00
Rainer Orth
cf1bde9a15
[Driver] Link Flang runtime on Solaris (#65644)
I noticed that `flang-new` cannot link Fortran executables on Solaris since the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`. The `linker-flags.f90` testcase is augmented to test for this,
renaming the `GNU` label to `UNIX` so it can be reused.  Also use the current form `--target=` in the tests
and join the `-l` lines in the test for readibility.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
2023-10-18 16:12:10 +02:00
Stephen Tozer
178619d71d
[Clang] Fill in documentation gaps for some attributes (#68967)
This patch adds some missing documentation for some attributes in
BitCodeFormat, where the integer code mappings for attributes after code
79 were not listed, and in LangRef where the incompatibility between
minsize/optsize and optnone was not mentioned.
2023-10-18 15:09:05 +01:00
Benjamin Maxwell
b0b8e83e66
[mlir] Fix use-after-free bugs in {RankedTensorType|VectorType}::Builder (#68969)
Previously, these would set their ArrayRef members to reference their
storage SmallVectors after a copy-on-write (COW) operation. This leads
to a use-after-free if the builder is copied and the original destroyed
(as the new builder would still reference the old SmallVector).

This could easily accidentally occur in code like (annotated):
```c++
// 1. `VectorType::Builder(type)` constructs a new temporary builder
// 2. `.dropDim(0)` updates the temporary builder by reference, and returns a `VectorType::Builder&`
//    - Modifying the shape is a COW operation, so `storage` is used, and `shape` updated the reference it
// 3. Assigning the reference to `auto` copies the builder (via the default C++ copy ctor)
//    -  There's no special handling for `shape` and `storage`, so the new shape points to the old builder's `storage`
auto newType = VectorType::Builder(type).dropDim(0);
// 4. When this line is reached the original temporary builder is destroyed
//    - Actually constructing the vector type is now a use-after-free
VectorType newVectorType = VectorType(newType);
```

This is fixed with these changes by using `CopyOnWriteArrayRef<T>`,
which implements the same functionality, but ensures no
dangling references are possible if it's copied. 

---

The VectorType::Builder also set the ArrayRef<bool> scalableDims member
to a temporary SmallVector when the provided scalableDims are empty.
This again leads to a use-after-free, and is unnecessary as
VectorType::get already handles being passed an empty scalableDims
array.

These bugs were in-part caught by UBSAN, see:
https://lab.llvm.org/buildbot/#/builders/5/builds/37355
2023-10-18 14:52:22 +01:00
Sirish Pande
28e4f97320
[AMDGPU] Save/Restore SCC bit across waterfall loop. (#68363)
Waterfall loop is overwriting SCC bit of status register. Make sure SCC
bit is saved and restored across.
We need to save/restore only in cases where SCC is live across waterfall
loop.

Co-authored-by: Sirish Pande <sirish.pande@amd.com>
2023-10-18 08:43:29 -05:00
Tobias Gysi
18e5055db3
[mlir][LLVM] Improve function debug info import (#69446)
This commit improves the import of function debug info by creating a
FileLineColLoc instead of just a NameLoc if possible.
2023-10-18 15:41:45 +02:00