platform/upstream/llvm.git
2 years ago[Hexagon] Remove isPredicateRegister in favor of isPredReg, NFC
Krzysztof Parzyszek [Tue, 28 Dec 2021 16:37:08 +0000 (08:37 -0800)]
[Hexagon] Remove isPredicateRegister in favor of isPredReg, NFC

HexagonMCChecker has its own function isPredicateRegister, which does
the same thing as HexagonMCInstrInfo::isPredReg.

2 years ago[Analysis] allow caller to choose signed/unsigned when computing constant range
Sanjay Patel [Tue, 28 Dec 2021 14:25:16 +0000 (09:25 -0500)]
[Analysis] allow caller to choose signed/unsigned when computing constant range

We should not lose analysis precision if an 'add' has both no-wrap
flags (nsw and nuw) compared to just one or the other.

This patch is modeled on a similar construct that was added with
D59386.

I don't think it is possible to expose a problem with an unsigned
compare because of the way this was coded (nuw is handled first).

InstCombine has an assert that fires with the example from:
https://github.com/llvm/llvm-project/issues/52884
...because it was expecting InstSimplify to handle this kind of
pattern with an smax.

Fixes #52884

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

2 years ago[InstSimplify] add tests for icmp with no-wrap add operand; NFC
Sanjay Patel [Mon, 27 Dec 2021 20:44:59 +0000 (15:44 -0500)]
[InstSimplify] add tests for icmp with no-wrap add operand; NFC

2 years ago[VPlan] Add abstract base class for header phi recipes (NFC).
Florian Hahn [Tue, 28 Dec 2021 14:37:28 +0000 (15:37 +0100)]
[VPlan] Add abstract base class for header phi recipes (NFC).

Not all header phis widen the phi, e.g. like the new
VPCanonicalIVPHIRecipe in D113223. To let those recipes also inherit
from a phi-like base class, add a more generic VPHeaderPHIRecipe
abstract base class.

Reviewed By: Ayal

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

2 years ago[InstCombine] Skip some GEP folds under opaque pointers
Nikita Popov [Tue, 28 Dec 2021 14:30:01 +0000 (15:30 +0100)]
[InstCombine] Skip some GEP folds under opaque pointers

In their current form, these folds are fundamentally incompatible
with opaque pointers. We should add a separate set of folds for
the canonicalization of the GEP source type. For now, skip these
folds.

2 years ago[InstCombine] Use GEP type instead of pointee type
Nikita Popov [Tue, 28 Dec 2021 13:57:43 +0000 (14:57 +0100)]
[InstCombine] Use GEP type instead of pointee type

The GEP source type is independent of whether it is a scalar or
vector GEP, as such we can simply preserve it.

2 years ago[ConstFold] Add another icmp of gep of global test (NFC)
Nikita Popov [Tue, 28 Dec 2021 13:28:28 +0000 (14:28 +0100)]
[ConstFold] Add another icmp of gep of global test (NFC)

This time with some complex arithmetic involving bitcasts.

2 years ago[Assembler] Regenerate test checks (NFC)
Nikita Popov [Tue, 28 Dec 2021 13:20:29 +0000 (14:20 +0100)]
[Assembler] Regenerate test checks (NFC)

Switch this Assembler test to use utc by adding a dummy function
and opt run line.

2 years ago[ConstFold] Don't fold signed comparison of gep of global
Nikita Popov [Tue, 28 Dec 2021 13:09:34 +0000 (14:09 +0100)]
[ConstFold] Don't fold signed comparison of gep of global

