Commit graph

431079 commits

Author SHA1 Message Date
Chuanqi Xu 15ddc09ef9 [C++20] [Modules] Handle linkage properly for specializations when overloading
Currently, the semantics of linkage in clang is slightly
different from the semantics in C++ spec. In C++ spec, only names
have linkage. So that all entities of the same should share
one linkage. But in clang, different entities of the same could
have different linkage.

It would break a use case where the template have external linkage and
its specialization have internal linkage due to its type argument is
internal linkage. The root cause is that the semantics of internal
linkage in clang is a mixed form of internal linkage and TU-local in
C++ spec. It is hard to solve the root problem and I tried to add a
workaround inplace.
2022-07-26 18:30:48 +08:00
Zakk Chen 93f8657c74 [RISCV][Clang] Refactor RISCVVEmitter. (NFC)
Remove MaskedPrototype and add several fields in RVVIntrinsicRecord,
compute Prototype in runtime.

Reviewed By: rogfer01

Differential Revision: https://reviews.llvm.org/D126741
2022-07-26 10:15:04 +00:00
Simon Pilgrim da2ed951ec Fix MSVC "not all control paths return a value" warning. NFC 2022-07-26 10:44:00 +01:00
Zakk Chen bc4eef509b [RISCV][Clang] Refactor and rename rvv intrinsic related stuff. (NFC)
This changed is based on https://reviews.llvm.org/D111617

Reviewed By: rogfer01

Differential Revision: https://reviews.llvm.org/D126740
2022-07-26 09:35:34 +00:00
Benjamin Kramer ad17e69923 [analyzer] Fix unused variable warning in release builds. NFC. 2022-07-26 11:29:38 +02:00
Benjamin Kramer 48a1a993fb [mlir] Fall back to posix_memalign for aligned_alloc on MacOS
aligned_alloc was added in MacOS 10.15, some users want to support older
versions. The runtime functions makes this easy, so just put in a call
to posix_memalign, which provides the same functionality.
2022-07-26 11:29:37 +02:00
Sebastian Neubauer ae222dae56 [CMake] Fix add_subdirectory llvm builds
Fixes a regression from D117973, that used CMAKE_BINARY_DIR instead of
LLVM_BINARY_DIR in some places.

Differential Revision: https://reviews.llvm.org/D130555
2022-07-26 11:24:23 +02:00
Simon Tatham ae16b2ed98 [llvm-objdump,ARM] Fix a lot more tests.
When I changed the output format of llvm-objdump for Arm and AArch64
in D130358, I hadn't realised llvm-objdump was used so much in the
plain MC tests as well as tests of itself and lld. Sorry!
2022-07-26 10:22:02 +01:00
David Spickett f3fbbe1cf3 [clang][analyzer][NFC] Use value_or instead of ValueOr
The latter is deprecated.
2022-07-26 09:16:45 +00:00
David Spickett d0479cb290 [lldb][ARM] Use portable printf tokens for 64 bit types
Fixes some warnings in the 32 bit build.
2022-07-26 09:12:57 +00:00
Simon Tatham 1c3d0a2e87 [llvm-objdump] Fix type mismatch in std::min.
I broke the build just now by trying to do std::min between a size_t
and a uint64_t, which of course worked fine on my 64-bit test platform.
2022-07-26 10:02:37 +01:00
David Spickett 10c2bab50e [lldb][ARM] Add tests for vpush/vpop D registers
Previously we just checked via S regs and were not checking
memory content after pushes.

The vpush test confirms that the fix in https://reviews.llvm.org/D130307
is working.

Memory will only be checked if an "after" state is provided.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D130468
2022-07-26 08:41:24 +00:00
Nimish Mishra 05e6fce84f [flang][OpenMP] Lowering support for default clause
This patch adds lowering support for default clause.

1. During symbol resolution in semantics, should the enclosing context have
a default data sharing clause defined and a `parser::Name` is not attached
to an explicit data sharing clause, the
`semantics::Symbol::Flag::OmpPrivate` flag (in case of `default(private)`)
and `semantics::Symbol::Flag::OmpFirstprivate` flag (in case of
`default(firstprivate)`) is added to the symbol.

2. During lowering, all symbols having either
   `semantics::Symbol::Flag::OmpPrivate` or
   `semantics::Symbol::Flag::OmpFirstprivate` flag are collected and
   privatised appropriately.

