platform/upstream/llvm.git
2 years ago[mlir][tosa] Move tosa canonicalizers to optional optimization pass
Aaron DeBattista [Fri, 17 Dec 2021 07:24:47 +0000 (23:24 -0800)]
[mlir][tosa] Move tosa canonicalizers to optional optimization pass

TOSA's canonicalizers that change dense operations should be moved to a
seperate optimization pass to avoid canonicalizing to operations not supported
for relevant backends.

Reviewed By: rsuderman

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

2 years agoPassthrough LLVM_USE_LLD LLVM_USE_LINKER into runtimes
Vitaly Buka [Thu, 16 Dec 2021 05:54:53 +0000 (21:54 -0800)]
Passthrough LLVM_USE_LLD LLVM_USE_LINKER into runtimes

Fixes https://github.com/llvm/llvm-project/issues/42339

Reviewed By: phosek, sylvestre.ledru

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

2 years agoPort __sanitizer::StopTheWorld to Windows
Clemens Wasser [Thu, 16 Dec 2021 19:56:29 +0000 (11:56 -0800)]
Port __sanitizer::StopTheWorld to Windows

This also makes the sanitizer_stoptheworld_test cross-platform by using the STL, rather than pthread.

Reviewed By: vitalybuka

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

2 years ago[sanitizer] Simplify sanitizer_stoptheworld_test
Vitaly Buka [Thu, 16 Dec 2021 22:14:09 +0000 (14:14 -0800)]
[sanitizer] Simplify sanitizer_stoptheworld_test

2 years agoDWARFVerifier: Skip resolution failures for locations in dwo files
David Blaikie [Fri, 17 Dec 2021 06:22:54 +0000 (22:22 -0800)]
DWARFVerifier: Skip resolution failures for locations in dwo files

When reading location lists in dwo files the addresses cannot be
resolved, but that's not a problem.

Long term this probably should be fixed with a different API that
exposes location expressions without the need to resolve the address
ranges, since that's all the verifier (in its current state) requires.
(though the verifier should probably also eventually verify the address
ranges in location lists are a subset of the enclosing scope's address
range)

2 years agoDWARFVerifier: Test failures to parse DW_AT_locations
David Blaikie [Fri, 17 Dec 2021 05:32:40 +0000 (21:32 -0800)]
DWARFVerifier: Test failures to parse DW_AT_locations

2 years ago[ELF] Optimize MergeInputSection::splitNonStrings. NFC
Fangrui Song [Fri, 17 Dec 2021 05:22:59 +0000 (21:22 -0800)]
[ELF] Optimize MergeInputSection::splitNonStrings. NFC

2 years ago[ELF] Speed up MergeInputSection::split*. NFC
Fangrui Song [Fri, 17 Dec 2021 05:17:02 +0000 (21:17 -0800)]
[ELF] Speed up MergeInputSection::split*. NFC

2 years ago[ELF] Use SmallVector for MergeInputSection::pieces. NFC
Fangrui Song [Fri, 17 Dec 2021 05:07:39 +0000 (21:07 -0800)]
[ELF] Use SmallVector for MergeInputSection::pieces. NFC

sizeof(pieces) decreases from 24 to 16 on ELF64.
One BumpPtrAllocator can store more MergeInputSections.
The lld executable becomes smaller.

2 years ago[ELF] Internalize createMergeSynthetic. NFC
Fangrui Song [Fri, 17 Dec 2021 04:50:06 +0000 (20:50 -0800)]
[ELF] Internalize createMergeSynthetic. NFC

Only called once. Moving to OutputSections.cpp can make it inlined.
finalizeInputSections can be very hot, especially in -O1 links with much debug info.

2 years agoDWARFVerifier: Cleanup a test, remove redundant abbreviation
David Blaikie [Fri, 17 Dec 2021 04:30:33 +0000 (20:30 -0800)]
DWARFVerifier: Cleanup a test, remove redundant abbreviation

2 years agoDWARFVerifier: Don't error on missing ranges in Split DWARF
David Blaikie [Fri, 17 Dec 2021 04:06:07 +0000 (20:06 -0800)]
DWARFVerifier: Don't error on missing ranges in Split DWARF

When verifying dwo files address ranges won't be able to be resolved due
to missing debug_addr (or missing debug_ranges in the case of DWARFv4
Split DWARF).

2 years ago[llvm-profgen] Fix warning of enumerated and non-enumerated type in conditional expre...
wlei [Thu, 16 Dec 2021 03:14:50 +0000 (19:14 -0800)]
[llvm-profgen] Fix warning of enumerated and non-enumerated type in conditional expression

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

2 years ago[mlir][ods] Added EnumAttr, an AttrDef implementation of enum attributes
Mogball [Fri, 17 Dec 2021 02:44:56 +0000 (02:44 +0000)]
[mlir][ods] Added EnumAttr, an AttrDef implementation of enum attributes

`EnumAttr` is a pure TableGen implementation of enum attributes using `AttrDef`. This is meant as a drop-in replacement for `StrEnumAttr`, which is soon to be deprecated. `StrEnumAttr` is often used over `IntEnumAttr` because its more readable in MLIR assembly formats. However, storing and manipulating strings is not efficient. Defining `StrEnumAttr` can also be awkward and relies on a lot of special logic in `EnumsGen`, and has some hidden sharp edges.

Also, `EnumAttr` stores the enum directly,  removing the need to convert to/from integers when calling attribute getters on ops.

Reviewed By: mehdi_amini

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

2 years ago[Modules] Incorrect ODR detection for unresolved using type
Chuanqi Xu [Fri, 17 Dec 2021 02:35:17 +0000 (10:35 +0800)]
[Modules] Incorrect ODR detection for unresolved using type

Implement `getUnresolvedUsingType()` and don't create a new
`UnresolvedUsingType` when there is already canonical declaration.