An inbounds GEP may still cross the sign boundary, so signed icmps
cannot be folded (https://alive2.llvm.org/ce/z/XSgi4D). This was
previously fixed for other folds in this function, but this one
was missed.

2 years ago[ConstFold] Add additional icmp of gep of global tests (NFC)
Nikita Popov [Tue, 28 Dec 2021 13:06:07 +0000 (14:06 +0100)]
[ConstFold] Add additional icmp of gep of global tests (NFC)

The fold is incorrect for the sgt case, as gep inbounds is allowed
to cross the sign boundary.

2 years ago[InstCombine] Make indexed compare fold opaque ptr compatible
Nikita Popov [Thu, 24 Jun 2021 20:31:06 +0000 (22:31 +0200)]
[InstCombine] Make indexed compare fold opaque ptr compatible

We need to make sure that the GEP source element types match.

A caveat here is that the used GEP source element type can be
arbitrary if no offset is stripped from the original GEP -- the
transform is somewhat inconsistent in that it always starts from
a GEP, but might not actually look through it if it has multiple
indices.

2 years ago[LV] Use specific first-order recurrence recipe as arg type (NFC).
Florian Hahn [Tue, 28 Dec 2021 09:53:56 +0000 (10:53 +0100)]
[LV] Use specific first-order recurrence recipe as arg type (NFC).

Required for further refactoring in D116304.

2 years ago[CodeGen] Drop unnecessary const from return types (NFC)
Kazu Hirata [Tue, 28 Dec 2021 08:38:11 +0000 (00:38 -0800)]
[CodeGen] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

2 years ago[InstCombine] Fix GEP with same index comparison with opaque pointers
Nikita Popov [Tue, 28 Dec 2021 08:14:27 +0000 (09:14 +0100)]
[InstCombine] Fix GEP with same index comparison with opaque pointers

We need to also check that the source element type is the same,
otherwise the indices may have different meaning. The added
addrspacecast demonstrates that we do still need to check the
pointer type.

2 years ago[NFC] [Coroutines] Add tests for coro-split-musttail
Chuanqi Xu [Tue, 28 Dec 2021 08:20:06 +0000 (16:20 +0800)]
[NFC] [Coroutines] Add tests for coro-split-musttail

Add two tests to address the problems during marking coro.resume
calls as musttail. The two problems are bitcast instruction and unused
instruciton respectively.

2 years ago[gn build] Port b5c5d8912e07
LLVM GN Syncbot [Tue, 28 Dec 2021 07:59:27 +0000 (07:59 +0000)]
[gn build] Port b5c5d8912e07

2 years ago[clang][dataflow] Add support for noreturn destructor calls
Stanislav Gatev [Mon, 20 Dec 2021 09:56:25 +0000 (09:56 +0000)]
[clang][dataflow] Add support for noreturn destructor calls

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Reviewed By: xazax.hun, gribozavr2

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

2 years ago[ELF] Change EhInputSection::pieces to SmallVector
Fangrui Song [Tue, 28 Dec 2021 05:34:38 +0000 (21:34 -0800)]
[ELF] Change EhInputSection::pieces to SmallVector

The decreased size does not matter that much as one file contributes at most one EhInputSection.

2 years ago[clang] Remove unused "using" (NFC)
Kazu Hirata [Tue, 28 Dec 2021 04:48:21 +0000 (20:48 -0800)]
[clang] Remove unused "using" (NFC)

Identified by misc-unused-using-decls.

2 years ago[ELF] Change InStruct/Partition pointers to unique_ptr
Fangrui Song [Tue, 28 Dec 2021 02:15:23 +0000 (18:15 -0800)]
[ELF] Change InStruct/Partition pointers to unique_ptr

and remove associated make<XXX> calls.
gnuHash and sysvHash are unchanged, otherwise LinkerScript::discard would
destroy the objects which may be referenced by input section descriptions.

My x86-64 lld executable is 121+KiB smaller.

2 years ago[RISCV] Support passing scalable vectur values through the stack.
Hsiangkai Wang [Mon, 27 Dec 2021 14:35:27 +0000 (22:35 +0800)]
[RISCV] Support passing scalable vectur values through the stack.

After consuming all vector registers, the scalable vector values will be
passed indirectly. The pointer values will be saved in general
registers. If all general registers are used up, we will report an error to
notify users the compiler does not support passing scalable vector
values through the stack. In this patch, we remove the restriction. After
all general registers are used up, we use the stack to save the
pointers which point to the indirect passed scalable vector values.

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

2 years ago[ELF] Use const reference. NFC
Fangrui Song [Tue, 28 Dec 2021 01:05:48 +0000 (17:05 -0800)]
[ELF] Use const reference. NFC

2 years ago[llvm] Drop unnecessary const from return types (NFC)
Kazu Hirata [Mon, 27 Dec 2021 23:58:03 +0000 (15:58 -0800)]
[llvm] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

2 years ago[ELF] addOrphanSections: avoid std::function
Fangrui Song [Mon, 27 Dec 2021 23:57:38 +0000 (15:57 -0800)]
[ELF] addOrphanSections: avoid std::function

2 years ago[DebugInfo] Drop unnecessary const from return types (NFC)
Kazu Hirata [Mon, 27 Dec 2021 23:42:52 +0000 (15:42 -0800)]
[DebugInfo] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

2 years ago[ASTMatchers] Simplify string comparisons (NFC)
Kazu Hirata [Mon, 27 Dec 2021 23:32:51 +0000 (15:32 -0800)]
[ASTMatchers] Simplify string comparisons (NFC)

Identified with readability-string-compare.

2 years ago[llvm] Fix header guards (NFC)
Kazu Hirata [Mon, 27 Dec 2021 23:20:12 +0000 (15:20 -0800)]
[llvm] Fix header guards (NFC)

Identified with llvm-header-guard.

2 years ago[ELF] Simplify and optimize SymbolTableSection<ELFT>::writeTo
Fangrui Song [Mon, 27 Dec 2021 23:16:14 +0000 (15:16 -0800)]
[ELF] Simplify and optimize SymbolTableSection<ELFT>::writeTo

2 years ago[RISCV] Fix type in f16 and f64 version of lrint/llrint/lround/llround test cases...
Craig Topper [Mon, 27 Dec 2021 22:59:21 +0000 (14:59 -0800)]
[RISCV] Fix type in f16 and f64 version of lrint/llrint/lround/llround test cases. NFC

Due to a copy/paste mistake we were always testing float.

This required splitting up the f16 tests into separate files since
we don't have an appropriate libcall to use when the types involved
aren't legal.

2 years ago[RISCV] Rename two tests to reflect extension being tested. NFC
Craig Topper [Mon, 27 Dec 2021 22:44:34 +0000 (14:44 -0800)]
[RISCV] Rename two tests to reflect extension being tested. NFC

2 years ago[OpenMP] Use alignment information in HeapToShared
Joseph Huber [Mon, 27 Dec 2021 20:02:32 +0000 (15:02 -0500)]
[OpenMP] Use alignment information in HeapToShared

This patch uses the return alignment attribute now present in the
`__kmpc_alloc_shared` runtime call to set the alignment of the shared
memory global created to replace it.

Depends on D115971

Reviewed By: jdoerfert

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

2 years ago[OpenMP][FIX] Change globalization alignment to 16
Joseph Huber [Fri, 17 Dec 2021 22:00:13 +0000 (17:00 -0500)]
[OpenMP][FIX] Change globalization alignment to 16

This patch changes the default aligntment from 8 to 16, and encodes this
information in the `__kmpc_alloc_shared` runtime call to communicate it
to the HeapToStack pass. The previous alignment of 8 was not sufficient
for the maximum size of primitive types on 64-bit systems, and needs to
be increaesd. This reduces the amount of space availible in the data
sharing stack, so this implementation will need to be improved later to
include the alignment requirements in the allocation call, and use it
properly in the data sharing stack in the runtime.

Depends on D115888

Reviewed By: jdoerfert

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

2 years ago[Attributor][Fix] Add alignment return attribute to HeapToStack
Joseph Huber [Fri, 17 Dec 2021 19:28:36 +0000 (14:28 -0500)]
[Attributor][Fix] Add alignment return attribute to HeapToStack

This patch changes the HeapToStack optimization to attach the return alignment
attribute information to the created alloca instruction. This would cause
problems when replacing the heap allocation with an alloca did not respect the
alignment of the original heap allocation, which would typically be aligned on
an 8 or 16 byte boundary. Malloc calls now contain alignment attributes,
so we can use that information here.

Reviewed By: jdoerfert

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

2 years ago[ELF] Delete stale declaration. NFC
Fangrui Song [Mon, 27 Dec 2021 20:56:38 +0000 (12:56 -0800)]
[ELF] Delete stale declaration. NFC

2 years ago[ELF] -r: move zero OutputSection::addr code into finalizeAddressDependentContent
Fangrui Song [Mon, 27 Dec 2021 20:10:23 +0000 (12:10 -0800)]
[ELF] -r: move zero OutputSection::addr code into finalizeAddressDependentContent

Ensure addresses are unchanged after finalizeAddressDependentContent.

2 years ago[profile] Fix writing binary id into profiles
Gulfem Savrun Yeniceri [Wed, 15 Dec 2021 21:51:33 +0000 (21:51 +0000)]
[profile] Fix writing binary id into profiles

This patch adds support to read all the PT_NOTE segments in the
executable to find the binary ids. Previously, it was only reading
the first PT_NOTE segment, and this was missing the cases where
binary id is in the following segments. As a result, binary-id.c
and binary-id-padding.c test were failing in the following cases:
1) sanitizer-x86_64-linux bot
   https://lab.llvm.org/staging/#/builders/97