Co-authored-by: Peixin Qiao <qiaopeixin@huawei.com>

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D123930
2022-07-26 14:11:43 +05:30
Sven van Haastregt c8d91b07bb Reassoc FMF should not optimize FMA(a, 0, b) to (b)
Optimizing (a * 0 + b) to (b) requires assuming that a is finite and not
NaN. DAGCombiner will do this optimization when the reassoc fast math
flag is set, which is not correct. Change DAGCombiner to only consider
UnsafeMath for this optimization.

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

Co-authored-by: Andrea Faulds <andrea.faulds@arm.com>
2022-07-26 09:39:12 +01:00
Simon Tatham 1bc7b06ffd [llvm-objdump,ARM] Make dumpARMELFData line up with instructions.
The whitespace in output lines containing disassembled instructions
was extremely mismatched against that in `.word` lines produced from
dumping literal pools and other data in Arm ELF files. This patch
adjusts `dumpARMELFData` so that it uses the same alignment system as
in the instruction pretty-printers. Now the two classes of line are
aligned sensibly alongside each other.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D130359
2022-07-26 09:35:31 +01:00
Simon Tatham 2b38f58930 [llvm-objdump,ARM] Add PrettyPrinters for Arm and AArch64.
Most Arm disassemblers, including GNU objdump and Arm's own `fromelf`,
emit an instruction's raw encoding as a 32-bit words or (for Thumb)
one or two 16-bit halfwords, in logical order rather than according to
their storage endianness. This is generally easier to read: it matches
the encoding diagrams in the architecture spec, it matches the value
you'd write in a `.inst` directive, and it means that fields within
the instruction encoding that span more than one byte (such as branch
offsets or `SVC` immediates) can be read directly in the encoding
without having to mentally reverse the bytes.

llvm-objdump already has a system of PrettyPrinter subclasses which
makes it easy for a target to drop in its own preferred formatting.
This patch adds pretty-printers for all the Arm targets, so that
llvm-objdump will display Arm instruction encodings in their preferred
layout instead of little-endian and bytewise.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D130358
2022-07-26 09:35:30 +01:00
Simon Tatham 55f1fbf005 [MC,llvm-objdump,ARM] Target-dependent disassembly resync policy.
Currently, when llvm-objdump is disassembling a code section and
encounters a point where no instruction can be decoded, it uses the
same policy on all targets: consume one byte of the section, emit it
as "<unknown>", and try disassembling from the next byte position.

On an architecture where instructions are always 4 bytes long and
4-byte aligned, this makes no sense at all. If a 4-byte word cannot be
decoded as an instruction, then the next place that a valid
instruction could //possibly// be found is 4 bytes further on.
Disassembling from a misaligned address can't possibly produce
anything that the code generator intended, or that the CPU would even
attempt to execute.

This patch introduces a new MCDisassembler virtual method called
`suggestBytesToSkip`, which allows each target to choose its own
resynchronization policy. For Arm (as opposed to Thumb) and AArch64,
I've filled in the new method to return a fixed width of 4.

Thumb is a more interesting case, because the criterion for
identifying 2-byte and 4-byte instruction encodings is very simple,
and doesn't require the particular instruction to be recognized. So
`suggestBytesToSkip` is also passed an ArrayRef of the bytes in
question, so that it can take that into account. The new test case
shows Thumb disassembly skipping over two unrecognized instructions,
and identifying one as 2-byte and one as 4-byte.

For targets other than Arm and AArch64, this is NFC: the base class
implementation of `suggestBytesToSkip` still returns 1, so that the
existing behavior is unchanged. Other targets can fill in their own
implementations as they see fit; I haven't attempted to choose a new
behavior for each one myself.

I've updated all the call sites of `MCDisassembler::getInstruction` in
llvm-objdump, and also one in sancov, which was the only other place I
spotted the same idiom of `if (Size == 0) Size = 1` after a call to
`getInstruction`.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D130357
2022-07-26 09:35:30 +01:00
David Spickett c4b6e5f950 [lldb][ARM] Misc improvements to TestEmulations
* Look for files that end width arm/thumb.dat,
  meaning we don't try to run, for example, vim swap files.
* Print the name of the test that failed.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D130467
2022-07-26 08:31:55 +00:00
Phoebe Wang 19c5638e4f [ArgPromotion] Transfer metadata nontemporal to promoted loads
Fixes #56703

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D130536
2022-07-26 16:30:08 +08:00
David Spickett 3ebd541944 [lldb][ARM] Print mismatched registers in emulation tests
Also correct the test failed message. It implies that what
it's done is compare the 'before' and 'ater' states from the
test input.