This solved an incorrect ODR detection in modules for uresolved using
type.

Reviewed By: rjmccall

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

2 years agoDWARFVerifier: Don't try to resolve decl_file in split CUs
David Blaikie [Thu, 16 Dec 2021 23:20:21 +0000 (15:20 -0800)]
DWARFVerifier: Don't try to resolve decl_file in split CUs

Since they refer to the debug_line in the skeleton unit, they can't be
resolved from the dwo CU.

But they can be resolved for split TUs, since those refer to
.debug_line.dwo, which is available in the dwo file.

2 years ago[gn build] Port 09103807e7dc
LLVM GN Syncbot [Fri, 17 Dec 2021 01:57:11 +0000 (01:57 +0000)]
[gn build] Port 09103807e7dc

2 years ago[NFC][regalloc] Introduce the RegAllocEvictionAdvisorAnalysis
Mircea Trofin [Tue, 14 Dec 2021 06:49:57 +0000 (22:49 -0800)]
[NFC][regalloc] Introduce the RegAllocEvictionAdvisorAnalysis

This patch introduces the eviction analysis and the eviction advisor,
the default implementation, and the scaffolding for introducing the
other implementations of the advisor.

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

2 years agoRevert "[analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space chara...
Nico Weber [Fri, 17 Dec 2021 01:46:51 +0000 (20:46 -0500)]
Revert "[analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file"

This reverts commit 333d66b09494b7ebc1a89f2befa79128a56f77e3.
Breaks tests on macOS, see comments on https://reviews.llvm.org/D102669

2 years agoExtract a helper function for computing estimate trip count of an exiting branch
Philip Reames [Fri, 17 Dec 2021 01:27:54 +0000 (17:27 -0800)]
Extract a helper function for computing estimate trip count of an exiting branch

Plan to use this in following change to support estimated trip counts derived from multiple loop exits.

2 years ago[WebAssembly] Support clang -fwasm-exceptions for bitcode
Heejin Ahn [Thu, 16 Dec 2021 02:10:57 +0000 (18:10 -0800)]
[WebAssembly] Support clang -fwasm-exceptions for bitcode

This supports bitcode compilation using `clang -fwasm-exceptions`.

---

The current situation:

Currently the backend requires two options for Wasm EH:
`-wasm-enable-eh` and `-exception-model=wasm`. Wasm SjLj requires two
options as well: `-wasm-enable-sjlj` and `-exception-model=wasm`. When
using Wasm EH via Emscripten, you only need to pass `-fwasm-exceptions`,
and these options will be added within the clang driver. This
description will focus on the case of Wasm EH going forward, but Wasm
SjLj's case is similar.

When you pass `-fwasm-exceptions` to emcc and clang driver, the clang
driver adds these options to the command line that calls the clang
frontend (`clang -cc1`): `-mllvm -wasm-enable-eh` and
`-exception-model=wasm`. `-wasm-enable-eh` is prefixed with `-mllvm`, so
it is passed as is to the backend. But `-exception-model` is parsed and
processed within the clang frontend and stored in `LangOptions` class.
This info is later transferred to `TargetOptions` class, and then
eventually passed to `MCAsmInfo` class. All LLVM code queries this
`MCAsmInfo` to get the exception model.

---

Problem:

The problem is the whole `LangOptions` processing is bypassed when
compiling bitcode, so the information transfer of `LangOptions` ->
`TargetOptions` -> `MCAsmInfo` does not happen. They are all set to
`ExceptionHandling::None`, which is the default value.

---

What other targets do, and why we can't do the same:

Other targets support bitcode compilation by the clang driver, but they
can do that by using different triples. For example, X86 target supports
multiple triples, each of which has its own subclass of `MCAsmInfo`, so
it can hardcode the appropriate exception model within those subclasses'
constructors. But we don't have separate triples for each exception
mode: none, emscripten, and wasm.

---

What this CL does:

If we can figure out whether `-wasm-enable-eh` is passed to the backend,
we can programatically set the exception model from the backend, rather
than requiring it to be passed.

So we check `WasmEnableEH` and `WasmEnableSjLj` variables, which are
`cl::opt` for `-wasm-enable-eh` and `-wasm-enable-sjlj`, in
`WebAssemblyMCAsmInfo` constructor, and if either of them is set, we set
`MCAsmInfo.ExceptionType` to Wasm. `TargetOptions` cannot be updated
there, so we make sure they are the same later.

Fixes https://github.com/emscripten-core/emscripten/issues/15712.

Reviewed By: dschuff

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

2 years ago[funcattrs] Add some additional indirect call tests
Philip Reames [Fri, 17 Dec 2021 00:38:40 +0000 (16:38 -0800)]
[funcattrs] Add some additional indirect call tests

2 years ago[gn build] Port bdc68ee70fa9
LLVM GN Syncbot [Fri, 17 Dec 2021 00:28:54 +0000 (00:28 +0000)]
[gn build] Port bdc68ee70fa9

2 years agoRevert "[InstrProf] Add Correlator class to read debug info"
Ellis Hoag [Fri, 17 Dec 2021 00:27:08 +0000 (16:27 -0800)]
Revert "[InstrProf] Add Correlator class to read debug info"

Also reverts an attempt to fix the build errors https://reviews.llvm.org/D115911

The original diff https://reviews.llvm.org/D114566 causes some build
errors that I need to investigate.

https://lab.llvm.org/buildbot/#/builders/118/builds/7037

This reverts commit 95946d2f8589b5450d8f9a9e9b4f7adf44386f8b.

Reviewed By: kyulee

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

2 years agoFix windows buildbots after https://reviews.llvm.org/D115324
Greg Clayton [Fri, 17 Dec 2021 00:13:58 +0000 (16:13 -0800)]
Fix windows buildbots after https://reviews.llvm.org/D115324