2) OpenSuse Tumbleweed
   https://github.com/llvm/llvm-project/issues/52695

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

2 years ago[Analysis] remove unneeded casts; NFC
Sanjay Patel [Mon, 27 Dec 2021 18:38:11 +0000 (13:38 -0500)]
[Analysis] remove unneeded casts; NFC

The callee does the casting too; this matches a plain call later in the same function for 'shl'.

2 years ago[InstCombine] add tests for shuffle + binop; NFC
Sanjay Patel [Tue, 21 Dec 2021 18:50:25 +0000 (13:50 -0500)]
[InstCombine] add tests for shuffle + binop; NFC

2 years ago[OpenMP][Plugin] Introduce generic resource pool
Shilei Tian [Mon, 27 Dec 2021 16:31:59 +0000 (11:31 -0500)]
[OpenMP][Plugin] Introduce generic resource pool

Currently CUDA streams are managed by `StreamManagerTy`. It works very well. Now
we have the need that some resources, such as CUDA stream and event, will be
hold by `libomptarget`. It is always good to buffer those resources. What's more
important, given the way that `libomptarget` and plugins are connected, we cannot
make sure whether plugins are still alive when `libomptarget` is destroyed. That
leads to an issue that those resouces hold by `libomptarget` might not be
released correctly. As a result, we need an unified management of all the resources
that can be shared between `libomptarget` and plugins.

`ResourcePoolTy` is designed to manage the type of resource for one device.
It has to work with an allocator which is supposed to provide `create` and
`destroy`. In this way, when the plugin is destroyed, we can make sure that
all resources allocated from native runtime library will be released correctly,
no matter whether `libomptarget` starts its destroy.

Reviewed By: ye-luo

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

2 years ago[SLP][NFC]Add a test for shuffled entries with different vector sizes,
Alexey Bataev [Mon, 27 Dec 2021 15:35:35 +0000 (07:35 -0800)]
[SLP][NFC]Add a test for shuffled entries with different vector sizes,
NFC.

2 years ago[ARM] Extend IsCMPZCSINC to handle CMOV
David Green [Mon, 27 Dec 2021 14:15:03 +0000 (14:15 +0000)]
[ARM] Extend IsCMPZCSINC to handle CMOV