Except that that's the whole point of the test, that the state changes.
It should tell you that it compared the result of the emulation to the
'after'.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D130464
2022-07-26 08:28:27 +00:00
Dmitri Gribenko 3281138aad [clang][dataflow] Fix SAT solver crashes on X ^ X and X v X
BooleanFormula::addClause has an invariant that a clause has no duplicated
literals. When the solver was desugaring a formula into CNF clauses, it
could construct a clause with such duplicated literals in two cases.

Reviewed By: sgatev, ymandel, xazax.hun

Differential Revision: https://reviews.llvm.org/D130522
2022-07-26 10:26:44 +02:00
isuckatcs a618d5e0dd [analyzer] Structured binding to tuple-like types
Introducing support for creating structured binding
to tuple-like types.

Differential Revision: https://reviews.llvm.org/D128837
2022-07-26 10:24:29 +02:00
David Spickett 290c4bc7be [LLDB][ARM] Generalise adding register state in emulation tests and add D registers
Since some s and d registers overlap we will error if we find both.
This prevents you overwriting one with the other in a test case.

Reviewed By: clayborg

Differential Revision: https://reviews.llvm.org/D130462
2022-07-26 08:22:26 +00:00
Cullen Rhodes 6082051da1 [AArch64][SVE] Add patterns to select mla/mls
Adds patterns for:

  add(a, select(mask, mul(b, c), splat(0))) -> mla(a, mask, b, c)
  sub(a, select(mask, mul(b, c), splat(0))) -> mls(a, mask, b, c)

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D130492
2022-07-26 07:52:44 +00:00
Cullen Rhodes 816a395bf6 [AArch64][SVE] NFC: Add tests for masked mla/mls patterns (D130492) 2022-07-26 07:52:44 +00:00
Kito Cheng 7a5cb15ea6 [RISCV] Lazily add RVV C intrinsics.
Leverage the method OpenCL uses that adds C intrinsics when the lookup
failed. There is no need to define C intrinsics in the header file any
more. It could help to avoid the large header file to speed up the
compilation of RVV source code. Besides that, only the C intrinsics used
by the users will be added into the declaration table.

This patch is based on https://reviews.llvm.org/D103228 and inspired by
OpenCL implementation.

### Experimental Results

#### TL;DR:

- Binary size of clang increase ~200k, which is +0.07%  for debug build and +0.13% for release build.
- Single file compilation speed up ~33x for debug build and ~8.5x for release build
- Regression time reduce ~10% (`ninja check-all`, enable all targets)

#### Header size change
```
       |      size |     LoC |
------------------------------
Before | 4,434,725 |  69,749 |
After  |     6,140 |     162 |
```

#### Single File Compilation Time
Testcase:
```
#include <riscv_vector.h>

vint32m1_t test_vadd_vv_vfloat32m1_t(vint32m1_t op1, vint32m1_t op2, size_t vl) {
  return vadd(op1, op2, vl);
}
```
##### Debug build:
Before:
```
real    0m19.352s
user    0m19.252s
sys     0m0.092s
```

After:
```
real    0m0.576s
user    0m0.552s
sys     0m0.024s
```

~33x speed up for debug build

##### Release build:
Before:
```
real    0m0.773s
user    0m0.741s
sys     0m0.032s
```

After:
```
real    0m0.092s
user    0m0.080s
sys     0m0.012s
```

~8.5x speed up for release build

#### Regression time
Note: the failed case is `tools/llvm-debuginfod-find/debuginfod.test` which is unrelated to this patch.

##### Debug build
Before:
```
Testing Time: 1358.38s
  Skipped          :    11
  Unsupported      :   446
  Passed           : 75767
  Expectedly Failed:   190
  Failed           :     1
```
After
```
Testing Time: 1220.29s
  Skipped          :    11
  Unsupported      :   446
  Passed           : 75767
  Expectedly Failed:   190
  Failed           :     1
```
##### Release build
Before:
```
Testing Time: 381.98s
  Skipped          :    12
  Unsupported      :  1407
  Passed           : 74765
  Expectedly Failed:   176
  Failed           :     1
```
After:
```
Testing Time: 346.25s
  Skipped          :    12
  Unsupported      :  1407
  Passed           : 74765
  Expectedly Failed:   176
  Failed           :     1
```

#### Binary size of clang

