platform/upstream/llvm.git
23 months ago[analyzer] Fix unused variable warning in release builds. NFC.
Benjamin Kramer [Tue, 26 Jul 2022 09:26:52 +0000 (11:26 +0200)]
[analyzer] Fix unused variable warning in release builds. NFC.

23 months ago[mlir] Fall back to posix_memalign for aligned_alloc on MacOS
Benjamin Kramer [Tue, 26 Jul 2022 09:14:37 +0000 (11:14 +0200)]
[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.

23 months ago[CMake] Fix add_subdirectory llvm builds
Sebastian Neubauer [Tue, 26 Jul 2022 08:40:48 +0000 (10:40 +0200)]
[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

23 months ago[llvm-objdump,ARM] Fix a lot more tests.
Simon Tatham [Tue, 26 Jul 2022 09:08:56 +0000 (10:08 +0100)]
[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!

23 months ago[clang][analyzer][NFC] Use value_or instead of ValueOr
David Spickett [Tue, 26 Jul 2022 09:16:06 +0000 (09:16 +0000)]
[clang][analyzer][NFC] Use value_or instead of ValueOr

The latter is deprecated.

23 months ago[lldb][ARM] Use portable printf tokens for 64 bit types
David Spickett [Tue, 26 Jul 2022 09:04:32 +0000 (09:04 +0000)]
[lldb][ARM] Use portable printf tokens for 64 bit types

Fixes some warnings in the 32 bit build.

23 months ago[llvm-objdump] Fix type mismatch in std::min.
Simon Tatham [Tue, 26 Jul 2022 08:43:26 +0000 (09:43 +0100)]
[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.

23 months ago[lldb][ARM] Add tests for vpush/vpop D registers
David Spickett [Fri, 22 Jul 2022 15:17:28 +0000 (15:17 +0000)]
[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

23 months ago[flang][OpenMP] Lowering support for default clause
Nimish Mishra [Tue, 26 Jul 2022 08:38:34 +0000 (14:08 +0530)]
[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

23 months agoReassoc FMF should not optimize FMA(a, 0, b) to (b)
Sven van Haastregt [Tue, 26 Jul 2022 08:39:12 +0000 (09:39 +0100)]
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>
23 months ago[llvm-objdump,ARM] Make dumpARMELFData line up with instructions.
Simon Tatham [Tue, 26 Jul 2022 08:20:52 +0000 (09:20 +0100)]
[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

23 months ago[llvm-objdump,ARM] Add PrettyPrinters for Arm and AArch64.
Simon Tatham [Tue, 26 Jul 2022 08:20:46 +0000 (09:20 +0100)]
[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

23 months ago[MC,llvm-objdump,ARM] Target-dependent disassembly resync policy.
Simon Tatham [Tue, 26 Jul 2022 08:20:41 +0000 (09:20 +0100)]
[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

23 months ago[lldb][ARM] Misc improvements to TestEmulations
David Spickett [Mon, 25 Jul 2022 08:48:13 +0000 (08:48 +0000)]
[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

23 months ago[ArgPromotion] Transfer metadata nontemporal to promoted loads
Phoebe Wang [Tue, 26 Jul 2022 08:02:30 +0000 (16:02 +0800)]
[ArgPromotion] Transfer metadata nontemporal to promoted loads

Fixes #56703

Reviewed By: nikic

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

23 months ago[lldb][ARM] Print mismatched registers in emulation tests
David Spickett [Fri, 22 Jul 2022 14:38:03 +0000 (14:38 +0000)]
[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

23 months ago[clang][dataflow] Fix SAT solver crashes on `X ^ X` and `X v X`
Dmitri Gribenko [Tue, 26 Jul 2022 08:16:13 +0000 (10:16 +0200)]
[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

23 months ago[analyzer] Structured binding to tuple-like types
isuckatcs [Wed, 29 Jun 2022 16:42:07 +0000 (18:42 +0200)]
[analyzer] Structured binding to tuple-like types

Introducing support for creating structured binding
to tuple-like types.

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

23 months ago[LLDB][ARM] Generalise adding register state in emulation tests and add D registers
David Spickett [Fri, 22 Jul 2022 14:13:32 +0000 (14:13 +0000)]
[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

23 months ago[AArch64][SVE] Add patterns to select mla/mls
Cullen Rhodes [Tue, 26 Jul 2022 07:52:24 +0000 (07:52 +0000)]
[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

23 months ago[AArch64][SVE] NFC: Add tests for masked mla/mls patterns (D130492)
Cullen Rhodes [Mon, 25 Jul 2022 12:41:51 +0000 (12:41 +0000)]
[AArch64][SVE] NFC: Add tests for masked mla/mls patterns (D130492)

23 months ago[RISCV] Lazily add RVV C intrinsics.
Kito Cheng [Wed, 13 Jul 2022 07:52:17 +0000 (15:52 +0800)]
[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

23 months ago[lldb][AArch64] Add support for memory tags in core files
David Spickett [Mon, 11 Jul 2022 12:26:55 +0000 (13:26 +0100)]
[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

23 months ago[Libomptarget] Add checks for AMDGPU TargetID using new image info
Saiyedul Islam [Mon, 25 Jul 2022 16:40:06 +0000 (11:40 -0500)]
[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

23 months ago[analyzer] Lambda capture non-POD type array
isuckatcs [Sun, 17 Jul 2022 17:04:45 +0000 (19:04 +0200)]
[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

23 months ago[cmake] Fix missing paren in `FindPrefixFromConfig`
John Ericson [Tue, 26 Jul 2022 07:29:11 +0000 (07:29 +0000)]
[cmake] Fix missing paren in `FindPrefixFromConfig`

This was in CMake syntax generation, so we didn't catch it eval time.

Follow up from D117973

23 months ago[flang] Rename variables in test. NFCI
Diana Picus [Thu, 30 Jun 2022 12:41:24 +0000 (12:41 +0000)]
[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

23 months ago[ARM] Add Tag_CPU_arch missing value descriptions in attribute parser
Victor Campos [Tue, 12 Jul 2022 15:13:12 +0000 (16:13 +0100)]
[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

23 months ago[LLDB][Reliability] Fix register value unpacking
Slava Gurevich [Thu, 21 Jul 2022 20:20:10 +0000 (13:20 -0700)]
[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

23 months ago[BOLT] Support files with no symbols
Amir Ayupov [Tue, 26 Jul 2022 07:07:34 +0000 (00:07 -0700)]
[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

23 months ago[analyzer] ArrayInitLoopExpr with array of non-POD type
isuckatcs [Sun, 17 Jul 2022 16:25:16 +0000 (18:25 +0200)]
[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

23 months ago[LoongArch] Use `end namespace xxx` style comment. NFC
Weining Lu [Tue, 26 Jul 2022 06:55:25 +0000 (14:55 +0800)]
[LoongArch] Use `end namespace xxx` style comment. NFC

23 months ago[clang-format] Fix a hang when formatting C# $@ string literals
owenca [Sat, 23 Jul 2022 06:39:43 +0000 (23:39 -0700)]
[clang-format] Fix a hang when formatting C# $@ string literals

Fixes #56624.

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

23 months ago[CMake][Fuchsia] Enable assertions and backtraces in stage 1 build
Alex Brachet [Tue, 26 Jul 2022 06:08:52 +0000 (06:08 +0000)]
[CMake][Fuchsia] Enable assertions and backtraces in stage 1 build

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

23 months ago[ADT] Deprecate Optional::getValueOr (NFC)
Kazu Hirata [Tue, 26 Jul 2022 06:01:02 +0000 (23:01 -0700)]
[ADT] Deprecate Optional::getValueOr (NFC)

This patch deprecates getValueOr in favor of value_or.

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

23 months ago[flang] Use value or * instead of getValue (NFC)
Kazu Hirata [Tue, 26 Jul 2022 06:01:01 +0000 (23:01 -0700)]
[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().

23 months agoRemove redundaunt virtual specifiers (NFC)
Kazu Hirata [Tue, 26 Jul 2022 06:00:59 +0000 (23:00 -0700)]
Remove redundaunt virtual specifiers (NFC)

Identified with tidy-modernize-use-override.

23 months agoUse isa instead of dyn_cast (NFC)
Kazu Hirata [Tue, 26 Jul 2022 06:00:58 +0000 (23:00 -0700)]
Use isa instead of dyn_cast (NFC)

23 months ago[mlir] Use value_or (NFC)
Kazu Hirata [Tue, 26 Jul 2022 06:00:56 +0000 (23:00 -0700)]
[mlir] Use value_or (NFC)

23 months agofix comment typo to cycle bots
Nico Weber [Tue, 26 Jul 2022 05:55:10 +0000 (01:55 -0400)]
fix comment typo to cycle bots

23 months ago[gn build] tweak how symbol_exports map files look on linux, for 94c00c10e
Nico Weber [Tue, 26 Jul 2022 05:50:48 +0000 (01:50 -0400)]
[gn build] tweak how symbol_exports map files look on linux, for 94c00c10e

After bc39d7bdd497 (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`.

23 months ago[CodeMetrics] use hasOneLiveUse instead of hasOneUse while analyzing inlinable callsites
Sinan Lin [Tue, 26 Jul 2022 05:45:13 +0000 (13:45 +0800)]
[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

23 months ago[gn build] port bc39d7bdd497 (libclang.map -> libclang.exports)
Nico Weber [Tue, 26 Jul 2022 05:39:15 +0000 (01:39 -0400)]
[gn build] port bc39d7bdd497 (libclang.map -> libclang.exports)

23 months ago[LoopDataPrefetch] Fix crash when TTI doesn't set CacheLineSize
zhongyunde [Tue, 26 Jul 2022 05:05:52 +0000 (13:05 +0800)]
[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

23 months agolibclang.so: Make SONAME the same as LLVM version
Tom Stellard [Tue, 26 Jul 2022 05:02:47 +0000 (22:02 -0700)]
libclang.so: Make SONAME the same as LLVM version

This partially reverts c7b3a91017d26266d7556b1ac7c49b06f0109b91.  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

23 months ago[BOLT][TEST] Update fptr.test
Amir Ayupov [Tue, 26 Jul 2022 05:00:24 +0000 (22:00 -0700)]
[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

23 months ago[DirectX backend] [NFC]Add DXILOpBuilder to generate DXIL operation
Xiang Li [Sat, 2 Jul 2022 20:44:46 +0000 (13:44 -0700)]
[DirectX backend] [NFC]Add DXILOpBuilder to generate DXIL operation

A new helper class DXILOpBuilder is added to create DXIL op function calls.

TableGen backend for DXILOperation will create table for DXIL op function parameter types.
When create DXIL op function, these parameter types will used to create the function type.

Reviewed By: bogner

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

23 months ago[CodeGen] Consider MangleCtx when move lazy emission States
Jun Zhang [Sat, 23 Jul 2022 05:55:10 +0000 (13:55 +0800)]
[CodeGen] Consider MangleCtx when move lazy emission States

Also move MangleCtx when moving some lazy emission states in
CodeGenModule. Without this patch clang-repl hits an invalid address
access when passing `-Xcc -O2` flag.

Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D130420

23 months ago[JITLink][COFF] Don't dead strip seh frame of exported function.
Sunho Kim [Tue, 26 Jul 2022 04:04:12 +0000 (13:04 +0900)]
[JITLink][COFF] Don't dead strip seh frame of exported function.

Adds keep-alive edges to pdata section to prevent dead strip of block when its parent function is alive.

Reviewed By: lhames

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

23 months ago[JITLink][COFF] Consider lib/dll files in llvm-jitlink.
Sunho Kim [Tue, 26 Jul 2022 03:59:44 +0000 (12:59 +0900)]
[JITLink][COFF] Consider lib/dll files in llvm-jitlink.

Consider lib/dll files in llvm-jitlink.

Reviewed By: lhames

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

23 months ago[X86][DAGISel] Don't widen shuffle element with AVX512
Luo, Yuanke [Tue, 12 Jul 2022 03:00:08 +0000 (11:00 +0800)]
[X86][DAGISel] Don't widen shuffle element with AVX512

Currently the X86 shuffle lowering would widen the element type for
shuffle if the mask element value is adjacent. For below example

  %t2 = add nsw <16 x i32> %t0, %t1
  %t3 = sub nsw <16 x i32> %t0, %t1
  %t4 = shufflevector <16 x i32> %t2, <16 x i32> %t3,
                      <16 x i32> <i32 16, i32 17, i32 2, i32 3, i32 4,
                       i32 5, i32 6, i32 7, i32 8, i32 9, i32 10,
                       i32 11, i32 12, i32 13, i32 14, i32 15>

  ret <16 x i32> %t4

Compiler would transform the shuffle to
  %t4 = shufflevector <8 x i64> %t2, <8 x i64> %t3,
                      <8 x i64> <i32 8, i32 1, i32 2, i32 3, i32 4,
                                 i32 5, i32 6, i32 7>
This may lose the oppotunity to let ISel select mask instruction when
avx512 is enabled.

This patch is to prevent the tranform when avx512 feature is enabled.
Thank Simon for the idea.

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

23 months ago[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 2
Slava Gurevich [Mon, 25 Jul 2022 22:52:21 +0000 (15:52 -0700)]
[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 2

Improve LLDB reliability by fixing the following "uninitialized variables" static code inspection warnings from
scan.coverity.com:

1476275, 1274012, 1455035, 1364789, 1454282
1467483, 1406152, 1406255, 1454837, 1454416
1467446, 1462022, 1461909, 1420566, 1327228
1367767, 1431254, 1467299, 1312678, 1431780
1454731, 1490403

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

23 months ago[flang] Remove unused variable lastPrivBlock (NFC)
Kazu Hirata [Tue, 26 Jul 2022 03:52:22 +0000 (20:52 -0700)]
[flang] Remove unused variable lastPrivBlock (NFC)

This fixes the warning:

  llvm-project/flang/lib/Lower/OpenMP.cpp:94:10: error: unused
  variable 'lastPrivBlock' [-Werror,-Wunused-variable]

23 months ago[JITLink][COFF] Implement IMAGE_COMDAT_SELECT_LARGEST partially.
Sunho Kim [Tue, 26 Jul 2022 03:51:33 +0000 (12:51 +0900)]
[JITLink][COFF] Implement IMAGE_COMDAT_SELECT_LARGEST partially.

Implement IMAGE_COMDAT_SELECT_LARGEST partially. It's going to fail if larger symbol appears but this hasn't happened at least in vcruntime library.

We probably would not implement this properly as it requires complicated runtime patching which is not of nature of JIT. However, we'd like to validate if larger section appears and report to the user in the near future.

Reviewed By: lhames

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

23 months ago[JITLink][COFF] Implement IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY/LIBRARY.
Sunho Kim [Tue, 26 Jul 2022 03:46:34 +0000 (12:46 +0900)]
[JITLink][COFF] Implement IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY/LIBRARY.

Implement IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY/LIBRARY characteristics flag.

Since COFFObjectFile class will set undefined flag for symbols with no alias flag, ORC ObjectFileInterface will not pull in this symbol. So, we only need to make sure the scope is local. NOLIBRARY and LIBRARY are handled in the same way for now. (which is what lld does right now)

Reviewed By: lhames

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

23 months ago[JITLink][COFF] Handle duplicate external symbols.
Sunho Kim [Tue, 26 Jul 2022 03:44:04 +0000 (12:44 +0900)]
[JITLink][COFF] Handle duplicate external symbols.

Handles duplicate external symbols. This happens in few static libraries generaed from msvc toolchain.

Reviewed By: lhames

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

23 months ago[bazel] Add new rule for c60b897d22b2feab3282c4fc2b390bc87560c7de
Weverything [Tue, 26 Jul 2022 03:26:19 +0000 (20:26 -0700)]
[bazel] Add new rule for c60b897d22b2feab3282c4fc2b390bc87560c7de

23 months ago[llvm][cmake] Make `install_symlink` workflow work with absolute install dirs
John Ericson [Mon, 25 Jul 2022 21:17:34 +0000 (21:17 +0000)]
[llvm][cmake] Make `install_symlink` workflow work with absolute install dirs

If `CMAKE_INSTALL_BINDIR` is a different absolute path per project, as
it is with NixOS when we install every package to its own prefix, the
old way fails when the absolute path gets prepended with `CMAKE_INSTALL_PREFIX`.

The `extend_path` function does what we want, but it is currently internal-only. So easier to just inline the one small case of it we need.

Also fix one stray `bin` -> `CMAKE_INSTALL_BINDIR`

Reviewed By: sebastian-ne

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

23 months ago[DAGCombiner] Teach scalarizeExtractedBinop to support scalable splat.
jacquesguan [Thu, 14 Jul 2022 02:41:42 +0000 (10:41 +0800)]
[DAGCombiner] Teach scalarizeExtractedBinop to support scalable splat.

This patch supports the scalable splat part for scalarizeExtractedBinop.

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

23 months agoRevert "[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan....
Slava Gurevich [Tue, 26 Jul 2022 01:23:19 +0000 (18:23 -0700)]
Revert "[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 2"

This reverts commit b9aedd94e6796e4b4866ab4c091b736b3db58cb7.

23 months ago[mlir][Math] Add constant folder for Exp2Op.
jacquesguan [Mon, 25 Jul 2022 10:11:53 +0000 (18:11 +0800)]
[mlir][Math] Add constant folder for Exp2Op.

This patch adds constant folder for Exp2Op which only supports single and double precision floating-point.

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

23 months ago[mlir] SCCP add missing pessimistic setting
Jacques Pienaar [Tue, 26 Jul 2022 00:41:17 +0000 (17:41 -0700)]
[mlir] SCCP add missing pessimistic setting

When this was updated in D127139 the update in-place case was no longer
marked as pessimistic. Add back in.

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

23 months ago[mlir][Parser] Fix memory leak when failing to parse a forward declared block
River Riddle [Tue, 19 Jul 2022 23:12:02 +0000 (16:12 -0700)]
[mlir][Parser] Fix memory leak when failing to parse a forward declared block

This commit fixes a failure edge case where we accidentally drop forward
declared blocks in the error case. This allows for running the
invalid.mlir test in asan mode now.

Fixes #51387

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

23 months ago[Flang][OpenMP] Add support for lastprivate clause for worksharing loop.
Arnamoy Bhattacharyya [Tue, 26 Jul 2022 00:31:23 +0000 (20:31 -0400)]
[Flang][OpenMP] Add support for lastprivate clause for worksharing loop.

This patch adds an initial support to the lastprivate clause for worksharing loop.  The patch creates necessary control flow to guarantee the store of the value from the logical last iteration of the workshare loop.

Reviewed By: kiranchandramohan

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

23 months ago[lld-macho] Implement -hidden-l
Daniel Bertalan [Mon, 25 Jul 2022 22:51:28 +0000 (00:51 +0200)]
[lld-macho] Implement -hidden-l

Similarly to -load_hidden, this flag instructs the linker to not export
symbols from the specified archive. While that flag takes a path,
-hidden-l looks for the specified library name in the search path.

The test changes are needed because -hidden-lfoo resolves to libfoo.a,
not foo.a.

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

23 months ago[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 2
Slava Gurevich [Mon, 25 Jul 2022 22:52:21 +0000 (15:52 -0700)]
[LLDB][NFC][Reliability] Fix uninitialized variables from Coverity scan. Part 2

Improve LLDB reliability by fixing the following "uninitialized variables" static code inspection warnings from
scan.coverity.com:

1476275, 1274012, 1455035, 1364789, 1454282
1467483, 1406152, 1406255, 1454837, 1454416
1467446, 1462022, 1461909, 1420566, 1327228
1367767, 1431254, 1467299, 1312678, 1431780
1454731, 1490403

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

23 months ago[mlir] Refactor the Parser library in preparation for an MLIR binary format
River Riddle [Sun, 10 Jul 2022 08:00:21 +0000 (01:00 -0700)]
[mlir] Refactor the Parser library in preparation for an MLIR binary format

The current Parser library is solely focused on providing API for
the textual MLIR format, but MLIR will soon also provide a binary
format. This commit renames the current Parser library to AsmParser to
better correspond to what the library is actually intended for. A new
Parser library is added which will act as a unified parser interface
between both text and binary formats. Most parser clients are
unaffected, given that the unified interface is essentially the same as
the current interface. Only clients that rely on utilizing the
AsmParserState, or those that want to parse Attributes/Types need to be
updated to point to the AsmParser library.

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

23 months ago[GlobalISel] Fix miscompile of G_UREM + G_UDIV due to not checking for equality
Amara Emerson [Mon, 25 Jul 2022 22:13:49 +0000 (15:13 -0700)]
[GlobalISel] Fix miscompile of G_UREM + G_UDIV due to not checking for equality
of the first operands of each.

Fixes issue #55287

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

23 months ago[Clang] Fix how we set the NumPositiveBits on an EnumDecl to cover the case of single...
Shafik Yaghmour [Mon, 25 Jul 2022 22:56:44 +0000 (15:56 -0700)]
[Clang] Fix how we set the NumPositiveBits on an EnumDecl to cover the case of single enumerator with value zero or an empty enum

Currently in Sema::ActOnEnumBody(...) when calculating NumPositiveBits we miss
the case where there is only a single enumerator with value zero and the case of
an empty enum. In both cases we end up with zero positive bits when in fact we
need one bit to store the value zero.

This PR updates the calculation to account for these cases.

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

23 months ago[RISCV] Refactor translateSetCCForBranch to prepare for D130508. NFC.
Craig Topper [Mon, 25 Jul 2022 22:42:42 +0000 (15:42 -0700)]
[RISCV] Refactor translateSetCCForBranch to prepare for D130508. NFC.

D130508 handles more constants than just 1 or -1. We need to extract
the constant instead of relying isOneConstant or isAllOnesConstant.

23 months ago[IRBuilder] Add assert for AtomicRMW ordering
Alexander Shaposhnikov [Mon, 25 Jul 2022 22:51:25 +0000 (22:51 +0000)]
[IRBuilder] Add assert for AtomicRMW ordering

Add assert for AtomicRMW: Ordering != AtomicOrdering::Unordered
(https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Verifier.cpp#L3944)
and adjust expandAtomicStore accordingly.

Test plan:
1/ ninja check-llvm check-clang check-lld
2/ Bootstrapped LLVM/Clang pass tests

Differential revision: https://reviews.llvm.org/D130457

23 months ago[BOLT] Process each block only once in fixCFGForPIC
Fabian Parzefall [Mon, 25 Jul 2022 21:48:48 +0000 (14:48 -0700)]
[BOLT] Process each block only once in fixCFGForPIC

Rather than iterating over the whole function from the start until no
internal calls are found, process each block only once and continue
processing after splitting. This version of the function also does not
seemingly invalidate iterators from within the loop.

Reviewed By: maksfb

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

23 months ago[Driver] Ignore unimplemented -mtune= for ARM/PowerPC
Fangrui Song [Mon, 25 Jul 2022 22:05:38 +0000 (15:05 -0700)]
[Driver] Ignore unimplemented -mtune= for ARM/PowerPC

This compensates for 8f0c901c1a172313a32bc06a1fcface76cd1220f which enabled
-Wunused-command-line-argument for unimplemented -mtune= in the generic code.
Ignoring -mtune= appears to be longstanding and the error-free behavior in the
presence of -Werror is unfortunately relied on by the Linux kernel's arm and
powerpc ports. Ignore the warnings for the upcoming 15.0.0 branch and will
implement functionality to fill the test gap soon.

Link: https://github.com/ClangBuiltLinux/linux/issues/1674
23 months ago[mlir][NFC] Remove TypeRange's constructors that cause ambiguity
lipracer [Mon, 25 Jul 2022 21:33:51 +0000 (15:33 -0600)]
[mlir][NFC] Remove TypeRange's constructors that cause ambiguity

ArrayRef<Value> can implicit convert to ValueRange,when we call TypeRange(SmallVector<Value>) is ambiguity.
TypeRange(ValueRange values)
TypeRange(ArrayRef<Value> values)

Reviewed By: rriddle, Mogball

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

23 months agoSplit class ValueRange to a new file
lipracer [Mon, 25 Jul 2022 20:42:18 +0000 (14:42 -0600)]
Split class ValueRange to a new file

When we apply parent patch : https://reviews.llvm.org/D129475
The prompt I get with the clang compiler is: ValueRange is imcomplete type,ValueRange is a forward declaration in the file TypeRange.h, and the file OperationSupport.h already includes the file TypeRange.h.The class TypeRange and the class ValueRange depend on each other.

Reviewed By: rriddle, Mogball

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

23 months agoMemoryBuiltins: remove malloc-family funcs from list
Augie Fackler [Wed, 30 Mar 2022 18:14:53 +0000 (14:14 -0400)]
MemoryBuiltins: remove malloc-family funcs from list

We no longer need specialized knowledge of these allocator functions in
this file since we have the correct attributes available now.

As far as I can tell the changes in the attributor tests are due to
things getting more consistent on alloc-family once we remove the static
list entries.

The two test changes in NewGVN merit extra scrutiny: NewGVN appears to
be _extremely_ sensitive to the inaccessiblememonly for reasons that
are beyond me. As a result, I had-enumerated all the attributes on
allocation functions in those two tests instead of using -inferattrs.
I assumed that the two -disable-simplify-libcalls tests there no
longer are sensible since the function declaration now includes all the
relevant attributes.

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

23 months agotests: add attributes that would normally come from inferattrs
Augie Fackler [Fri, 18 Mar 2022 20:26:24 +0000 (16:26 -0400)]
tests: add attributes that would normally come from inferattrs

As my goal is to remove at least _some_ functions from the static list
in MemoryBuiltins.cpp, these tests either need to run inferattrs or
statically declare these attributes to keep passing. A couple of tests
had alternate cases which are no longer meaningful, e.g.
`malloc-load-removal.ll`.

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

23 months agoRevert "[llvm][cmake] Make `install_symlink` workflow work with absolute install...
John Ericson [Mon, 25 Jul 2022 21:15:14 +0000 (21:15 +0000)]
Revert "[llvm][cmake] Make `install_symlink` workflow work with absolute install dirs"

`ExtendPath` needs to be moved from internal to external CMake if it is
to be used to `AddLLVM`. See, for example, the failure in
https://lab.llvm.org/buildbot#builders/61/builds/29940

This reverts commit 5acd376438a53747c84e38c8b69fc74a270da680.

23 months ago[llvm][cmake] Make `install_symlink` workflow work with absolute install dirs
John Ericson [Fri, 21 Jan 2022 02:54:54 +0000 (02:54 +0000)]
[llvm][cmake] Make `install_symlink` workflow work with absolute install dirs

If `CMAKE_INSTALL_BINDIR` is a different absolute path per project, as
it is with NixOS when we install every package to its own prefix, the
old way fails when the absolute path gets prepended with `CMAKE_INSTALL_PREFIX`.

Using `extend_path` from the install-time script isn't really possible, so we just make the caller responsible for making the path absolute instead.

Also fix one stray `bin` -> `CMAKE_INSTALL_BINDIR`

Reviewed By: sebastian-ne

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

23 months ago[cmake] Support custom package install paths
John Ericson [Sat, 1 Jan 2022 20:18:27 +0000 (20:18 +0000)]
[cmake] Support custom package install paths

Firstly, we we make an additional GNUInstallDirs-style variable. With
NixOS, for example, this is crucial as we want those to go in
`${dev}/lib/cmake` not `${out}/lib/cmake` as that would a cmake subdir
of the "regular" libdir, which is installed even when no one needs to do
any development.

Secondly, we make *Config.cmake robust to absolute package install
paths. We for NixOS will in fact be passing them absolute paths to make
the `${dev}` vs `${out}` distinction mentioned above, and the
GNUInstallDirs-style variables are suposed to support absolute paths in
general so it's good practice besides the NixOS use-case.

Thirdly, we make `${project}_INSTALL_PACKAGE_DIR` CACHE PATHs like other
install dirs are.

Reviewed By: sebastian-ne

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

23 months ago[Libomptarget] Reintroduce host architecture checks for device RTL
Joseph Huber [Mon, 25 Jul 2022 19:16:06 +0000 (15:16 -0400)]
[Libomptarget] Reintroduce host architecture checks for device RTL

A previous patch removed the need to set the auxiliary architecture as
it was no longer needed for the clang invocation after moving to using
the clang frontend. However, this had a second use of preventing
unsupported host architectures from building the device runtime. This
caused failures when trying to build on 32-bit hosts for example.

Fixes #56699

Reviewed By: tianshilei1992

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

23 months ago[asan][test] Additional test requiring weak symbol for dyld64.
Roy Sundahl [Mon, 25 Jul 2022 16:31:02 +0000 (09:31 -0700)]
[asan][test] Additional test requiring weak symbol for dyld64.

Extension of D127929

rdar://80997227

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

23 months agoReland "[lld-macho] Implement -load_hidden"
Daniel Bertalan [Mon, 25 Jul 2022 09:45:55 +0000 (11:45 +0200)]
Reland "[lld-macho] Implement -load_hidden"

This flag was introduced in ld64-609. It instructs the linker to link to
a static library while treating its symbols as if they had hidden
visibility. This is useful when building a dylib that links to static
libraries but we don't want the symbols from those to be exported.

Closes #51505

This reland adds bitcode file handling, so we won't get any compile
errors due to BitcodeFile::forceHidden being unused.

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

23 months ago[libc][Obvious] Use the correct StringView constructor in dirent_test.
Siva Chandra Reddy [Mon, 25 Jul 2022 20:45:46 +0000 (20:45 +0000)]
[libc][Obvious] Use the correct StringView constructor in dirent_test.

23 months ago[WebAssembly] Use `localexec` as default TLS model for non-Emscripten targets
Andrew Brown [Mon, 25 Jul 2022 20:16:07 +0000 (13:16 -0700)]
[WebAssembly] Use `localexec` as default TLS model for non-Emscripten targets

Only Emscripten supports dynamic linking with threads. To use
thread-local storage for other targets, this change defaults to the
`localexec` model.

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

23 months ago[libc] Add dirent.h functions opendir, readdir, closedir and dirfd.
Siva Chandra Reddy [Sat, 23 Jul 2022 07:35:46 +0000 (07:35 +0000)]
[libc] Add dirent.h functions opendir, readdir, closedir and dirfd.

Reviewed By: lntue

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

23 months agoRegAllocGreedy: Add a command line flag for reverseLocalAssignment
Matt Arsenault [Sat, 23 Jul 2022 13:33:21 +0000 (09:33 -0400)]
RegAllocGreedy: Add a command line flag for reverseLocalAssignment

Introduce a flag like for some of the other target heuristic controls
to help with experimentation.

23 months agoAMDGPU: Adjust register allocation priority values down
Matt Arsenault [Sat, 23 Jul 2022 14:22:41 +0000 (10:22 -0400)]
AMDGPU: Adjust register allocation priority values down

Set the priorities consistently to number of registers in the tuple -
1. Previously we started at 1, and also tried to give SGPR higher
values than VGPRs. There's no point in assigning SGPRs higher values
now that those are allocated in a separate regalloc run.

This avoids overflowing the 5 bits used for the class priority in the
allocation heuristic for 32 element tuples. This avoids some cases
where smaller registers unexpectedly get prioritized over larger.

23 months ago[OpenMP] Remove noinline attributes in the device runtime
Joseph Huber [Mon, 25 Jul 2022 19:27:41 +0000 (15:27 -0400)]
[OpenMP] Remove noinline attributes in the device runtime

We previously used the `noinline` attributes to specify some defintions
which should be kept alive in the runtime. These were then stripped
immediately in the OpenMPOpt module pass. However, Since the changes in
D130298, we not explicitly state which functions will have external
visiblity in the bitcode library. Additionally the OpenMPOpt module pass
should run before the inliner pass, so this shouldn't make a difference
in whether or not the functions will be alive for the initial pass of
OpenMPOpt. This should simplify the interface, and additionally save
time spend on scanning funciton names for noinline.

Reviewed By: jdoerfert

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

23 months ago[Passes] add a tail-call-elim pass near the end of the opt pipeline
Sanjay Patel [Mon, 25 Jul 2022 14:09:09 +0000 (10:09 -0400)]
[Passes] add a tail-call-elim pass near the end of the opt pipeline

We call tail-call-elim near the beginning of the pipeline,
but that is too early to annotate calls that get added later.

In the motivating case from issue #47852, the missing 'tail'
on memset leads to sub-optimal codegen.

I experimented with removing the early instance of
tail-call-elim instead of just adding another pass, but that
appears to be slightly worse for compile-time:
+0.15% vs. +0.08% time.
"tailcall" shows adding the pass; "tailcall2" shows moving
the pass to later, then adding the original early pass back
(so 1596886802 is functionally equivalent to 180b0439dc ):
https://llvm-compile-time-tracker.com/index.php?config=NewPM-O3&stat=instructions&remote=rotateright

Note that there was an effort to split the tail call functionality
into 2 passes - that could help reduce compile-time if we find
that this change costs more in compile-time than expected based
on the preliminary testing:
D60031

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

23 months ago[flang] Allow restricted specific intrinsic functions as implicitly-interfaced proced...
Peter Klausler [Fri, 22 Jul 2022 18:48:07 +0000 (11:48 -0700)]
[flang] Allow restricted specific intrinsic functions as implicitly-interfaced procedure pointer targets

The predicate "CanBeCalledViaImplicitInterface()" was returning false for
restricted specific intrinsic functions (e.g., SIN) because their procedure
characteristics have the elemental attribute; this leads to a bogus semantic
error when one attempts to use them as proc-targets in procedure pointer
assignment statements when the left-hand side of the assignment is a procedure
pointer with an implicit interface.  However, these restricted specific intrinsic
functions have always been allowed as special cases for such usage -- it is
as if they are elemental when it is necessary for them to be so, but not
when it's a problem.

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

23 months ago[flang][runtime] Reset unit frame buffer when re-opening
Peter Klausler [Fri, 22 Jul 2022 21:32:03 +0000 (14:32 -0700)]
[flang][runtime] Reset unit frame buffer when re-opening

An OPEN statement that implies closing a connection must invalidate
the unit's frame buffer so as to prevent stale data from the old
connection from being read into the newly-connected unit.

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

23 months agoRevert "[lld-macho] Implement -load_hidden"
Daniel Bertalan [Mon, 25 Jul 2022 19:11:19 +0000 (21:11 +0200)]
Revert "[lld-macho] Implement -load_hidden"

This reverts commit 4c79e1a3f4eb790f40239833ae237e828ce07386.

Broke this bot: https://lab.llvm.org/buildbot/#builders/57/builds/20319

23 months ago[lld-macho] Implement -load_hidden
Daniel Bertalan [Mon, 25 Jul 2022 09:45:55 +0000 (11:45 +0200)]
[lld-macho] Implement -load_hidden

This flag was introduced in ld64-609. It instructs the linker to link to
a static library while treating its symbols as if they had hidden
visibility. This is useful when building a dylib that links to static
libraries but we don't want the symbols from those to be exported.

Closes #51505

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

23 months ago[RISCV] Add more test cases for select with (setge X, C) condition.
Craig Topper [Mon, 25 Jul 2022 18:48:52 +0000 (11:48 -0700)]
[RISCV] Add more test cases for select with (setge X, C) condition.

InstCombine and SelectionDAG will tend to canonicalize these conditions
to (setgt X, C-1). C-1 might be more costly to materialize than C would
have been.

23 months ago[Flang][OpenMP] Initial support for integer reduction in worksharing-loop
Kiran Chandramohan [Mon, 25 Jul 2022 18:21:17 +0000 (18:21 +0000)]
[Flang][OpenMP] Initial support for integer reduction in worksharing-loop

Lower the Flang parse-tree containing OpenMP reductions to the OpenMP
dialect. The OpenMP dialect models reductions with,
1) A reduction declaration operation that specifies how to initialize, combine,
and atomically combine private reduction variables.
2) The OpenMP operation (like wsloop) that supports reductions has an array of
reduction accumulator variables (operands) and an array attribute of the same
size that points to the reduction declaration to be used for the reduction
accumulation.
3) The OpenMP reduction operation that takes a value and an accumulator.
This operation replaces the original reduction operation in the source.

(1) is implemented by the `createReductionDecl` in OpenMP.cpp,
(2) is implemented while creating the OpenMP operation,
(3) is implemented by the `genOpenMPReduction` function in OpenMP.cpp, and
called from Bridge.cpp. The implementation of (3) is not very robust.

NOTE 1: The patch currently supports only reductions for integer type addition.
NOTE 2: Only supports reduction in the worksharing loop.
NOTE 3: Does not generate atomic combination region.
NOTE 4: Other options for creating the reduction operation include
a) having the reduction operation as a construct containing an assignment
and then handling it appropriately in the Bridge.
b) we can modify `genAssignment` or `genFIR(AssignmentStmt)` in the Bridge to
handle OpenMP reduction but so far we have tried not to mix OpenMP
and non-OpenMP code and this will break that.
I will try (b) in a separate patch.
NOTE 5: OpenMP dialect gained support for reduction with the patches:
D105358, D107343. See https://discourse.llvm.org/t/rfc-openmp-reduction-support/3367
for more details.

Reviewed By: awarzynski

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

Co-authored-by: Peixin-Qiao <qiaopeixin@huawei.com>
23 months ago[clang][dataflow] Rename iterators from IT to It
Dmitri Gribenko [Mon, 25 Jul 2022 18:23:23 +0000 (20:23 +0200)]
[clang][dataflow] Rename iterators from IT to It

The latter way to abbreviate is a lot more common in the LLVM codebase.

Reviewed By: sgatev, xazax.hun

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

23 months ago[libc] Add a simple StringStream class.
Siva Chandra Reddy [Fri, 22 Jul 2022 06:54:54 +0000 (06:54 +0000)]
[libc] Add a simple StringStream class.

This class will be used in future changes to construct simple strings.

Reviewed By: michaelrj

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

23 months ago[clang][dataflow] Fix MapLattice::insert() to not drop return value
Eric Li [Mon, 25 Jul 2022 16:18:53 +0000 (12:18 -0400)]
[clang][dataflow] Fix MapLattice::insert() to not drop return value

Fix `MapLattice` API to return `std::pair<iterator, bool>`,
allowing users to detect when an element has been inserted without
performing a redundant map lookup.

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

23 months ago[Kaleidoscope] Fix DWARF function creation example
Justin Brooks [Mon, 25 Jul 2022 18:18:53 +0000 (18:18 +0000)]
[Kaleidoscope] Fix DWARF function creation example

The full code listing was fixed in fdaeb0c647eb66763721a7fe74e0a36b007dcd75

Reviewed By: dblaikie

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