A 'CMOV 1, 0, CC, %cpsr, Cmp' is the same as a 'CSINC 0, 0, CC, Cmp',
and can be treated the same in IsCMPZCSINC added in D114013. This allows
us to remove the unnecessary CMOV in the same way that we could remove a
CSINC.

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

2 years ago[InstCombine] Fix GEP of GEP fold with opaque pointers
Nikita Popov [Mon, 27 Dec 2021 13:53:38 +0000 (14:53 +0100)]
[InstCombine] Fix GEP of GEP fold with opaque pointers

We need to check that result and source element types match, as
this is no longer automatically enforced with opaque pointers.

2 years ago[InstCombine] Extract GEP of GEP fold into separate function
Nikita Popov [Mon, 27 Dec 2021 13:50:04 +0000 (14:50 +0100)]
[InstCombine] Extract GEP of GEP fold into separate function

This change may not be entirely NFC, because a number of early
returns will now only early return from this particular fold,
rather than the whole visitGetElementPtr() implementation. This
is also the reason why I'm doing this change, as I don't think
this was intended.

2 years ago[MLIR] Use IntegerPolyhedron in Simplex instead of FlatAffineConstraints
Groverkss [Mon, 27 Dec 2021 13:36:32 +0000 (19:06 +0530)]
[MLIR] Use IntegerPolyhedron in Simplex instead of FlatAffineConstraints

This patch replaces usage of FlatAffineConstraints in Simplex with
IntegerPolyhedron. This removes dependency of Simplex on FlatAffineConstraints
and puts it on IntegerPolyhedron, which is part of Presburger library.

Reviewed By: arjunp

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

2 years ago[X86] Use WriteVecMove scheduler classes for VPMOVM2* instructions
Simon Pilgrim [Mon, 27 Dec 2021 13:21:20 +0000 (13:21 +0000)]
[X86] Use WriteVecMove scheduler classes for VPMOVM2* instructions

These match the port behaviour of reg-reg predicated xmm/ymm/zmm moves

Fixes #34958

2 years ago[MLIR] Move `print()` and `dump()` from FlatAffineConstraints to IntegerPolyhedron.
Groverkss [Mon, 27 Dec 2021 13:09:57 +0000 (18:39 +0530)]
[MLIR] Move `print()` and `dump()` from FlatAffineConstraints to IntegerPolyhedron.

This patch moves `FlatAffineConstraints::print` and
`FlatAffineConstraints::dump()` to IntegerPolyhedron.

Reviewed By: arjunp

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

2 years agoFix forward for "signed version of createExpression"
Anton Daubert [Mon, 27 Dec 2021 12:50:02 +0000 (13:50 +0100)]
Fix forward for "signed version of createExpression"

Fix forward for "signed version of createExpression" change in https://github.com/llvm/llvm-project/commit/ec501f15a8b8ace2b283732740d6d65d40d82e09

Reviewed By: bgraur, achieveartificialintelligence

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

2 years ago[NFC] [Coroutines] Add tests to address the problem for converting to musttail
Chuanqi Xu [Mon, 27 Dec 2021 12:24:37 +0000 (20:24 +0800)]
[NFC] [Coroutines] Add tests to address the problem for converting to musttail
call

Add two tests to address the problem for missing oppotunities to convert
calls to musttail call.

2 years ago[X86] Add scheduler classes for zmm vector reg-reg move instructions
Simon Pilgrim [Mon, 27 Dec 2021 12:13:17 +0000 (12:13 +0000)]
[X86] Add scheduler classes for zmm vector reg-reg move instructions

Basic zmm reg-reg moves (with predication) are more port limited than xmm/ymm moves, so we need to add a separate class for them.

We still appear to be missing move-elimination patterns for most of the intel models, which looks to be one of the main diffs for basic codegen analysis between llvm-mca and uops.info

Load/stores are a bit messier and might be better handled as overrides.

2 years ago[CodeGen] Avoid one more pointer element type access
Nikita Popov [Mon, 27 Dec 2021 11:42:42 +0000 (12:42 +0100)]
[CodeGen] Avoid one more pointer element type access

The number of elements is always a SizeTy here.

2 years ago[MCA][X86] Add AVX512 vector move instruction test coverage
Simon Pilgrim [Fri, 24 Dec 2021 22:46:20 +0000 (22:46 +0000)]
[MCA][X86] Add AVX512 vector move instruction test coverage

2 years ago[IndVars] Support opaque pointers in LFTR
Nikita Popov [Mon, 27 Dec 2021 11:31:02 +0000 (12:31 +0100)]
[IndVars] Support opaque pointers in LFTR

Remove the assertion about the pointer element type, only check
that the stride is one. Ultimately, the actual pointer type here
doesn't matter, because SCEVExpander would insert appropriate
casts if necessary.

2 years agoGlobalISel: remove redundant line added in D114198. NFC
Petar Avramovic [Mon, 27 Dec 2021 11:13:41 +0000 (12:13 +0100)]
GlobalISel: remove redundant line added in D114198. NFC

2 years agoRevert "[NFC] [Coroutines] Add a test for icmp use of coro.suspend to prevent musttai...
Chuanqi Xu [Mon, 27 Dec 2021 11:05:22 +0000 (19:05 +0800)]
Revert "[NFC] [Coroutines] Add a test for icmp use of coro.suspend to prevent musttail call converting"

