platform/upstream/llvm.git
2 years ago[lld/test] List one test dep per line
Nico Weber [Fri, 17 Dec 2021 14:50:59 +0000 (09:50 -0500)]
[lld/test] List one test dep per line

Matches llvm's and clang's /test/CMakeLists.txt, makes it easier to
see in diffs which deps get added, and makes it easier to see if
a given dependency is present or not.

No behavior change.

2 years ago[asan/mac] Fix remaining -Wformat warnings
Nico Weber [Fri, 17 Dec 2021 14:36:16 +0000 (09:36 -0500)]
[asan/mac] Fix remaining -Wformat warnings

AARCH64_GET_REG() is used to initialize uptrs, and after D79132
the ptrauth branch of its implementation explicitly casts to uptr.

The non-ptrauth branch returns ucontext->uc_mcontext->__ss.__fp (etc),
which has either type void* or __uint64_t (ref usr/include/mach/arm/_structs.h)
where __uint64_t is a unsigned long long (ref usr/include/arm/_types.h).
uptr is an unsigned long (ref
compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h). So explicitly
cast to uptr in this branch as well, so that AARCH64_GET_REG() has a
well-defined type.

Then change DUMPREGA64() tu use %lx instead of %llx since that's the right type
for uptr. (Most other places in compiler-rt print uptrs as %p and cast the arg
to (void*), but there are explicit 0x%016 format strings in the surroundings,
so be locally consistent with that.)

No behavior change, in the end it's just 64-bit unsigneds by slightly different
names.

2 years ago[DAG] foldConstantFPMath - fold vector splats as well as scalar constants
Simon Pilgrim [Fri, 17 Dec 2021 14:24:26 +0000 (14:24 +0000)]
[DAG] foldConstantFPMath - fold vector splats as well as scalar constants

2 years ago[asan/mac] Fix a few -Wformat warnings
Nico Weber [Fri, 17 Dec 2021 14:16:07 +0000 (09:16 -0500)]
[asan/mac] Fix a few -Wformat warnings

All other places cast uptrs to (void*) when printing it via
%p after D113099, so do that here too.

2 years ago[asan/mac] Fix a -Wformat warning
Nico Weber [Fri, 17 Dec 2021 14:15:06 +0000 (09:15 -0500)]
[asan/mac] Fix a -Wformat warning

internal_getpid() is manually cast to int in all other places that
pass its result to a printf string, so do that here too for now.

2 years agoImplement some constexpr vector unary operators, fix boolean-ops
Erich Keane [Mon, 13 Dec 2021 16:40:03 +0000 (08:40 -0800)]
Implement some constexpr vector unary operators, fix boolean-ops

As requested in the review, this implements unary +,-,~, and ! for
vector types.

All of our boolean operations on vector types should be using something
like vcmpeqd, which results in a mask of '-1' for the 'truth' type. We are
currently instead using '1', which results in some incorrect
calculations when used later (note that it does NOT result in a boolean
vector, as that is not really a thing).

This patch corrects that 1 to be a -1, and updates the affected tests.

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

2 years ago[AArch64] Regenerate concat_vector-truncate-combine.ll tests
Simon Pilgrim [Fri, 17 Dec 2021 13:59:19 +0000 (13:59 +0000)]
[AArch64] Regenerate concat_vector-truncate-combine.ll tests

2 years ago[NFC][SVE] Add missing tests for i32 INC/DEC patterns.
Paul Walker [Thu, 9 Dec 2021 18:30:22 +0000 (18:30 +0000)]
[NFC][SVE] Add missing tests for i32 INC/DEC patterns.

D111441 included trunc isel patterns for sve_int_pred_pattern_a
but no accompanying tests. This patch adds the missing tests and
also simplifies the isel patterns that use sve_cnt_shl_imm.

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

2 years ago[clang][deps] NFC: Unify ErrorOr patterns
Jan Svoboda [Fri, 17 Dec 2021 12:00:52 +0000 (13:00 +0100)]
[clang][deps] NFC: Unify ErrorOr patterns

This patch canonicalized some code into repetitive ErrorOr pattern. This will make refactoring easier if we ever come up with a way to simplify this.