##### Debug build
Before
```
   text    data     bss     dec     hex filename
335261851       12726004         552812 348540667       14c64efb        bin/clang
```
After
```
   text    data     bss     dec     hex filename
335442803       12798708         552940 348794451       14ca2e53        bin/clang
```
+253K, +0.07% code size

##### Release build
Before
```
   text    data     bss     dec     hex filename
144123975       8374648  483140 152981763       91e5103 bin/clang
```
After
```
   text    data     bss     dec     hex filename
144255762       8447296  483268 153186326       9217016 bin/clang
```
+204K, +0.13%

Authored-by: Kito Cheng <kito.cheng@sifive.com>
Co-Authored-by: Hsiangkai Wang <kai.wang@sifive.com>

Reviewed By: khchen, aaron.ballman

Differential Revision: https://reviews.llvm.org/D111617
2022-07-26 15:47:47 +08:00
David Spickett 2f9fa9ef53 [lldb][AArch64] Add support for memory tags in core files
This teaches ProcessElfCore to recognise the MTE tag segments.

https://www.kernel.org/doc/html/latest/arm64/memory-tagging-extension.html#core-dump-support

These segments contain all the tags for a matching memory segment
which will have the same size in virtual address terms. In real terms
it's 2 tags per byte so the data in the segment is much smaller.

Since MTE is the only tag type supported I have hardcoded some
things to those values. We could and should support more formats
as they appear but doing so now would leave code untested until that
happens.

A few things to note:
* /proc/pid/smaps is not in the core file, only the details you have
  in "maps". Meaning we mark a region tagged only if it has a tag segment.
* A core file supports memory tagging if it has at least 1 memory
  tag segment, there is no other flag we can check to tell if memory
  tagging was enabled. (unlike a live process that can support memory
  tagging even if there are currently no tagged memory regions)

Tests have been added at the commands level for a core file with
mte and without.

There is a lot of overlap between the "memory tag read" tests here and the unit tests for
MemoryTagManagerAArch64MTE::UnpackTagsFromCoreFileSegment, but I think it's
worth keeping to check ProcessElfCore doesn't cause an assert.

Depends on D129487

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D129489
2022-07-26 08:46:36 +01:00
Saiyedul Islam 4075a811ad
[Libomptarget] Add checks for AMDGPU TargetID using new image info
This patch extends the is_valid_binary routine to also check if the
binary's target ID matches the one parsed from the system's runtime
environment.
This should allow us to only use the binary whose compute capability
matches, allowing us to support basic multi-architecture binaries for
AMDGPU.
It also handles compatibility testing of target IDs of the image and
the enviornment.

Depends on D127432

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D127769
2022-07-26 02:44:31 -05:00
isuckatcs 996b092c5e [analyzer] Lambda capture non-POD type array
This patch introduces a new `ConstructionContext` for
lambda capture. This `ConstructionContext` allows the
analyzer to construct the captured object directly into
it's final region, and makes it possible to capture
non-POD arrays.

Differential Revision: https://reviews.llvm.org/D129967
2022-07-26 09:40:25 +02:00
John Ericson ae72cc72d7 [cmake] Fix missing paren in FindPrefixFromConfig
This was in CMake syntax generation, so we didn't catch it eval time.

Follow up from D117973
2022-07-26 07:35:12 +00:00
Diana Picus 05a948e67d [flang] Rename variables in test. NFCI
Use pertinent names instead of numbered values, to make it easier to
update the test in future patches.

Differential Revision: https://reviews.llvm.org/D130474
2022-07-26 07:33:24 +00:00
Victor Campos b43bec19b9 [ARM] Add Tag_CPU_arch missing value descriptions in attribute parser
The ARM attribute parser for Tag_CPU_arch is missing value descriptions
for Armv8-A and Armv8-R.

This patch adds these descriptions.

Reviewed By: pratlucas

Differential Revision: https://reviews.llvm.org/D129631
2022-07-26 08:32:40 +01:00
Slava Gurevich e80dbfddc5 [LLDB][Reliability] Fix register value unpacking
Fix incorrect direction for bit-shifting.

Coverity warning 1355603 (scan.coverity.com)

Differential Revision: https://reviews.llvm.org/D130307
2022-07-26 00:22:40 -07:00
Amir Ayupov 77c1977384 [BOLT] Support files with no symbols
`LastSymbol` handling in `discoverFileObjects` assumes a non-zero number of
symbols in an object file. It's not the case for broken_dynsym.test added in
D130073, and potentially other stripped binaries.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D130544
2022-07-26 00:07:59 -07:00
isuckatcs 8a13326d18 [analyzer] ArrayInitLoopExpr with array of non-POD type
This patch introduces the evaluation of ArrayInitLoopExpr
in case of structured bindings and implicit copy/move
constructor. The idea is to call the copy constructor for
every element in the array. The parameter of the copy
constructor is also manually selected, as it is not a part
of the CFG.