This reverts commit 21aa4d5d5ef947d824c50a22d15fb93d7df0b711.

The test added is not proper. It would be passed all the time since it
is in the ramp function.

2 years ago[CodeGen] Avoid more pointer element type accesses
Nikita Popov [Fri, 24 Dec 2021 13:01:54 +0000 (14:01 +0100)]
[CodeGen] Avoid more pointer element type accesses

2 years ago[LV] Sink BTC creation to actual use (NFC).
Florian Hahn [Mon, 27 Dec 2021 10:25:45 +0000 (11:25 +0100)]
[LV] Sink BTC creation to actual use (NFC).

Suggested separately in D116123.

2 years ago[NFC] [Coroutines] Add a test for icmp use of coro.suspend to prevent musttail call...
Chuanqi Xu [Mon, 27 Dec 2021 09:26:44 +0000 (17:26 +0800)]
[NFC] [Coroutines] Add a test for icmp use of coro.suspend to prevent musttail call converting

Add a test to show the false negative optimization oppotunity to not convert a resume
call to musttail call. It should could be.

2 years ago[MLIR] Add forgotten directory Support to unittests cmake
Arjun P [Mon, 27 Dec 2021 09:07:47 +0000 (14:37 +0530)]
[MLIR] Add forgotten directory Support to unittests cmake

The Support directory was removed from the unittests cmake when the directory
was removed in 204c3b551626a925dfdc3822a6f240bdc8ef5d3a. Subsequent commits
added the directory back but seem to have missed adding it back to the cmake.

This patch also removes MLIRSupportIndentedStream from the list of linked
libraries to avoid an ODR violation (it's already part of MLIRSupport which
is also being linked here). Otherwise ASAN complains:

```
=================================================================
==102592==ERROR: AddressSanitizer: odr-violation (0x7fbdf214eee0):
  [1] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
  [2] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
These globals were registered at these points:
  [1]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf214a61b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupportIndentedOstream.so.14git+0x661b)

  [2]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf2061c4b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupport.so.14git+0x11bc4b)

==102592==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY AddressSanitizer: odr-violation: global 'vtable for mlir::raw_indented_ostream' at /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
==102592==ABORTING
```

This patch also fixes a build issue with `DebugAction::classof` under Windows.

This commit re-lands this patch, which was previously reverted in
2132906836cf0618e76485c67a60305bf1557ffc due to a buildbot failure that
turned out to be because of a flaky test.

Reviewed By: jpienaar

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

2 years ago[OpenCL] Allow optional __generic in __remove_address_space utility
Justas Janickas [Tue, 30 Nov 2021 09:17:09 +0000 (09:17 +0000)]
[OpenCL] Allow optional __generic in __remove_address_space utility

2 years ago[Inline][X86] Avoid inlining if it would create ABI-incompatible calls (PR52660)
Nikita Popov [Wed, 15 Dec 2021 16:04:01 +0000 (17:04 +0100)]
[Inline][X86] Avoid inlining if it would create ABI-incompatible calls (PR52660)

X86 allows inlining functions if the callee target features are a
subset of the caller target features. This ensures that we don't
inline something into a caller that does not support it.

However, this does not account for possible call ABI mismatches as
a result of inlining. If a call passing a vector argument was
originally in a -avx function, calling another -avx function, the
vector is passed in xmm. If we now inline it into a +avx function,
then it will be passed in ymm, even though the callee expects it in xmm.

Fix this by scanning over all calls in the function and checking
whether ABI incompatibility is possible. Calls that only pass scalar
types are excluded, as I believe those always use the same ABI
independent of target features.

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

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

2 years ago[ELF] Move excludeLibs/redirectSymbols/replaceCommonSymbols adjacent
Fangrui Song [Mon, 27 Dec 2021 08:31:54 +0000 (00:31 -0800)]
[ELF] Move excludeLibs/redirectSymbols/replaceCommonSymbols adjacent

Make post-thinlto-index symbol resolution passes closer.

2 years ago[ELF] Delete unused LazyObjKind
Fangrui Song [Mon, 27 Dec 2021 08:03:53 +0000 (00:03 -0800)]
[ELF] Delete unused LazyObjKind

2 years ago[Target] Use range-based for loops (NFC)
Kazu Hirata [Mon, 27 Dec 2021 07:49:38 +0000 (23:49 -0800)]
[Target] Use range-based for loops (NFC)

2 years ago[ELF] Serialize deleteFallThruJmpInsn to fix concurrency issue
Fangrui Song [Mon, 27 Dec 2021 07:26:13 +0000 (23:26 -0800)]
[ELF] Serialize deleteFallThruJmpInsn to fix concurrency issue

New deleteFallThruJmpInsn calls `make<JumpInstrMod>` which cannot be called
concurrently. Losing parallelism is unfortunate but we can think of a better
approach if parallelism here justifies itself.

2 years ago[ELF] Unify sizeof(InputSection) limits for _WIN32 and others
Fangrui Song [Mon, 27 Dec 2021 07:02:24 +0000 (23:02 -0800)]
[ELF] Unify sizeof(InputSection) limits for _WIN32 and others

Windows sizeof(InputSection) seems to match non-Windows now.