2 years ago[clang][deps] NFC: Take and store entry as reference
Jan Svoboda [Fri, 17 Dec 2021 12:02:34 +0000 (13:02 +0100)]
[clang][deps] NFC: Take and store entry as reference

2 years ago[clang][deps] NFC: Remove explicit call to implicit constructor
Jan Svoboda [Fri, 17 Dec 2021 12:43:12 +0000 (13:43 +0100)]
[clang][deps] NFC: Remove explicit call to implicit constructor

2 years ago[clang][deps] NFC: Rename member variable
Jan Svoboda [Fri, 17 Dec 2021 12:30:38 +0000 (13:30 +0100)]
[clang][deps] NFC: Rename member variable

2 years ago[clang][deps] NFC: Fix whitespace formatting
Jan Svoboda [Fri, 17 Dec 2021 12:34:56 +0000 (13:34 +0100)]
[clang][deps] NFC: Fix whitespace formatting

2 years ago[lldb/qemu] Add emulator-env-vars setting
Pavel Labath [Fri, 17 Dec 2021 12:51:58 +0000 (13:51 +0100)]
[lldb/qemu] Add emulator-env-vars setting

This setting is for variables we want to pass to the emulator only --
then will be automatically removed from the target environment by our
environment diffing code. This variable can be used to pass various
QEMU_*** variables (although most of these can be passed through
emulator-args as well), as well as any other variables that can affect
the operation of the emulator (e.g. LD_LIBRARY_PATH).

2 years ago[DAG] foldConstantFPMath - use APFloat& for read-only constant fold arg. NFC.
Simon Pilgrim [Fri, 17 Dec 2021 12:33:54 +0000 (12:33 +0000)]
[DAG] foldConstantFPMath - use APFloat& for read-only constant fold arg. NFC.

We just need to copy the 1st arg (which we use for the constant fold result) - use a cheaper const reference for the 2nd arg.

2 years ago[gn build] (semiautomatically) port 3f5f687e2e8b
Nico Weber [Fri, 17 Dec 2021 12:26:34 +0000 (07:26 -0500)]
[gn build] (semiautomatically) port 3f5f687e2e8b

2 years ago[FuncSpec] Create helper to update state. NFC.
Sjoerd Meijer [Fri, 17 Dec 2021 12:02:44 +0000 (12:02 +0000)]
[FuncSpec] Create helper to update state. NFC.

This creates a helper function updateSpecializedFuncs and is a NFC just to make
the function that drives the transformation easier to read.

2 years ago[DAG] Constant fold + canonicalize integer binops before SimplifyVBinOp call
Simon Pilgrim [Fri, 17 Dec 2021 12:01:56 +0000 (12:01 +0000)]
[DAG] Constant fold + canonicalize integer binops before SimplifyVBinOp call

SimplifyVBinOp still has a FoldConstantArithmetic call, which now it isn't vector specific we should be able to remove (once fp binops are tidied up); but we can at least clean up the integer opcodes to perform the basic constant/undef handling in common code first.

2 years ago[NFC] Fix type-units-maybe-unused-types.ll from D115325 (78d15a112cbd)
OCHyams [Fri, 17 Dec 2021 11:39:35 +0000 (11:39 +0000)]
[NFC] Fix type-units-maybe-unused-types.ll from D115325 (78d15a112cbd)

78d15a112cbd adds llvm/test/DebugInfo/Generic/type-units-maybe-unused-types.ll

Move the test into llvm/test/DebugInfo/X86 and add -mtriple=x86_64-linux-gnu
because not all platforms support type units.

Example of failing bot: type-units-maybe-unused-types.ll

Original review: https://reviews.llvm.org/D115325

2 years ago[CodeGen] Avoid more pointer element type accesses
Nikita Popov [Fri, 17 Dec 2021 10:00:25 +0000 (11:00 +0100)]
[CodeGen] Avoid more pointer element type accesses

2 years ago[analyzer][NFC] Change return value of StoreManager::attemptDownCast function from...
Denys Petrov [Thu, 16 Dec 2021 16:48:30 +0000 (18:48 +0200)]
[analyzer][NFC] Change return value of StoreManager::attemptDownCast function from SVal to Optional<SVal>