Windows has trouble deleting the executable due to permissions.

2 years ago[InstrProf] Fix build error in Correlator class
Ellis Hoag [Thu, 16 Dec 2021 23:58:51 +0000 (15:58 -0800)]
[InstrProf] Fix build error in Correlator class

For some reason this did not fail to compile for me locally, but did
fail on one of the builders. Here is the error:

https://lab.llvm.org/buildbot/#/builders/58/builds/14969
```
/home/buildbot/as-builder-4/lld-x86_64-ubuntu-fast/llvm-project/llvm/lib/ProfileData/InstrProfCorrelator.cpp: In static member function ‘static llvm::Expected<std::unique_ptr<llvm::InstrProfCorrelator::Context> > llvm::InstrProfCorrelator::Context::get(std::unique_ptr<llvm::MemoryBuffer>, const llvm::object::ObjectFile&)’:
/home/buildbot/as-builder-4/lld-x86_64-ubuntu-fast/llvm-project/llvm/lib/ProfileData/InstrProfCorrelator.cpp:44:10: error: could not convert ‘C’ from ‘std::unique_ptr<llvm::InstrProfCorrelator::Context>’ to ‘llvm::Expected<std::unique_ptr<llvm::InstrProfCorrelator::Context> >’
   return C;
```

Reviewed By: kyulee

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

2 years ago[gn build] Port 95946d2f8589
Nico Weber [Thu, 16 Dec 2021 23:31:56 +0000 (18:31 -0500)]
[gn build] Port 95946d2f8589

2 years ago[gn build] port 78523516bc (cut MC->ProfileData dep)
Nico Weber [Thu, 16 Dec 2021 23:37:30 +0000 (18:37 -0500)]
[gn build] port 78523516bc (cut MC->ProfileData dep)

2 years ago[mlir][tosa] Handle rescale case where shift > 63
Rob Suderman [Thu, 16 Dec 2021 23:30:45 +0000 (15:30 -0800)]
[mlir][tosa] Handle rescale case where shift > 63

It is possible for the shift value to exceed the number of bits. In these
cases we can just multiply by zero. This is relatively rare occurence but
should be handled.

Reviewed By: not-jenni

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

2 years ago[mlir][tosa] Add tosa.max_pool2d as no-op canonicalization
not-jenni [Thu, 16 Dec 2021 23:20:34 +0000 (15:20 -0800)]
[mlir][tosa] Add tosa.max_pool2d as no-op canonicalization

When the input and output of a pool2d op are both 1x1, it can be canonicalized to a no-op

Reviewed By: rsuderman

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

2 years ago[NFC][sanitizer] Remove unused variable
Vitaly Buka [Thu, 16 Dec 2021 23:24:14 +0000 (15:24 -0800)]
[NFC][sanitizer] Remove unused variable

2 years ago[dSYM][NFC] Add error test case for llvm-dwarfdump
Ellis Hoag [Thu, 16 Dec 2021 23:21:54 +0000 (15:21 -0800)]
[dSYM][NFC] Add error test case for llvm-dwarfdump

Add a test to `llvm-dwarfdump` to simply test that the error messages
make sense when passing bad `.dSYM`s.

Reviewed By: clayborg

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

2 years ago[InstrProf] Add Correlator class to read debug info
Ellis Hoag [Thu, 16 Dec 2021 22:45:54 +0000 (14:45 -0800)]
[InstrProf] Add Correlator class to read debug info

Extend `llvm-profdata` to read in a `.proflite` file and also a debug info file to generate a normal `.profdata` profile. This reduces the binary size by 8.4% when building an instrumented Clang binary without value profiling (164 MB vs 179 MB).

This work is part of the "lightweight instrumentation" RFC: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

Reviewed By: kyulee

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

2 years ago[mlir][tosa] Minor cleanup of tosa.conv2d canonicalizer
Rob Suderman [Thu, 16 Dec 2021 21:53:33 +0000 (13:53 -0800)]
[mlir][tosa] Minor cleanup of tosa.conv2d canonicalizer

Slight rename and better variable type usage in tosa.conv2d to
tosa.fully_connected lowering. Included disabling pass for padded
convolutions.

Reviewed By: not-jenni

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

2 years ago[libc++][ranges][NFC] Remove extraneous cleanup checks.
Konstantin Varlamov [Thu, 16 Dec 2021 22:47:08 +0000 (14:47 -0800)]
[libc++][ranges][NFC] Remove extraneous cleanup checks.

There is no need to check the counters on `Counted` after destroying
elements in the range because these tests are not testing `destroy`.

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

2 years agoDebugInfoVerifier: Verify dwo units
David Blaikie [Thu, 16 Dec 2021 22:39:51 +0000 (14:39 -0800)]
DebugInfoVerifier: Verify dwo units

Initial pass - follow-up patches to address various limitations (debug
ranges, location lists... )

2 years ago[Try2][InstrProf] Attach debug info to counters
Ellis Hoag [Thu, 16 Dec 2021 22:19:03 +0000 (14:19 -0800)]
[Try2][InstrProf] Attach debug info to counters

Add the llvm flag `-debug-info-correlate` to attach debug info to instrumentation counters so we can correlate raw profile data to their functions. Raw profiles are dumped as `.proflite` files. The next diff enables `llvm-profdata` to consume `.proflite` and debug info files to produce a normal `.profdata` profile.

Part of the "lightweight instrumentation" work: https://groups.google.com/g/llvm-dev/c/r03Z6JoN7d4

The original diff https://reviews.llvm.org/D114565 was reverted because of the `Instrumentation/InstrProfiling/debug-info-correlate.ll` test, which is fixed in this commit.

Reviewed By: kyulee

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