2 years ago[ELF] Optimize basic block section bytesDropped/jumpInstrMods
Fangrui Song [Mon, 27 Dec 2021 06:17:30 +0000 (22:17 -0800)]
[ELF] Optimize basic block section bytesDropped/jumpInstrMods

and make them more space efficient. This decreases sizeof(InputSection) from 176
to 160, and decreases peak memory usage by 0.3% when linking Chrome.

2 years ago[clang][CodeGen] Remove the signed version of createExpression
Shao-Ce SUN [Mon, 27 Dec 2021 06:15:30 +0000 (14:15 +0800)]
[clang][CodeGen] Remove the signed version of createExpression

Fix a TODO. Remove the callers of this signed version and delete.

Reviewed By: CodaFi

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

2 years ago[RISCV] Convert whole register copies as the source defined explicitly.
Hsiangkai Wang [Thu, 16 Dec 2021 10:12:38 +0000 (18:12 +0800)]
[RISCV] Convert whole register copies as the source defined explicitly.

The implicit defines may come from a partial define in an instruction.
It does not mean the defining instruction and the COPY instruction have
the same vl and vtype. When the source comes from the implicit defines,
do not convert the whole register copies to vmv.v.v.

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

2 years ago[libcxx] [Coroutines] Support noop_coroutine for GCC
Chuanqi Xu [Mon, 27 Dec 2021 05:52:42 +0000 (13:52 +0800)]
[libcxx] [Coroutines] Support noop_coroutine for GCC

We didn't support noop_coroutine for GCC in previous conforming patch.
So that GCC couldn't use noop_coroutine() defined in <coroutine>. And
after this patch, GCC should be able to compile the whole <coroutine>
header.

Reviewed By: Quuxplusone

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

2 years ago[ELF] ScriptParser: change std::vector to SmallVector
Fangrui Song [Mon, 27 Dec 2021 04:12:55 +0000 (20:12 -0800)]
[ELF] ScriptParser: change std::vector to SmallVector

2 years ago[ELF] SymbolTable::symbols: don't filter out PlaceholderKind
Fangrui Song [Mon, 27 Dec 2021 02:11:45 +0000 (18:11 -0800)]
[ELF] SymbolTable::symbols: don't filter out PlaceholderKind

Placeholders (-y and redirectSymbols removed versioned symbols) are very rare and
the check just makes symbol table iteration slower. Most iterations filter out
placeholders anyway, so this change just drops the filter behavior.

For "Add symbols to symtabs", we need to ensure that redirectSymbols sets
isUsedInRegularObj to false when making a symbol placeholder, to avoid an
assertion failure in SymbolTableSection<ELFT>::writeTo.

My .text is 2KiB smaller. The speed-up linking chrome is 0.x%.

2 years ago[RISCV] Reduce repetitive codes in flw, fsw
Shao-Ce SUN [Fri, 24 Dec 2021 01:22:28 +0000 (09:22 +0800)]
[RISCV] Reduce repetitive codes in flw, fsw

Trying to improve code reuse in F,D,Zfh *.td files.

Reviewed By: craig.topper

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

2 years ago[ELF] Add Symbol::hasVersionSuffix
Fangrui Song [Mon, 27 Dec 2021 01:25:54 +0000 (17:25 -0800)]
[ELF] Add Symbol::hasVersionSuffix

"Process symbol versions" may take 2+% time.
"Redirect symbols" may take 0.6% time.
This change speeds up the two passes and makes `*sym.getVersionSuffix()
== '@'` in the `undefined reference` diagnostic cleaner.

Linking chrome (no debug info) and another large program is 1.5% faster.

For empty-ver2.s: the behavior now matches GNU ld, though I'd consider the input
invalid and the exact behavior does not matter.

2 years ago[ELF] De-template InputSectionBase::getEnclosingFunction
Fangrui Song [Sun, 26 Dec 2021 23:21:22 +0000 (15:21 -0800)]
[ELF] De-template InputSectionBase::getEnclosingFunction

2 years ago[ELF] Remove unused InputSection::getOffsetInFile
Fangrui Song [Sun, 26 Dec 2021 23:18:56 +0000 (15:18 -0800)]
[ELF] Remove unused InputSection::getOffsetInFile

2 years agoUse static_assert instead of assert (NFC)
Kazu Hirata [Sun, 26 Dec 2021 22:26:44 +0000 (14:26 -0800)]
Use static_assert instead of assert (NFC)

Identified with misc-static-assert.

2 years ago[ELF] LinkerScript/OutputSection: change other std::vector members to SmallVector
Fangrui Song [Sun, 26 Dec 2021 21:53:47 +0000 (13:53 -0800)]
[ELF] LinkerScript/OutputSection: change other std::vector members to SmallVector

11+KiB smaller .text with both libc++ and libstdc++ builds.

2 years ago[clang] Remove redundant calls to c_str() (NFC)
Kazu Hirata [Sun, 26 Dec 2021 21:31:40 +0000 (13:31 -0800)]
[clang] Remove redundant calls to c_str() (NFC)

Identified with readability-redundant-string-cstr.