Summary: Refactor return value of `StoreManager::attemptDownCast` function by removing the last parameter `bool &Failed` and replace the return value `SVal` with `Optional<SVal>`.  Make the function consistent with the family of `evalDerivedToBase` by renaming it to `evalBaseToDerived`. Aligned the code on the call side with these changes.

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

2 years ago[AMDGPU] Fixes in ISelDAG path and GlobalISel path for 'bias' operand with A16 bit on
rkorsa [Fri, 17 Dec 2021 07:26:38 +0000 (12:56 +0530)]
[AMDGPU] Fixes in ISelDAG path and GlobalISel path for 'bias' operand with A16 bit on

The LOD bias operand is of type 'half' when the A16-bit is ON' for MIMG instructions.
'bias' is only 16-bit but occupies 32-bits with upper 16-bits containing junk.
The patch fixes both the paths(ISelDAG and GlobalISel) for proper encoding of LOD bias operand.

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

2 years ago[flang][codegen] Add a conversion for `fir.coordinate_of` - part 2
Andrzej Warzynski [Tue, 23 Nov 2021 18:13:51 +0000 (18:13 +0000)]
[flang][codegen] Add a conversion for `fir.coordinate_of` - part 2

This patch extends the `FIRToLLVMLowering` pass in Flang by extending
the hook to transform `fir.coordinate_of` into a sequence of LLVM MLIR
instructions (i.e. `CoordinateOpConversion::doRewrite`). The following
case is added:
  3.1 the input object is inside `!fir.ref` (e.g. `!fir.ref<!fir.array>` or
      `!fir.ref<!fir.type>`).
  3.2 the input object is inside `!fir.ptr` (e.g. `!fir.ptr<!fir.array>` or
      `!fir.ptr<!fir.type>`).
From the point of view of the conversion, 3.1 and 3.2 are currently identical.

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

Originally written by:
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Depends on: D114159

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

2 years ago[libc++] Disable _LIBCPP_DEBUG_ASSERT during constant evaluation
Nikolas Klauser [Thu, 16 Dec 2021 13:55:03 +0000 (14:55 +0100)]
[libc++] Disable _LIBCPP_DEBUG_ASSERT during constant evaluation

Disable `_LIBCPP_DEBUG_ASSERT` and debug iterators in <string> during constant evaluation

Reviewed By: ldionne, #libc

Spies: goncharov, libcxx-commits

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

2 years ago[LV] Pass VectorHeader block to emitTransformedIndex (NFC).
Florian Hahn [Mon, 13 Dec 2021 19:12:56 +0000 (19:12 +0000)]
[LV] Pass VectorHeader block to emitTransformedIndex (NFC).

Pass in the vector header instead of relying on ILV::LoopVectorBody.
This reduces the dependence on state from ILV. Where VPTransformState is
available, State.CFG.PrevBB can be used.

2 years ago[DWARF] Fix PR51087 Extraneous enum record in DWARF with type units
OCHyams [Fri, 17 Dec 2021 09:25:52 +0000 (09:25 +0000)]
[DWARF] Fix PR51087 Extraneous enum record in DWARF with type units

Fixes https://llvm.org/PR51087: Extraneous enum record in DWARF with type units.

As explained in PR51087 we sometimes get skeleton DIEs for enums in a Dwarf
Compile Unit (CU) that are not referenced from any CU and are already described
by a type unit.

Types for enums are emitted whether used or not, all together before most types
in the CU. Mechanically, the extraneous CU records are generated because the
enum types are generated with a call to CU->getOrCreateTypeDIE. This function
will recursively get-or-create the parent DIE (in the CU) and the type unit for
each. We don't need the CU-side DIEs if the type units are sucesfully
emitted. Fix by only emitting the type units for enums if possible, falling back
to a call to getOrCreateTypeDIE if not. Do the same for retained types.

Reviewed By: dblaikie

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

2 years ago[flang] Make the frontend driver error out when requesting multiple actions
Andrzej Warzynski [Thu, 14 Oct 2021 08:07:30 +0000 (08:07 +0000)]
[flang] Make the frontend driver error out when requesting multiple actions

