platform/upstream/llvm.git
2 years agoMaking the code compliant to the documentation about Floating Point
Zahira Ammarguellat [Thu, 12 Aug 2021 20:13:16 +0000 (16:13 -0400)]
Making the code compliant to the documentation about Floating Point
support default values for C/C++. FPP-MODEL=PRECISE enables FFP-CONTRACT
FMA is enabled.

Fix for https://bugs.llvm.org/show_bug.cgi?id=50222

2 years agoRevert "[IndVars] Pass TTI to replaceCongruentIVs"
Dmitry Makogon [Mon, 8 Nov 2021 12:35:14 +0000 (19:35 +0700)]
Revert "[IndVars] Pass TTI to replaceCongruentIVs"

This reverts commit db289340c841990055a164e8eb2a3b5ff25677bf.

The patch caused 2 crashes with expensive checks enabled.

2 years ago[AArch64][SVE] Combine FADD and FMUL aarch64 intrinsics to FMLA
Matt [Wed, 3 Nov 2021 11:31:41 +0000 (11:31 +0000)]
[AArch64][SVE] Combine FADD and FMUL aarch64 intrinsics to FMLA

This is a refinement to the work in
https://reviews.llvm.org/D111638

Fold (fadd p a (fmul p b c)) into (fma p a b c)

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

2 years ago[IndVars] Pass TTI to replaceCongruentIVs
Dmitry Makogon [Tue, 2 Nov 2021 15:19:51 +0000 (22:19 +0700)]
[IndVars] Pass TTI to replaceCongruentIVs

In IndVarSimplify after simplifying and extending loop IVs we call 'replaceCongruentIVs'.
This function optionally takes a TTI argument to be able to replace narrow IVs uses
with truncates of the widest one.
For some reason the TTI wasn't passed to the function, so it couldn't perform such
transform.
This patch fixes it.

Reviewed By: mkazantsev

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

2 years ago[DAG] Add BuildVectorSDNode::getConstantRawBits helper
Simon Pilgrim [Mon, 8 Nov 2021 12:07:26 +0000 (12:07 +0000)]
[DAG] Add BuildVectorSDNode::getConstantRawBits helper

We have several places where we need to extract the raw bits data from a BUILD_VECTOR node, so consolidate this to a single helper function that handles Undefs and Integer/FP constants, including implicit truncation.

This should make it easier to extend D113202 to handle more constant folding of bitcasted constant data.

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

2 years ago[mlir][linalg] Improve hoist padding buffer size computation.
Tobias Gysi [Mon, 8 Nov 2021 10:22:46 +0000 (10:22 +0000)]
[mlir][linalg] Improve hoist padding buffer size computation.

Adapt the Fourier Motzkin elimination to take into account affine computations happening outside of the cloned loop nest.

Depends On D112713

Reviewed By: nicolasvasilache

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

2 years ago[OpenMP] libomp: Fix handling of barrier pattern environment variables
@t-msn [Mon, 8 Nov 2021 12:01:19 +0000 (15:01 +0300)]
[OpenMP] libomp: Fix handling of barrier pattern environment variables

It is better to set all barrier patterns to use "dist" when at least
one environment variable specifies "dist". Otherwise if only one
environment is set to "dist" and others left blank inadvertently,
it would result in mixing dist barrier with default hyper barrier
pattern.

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

2 years ago[flang][CodeGen] Transform `fir.call` to `llvm.call`
Andrzej Warzynski [Fri, 5 Nov 2021 13:41:39 +0000 (13:41 +0000)]
[flang][CodeGen] Transform `fir.call` to `llvm.call`

This patch extends the `FIRToLLVMLowering` pass in Flang by adding a
hook to transform `fir.call` to `llvm.call`.

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

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

Patch originally written by:
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: V Donaldson <vdonaldson@nvidia.com>
Differential Revision: https://reviews.llvm.org/D113278

2 years ago[VE] default to integrated asm in AsmInfo
Simon Moll [Mon, 8 Nov 2021 10:58:07 +0000 (11:58 +0100)]
[VE] default to integrated asm in AsmInfo

VE integrated asm has been the default in Clang. Also use the default setting for integrated asm in the backend.

Reviewed By: kaz7

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

2 years ago[AArch64] Precommit i256 test from D111530
Simon Pilgrim [Mon, 8 Nov 2021 10:47:45 +0000 (10:47 +0000)]
[AArch64] Precommit i256 test from D111530

2 years ago[mlir][linalg] Improve the padding packing loop computation.
Tobias Gysi [Mon, 8 Nov 2021 09:52:13 +0000 (09:52 +0000)]
[mlir][linalg] Improve the padding packing loop computation.

The revision updates the packing loop search in hoist padding. Instead of considering all loops in the backward slice, we now compute a separate backward slice containing the index computations only. This modification ensures we do not add packing loops that are not used to index the packed buffer due to spurious dependencies. One instance where such spurious dependencies can appear is the extract slice operation introduced between the tile loops of a double tiling.

Depends On D112412

Reviewed By: nicolasvasilache

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

2 years ago[AArch64] Combine fptoi.sat(fmul) to fixed point cvtf
David Green [Mon, 8 Nov 2021 10:07:34 +0000 (10:07 +0000)]
[AArch64] Combine fptoi.sat(fmul) to fixed point cvtf