Differential Revision: https://reviews.llvm.org/D129496
2022-07-26 09:07:22 +02:00
Weining Lu 904a87ace3 [LoongArch] Use end namespace xxx style comment. NFC 2022-07-26 15:01:29 +08:00
owenca 0ffb3dd33e [clang-format] Fix a hang when formatting C# $@ string literals
Fixes #56624.

Differential Revision: https://reviews.llvm.org/D130411
2022-07-25 23:17:54 -07:00
Alex Brachet 0df7d8bc35 [CMake][Fuchsia] Enable assertions and backtraces in stage 1 build
Differential Revision: https://reviews.llvm.org/D130514
2022-07-26 06:09:38 +00:00
Kazu Hirata c8cf669f60 [ADT] Deprecate Optional::getValueOr (NFC)
This patch deprecates getValueOr in favor of value_or.

Differential Revision: https://reviews.llvm.org/D130140
2022-07-25 23:01:02 -07:00
Kazu Hirata 3356d72a5f [flang] Use value or * instead of getValue (NFC)
This patch replaces x.getValue() with *x if the reference is obviously
protected by a presence check.  Otherwise, it replaces x.getValue()
with x.value().
2022-07-25 23:01:01 -07:00
Kazu Hirata 3f3930a451 Remove redundaunt virtual specifiers (NFC)
Identified with tidy-modernize-use-override.
2022-07-25 23:00:59 -07:00
Kazu Hirata ae002f8bca Use isa instead of dyn_cast (NFC) 2022-07-25 23:00:58 -07:00
Kazu Hirata 2789c4f51c [mlir] Use value_or (NFC) 2022-07-25 23:00:56 -07:00
Nico Weber 620ca754e3 fix comment typo to cycle bots 2022-07-26 01:55:10 -04:00
Nico Weber a9b21ec484 [gn build] tweak how symbol_exports map files look on linux, for 94c00c10e
After bc39d7bdd4 (ported to GN in 94c00c10e), libclang uses symbol_exports,
and clang/test/LibClang/symbols.test wants the versioned name to be `LLVM_[0-9]$`
instead of `FOO`.
2022-07-26 01:52:00 -04:00
Sinan Lin 7a2f5dca09 [CodeMetrics] use hasOneLiveUse instead of hasOneUse while analyzing inlinable callsites
It would be better for CodeMetrics to use hasOneLiveUse while analyzing
static and called once callsites, since inline cost now uses
hasOneLiveUse instead of hasOneUse to avoid overpessimization on dead
constant cases (since this patch https://reviews.llvm.org/D109294).

This change has no noticeable influence now, but it helps improve the
accuracy of cost models of passes that use CodeMetrics.

Reviewed By: fhahn, nikic

Differential Revision: https://reviews.llvm.org/D130461
2022-07-26 13:46:19 +08:00
Nico Weber 94c00c10e8 [gn build] port bc39d7bdd4 (libclang.map -> libclang.exports) 2022-07-26 01:39:15 -04:00
zhongyunde d485c1b73e [LoopDataPrefetch] Fix crash when TTI doesn't set CacheLineSize
Fix https://github.com/llvm/llvm-project/issues/56681

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D130418
2022-07-26 13:08:42 +08:00
Tom Stellard bc39d7bdd4 libclang.so: Make SONAME the same as LLVM version
This partially reverts c7b3a91017.  Having
libclang.so with a different SONAME than the other LLVM libraries was
causing a lot of confusion for users.  Also, this change did not really
acheive it's purpose of allowing apps to use newer versions of
libclang.so without rebuilding, because a new version of libclang.so
requires a new version of libLLVM.so, which does not have a stable ABI.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D129160
2022-07-25 22:03:34 -07:00
Amir Ayupov 79c2fe066d [BOLT][TEST] Update fptr.test
The test exercises an implicit ptr-to-int conversion which is made an error in
D129881. We acknowledge the error but still want to test this case.
Add `-Wno-int-conversion` to silence the error.

Reviewed By: maksfb

Differential Revision: https://reviews.llvm.org/D130546
2022-07-25 22:00:46 -07:00