2 years ago[libc] fix memcpy builtin looping
Michael Jones [Fri, 10 Dec 2021 18:55:38 +0000 (10:55 -0800)]
[libc] fix memcpy builtin looping

previously, memcpy could get stuck in a loop, calling __builtin_memcpy
which would redirect to itself. This patch removes that path.

Reviewed By: gchatelet, sivachandra, lntue

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

2 years ago[gn build] Port 8a85be807bd4
LLVM GN Syncbot [Thu, 16 Dec 2021 21:40:46 +0000 (21:40 +0000)]
[gn build] Port 8a85be807bd4

2 years agoRevert "AMDGPU: Update pass pipeline test"
Ron Lieberman [Thu, 16 Dec 2021 21:39:04 +0000 (21:39 +0000)]
Revert "AMDGPU: Update pass pipeline test"

needed to match revert of
rG2b4876157562: AMDGPU: Remove AMDGPUFixFunctionBitcasts pass

This reverts commit 7ca355225d530acb24b50a5fcccf5c40938b30bf.

2 years agoNo need to checkout a repo
Anton Korobeynikov [Thu, 16 Dec 2021 21:31:19 +0000 (00:31 +0300)]
No need to checkout a repo

2 years agoSend to llvm-bugs
Anton Korobeynikov [Thu, 16 Dec 2021 21:30:01 +0000 (00:30 +0300)]
Send to llvm-bugs

2 years ago[sanitizer] Define SANITIZER_ARM SANITIZER_X64 SANITIZER_ARM64
Vitaly Buka [Thu, 16 Dec 2021 21:19:13 +0000 (13:19 -0800)]
[sanitizer] Define SANITIZER_ARM SANITIZER_X64 SANITIZER_ARM64

2 years ago[sanitizer] Clang-format sanitizer_platform.h
Vitaly Buka [Thu, 16 Dec 2021 21:21:06 +0000 (13:21 -0800)]
[sanitizer] Clang-format sanitizer_platform.h

2 years agoInstall test mailer for github bugs
Anton Korobeynikov [Thu, 16 Dec 2021 21:25:55 +0000 (00:25 +0300)]
Install test mailer for github bugs

2 years agoRevert "AMDGPU: Remove AMDGPUFixFunctionBitcasts pass"
Ron Lieberman [Thu, 16 Dec 2021 21:21:32 +0000 (21:21 +0000)]
Revert "AMDGPU: Remove AMDGPUFixFunctionBitcasts pass"

Offload abort in Nekbone

This reverts commit 2b4876157562bc76e86f193d371348993905bc61.

2 years agoAllow calls with known writes when trying to remove allocas [part 2]
Philip Reames [Thu, 16 Dec 2021 21:05:55 +0000 (13:05 -0800)]
Allow calls with known writes when trying to remove allocas [part 2]

This is a slight generalization of D115829. I noticed this while restructuring code for a follow up patch to perform the same optimizations in DSE.

If we have a call whose only visible effect is writing to an alloca, and we're removing the alloca anyways, we don't care if the call also reads from the same alloca. That read will be unobservable and thus doesn't block removal of the call.

Worth noting is that this observation generalizes for non-argument reads. It just happens that case reduces to a readonly call, and is already handled separately.

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

2 years ago[compiler-rt][NFC] add note to interface_symbols_linux.cpp about darwin
Emily Shi [Thu, 16 Dec 2021 21:05:51 +0000 (13:05 -0800)]
[compiler-rt][NFC] add note to interface_symbols_linux.cpp about darwin