We already have patterns for fptosi and fptoui plus fmul to fixed point
convert, this adds equivalent patterns for fptosi.sat and fptoui.sat,
which should apply equally well for the legal saturating variants.

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

2 years ago[flang] Set the addendum when establishing pointer section in descriptor
Jean Perier [Mon, 8 Nov 2021 10:04:20 +0000 (11:04 +0100)]
[flang] Set the addendum when establishing pointer section in descriptor

If the source has an addendum, the descriptor that is being established
to describe a section over the source needs to copy the addendum so that
derived type information is correctly set in the descriptor being
established.

This allows namelist IO with derived type to work correctly.

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

2 years ago[LoopVectorize] Permit fixed-width epilogue loops for scalable vector bodies
David Sherwood [Tue, 7 Sep 2021 10:20:41 +0000 (11:20 +0100)]
[LoopVectorize] Permit fixed-width epilogue loops for scalable vector bodies

At the moment in LoopVectorizationCostModel::selectEpilogueVectorizationFactor
we bail out if the main vector loop uses a scalable VF. This patch adds
support for generating epilogue vector loops using a fixed-width VF when the
main vector loop uses a scalable VF.

I've changed LoopVectorizationCostModel::selectEpilogueVectorizationFactor
so that we convert the scalable VF into a fixed-width VF and do profitability
checks on that instead. In addition, since the scalable and fixed-width VFs
live in different VPlans that means I had to change the calls to
LVP.hasPlanWithVFs so that we only pass in the fixed-width VF.

New tests added here:

  Transforms/LoopVectorize/AArch64/sve-epilog-vect.ll

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

2 years ago[PowerPC] Implement basic macro fusion in Power10
Qiu Chaofan [Mon, 8 Nov 2021 09:22:50 +0000 (17:22 +0800)]
[PowerPC] Implement basic macro fusion in Power10

Including basic fusion types around arithmetic and logical instructions.

Reviewed By: jsji

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

2 years ago[AArch64] Canonicalize X*(Y+1) or X*(1-Y) to madd/msub
Andrew Wei [Mon, 8 Nov 2021 08:28:31 +0000 (16:28 +0800)]
[AArch64] Canonicalize X*(Y+1) or X*(1-Y) to madd/msub

Performing the rearrangement for add/sub and mul instructions to match the madd/msub pattern

Reviewed By: dmgreen, sdesmalen, david-arm

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

2 years ago[libc++][NFC] Inline most of `__vector_base` into `vector`.
Konstantin Varlamov [Mon, 8 Nov 2021 08:10:13 +0000 (00:10 -0800)]
[libc++][NFC] Inline most of `__vector_base` into `vector`.

`__vector_base` exists for historical reasons and cannot be eliminated
entirely without breaking the ABI. Member variables are left
untouched -- this patch only does changes that clearly cannot affect the
ABI.

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

2 years agoRevert "[libc++] Always define a key function for std::bad_function_call in the dylib"
Konstantin Varlamov [Mon, 8 Nov 2021 08:44:17 +0000 (00:44 -0800)]
Revert "[libc++] Always define a key function for std::bad_function_call in the dylib"

This reverts commit bc74231756d6c317505a9fa4c5a269134687ae56. It was
committed accidentally.

2 years ago[fir] Add test for FIR types conversion
Valentin Clement [Mon, 8 Nov 2021 08:41:19 +0000 (09:41 +0100)]
[fir] Add test for FIR types conversion

Add a separate file to test FIR types conversion to LLVM types.
Conversion comes from `flang/lib/Optimizer/CodeGen/TypeConverter.h`

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

Reviewed By: kiranchandramohan, awarzynski

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

2 years ago[libc++] Always define a key function for std::bad_function_call in the dylib
Louis Dionne [Tue, 2 Nov 2021 19:14:48 +0000 (12:14 -0700)]
[libc++] Always define a key function for std::bad_function_call in the dylib

However, whether applications rely on the std::bad_function_call vtable
being in the dylib is still controlled by the ABI macro, since changing
that would be an ABI break.

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

2 years ago[AMDGPU] Test Commit. NFC
skc7 [Mon, 8 Nov 2021 05:37:19 +0000 (05:37 +0000)]
[AMDGPU] Test Commit. NFC

Reviewed By: hsmhsm

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

2 years ago[XCOFF][llvm-readobj] improve the relocation output.
Esme-Yi [Mon, 8 Nov 2021 03:15:52 +0000 (03:15 +0000)]
[XCOFF][llvm-readobj] improve the relocation output.

Summary:
1. implemented the unexpanded relocations output.
2. modified the expanded output format to align.

Reviewed By: shchenz, jhenderson

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

2 years ago[RISCV] Optimize (add (mul r, c0), c1)
Ben Shi [Tue, 5 Oct 2021 12:28:36 +0000 (12:28 +0000)]
[RISCV] Optimize (add (mul r, c0), c1)

Optimize (add (mul x, c0), c1) ->
         (add (mul (add x, c1/c0+1), c0), c1%c0-c0),
if c1/c0+1 and c1%c0-c0 are simm12, while c1 is not.

Optimize (add (mul x, c0), c1) ->
         (add (mul (add x, c1/c0-1), c0), c1%c0+c0),
if c1/c0-1 and c1%c0+c0 are simm12, while c1 is not.

Reviewed By: craig.topper, asb

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