With this change, the following invocations will be treated as errors
(multiple actions are specified):
```
$ flang-new -fc1 -E -fsyntax-only file.95
$ flang-new -fc1 -fsyntax-only -fdebug-dump-symbols file.95
```
In the examples above it is not clear whether it is `-fsyntax-only` or
the other action that is run (i.e. `-E` or `-fdebug-dump-symbols`). It
makes sense to disallow such usage. This should also lead to cleaner and
clearer tests (the `RUN` lines using `%flang_fc1` will only allow one
action).

This change means that `flang-new -fc1` and `clang -cc1` will behave
differently when multiple action options are specified. As frontend
drivers are mostly used by compiler developers, this shouldn't affect or
confuse the compiler end-users. Also, `flang-new` and `clang` remain
consistent.

Tests are updated accordingly. More specifically, I've made sure that
every test specifies only one action. I've also taken the opportunity to
simplify "multiple-input-files.f90" a bit.

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

2 years ago[FuncSpec] Respect MaxConstantsThreshold
Sjoerd Meijer [Fri, 17 Dec 2021 09:25:45 +0000 (09:25 +0000)]
[FuncSpec] Respect MaxConstantsThreshold

This is a follow up of D115458 and truncates the worklist of actual arguments
that can be specialised to 'MaxConstantsThreshold' candidates if
MaxConstantsThreshold was exceeded. Thus, this changes the behaviour of option
-func-specialization-max-constants. Before it didn't specialise at all when
this threshold was exceeded, but now it specialises up to MaxConstantsThreshold
candidates from the sorted worklist.

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

2 years ago[ARM] Handle splats of constants for MVE qr instruction
David Green [Fri, 17 Dec 2021 09:16:28 +0000 (09:16 +0000)]
[ARM] Handle splats of constants for MVE qr instruction

Some MVE instructions have qr variants that take a Q and R register,
splatting the R register for each lane. This is usually handled fine for
standard splats as we sink the splat into the loop and combine the
resulting dup into the qr instruction. It does not work for constant
splats though, as we generate a vmovimm or constant pool load instead.

This intercepts that, generating a vdup of the constant instead where we
can turn the result into a qr instruction variant.

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

2 years ago[lldb] Fix matchers for char array formatters
Pavel Labath [Thu, 28 Oct 2021 11:33:58 +0000 (13:33 +0200)]
[lldb] Fix matchers for char array formatters

They were being applied too narrowly (they didn't cover signed char *,
for instance), and too broadly (they covered SomeTemplate<char[6]>) at
the same time.

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

2 years agoRecommit "[FuncSpec] Decouple cost/benefit analysis, allowing sorting of candidates."
Sjoerd Meijer [Thu, 16 Dec 2021 16:06:23 +0000 (16:06 +0000)]
Recommit "[FuncSpec] Decouple cost/benefit analysis, allowing sorting of candidates."

Replaced llvm:sort with llvm::stable_sort, this was failing on the bot with
expensive checks enabled.

2 years ago[examples][BuildingAJIT] Fix use-after-move bug in Chapter 4.
seven-mile [Fri, 17 Dec 2021 08:55:42 +0000 (19:55 +1100)]
[examples][BuildingAJIT] Fix use-after-move bug in Chapter 4.

Reviewed By: lhames

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

2 years ago[CodeGen] Store element type in RValue
Nikita Popov [Thu, 16 Dec 2021 15:56:51 +0000 (16:56 +0100)]
[CodeGen] Store element type in RValue

For aggregates, we need to store the element type to be able to
reconstruct the aggregate Address. This increases the size of this
packed structure (as the second value is already used for alignment
in this case), but I did not observe any compile-time or memory
usage regression from this change.

2 years ago[llvm-c] Accept GEP operators in some APIs
Nikita Popov [Thu, 16 Dec 2021 08:36:42 +0000 (09:36 +0100)]
[llvm-c] Accept GEP operators in some APIs

As requested in D115787, I've added a test for LLVMConstGEP2 and
LLVMConstInBoundsGEP2. However, to make this work in the echo test,
I also had to change a couple of APIs to work on GEP operators,
rather than only GEP instructions.

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

2 years ago[ELF] InputSection::writeTo: reorder type checks and add LLVM_UNLIKELY
Fangrui Song [Fri, 17 Dec 2021 07:42:50 +0000 (23:42 -0800)]
[ELF] InputSection::writeTo: reorder type checks and add LLVM_UNLIKELY

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