There were changes made to the linux version of this test that were not made for darwin
(see https://reviews.llvm.org/D115837) and this caused downstream failures.

Adding comment to this test to remind people to edit interface_symbols_darwin.cpp.
There is the reverse of this comment in the darwin file to remind us to edit the linux version already.

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

2 years ago[compiler-rt] removed memory access callback from asan interface for darwin
Emily Shi [Thu, 16 Dec 2021 21:02:47 +0000 (13:02 -0800)]
[compiler-rt] removed memory access callback from asan interface for darwin

These symbols were introduced in https://reviews.llvm.org/D114558 but were not properly guarded for mac which caused downstream CI failures

Reviewed By: kubamracek, yln

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

2 years ago[sanitizer] Portable sanitizer_stoptheworld_test
Clemens Wasser [Thu, 16 Dec 2021 20:48:36 +0000 (12:48 -0800)]
[sanitizer] Portable sanitizer_stoptheworld_test

Part of D115204

2 years ago[sanitizer] Clang format before D115204
Vitaly Buka [Thu, 16 Dec 2021 20:17:52 +0000 (12:17 -0800)]
[sanitizer] Clang format before D115204

2 years ago[Sanitizer] Disable LSan when testing on iOS simulators
Julian Lettner [Wed, 15 Dec 2021 19:21:42 +0000 (11:21 -0800)]
[Sanitizer] Disable LSan when testing on iOS simulators

LSan (`ASAN_OPTIONS=detect_leaks=1`) is supported on macOS, but disabled
by default on Darwin (`SANITIZER_MAC`):
```
COMMON_FLAG(bool, detect_leaks, !SANITIZER_MAC, "Enable memory leak detection.")
```

We enable it here for ASan tests to prevent regressions (per comment).
However, LSan is not supported for the iOS simulator and the tests fail
when it is enabled.

Make this "Is macOS?" check more precise since the current one (`Darwin
&& x86_64`) has two issues:
 * Includes the simulators
 * Excludes macOS on Apple Silicon

This will allow us to (re)enable simulator testing on Green dragon to
give open source better feedback about sanitizer changes:
https://green.lab.llvm.org

rdar://86529234

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

2 years ago[clang-format] add support for branch attribute macros
mydeveloperday [Thu, 16 Dec 2021 20:32:32 +0000 (20:32 +0000)]
[clang-format] add support for branch attribute macros

https://github.com/llvm/llvm-project/issues/49184

clang-format doesn't handle the use of AttributeMacros where `[[unlikely]]` / `[[likely]]` could be used in `if` statements

This was not covered in the original commit {{D80144}}

Fixes #49184

Reviewed By: curdeius, owenpan

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

2 years ago[instcombine Use reference for never-null pointer in isAllocSiteRemovable [nfc]
Philip Reames [Thu, 16 Dec 2021 20:03:03 +0000 (12:03 -0800)]
[instcombine Use reference for never-null pointer in isAllocSiteRemovable [nfc]

2 years ago[Bazel] Add LLVM_BUILD_* variables to llvm-config.h to mirror ec37e0bbafab75fa64f1ddb...
Dmitri Gribenko [Thu, 16 Dec 2021 19:52:20 +0000 (20:52 +0100)]
[Bazel] Add LLVM_BUILD_* variables to llvm-config.h to mirror ec37e0bbafab75fa64f1ddb4cdeceb5400491ef8

2 years ago[lsan] Format CAN_SANITIZE_LEAKS defines
Clemens Wasser [Thu, 16 Dec 2021 19:48:35 +0000 (11:48 -0800)]
[lsan] Format CAN_SANITIZE_LEAKS defines

Reviewed By: vitalybuka

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

2 years ago[libc] Fix problem with using isnan in test/src/math/logf_test.cpp.
Tue Ly [Thu, 16 Dec 2021 19:41:37 +0000 (14:41 -0500)]
[libc] Fix problem with using isnan in test/src/math/logf_test.cpp.

The default isnan returns an int, and hence failing the EXPECT_TRUE tests.

Reviewed By: sivachandra

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

2 years agoAdd a flag to force tsan's background thread
Matt Kulukundis [Thu, 16 Dec 2021 19:45:49 +0000 (11:45 -0800)]
Add a flag to force tsan's background thread

Reviewed By: dvyukov, vitalybuka

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

2 years ago[gn build] Port da816ca0cb3b
LLVM GN Syncbot [Thu, 16 Dec 2021 19:27:34 +0000 (19:27 +0000)]
[gn build] Port da816ca0cb3b

2 years ago[gn build] port ec37e0bbafab
Nico Weber [Thu, 16 Dec 2021 19:27:18 +0000 (14:27 -0500)]
[gn build] port ec37e0bbafab

2 years ago[Debuginfod] Remove f-string from llvm-debuginfod-find lit test.
Noah Shutty [Thu, 16 Dec 2021 19:22:08 +0000 (19:22 +0000)]
[Debuginfod] Remove f-string from llvm-debuginfod-find lit test.

This removes a python3 f-String from the llvm-debuginfod-find lit test script to maximize compatibility with different python versions, as it seemed to cause some issues.

Reviewed By: phosek

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

2 years ago[llvm] Fix small typos in Programmer's Manual and Chrono.h.
Noah Shutty [Thu, 16 Dec 2021 19:20:25 +0000 (19:20 +0000)]
[llvm] Fix small typos in Programmer's Manual and Chrono.h.

The Programmer's Manual guidance on the StringRef class (https://llvm.org/docs/ProgrammersManual.html#the-stringref-class) refers to `iterator StringRef::find(StringRef Key)` which does not exist. Based on context this is surely a small typo meant to be `iterator StringMap::find(StringRef Key)`.

This also corrects some small typos in the comments of llvm/include/llvm/Support/Chrono.h

Reviewed By: phosek

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

2 years ago[SLP]Early exit out of the reordering if shuffled/perfect diamond match found.
Alexey Bataev [Wed, 15 Dec 2021 18:19:29 +0000 (10:19 -0800)]
[SLP]Early exit out of the reordering if shuffled/perfect diamond match found.

Need to early exit out of the reordering process if the perfect/shuffled match is found in the operands. Such pattern will result in not profitable reordering because of (false positive) external use of scalars.

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

2 years ago[mlir][ods] Fix OpFormatGen calling inferReturnTypes before region/segment resolution
Mogball [Wed, 15 Dec 2021 06:22:04 +0000 (06:22 +0000)]
[mlir][ods] Fix OpFormatGen calling inferReturnTypes before region/segment resolution

The generated parser for ops with type inference calls `inferReturnTypes` before region resolution and segment attribute resolution, i.e. regions and the segment attributes are not passed to the `inferReturnTypes` even though it may need that information.

In particular, an op that has sized operand segments which queries those operands in its `inferReturnTypes` function will crash because the segment attributes hadn't been added yet.

Reviewed By: rriddle

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

2 years agoAllow calls with known writes when trying to remove allocas
Philip Reames [Thu, 16 Dec 2021 19:02:27 +0000 (11:02 -0800)]
Allow calls with known writes when trying to remove allocas

isAllocSiteRemovable tracks whether all uses of an alloca are both non-capturing, and non-reading. If so, we can remove said alloca because nothing can depend on its content or address.

This patch extends this reasoning to allow writes from calls where we can prove the call has no side effect other than writing to said allocation. This is a fairly natural fit for the existing code with one subtle detail - the call can write to multiple locations at once which stores can't.

As a follow up, we can likely sink the intrinsic handling into the generic code by allowing readnone arguments as well. I deliberately left that out to minimize conceptual churn.

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

2 years ago[mlir] Fix invalidated reference when loading dependent dialects
Mogball [Thu, 16 Dec 2021 01:19:56 +0000 (01:19 +0000)]
[mlir] Fix invalidated reference when loading dependent dialects

When a dialect is loaded with `getOrLoadDialect`, its constructor may recurse and call `getOrLoadDialect` on a dependent dialect, which may result in an insertion in the dialect map, invalidating the reference to the (previously null) dialect pointer.

Reviewed By: mehdi_amini

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

2 years ago[libc] Implement correctly rounded logf based on RLIBM library.
Tue Ly [Mon, 6 Dec 2021 18:26:16 +0000 (13:26 -0500)]
[libc] Implement correctly rounded logf based on RLIBM library.

Implement correctly rounded logf based on RLIBM library: https://people.cs.rutgers.edu/~sn349/rlibm/.

Reviewed By: sivachandra, santoshn, jpl169, zimmermann6

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

2 years ago[libunwind] Provide a way to conveniently install libunwind headers
PoYao Chang [Thu, 16 Dec 2021 18:32:12 +0000 (13:32 -0500)]
[libunwind] Provide a way to conveniently install libunwind headers

This adds a CMake option (defaults to OFF to not be intrusive) to activate
2 new targets `install-unwind-headers` and `install-unwind-headers-stripped`.
So, for example:

  cmake -S runtimes -B build -G Ninja \
    -DLLVM_ENABLE_RUNTIMES='libunwind' \
    -DLIBUNWIND_INSTALL_HEADERS=ON

And then, `ninja -C build install-unwind` would install headers in addition
to good ol' dylibs and archives, i.e., targets `install-unwind*` `DEPENDS`
on `install-unwind-headers*`. On the other hand,
`ninja -C build install-unwind-headers` gives you headers only.

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

2 years ago[OpenCL] Add pure attribute to vload builtins
Stuart Brady [Thu, 16 Dec 2021 18:30:58 +0000 (18:30 +0000)]
[OpenCL] Add pure attribute to vload builtins

Use the "pure" attribute (or "readonly") for the vload, vload_half and
vloada_half builtins.

Includes test changes to SemaOpenCL/fdeclare-opencl-builtins.cl to avoid
triggering unused-result warnings.

Reviewed By: svenvh

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

2 years agoAdded the ability to cache the finalized symbol tables subsequent debug sessions...
Greg Clayton [Thu, 16 Dec 2021 17:59:25 +0000 (09:59 -0800)]
Added the ability to cache the finalized symbol tables subsequent debug sessions to start faster.

This is an updated version of the https://reviews.llvm.org/D113789 patch with the following changes:
- We no longer modify modification times of the cache files
- Use LLVM caching and cache pruning instead of making a new cache mechanism (See DataFileCache.h/.cpp)
- Add signature to start of each file since we are not using modification times so we can tell when caches are stale and remove and re-create the cache file as files are changed
- Add settings to control the cache size, disk percentage and expiration in days to keep cache size under control

This patch enables symbol tables to be cached in the LLDB index cache directory. All cache files are in a single directory and the files use unique names to ensure that files from the same path will re-use the same file as files get modified. This means as files change, their cache files will be deleted and updated. The modification time of each of the cache files is not modified so that access based pruning of the cache can be implemented.

The symbol table cache files start with a signature that uniquely identifies a file on disk and contains one or more of the following items:
- object file UUID if available
- object file mod time if available
- object name for BSD archive .o files that are in .a files if available

If none of these signature items are available, then the file will not be cached. This keeps temporary object files from expressions from being cached.

When the cache files are loaded on subsequent debug sessions, the signature is compare and if the file has been modified (uuid changes, mod time changes, or object file mod time changes) then the cache file is deleted and re-created.

Module caching must be enabled by the user before this can be used:

symbols.enable-lldb-index-cache (boolean) = false

(lldb) settings set symbols.enable-lldb-index-cache true

There is also a setting that allows the user to specify a module cache directory that defaults to a directory that defaults to being next to the symbols.clang-modules-cache-path directory in a temp directory:

(lldb) settings show symbols.lldb-index-cache-path
/var/folders/9p/472sr0c55l9b20x2zg36b91h0000gn/C/lldb/IndexCache

If this setting is enabled, the finalized symbol tables will be serialized and saved to disc so they can be quickly loaded next time you debug.

Each module can cache one or more files in the index cache directory. The cache file names must be unique to a file on disk and its architecture and object name for .o files in BSD archives. This allows universal mach-o files to support caching multuple architectures in the same module cache directory. Making the file based on the this info allows this cache file to be deleted and replaced when the file gets updated on disk. This keeps the cache from growing over time during the compile/edit/debug cycle and prevents out of space issues.

If the cache is enabled, the symbol table will be loaded from the cache the next time you debug if the module has not changed.

The cache also has settings to control the size of the cache on disk. Each time LLDB starts up with the index cache enable, the cache will be pruned to ensure it stays within the user defined settings:

(lldb) settings set symbols.lldb-index-cache-expiration-days <days>

A value of zero will disable cache files from expiring when the cache is pruned. The default value is 7 currently.

(lldb) settings set symbols.lldb-index-cache-max-byte-size <size>

A value of zero will disable pruning based on a total byte size. The default value is zero currently.
(lldb) settings set symbols.lldb-index-cache-max-percent <percentage-of-disk-space>

A value of 100 will allow the disc to be filled to the max, a value of zero will disable percentage pruning. The default value is zero.

Reviewed By: labath, wallace

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

2 years agoAdapt test to be compatible with AIX
Jake Egan [Thu, 16 Dec 2021 17:34:31 +0000 (12:34 -0500)]
Adapt test to be compatible with AIX

This patch updates the following test, which is falling to match ASM lines on AIX for two reasons:
 - `.debug_info` is mapped to `.dwinfo`, so the test fails to match `debug_info` before `DW_TAG_label` occurs
 - AIX uses inline strings, so `DW_AT_NAME` format is different and does not match `DW_AT_decl_file` in the next line.

Reviewed By: shchenz

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

2 years agoRe-apply "Only define LLVM_EXTERNAL_VISIBILITY when building libLLVM dylib"
Ben Langmuir [Fri, 10 Dec 2021 19:49:04 +0000 (11:49 -0800)]
Re-apply "Only define LLVM_EXTERNAL_VISIBILITY when building libLLVM dylib"

With a fix for BUILD_SHARED_LIBS.

Original commit message:

When building LLVM static libraries, we should not make symbols more
visible than CMAKE_CXX_VISIBILITY_PRESET, since the goal may be to have
a purely hidden llvm embedded in another library. Instead, we only
define LLVM_EXTERNAL_VISIBILITY for the dynamic library build (when
LLVM_BUILD_LLVM_DYLIB=YES or BUILD_SHARED_LIBS=YES).

Original Review: https://reviews.llvm.org/D113610

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

2 years ago[libc] Add documentation about how to add a math function to LLVM-libc.
Tue Ly [Mon, 13 Dec 2021 05:00:49 +0000 (00:00 -0500)]
[libc] Add documentation about how to add a math function to LLVM-libc.

Add documentation about how to add a math function to LLVM-libc.

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

2 years ago[libc++] [test] Simplify sentinel_wrapper and sized_sentinel.
Arthur O'Dwyer [Thu, 7 Oct 2021 01:23:13 +0000 (21:23 -0400)]
[libc++] [test] Simplify sentinel_wrapper and sized_sentinel.

Remove `s.base()`; every test that wants to get the base of a "test sentinel"
should use the ADL `base(s)` from now on.

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

2 years ago[lldb] Silence CMake warnings about missing FindFBSDVMCore
Michał Górny [Thu, 16 Dec 2021 16:11:07 +0000 (17:11 +0100)]
[lldb] Silence CMake warnings about missing FindFBSDVMCore

Pass QUIET to find_package() in order to quiet the warning about missing
FindFBSDVMCore.cmake.  FBSDVMCore always provides native CMake config
files, therefore providing a fallback module serves no purpose.

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

2 years ago[RISCV] Revert Zfhmin related changes that aren't tested and depend on f16 being...
Craig Topper [Thu, 16 Dec 2021 16:48:37 +0000 (08:48 -0800)]
[RISCV] Revert Zfhmin related changes that aren't tested and depend on f16 being a legal type.

Our Zfhmin support is only MC layer, but these are CodeGen layer
interfaces. If f16 isn't a Legal type for CodeGen with Zfhmin, then
these interfaces should keep their non-Zfh behavior.

Reviewed By: luismarques

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

2 years ago[X86] combineAnd - don't demand operand vector elements if the other operand element...
Simon Pilgrim [Thu, 16 Dec 2021 16:46:39 +0000 (16:46 +0000)]
[X86] combineAnd - don't demand operand vector elements if the other operand element is zero

If either operand has a zero element, then we don't need the equivalent element from the other operand, as no bits will be set.

2 years ago[analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters...
Ella Ma [Thu, 16 Dec 2021 16:47:59 +0000 (17:47 +0100)]
[analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

This error was found when analyzing MySQL with CTU enabled.

When there are space characters in the lookup name, the current
delimiter searching strategy will make the file path wrongly parsed.
And when two lookup names have the same prefix before their first space
characters, a 'multiple definitions' error will be wrongly reported.

e.g. The lookup names for the two lambda exprs in the test case are
`c:@S@G@F@G#@Sa@F@operator int (*)(char)#1` and
`c:@S@G@F@G#@Sa@F@operator bool (*)(char)#1` respectively. And their
prefixes are both `c:@S@G@F@G#@Sa@F@operator` when using the first space
character as the delimiter.

Solving the problem by adding a length for the lookup name, making the
index items in the format of `USR-Length:USR File-Path`.

Reviewed By: steakhal

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

2 years ago[TSan] Make test fail more predictably
Julian Lettner [Thu, 16 Dec 2021 04:34:39 +0000 (20:34 -0800)]
[TSan] Make test fail more predictably

This test would hang when the system ran out of resources and we fail to
create all 300 threads.

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

2 years ago[clang] Cleanup unneeded Function nullptr checks [NFC]
Mike Rice [Wed, 15 Dec 2021 18:23:21 +0000 (10:23 -0800)]
[clang] Cleanup unneeded Function nullptr checks [NFC]

Add an assert and avoid unneeded checks of Fn in
CodeGenFunction::GenerateCode.

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

2 years agoAMDGPU: Return result from indicatePessimisticFixpoint
Matt Arsenault [Thu, 16 Dec 2021 15:05:00 +0000 (10:05 -0500)]
AMDGPU: Return result from indicatePessimisticFixpoint

I don't think this fixes anything.

2 years ago[X86] combineAnd - pull out repeated getOperand() and SDLoc() calls. NFCI.
Simon Pilgrim [Thu, 16 Dec 2021 16:22:39 +0000 (16:22 +0000)]
[X86] combineAnd - pull out repeated getOperand() and SDLoc() calls. NFCI.

2 years ago[X86] Rename LowerScalarImmediateShift/LowerScalarVariableShift helpers. NFC.
Simon Pilgrim [Thu, 16 Dec 2021 12:14:18 +0000 (12:14 +0000)]
[X86] Rename LowerScalarImmediateShift/LowerScalarVariableShift helpers. NFC.

Rename them to LowerShiftByScalarImmediate/LowerShiftByScalarVariable to make it easier to find them wrt LowerShift()

2 years agoRevert "A new hidden option exec-on-ir-change=exe that calls exe each time IR changes"
Jamie Schmeiser [Thu, 16 Dec 2021 15:51:15 +0000 (10:51 -0500)]
Revert "A new hidden option exec-on-ir-change=exe that calls exe each time IR changes"

This reverts commit dff0e8b4ff13af311512c369d059f1e095e83a60.

Failing build:  https://lab.llvm.org/buildbot/#/builders/42/builds/2800

2 years ago[lldb][docs] Update instructions for building libc++
Tor Arne Vestbø [Thu, 16 Dec 2021 15:46:12 +0000 (16:46 +0100)]
[lldb][docs] Update instructions for building libc++

Reviewed By: sylvestre.ledru

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

2 years ago[CodeGen] Avoid more pointer element type accesses
Nikita Popov [Thu, 16 Dec 2021 14:36:20 +0000 (15:36 +0100)]
[CodeGen] Avoid more pointer element type accesses

This is enough to build sqlite3 with opaque pointers.

2 years ago[llvm][docs] Describe how to work with patch series on Phabricator
David Spickett [Fri, 10 Dec 2021 14:35:50 +0000 (14:35 +0000)]
[llvm][docs] Describe how to work with patch series on Phabricator

Reviewed By: awarzynski, jhenderson

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

2 years agoDefine __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)
Hans Wennborg [Tue, 19 Oct 2021 15:38:28 +0000 (17:38 +0200)]
Define __STDC_NO_THREADS__ when targeting windows-msvc (PR48704)

MSVC's libc doesn't provide thread.h, so we should set the macro to
indicate that.

We could just set it in C mode, but I noticed that Darwin sets it
unconditionally, so perhaps we should do the same here.

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

2 years ago[CodeGen] Always update map entry after adding initializer
Nikita Popov [Thu, 16 Dec 2021 15:15:38 +0000 (16:15 +0100)]
[CodeGen] Always update map entry after adding initializer

With opaque pointers the pointer cast may be a no-op, such that
var and castedAddr are the same. However, we still need to update
the map entry as the underlying global changed. We could explicitly
check whether the global was replaced, but we may as well just
always update the entry.

2 years ago[lld] Add cet-report and bti-report flags
Daniel Kiss [Thu, 16 Dec 2021 15:18:08 +0000 (16:18 +0100)]
[lld] Add cet-report and bti-report flags

Implement cet-report as supported in binutils.
bti-report has the same behaviour for AArch64-BTI.

Fixes https://github.com/llvm/llvm-project/issues/44828

Reviewed By: MaskRay

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

2 years agoAvoid by-value copies of referenced objects
Nathan Sidwell [Tue, 12 Oct 2021 16:28:20 +0000 (09:28 -0700)]
Avoid by-value copies of referenced objects

These were detected by the new -Wauto-by-value-copy (D114989) warning, these by-value
constant copies need only be references.

Reviewed By: aaron.ballman

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

2 years ago[clang] p2085 out-of-class comparison operator defaulting
Nathan Sidwell [Wed, 16 Jun 2021 17:43:43 +0000 (10:43 -0700)]
[clang] p2085 out-of-class comparison operator defaulting

This implements p2085, allowing out-of-class defaulting of comparison
operators, primarily so they need not be inline, IIUC intent. this was
mostly straigh forward, but required reimplementing
Sema::CheckExplicitlyDefaultedComparison, as now there's a case where
we have no a priori clue as to what class a defaulted comparison may
be for. We have to inspect the parameter types to find out. Eg:

class X { ... };
bool operator==(X, X) = default;

Thus reimplemented the parameter type checking, and added 'is this a
friend' functionality for the above case.

Reviewed By: mizvekov

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

2 years agoRevert "[OpenCL] Add pure attribute to vload builtins"
Stuart Brady [Thu, 16 Dec 2021 15:16:41 +0000 (15:16 +0000)]
Revert "[OpenCL] Add pure attribute to vload builtins"

This reverts commit 1a376bc285358037a5edc48b0d125f91bf5a69ca.

This broke clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

2 years ago[fir] Move Factory.h to flang/Optimizer/Builder
Valentin Clement [Thu, 16 Dec 2021 15:08:17 +0000 (16:08 +0100)]
[fir] Move Factory.h to flang/Optimizer/Builder

Move the Factory.h header file to flang/Optimizer/Builder.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

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

2 years ago[OpenCL] Add pure attribute to vload builtins
Stuart Brady [Thu, 16 Dec 2021 14:55:31 +0000 (14:55 +0000)]
[OpenCL] Add pure attribute to vload builtins

Use the "pure" attribute (or "readonly") for the vload, vload_half and
vloada_half builtins.

Reviewed By: svenvh

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

2 years ago[mlir] Add canonicalization for extract(tensor.from_elements) in 0d case.
Alexander Belyaev [Thu, 16 Dec 2021 14:46:08 +0000 (15:46 +0100)]
[mlir] Add canonicalization for extract(tensor.from_elements) in 0d case.

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

2 years ago[mlir][spirv] Perform partial conversion in VectorToSPIRVPass
Lei Zhang [Thu, 16 Dec 2021 14:35:47 +0000 (09:35 -0500)]
[mlir][spirv] Perform partial conversion in VectorToSPIRVPass

This allows the pass to participate in progressive lowering
and it also allows us to write tests better.

Along the way, cleaned up the tests.

Reviewed By: ThomasRaoux

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

2 years ago[CodeGen] Store element type in ParamValue
Nikita Popov [Thu, 16 Dec 2021 14:29:26 +0000 (15:29 +0100)]
[CodeGen] Store element type in ParamValue

ParamValue is basically a union between an Address and a Value*.
To be able to reconstruct the Address, we now need to store the
pointer element type.

2 years ago[VPlan] Add VPBlockBase::successors() returning an iterator_range (NFC).
Florian Hahn [Thu, 16 Dec 2021 14:28:39 +0000 (14:28 +0000)]
[VPlan] Add VPBlockBase::successors() returning an iterator_range (NFC).

This will also be helpful for D115793.

2 years ago[CodeGen] Avoid more pointer element type accesses
Nikita Popov [Thu, 16 Dec 2021 11:59:45 +0000 (12:59 +0100)]
[CodeGen] Avoid more pointer element type accesses