2 years ago[ELF] Change InputSectionDescription members from vector to SmallVector
Fangrui Song [Sun, 26 Dec 2021 21:06:54 +0000 (13:06 -0800)]
[ELF] Change InputSectionDescription members from vector to SmallVector

This decreases sizeof(lld::elf::InputSectionDescription) from 264 to 232.

2 years ago[LV] Move getStepVector out of ILV (NFC).
Florian Hahn [Sun, 26 Dec 2021 20:17:25 +0000 (21:17 +0100)]
[LV] Move getStepVector out of ILV (NFC).

First step to split up induction handling and move it outside ILV.
Used in D116123 and following.

2 years ago[ELF] Move outSecOff addition from InputSection::writeTo to the caller
Fangrui Song [Sun, 26 Dec 2021 20:11:40 +0000 (12:11 -0800)]
[ELF] Move outSecOff addition from InputSection::writeTo to the caller

Simplify the code a bit and improve consistency with SyntheticSection::writeTo.

2 years agoRemove redundant string initialization (NFC)
Kazu Hirata [Sun, 26 Dec 2021 17:39:26 +0000 (09:39 -0800)]
Remove redundant string initialization (NFC)

Identified with readability-redundant-string-init.

2 years agoEnsure newlines at the end of files (NFC)
Kazu Hirata [Sun, 26 Dec 2021 16:51:06 +0000 (08:51 -0800)]
Ensure newlines at the end of files (NFC)

2 years ago[Orc] Remove a redundant declaration (NFC)
Kazu Hirata [Sun, 26 Dec 2021 09:01:38 +0000 (01:01 -0800)]
[Orc] Remove a redundant declaration (NFC)

DebugUtils.h contains an identical declaration with a correct comment,
namely:

  /// Render a LookupKind.
  raw_ostream &operator<<(raw_ostream &OS, const LookupKind &K);

Identified with readability-redundant-declaration.

2 years agoRevert "[MLIR] Add forgotten directory Support to unittests cmake"
Arjun P [Sun, 26 Dec 2021 08:29:23 +0000 (13:59 +0530)]
Revert "[MLIR] Add forgotten directory Support to unittests cmake"

This reverts commit 0c553cc1af2e4c14100df6cf4a6fc91987e778e6.