2 years ago[PowerPC] comment for different input register classes; nfc
Chen Zheng [Mon, 8 Nov 2021 02:15:51 +0000 (02:15 +0000)]
[PowerPC] comment for different input register classes; nfc

Add comments to explain why XXPERMDIs and XXPERMDI have different input register
classes, vsfrc for XXPERMDIs and vsrc for XXPERMDI.

This addresses the comments in abandoned patch D113178, we keep using `f0` instead
of using `vs0` for XXPERMDIs on purpose.

2 years ago[CSKY] Add CSKY 16-bit instruction format and encoding
Zi Xuan Wu [Mon, 8 Nov 2021 02:02:15 +0000 (10:02 +0800)]
[CSKY] Add CSKY 16-bit instruction format and encoding

CSKY is a ARCH which supports mixture of 16-bit and 32-bit instructions natively,
and there is not an indivual predictor or feature to enable/disable 16-bit instruction.
So I think it's better to add 16-bit instruction early, and naturally to use 16-bit and 32-bit instructions.

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

2 years ago[AsmPrinter][ORE] use correct opcode name
Chen Zheng [Thu, 4 Nov 2021 07:47:39 +0000 (07:47 +0000)]
[AsmPrinter][ORE] use correct opcode name

Reviewed By: jsji

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

2 years ago[ORE][AsmPrinter] add testcase for D113173; NFC
Chen Zheng [Thu, 4 Nov 2021 07:39:29 +0000 (07:39 +0000)]
[ORE][AsmPrinter] add testcase for D113173; NFC

2 years ago[Transforms] Use make_early_inc_range (NFC)
Kazu Hirata [Mon, 8 Nov 2021 01:03:15 +0000 (17:03 -0800)]
[Transforms] Use make_early_inc_range (NFC)

2 years ago[X86][AVX2] Recognise 256-bit truncation shuffles and mask 256-bit source
Simon Pilgrim [Sun, 7 Nov 2021 21:24:55 +0000 (21:24 +0000)]
[X86][AVX2] Recognise 256-bit truncation shuffles and mask 256-bit source

For v8i16 shuffle patterns that are lowered with AND+PACKUS, check to see if the sources are from a 256-bit vector and perform the masking using BLENDW at the 256-bit level.

With the test changes we can see more examples of duplicate XMM/YMM zero vectors (PR26018) :(

2 years ago[fir] Add fir.extract_value and fir.insert_value conversion
Valentin Clement [Sun, 7 Nov 2021 13:43:00 +0000 (14:43 +0100)]
[fir] Add fir.extract_value and fir.insert_value conversion

This patch add the conversion pattern for fir.extract_value
and fir.insert_value. fir.extract_value is lowered to llvm.extractvalue
anf fir.insert_value is lowered to llvm.insertvalue.
This patch also adds the type conversion for the BoxType and RecordType
needed to have some comprehensive tests.

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

This patch was landed and reverted once.
TypeBuilderFunc getModel<Fortran::ISO::CFI_index_t>() was clashing
with getModel<long long> on windows since they both are 64 bits
signed interger. On linux CFI_index_t is long. Change CFI_index_t
to getModel<long>.

Reviewed By: awarzynski

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[ConstantRange] Add exact union/intersect (NFC)
Nikita Popov [Sun, 7 Nov 2021 20:14:21 +0000 (21:14 +0100)]
[ConstantRange] Add exact union/intersect (NFC)

For some optimizations on comparisons it's necessary that the
union/intersect is exact and not a superset. Add methods that
return Optional<ConstantRange> only if the result is exact.

For the sake of simplicity this is implemented by comparing
the subset and superset approximations for now, but it should be
possible to do this more directly, as unionWith() and intersectWith()
already distinguish the cases where the result is imprecise for the
preferred range type functionality.

2 years ago[ConstantRange] Support zero size in isSizeLargerThan()
Nikita Popov [Sun, 7 Nov 2021 20:21:41 +0000 (21:21 +0100)]
[ConstantRange] Support zero size in isSizeLargerThan()

From an API perspective, it does not make a lot of sense that 0
is not a valid argument to this function. Add the exact check needed
to support it.

2 years ago[lldb] Remove failures case from TestTaggedPointerCmd
Jonas Devlieghere [Sun, 7 Nov 2021 18:39:11 +0000 (10:39 -0800)]
[lldb] Remove failures case from TestTaggedPointerCmd

Somehow every pointer looks like it's tagged on GreenDragon. Removing
the check to unblock the bot until we can get to the bottom of this.

2 years ago[AArch64] Rewrite and update fcvt-fixed.ll. NFC
David Green [Sun, 7 Nov 2021 18:11:49 +0000 (18:11 +0000)]
[AArch64] Rewrite and update fcvt-fixed.ll. NFC

This rewrites the fcvt-fixed.ll test case to be separate functions, not
one large function with volatile global stores. It also adds fp16 and
fptoi.sat testing at the same time.

2 years ago[BasicAA] Use index size instead of pointer size
Nikita Popov [Sat, 23 Oct 2021 20:50:24 +0000 (22:50 +0200)]
[BasicAA] Use index size instead of pointer size

When accumulating the GEP offset in BasicAA, we should use the
pointer index size rather than the pointer size.

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

2 years ago[AMDGPU] Remove unused declaration selectSMRD (NFC)
Kazu Hirata [Sun, 7 Nov 2021 17:53:18 +0000 (09:53 -0800)]
[AMDGPU] Remove unused declaration selectSMRD (NFC)

The function body proper was removed on Feb 20, 2019 in commit
79b5c3842b684f873d1ffad502336e973616ea51.

2 years ago[ARM, X86] Use MachineBasicBlock::{predecessors,successors} (NFC)
Kazu Hirata [Sun, 7 Nov 2021 17:53:16 +0000 (09:53 -0800)]
[ARM, X86] Use MachineBasicBlock::{predecessors,successors} (NFC)

2 years ago[AST, Analysis] Use llvm::reverse (NFC)
Kazu Hirata [Sun, 7 Nov 2021 17:53:14 +0000 (09:53 -0800)]
[AST, Analysis] Use llvm::reverse (NFC)

2 years ago[compiler-rt] Produce the right arch suffix for arm baremetal
Manoj Gupta [Sun, 7 Nov 2021 02:14:42 +0000 (19:14 -0700)]
[compiler-rt] Produce the right arch suffix for arm baremetal

D98452 introduced a mismatch between clang expectations for
builtin name for baremetal targets on arm. Fix it by
adding a case for baremetal. This now matches the output of
"clang -target armv7m-none-eabi -print-libgcc-file-name \
-rtlib=compiler-rt"

Reviewed By: mstorsjo

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

2 years ago[AVR] Remove a global initializer. NFCI.
Benjamin Kramer [Sun, 7 Nov 2021 15:30:03 +0000 (16:30 +0100)]
[AVR] Remove a global initializer. NFCI.

2 years ago[libc++][doc] Don't mention Prague twice.
Mark de Wever [Sun, 7 Nov 2021 15:21:05 +0000 (16:21 +0100)]
[libc++][doc] Don't mention Prague twice.

2 years ago[libc++] Make test_allocator constexpr-friendly for constexpr string/vector
Nikolas Klauser [Sun, 7 Nov 2021 15:11:24 +0000 (16:11 +0100)]
[libc++] Make test_allocator constexpr-friendly for constexpr string/vector

Make test_allocator etc. constexpr-friendly so they can be used to test constexpr string and possibly constexpr vector

Reviewed By: Quuxplusone, #libc, ldionne

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

2 years ago[SLP] Fix Wdocumentation warning - remove \returns from void function. NFC.
Simon Pilgrim [Sun, 7 Nov 2021 15:08:39 +0000 (15:08 +0000)]
[SLP] Fix Wdocumentation warning - remove \returns from void function. NFC.

2 years ago[X86] Update RET/LRET instruction to use the same naming convention as IRET (PR36876...
Simon Pilgrim [Sun, 7 Nov 2021 15:06:54 +0000 (15:06 +0000)]
[X86] Update RET/LRET instruction to use the same naming convention as IRET (PR36876). NFC

Be more consistent in the naming convention for the various RET instructions to specify in terms of bitwidth.

Helps prevent future scheduler model mismatches like those that were only addressed in D44687.

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

2 years agoPut implementation details into anonymous namespaces. NFCI.
Benjamin Kramer [Sun, 7 Nov 2021 14:18:30 +0000 (15:18 +0100)]
Put implementation details into anonymous namespaces. NFCI.

2 years ago[clang] Use llvm::reverse. NFCI.
Benjamin Kramer [Sun, 7 Nov 2021 13:24:33 +0000 (14:24 +0100)]
[clang] Use llvm::reverse. NFCI.

2 years ago[X86][AVX] Add missing X86ISD::VBROADCAST(v4f32 -> v8f32) isel pattern for AVX1 targets
Simon Pilgrim [Sun, 7 Nov 2021 12:59:35 +0000 (12:59 +0000)]
[X86][AVX] Add missing X86ISD::VBROADCAST(v4f32 -> v8f32) isel pattern for AVX1 targets

D109434 addressed the v2f64 -> v4f64 case, an internal test has found an equivalent crash for the v4f32 -> v8f32 case.

2 years ago[X86] Add AVX512 test coverage to vselect-zero.ll
Simon Pilgrim [Sun, 7 Nov 2021 12:44:01 +0000 (12:44 +0000)]
[X86] Add AVX512 test coverage to vselect-zero.ll

Noticed on D113212

2 years ago[DAG] SimplifyVBinOp - replace FoldConstantVectorArithmetic with FoldConstantArithmetic
Simon Pilgrim [Fri, 5 Nov 2021 14:59:14 +0000 (14:59 +0000)]
[DAG] SimplifyVBinOp - replace FoldConstantVectorArithmetic with FoldConstantArithmetic

Currently FoldConstantArithmetic only handles binops, so replacing other uses of FoldConstantVectorArithmetic (in particular for SETCC nodes), still require more work.

2 years ago[NFC][Docs] Add missing Doxygen group comments for LLVM-C
Mats Larsen [Sun, 7 Nov 2021 11:23:17 +0000 (12:23 +0100)]
[NFC][Docs] Add missing Doxygen group comments for LLVM-C

The LLVM-C API is relatively small so we've previously added doxygen tags
so it's easier to navigate the LLVM-C web docs. Over the years, more
headers were added without proper doxygen tags, effectively hiding them
from the main LLVM-C doxygen page. This patch adds comments to headers
which did not have them.

Reviewed By: lhames

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

2 years ago[sanitizer][aarch64] Add cast to drop reliance on the type of uc_mcontext.__reserved
Fangrui Song [Sun, 7 Nov 2021 06:26:05 +0000 (22:26 -0800)]
[sanitizer][aarch64] Add cast to drop reliance on the type of uc_mcontext.__reserved

https://sourceware.org/bugzilla/show_bug.cgi?id=22742
uc_mcontext.__reserved probably should not be considered user visible API but
unfortunate it is: it is the only way to access cpu states of some Linux
asm/sigcontext.h extensions. That said, the declaration may be
long double __reserved[256]; (used by musl)
instead of
unsigned char __reserved[4096] __attribute__((__aligned__(16))); (glibc)
to avoid dependency on a GNU variable attribute.

2 years ago[hwasan] Replace _Unwind_Word with uintptr_t
Fangrui Song [Sun, 7 Nov 2021 05:34:50 +0000 (21:34 -0800)]
[hwasan] Replace _Unwind_Word with uintptr_t

GCC introduced `__attribute__((mode(unwind_word)))` to work around
Cell Broadband Engine SPU (which was removed from GCC in 2019-09),
which is irrelevant to hwasan.
_Unwind_GetGR/_Unwind_GetCFA from llvm-project/libunwind don't use unwind_word.

Using _Unwind_Word can lead to build failures if libunwind's unwind.h is
preferred over unwind.h in the Clang resource directory (e.g. built with GCC).

2 years ago[WebAssembly] Remove unused declaration SelectExternRefAddr (NFC)
Kazu Hirata [Sun, 7 Nov 2021 02:31:22 +0000 (18:31 -0800)]
[WebAssembly] Remove unused declaration SelectExternRefAddr (NFC)

2 years ago[AMDGPU] Use MachineBasicBlock::{predecessors,successors} (NFC)
Kazu Hirata [Sun, 7 Nov 2021 02:31:20 +0000 (18:31 -0800)]
[AMDGPU] Use MachineBasicBlock::{predecessors,successors} (NFC)

2 years ago[llvm] Use llvm::reverse (NFC)
Kazu Hirata [Sun, 7 Nov 2021 02:31:18 +0000 (18:31 -0800)]
[llvm] Use llvm::reverse (NFC)

2 years ago[Clang][Attr] fix a btf_type_attr CGDebugInfo codegen bug
Yonghong Song [Sun, 7 Nov 2021 00:46:40 +0000 (17:46 -0700)]
[Clang][Attr] fix a btf_type_attr CGDebugInfo codegen bug

Nathan Chancellor reported a crash due to commit
3466e00716e1 (Reland "[Attr] support btf_type_tag attribute").

The following test can reproduce the crash:
  $ cat efi.i
  typedef unsigned long efi_query_variable_info_t(int);
  typedef struct {
    struct {
      efi_query_variable_info_t __attribute__((regparm(0))) * query_variable_info;
    };
  } efi_runtime_services_t;
  efi_runtime_services_t efi_0;
  $ clang -m32 -O2 -g -c -o /dev/null efi.i

The reason is that FunctionTypeLoc.getParam(Idx) may return a
nullptr which should be checked before dereferencing the
result pointer. This patch fixed this issue.

2 years ago[yaml2obj][COFF] Make some PEHeader fields optional
Fangrui Song [Sat, 6 Nov 2021 23:39:59 +0000 (16:39 -0700)]
[yaml2obj][COFF] Make some PEHeader fields optional

This makes it easy to write tests where the irrelevant fields are not needed.

2 years ago[IR][ShuffleVector] Fix Wdangling-else warning in InstructionsTest
Luke Benes [Sat, 6 Nov 2021 21:06:55 +0000 (00:06 +0300)]
[IR][ShuffleVector] Fix Wdangling-else warning in InstructionsTest

Fix a dangling else that gcc-11 warned about. The EXPECT_EQ macro
expands to an if-else, so the whole construction contains a hidden
dangling else.

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

2 years ago[ConstantRange] Add getEquivalentICmp() variant with offset (NFCI)
Nikita Popov [Sat, 6 Nov 2021 20:56:53 +0000 (21:56 +0100)]
[ConstantRange] Add getEquivalentICmp() variant with offset (NFCI)

Add a variant of getEquivalentICmp() that produces an optional
offset. This allows us to create an equivalent icmp for all ranges.

Use this in the with.overflow folding code, which was doing this
adjustment separately -- this clarifies that the fold will indeed
always apply.

2 years ago[X86] Simplify a call to MachineBasicBlock::erase (NFC)
Kazu Hirata [Sat, 6 Nov 2021 20:08:25 +0000 (13:08 -0700)]
[X86] Simplify a call to MachineBasicBlock::erase (NFC)

2 years ago[Hexagon] Remove an extraneous variable (NFC)
Kazu Hirata [Sat, 6 Nov 2021 20:08:23 +0000 (13:08 -0700)]
[Hexagon] Remove an extraneous variable (NFC)

2 years ago[Target] Use llvm::reverse (NFC)
Kazu Hirata [Sat, 6 Nov 2021 20:08:21 +0000 (13:08 -0700)]
[Target] Use llvm::reverse (NFC)

2 years ago[InstSimplify] Remove incorrect icmp of gep fold (PR52429)
Nikita Popov [Sat, 6 Nov 2021 11:54:29 +0000 (12:54 +0100)]
[InstSimplify] Remove incorrect icmp of gep fold (PR52429)

As described in https://bugs.llvm.org/show_bug.cgi?id=52429 this
fold is incorrect, because inbounds only guarantees that the
pointers don't wrap in the unsigned space: It is possible that
the sign boundary is crossed by an object.

I'm dropping the fold entirely rather than adjusting it, because
computePointerICmp() fully subsumes it (just with correct predicate
handling).

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

2 years ago[llvm-objdump] Remove untested diagnostic "missing data dir for TLS table"
Fangrui Song [Sat, 6 Nov 2021 18:18:29 +0000 (11:18 -0700)]
[llvm-objdump] Remove untested diagnostic "missing data dir for TLS table"

2 years ago[SCEV] Make eraseValueFromMap() private (NFC)
Nikita Popov [Sat, 6 Nov 2021 16:12:18 +0000 (17:12 +0100)]
[SCEV] Make eraseValueFromMap() private (NFC)

The public API for this functionality is forgetValue(). There was
only one call from LoopVectorize, which was directly next to a
forgetValue() call and as such redundant.

2 years ago[NFC][X86][Costmodel] Add tests for i32/i64 replication shuffles
Roman Lebedev [Sat, 6 Nov 2021 14:12:00 +0000 (17:12 +0300)]
[NFC][X86][Costmodel] Add tests for i32/i64 replication shuffles

While this isn't what we eventually need (i8 or i1),
approaching from this end is more straight-forward.

2 years ago[Test][SLPVectorizer] Precommit test for PR52275
Anton Afanasyev [Sat, 6 Nov 2021 13:21:59 +0000 (16:21 +0300)]
[Test][SLPVectorizer] Precommit test for PR52275

2 years ago[MLIR][OpenMP] Added omp.sections and omp.section
Shraiysh Vaishay [Sat, 6 Nov 2021 13:21:35 +0000 (18:51 +0530)]
[MLIR][OpenMP] Added omp.sections and omp.section

Added omp.sections and omp.section operation according to the
section 2.8.1 of OpenMP Standard 5.0.

Reviewed By: kiranchandramohan

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

2 years ago[TTI][CostModel] `getUserCost()`: recognize replication shuffles and query their...
Roman Lebedev [Sat, 6 Nov 2021 13:45:15 +0000 (16:45 +0300)]
[TTI][CostModel] `getUserCost()`: recognize replication shuffles and query their cost

This finally creates proper test coverage for replication shuffles,
that are used by LV for conditional loads, and will allow to add
proper costmodel at least for AVX512.

Reviewed By: RKSimon

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

2 years ago[NFC][TTI] Add/extract `getReplicationShuffleCost()` method, deduplicate it's impleme...
Roman Lebedev [Sat, 6 Nov 2021 13:45:15 +0000 (16:45 +0300)]
[NFC][TTI] Add/extract `getReplicationShuffleCost()` method, deduplicate it's implementations

Hiding it in `getInterleavedMemoryOpCost()` is problematic for a number of reasons,
including testability and reuse, let's do better.

In a followup `getUserCost()` will be taught to use to to estimate the mask costs,
which will allow for better cost model tests for it.

Reviewed By: RKSimon

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

2 years ago[DAGCombiner] remove vselect fold that was accidentally added
Sanjay Patel [Sat, 6 Nov 2021 13:34:30 +0000 (09:34 -0400)]
[DAGCombiner] remove vselect fold that was accidentally added

This diff snuck into the unrelated:
025a2f73a319

It's a suggested follow-up for D113212, but I need to add test
coverage first.

2 years ago[InstCombine] match usub.sat from umax intrinsic
Sanjay Patel [Fri, 5 Nov 2021 21:32:24 +0000 (17:32 -0400)]
[InstCombine] match usub.sat from umax intrinsic

umax(X, Op1) - Op1 --> usub.sat(X, Op1)

https://alive2.llvm.org/ce/z/HpcGiJ

This happens in 2 or more steps with an icmp-select idiom
instead of an intrinsic. This is another step towards
canonicalization of the min/max intrinsics. See:
D98152

2 years ago[InstCombine] add tests for umax with sub; NFC
Sanjay Patel [Fri, 5 Nov 2021 20:40:02 +0000 (16:40 -0400)]
[InstCombine] add tests for umax with sub; NFC

2 years agoFix lit test failures in CodeGenCoroutines
hyeongyu kim [Sat, 6 Nov 2021 10:58:34 +0000 (19:58 +0900)]
Fix lit test failures in CodeGenCoroutines

2 years ago[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn...
hyeongyukim [Fri, 15 Oct 2021 10:26:07 +0000 (19:26 +0900)]
[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions.
I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default.

Test updates are made as a separate patch: D108453

Reviewed By: eugenis

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

[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default (2)

This patch updates test files after D105169.
Autogenerated test codes are changed by `utils/update_cc_test_checks.py,` and non-autogenerated test codes are changed as follows:

(1) I wrote a python script that (partially) updates the tests using regex: {F18594904} The script is not perfect, but I believe it gives hints about which patterns are updated to have `noundef` attached.

(2) The remaining tests are updated manually.

Reviewed By: eugenis

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

Resolve lit failures in clang after 8ca4b3e's land

Fix lit test failures in clang-ppc* and clang-x64-windows-msvc

Fix missing failures in clang-ppc64be* and retry fixing clang-x64-windows-msvc

Fix internal_clone(aarch64) inline assembly

2 years ago[Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)
Jason Rice [Fri, 5 Nov 2021 10:30:39 +0000 (12:30 +0200)]
[Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

The structured bindings decomposition of a non-dependent array in a dependent context (a template) were, upon instantiation, creating nested OpaqueValueExprs that would trigger assertions in CodeGen. Additionally the OpaqueValuesExpr's contained SourceExpr is being emitted in CodeGen, but there was no code for its transform in template instantiation. This would trigger other assertions such as when emitting a DeclRefExpr that refers to a VarDecl that is not marked as ODR-used.

This is all based on cursory deduction, but with the way the code flows from SemaTemplateInstantiate back to SemaInit, it is apparent that the nesting of OpaqueValueExpr is unintentional.

This commit fixes https://bugs.llvm.org/show_bug.cgi?id=45964 and possible other issues involving OpaqueValueExprs in template instantiations might be resolved.

Reviewed By: aaron.ballman, rjmccall

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

2 years ago[sanitizer] Intercept lstat on Linux
Vitaly Buka [Sat, 6 Nov 2021 07:49:51 +0000 (00:49 -0700)]
[sanitizer] Intercept lstat on Linux

It's availible from GLIBC 2.33
Fixes use-of-uninitialized-value llvm/lib/Support/Unix/Path.inc:467:29 in llvm::sys::fs::remove(llvm::Twine const&, bool)

2 years ago[clang-tidy] run-clang-tidy.py: analyze unique files only
Serikzhan Kazi [Sat, 6 Nov 2021 06:53:18 +0000 (19:53 +1300)]
[clang-tidy] run-clang-tidy.py: analyze unique files only

The files in compile-commands.json can potentially include duplicates.
Change run-clang-tidy.py so that it does not run on the duplicate entries.

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

2 years agoRevert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis...
Juneyoung Lee [Sat, 6 Nov 2021 06:39:19 +0000 (15:39 +0900)]
Revert "[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default"

This reverts commit 7584ef766a7219b6ee5a400637206d26e0fa98ac.

2 years ago[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn...
Juneyoung Lee [Sat, 6 Nov 2021 06:34:49 +0000 (15:34 +0900)]
[Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

Turning on `enable_noundef_analysis` flag allows better codegen by removing freeze instructions.
I modified clang by renaming `enable_noundef_analysis` flag to `disable-noundef-analysis` and turning it off by default.

Test updates are made as a separate patch: D108453

Reviewed By: eugenis

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

2 years ago[lldb] Fix C2360: initialization of 'identifier' is skipped by 'case' label
Jonas Devlieghere [Sat, 6 Nov 2021 06:08:27 +0000 (23:08 -0700)]
[lldb] Fix C2360: initialization of 'identifier' is skipped by 'case' label

Make sure that every case has its own lexical block.

2 years agoFix lld test after dwarfdump array syntax change
David Blaikie [Sat, 6 Nov 2021 06:00:05 +0000 (23:00 -0700)]
Fix lld test after dwarfdump array syntax change

2 years ago[lldb] Don't set the OS for ARMGetSupportedArchitectureAtIndex
Jonas Devlieghere [Sat, 6 Nov 2021 05:07:54 +0000 (22:07 -0700)]
[lldb] Don't set the OS for ARMGetSupportedArchitectureAtIndex

Don't set the OS when computing supported architectures in
PlatformDarwin::ARMGetSupportedArchitectureAtIndex.

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

2 years agoDebugInfo: Simplified Template Names: drop unneeded space in arrays
David Blaikie [Sat, 6 Nov 2021 05:49:54 +0000 (22:49 -0700)]
DebugInfo: Simplified Template Names: drop unneeded space in arrays

Matching a recent clang change I've made, now 'int[3]' is formatted
without the space between the type and array bound. This commit updates
libDebugInfoDWARF/llvm-dwarfdump to match that formatting.

2 years ago[lldb] Remove 'result' variable which is set but not used (NFC)
Jonas Devlieghere [Sat, 6 Nov 2021 03:41:28 +0000 (20:41 -0700)]
[lldb] Remove 'result' variable which is set but not used (NFC)

2 years ago[lldb] Remove nested switches from ARMGetSupportedArchitectureAtIndex (NFC)
Jonas Devlieghere [Sat, 6 Nov 2021 03:31:07 +0000 (20:31 -0700)]
[lldb] Remove nested switches from ARMGetSupportedArchitectureAtIndex (NFC)

Remove the nested switches from the ARMGetSupportedArchitectureAtIndex
implementation.

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

2 years agoRevert "[libcxxabi][ARM] Make CXX_end_cleanup compatible with Armv6-M"
Vladimir Vereschaka [Sat, 6 Nov 2021 03:58:21 +0000 (20:58 -0700)]
Revert "[libcxxabi][ARM] Make CXX_end_cleanup compatible with Armv6-M"

This reverts commit 3255578ee1dbb5561025ac89cd33ba08e8f26efb.

Failed buildbot's Armv7 builds:
https://lab.llvm.org/buildbot/#/builders/60/builds/5303

2 years ago[RISCV]: Fix typo by abstracting VWholeLoad* classes
Bin Cheng [Thu, 4 Nov 2021 10:07:24 +0000 (18:07 +0800)]
[RISCV]: Fix typo by abstracting VWholeLoad* classes

This patch abstracts VWholeLoad* classes into VWholeLoadN, simplifies
existing code as well as fixes a typo.

Reviewed By: craig.topper

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

2 years ago[RISCV][NFC]: Refactor classes for load/store instructions of RVV
Bin Cheng [Thu, 4 Nov 2021 10:05:48 +0000 (18:05 +0800)]
[RISCV][NFC]: Refactor classes for load/store instructions of RVV

This patch refactors classes for load/store of V extension by:
- Introduce new class for VUnitStrideLoadFF and VUnitStrideSegmentLoadFF
  so that uses of L/SUMOP* are not spread around different places.
- Reorder classes for Unit-Stride load/store in line with table
  describing lumop/sumop in riscv-v-spec.pdf.

Reviewed By: HsiangKai, craig.topper

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

2 years ago[llvm] Use make_early_inc_range (NFC)
Kazu Hirata [Sat, 6 Nov 2021 02:39:06 +0000 (19:39 -0700)]
[llvm] Use make_early_inc_range (NFC)

2 years ago[Transforms] Fix a warning
Kazu Hirata [Sat, 6 Nov 2021 02:30:14 +0000 (19:30 -0700)]
[Transforms] Fix a warning

This patch fixes:

  mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp:124:3:
  error: default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

by removing the default case.

2 years ago[llvm-profgen] Fix index out of bounds error while using ip.advance
wlei [Fri, 5 Nov 2021 03:51:04 +0000 (20:51 -0700)]
[llvm-profgen] Fix index out of bounds error while using ip.advance

Previously we assume there're some non-executing sections at the bottom of the text section so that we won't hit the array's bound. But on BOLTed binary, it turned out .bolt section is at the bottom of text section which can be profiled, then it crash llvm-profgen. This change try to fix it.

Reviewed By: hoy, wenlei

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

2 years ago[mlir][sparse] Factoring magic numbers into a header
wren romano [Fri, 5 Nov 2021 22:15:39 +0000 (15:15 -0700)]
[mlir][sparse] Factoring magic numbers into a header

Addresses https://bugs.llvm.org/show_bug.cgi?id=52303

Reviewed By: aartbik

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

2 years agoDWARF Simplified Template Names: Narrow down the handling for operator overloads
David Blaikie [Fri, 5 Nov 2021 22:28:23 +0000 (15:28 -0700)]
DWARF Simplified Template Names: Narrow down the handling for operator overloads

Actually we can, for now, remove the explicit "operator" handling
entirely - since clang currently won't try to flag any of these as
rebuildable. That seems like a reasonable state for now, but it could be
narrowed down to only apply to conversion operators, most likely - but
would need more nuance for op> and op>> since they would be incorrectly
flagged as already having their template arguments (due to the trailing
'>').

2 years ago[SCEV] Use constant range of RHS to prove NUW on narrow IV in trip count logic
Philip Reames [Fri, 5 Nov 2021 22:35:53 +0000 (15:35 -0700)]
[SCEV] Use constant range of RHS to prove NUW on narrow IV in trip count logic

The basic idea here is that given a zero extended narrow IV, we can prove the inner IV to be NUW if we can prove there's a value the inner IV must take before overflow which must exit the loop.

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

2 years ago[libFuzzer] Disable Msan on InternalStrnlen
Vitaly Buka [Fri, 5 Nov 2021 22:09:45 +0000 (15:09 -0700)]
[libFuzzer] Disable Msan on InternalStrnlen

It's called from ATTRIBUTE_NO_SANITIZE_MEMORY code.
It worked as expected if inlined and complained otherwise.

Reviewed By: eugenis

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

2 years agoIn spir functions, llvm.dbg.declare intrinsics created
Zahira Ammarguellat [Mon, 1 Nov 2021 21:08:08 +0000 (14:08 -0700)]
In spir functions, llvm.dbg.declare intrinsics created
for parameters and locals need to refer to the stack
allocation in the alloca address space.

2 years ago[NFC][CostModel] Add exhaustive test coverage for replication shuffles
Roman Lebedev [Fri, 5 Nov 2021 21:53:08 +0000 (00:53 +0300)]
[NFC][CostModel] Add exhaustive test coverage for replication shuffles

This coverage has been brought to you by https://godbolt.org/z/nfc3cY1za

2 years ago[NFC][Verifier] Remove redundant Module parameters
Scott Linder [Thu, 4 Nov 2021 15:22:48 +0000 (15:22 +0000)]
[NFC][Verifier] Remove redundant Module parameters

These `M` parameters shadow the `M` member in `VerifierSupport`, and
both always refer to the same module. Eliminate the redundant parameters
and always use the member.

Reviewed By: dexonsmith

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

2 years ago[TwoAddressInstructionPass] Update existing physreg live intervals
Jay Foad [Thu, 4 Nov 2021 13:43:09 +0000 (13:43 +0000)]
[TwoAddressInstructionPass] Update existing physreg live intervals

In TwoAddressInstructionPass::processTiedPairs with
-early-live-intervals, update any preexisting physreg live intervals,
as well as virtreg live intervals. By default (without
-precompute-phys-liveness) physreg live intervals only exist for
registers that are live-in to some basic block.

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