This caused a buildbot failure (https://lab.llvm.org/buildbot#builders/197/builds/888).

```
******************** TEST 'ScudoStandalone-Unit :: ./ScudoUnitTest-aarch64-Test/ScudoCommonTest.ResidentMemorySize' FAILED ********************
Script:
--
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/stage1/projects/compiler-rt/lib/scudo/standalone/tests/./ScudoUnitTest-aarch64-Test --gtest_filter=ScudoCommonTest.ResidentMemorySize
--
Note: Google Test filter = ScudoCommonTest.ResidentMemorySize
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ScudoCommonTest
[ RUN      ] ScudoCommonTest.ResidentMemorySize
/home/tcwg-buildbot/worker/clang-aarch64-sve-vla/llvm/compiler-rt/lib/scudo/standalone/tests/common_test.cpp:49: Failure
Expected: (getResidentMemorySize()) > (OnStart + Size - Threshold), actual: 707358720 vs 943153152
[  FAILED  ] ScudoCommonTest.ResidentMemorySize (21709 ms)
[----------] 1 test from ScudoCommonTest (21709 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (21709 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] ScudoCommonTest.ResidentMemorySize
 1 FAILED TEST
********************
```

2 years ago[ELF] Remove one redundant computeBinding
Fangrui Song [Sun, 26 Dec 2021 07:59:27 +0000 (23:59 -0800)]
[ELF] Remove one redundant computeBinding

This does resolve the redundancy in includeInDynsym().

2 years ago[ELF] reportRangeError: mention symbol name for non-STT_SECTION local symbols like...
Fangrui Song [Sun, 26 Dec 2021 07:46:47 +0000 (23:46 -0800)]
[ELF] reportRangeError: mention symbol name for non-STT_SECTION local symbols like non-global symbols

2 years ago[ELF] sortSymTabSymbols: change vector to SmallVector
Fangrui Song [Sun, 26 Dec 2021 07:16:26 +0000 (23:16 -0800)]
[ELF] sortSymTabSymbols: change vector to SmallVector

This function may take ~1% time. SmallVector<SymbolTableEntry, 0> is smaller (16 bytes
instead of 24) and more efficient.

2 years ago[ELF][test] Make some TLS tests less sensitive to addresses
Fangrui Song [Sun, 26 Dec 2021 06:05:20 +0000 (22:05 -0800)]
[ELF][test] Make some TLS tests less sensitive to addresses

2 years agoFix clang-tidy performance-move-const-arg in DLTI Dialect (NFC)
Mehdi Amini [Sun, 26 Dec 2021 02:13:54 +0000 (02:13 +0000)]
Fix clang-tidy performance-move-const-arg in DLTI Dialect (NFC)

The const loop iterator was inhibiting the std::move().

2 years agoDebugInfo: Don't hash DIE offsets before they're computed
David Blaikie [Sat, 25 Dec 2021 23:59:29 +0000 (15:59 -0800)]
DebugInfo: Don't hash DIE offsets before they're computed

Instead of hashing DIE offsets, hash DIE references the same as they
would be when used outside of a loclist - that is, deep hash the type on
first use, and hash the numbering on subsequent uses.

This does produce different hashes for different type references, where
it did not before (because we were hashing zero all the time - so it
didn't matter what type was referenced, the hash would be identical).

This also allows us to enforce that the DIE offset (& size) is not
queried before it is used (which came up while investigating another bug
recently).

2 years ago[ELF] scanReloc: remove unused start parameter. NFC
Fangrui Song [Sat, 25 Dec 2021 22:34:05 +0000 (14:34 -0800)]
[ELF] scanReloc: remove unused start parameter. NFC

This was once used as a workaround for detecting missing PPC64 TLSGD/TLSLD
relocations produced by ancient IBM XL C/C++.

2 years ago[ELF] De-template handleTlsRelocation. NFC
Fangrui Song [Sat, 25 Dec 2021 22:23:12 +0000 (14:23 -0800)]
[ELF] De-template handleTlsRelocation. NFC

2 years ago[MLIR] Add forgotten directory Support to unittests cmake
Arjun P [Sat, 25 Dec 2021 20:18:19 +0000 (01:48 +0530)]
[MLIR] Add forgotten directory Support to unittests cmake

The Support directory was removed from the unittests cmake when the directory
was removed in 204c3b551626a925dfdc3822a6f240bdc8ef5d3a. Subsequent commits
added the directory back but seem to have missed adding it back to the cmake.

This patch also removes MLIRSupportIndentedStream from the list of linked
libraries to avoid an ODR violation (it's already part of MLIRSupport which
is also being linked here). Otherwise ASAN complains:

```
=================================================================
==102592==ERROR: AddressSanitizer: odr-violation (0x7fbdf214eee0):
  [1] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
  [2] size=120 'vtable for mlir::raw_indented_ostream' /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
These globals were registered at these points:
  [1]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf214a61b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupportIndentedOstream.so.14git+0x661b)

  [2]:
    #0 0x28a71d in __asan_register_globals (/home/arjun/llvm-project/build/tools/mlir/unittests/Support/MLIRSupportTests+0x28a71d)
    #1 0x7fbdf2061c4b in asan.module_ctor (/home/arjun/llvm-project/build/lib/libMLIRSupport.so.14git+0x11bc4b)

==102592==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY AddressSanitizer: odr-violation: global 'vtable for mlir::raw_indented_ostream' at /home/arjun/llvm-project/mlir/lib/Support/IndentedOstream.cpp
==102592==ABORTING
```

Reviewed By: jpienaar

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

2 years ago[lldb] Add support for UTF-8 unicode formatting
Luís Ferreira [Sat, 25 Dec 2021 19:37:45 +0000 (19:37 +0000)]
[lldb] Add support for UTF-8 unicode formatting

This patch adds missing formatting for UTF-8 unicode.

Cross-referencing https://reviews.llvm.org/D66447

Reviewed By: labath

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

2 years ago[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available to...
Groverkss [Sat, 25 Dec 2021 17:05:57 +0000 (22:35 +0530)]
[MLIR][FlatAffineConstraints][NFC] Move some static functions to be available to Presburger/

This patch moves some static functions from AffineStructures.cpp to
Presburger/Utils.cpp and some to be private members of FlatAffineConstraints
(which will later be moved to IntegerPolyhedron) to allow for a smoother
transition for moving FlatAffineConstraints math functionality to
Presburger/IntegerPolyhedron.

This patch is part of a series of patches for moving math functionality to
Presburger directory.

Reviewed By: arjunp, bondhugula

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

2 years ago[NFC] Method for evaluation of FCmpInst for constant operands
Serge Pavlov [Sun, 19 Sep 2021 17:12:21 +0000 (00:12 +0700)]
[NFC] Method for evaluation of FCmpInst for constant operands

New method `FCmpInst::compare` is added, which evaluates the given
compare predicate for constant operands. Interface is made similar to
`ICmpInst::compare`.

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

2 years ago[StaticAnalyzer] Remove redundant declaration isStdSmartPtr (NFC)
Kazu Hirata [Sat, 25 Dec 2021 08:35:41 +0000 (00:35 -0800)]
[StaticAnalyzer] Remove redundant declaration isStdSmartPtr (NFC)

An identical declaration is present just a couple of lines above the
line being removed in this patch.

Identified with readability-redundant-declaration.

2 years agoRemove redundant return and continue statements (NFC)
Kazu Hirata [Sat, 25 Dec 2021 07:17:53 +0000 (23:17 -0800)]
Remove redundant return and continue statements (NFC)

Identified with readability-redundant-control-flow.

2 years ago[ELF] Move TLS dynamic relocations to postScanRelocations
Fangrui Song [Sat, 25 Dec 2021 06:36:49 +0000 (22:36 -0800)]
[ELF] Move TLS dynamic relocations to postScanRelocations

This temporarily increases sizeof(SymbolUnion), but allows us to mov GOT/PLT/etc
index members outside Symbol in the future.

Then, we can make TLSDESC and TLSGD use different indexes and support mixed
TLSDESC and TLSGD (tested by x86-64-tlsdesc-gd-mixed.s).

Note: needsTlsGd and needsTlsGdToIe may optionally be combined.

Test updates are due to reordered GOT entries.