platform/upstream/llvm.git
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

2 years agoRevert "[fir] Add fir.extract_value and fir.insert_value conversion"
Valentin Clement [Fri, 5 Nov 2021 21:16:37 +0000 (22:16 +0100)]
Revert "[fir] Add fir.extract_value and fir.insert_value conversion"

This reverts commit ea55503d7ca5b6ded73b0fd01a8c528f68e00521.

2 years ago[clang][asan] Add test for ensuring PR52382 is fixed
Leonard Chan [Fri, 5 Nov 2021 21:08:09 +0000 (14:08 -0700)]
[clang][asan] Add test for ensuring PR52382 is fixed

The fix for PR52382 was already introduced in D112732 which ensures that module
instrumentation always runs after function instrumentation. This adds a test
that ensures the PR is addressed and prevent regression.

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

2 years ago[IR] Improve member `ShuffleVectorInst::isReplicationMask()`
Roman Lebedev [Fri, 5 Nov 2021 16:11:55 +0000 (19:11 +0300)]
[IR] Improve member `ShuffleVectorInst::isReplicationMask()`

When we have an actual shuffle, we can impose the additional restriction
that the mask replicates the elements of the first operand, so we know
the replication factor as a ratio of output and op0 vector sizes.

2 years ago[lldb] Use std::string instead of llvm::Twine in GDBRemoteCommunicationClient
Jonas Devlieghere [Fri, 5 Nov 2021 20:18:06 +0000 (13:18 -0700)]
[lldb] Use std::string instead of llvm::Twine in GDBRemoteCommunicationClient

From the documentation:

  A Twine is not intended for use directly and should not be stored, its
  implementation relies on the ability to store pointers to temporary
  stack objects which may be deallocated at the end of a statement.
  Twines should only be used accepted as const references in arguments,
  when an API wishes to accept possibly-concatenated strings.

rdar://84799118

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

2 years ago[lldb] Improve 'lang objc tagged-pointer info' command
Jonas Devlieghere [Fri, 5 Nov 2021 20:13:41 +0000 (13:13 -0700)]
[lldb] Improve 'lang objc tagged-pointer info' command

Don't try to get a class descriptor for a pointer that doesn't look like
a tagged pointer. Also print addresses as fixed-width hex and update the
test.

2 years ago[libc++] Fix hang in counting_semaphore::try_acquire
Arthur O'Dwyer [Thu, 4 Nov 2021 21:58:33 +0000 (17:58 -0400)]
[libc++] Fix hang in counting_semaphore::try_acquire

Before this patch, `try_acquire` blocks instead of returning false.
This is because `__libcpp_thread_poll_with_backoff` interprets zero
as meaning infinite, causing `try_acquire` to wait indefinitely.

Thanks to Pablo Busse (pabusse) for the patch!

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

2 years agoAdd some support for pretty printing Twines containing std::string in gdb
David Blaikie [Fri, 5 Nov 2021 19:54:39 +0000 (12:54 -0700)]
Add some support for pretty printing Twines containing std::string in gdb

This isn't perfect, since it doesn't use lazy_string - so if the
std::string does contain unprintable characters it might fail, but seems
better than nothing & LLVM doesn't generally store binary data in
std::strings.

2 years ago[mlir][sparse] run more integration tests with and without SIMD
Aart Bik [Thu, 4 Nov 2021 17:28:32 +0000 (10:28 -0700)]
[mlir][sparse] run more integration tests with and without SIMD

Reviewed By: wrengr

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

2 years ago[lldb] Use is_style_posix() for path style checks
Martin Storsjö [Fri, 5 Nov 2021 09:12:22 +0000 (11:12 +0200)]
[lldb] Use is_style_posix() for path style checks

Since a8b54834a186f5570b49b614e31b961a9cf1cbfe, there are two
distinct Windows path styles, `windows_backslash` (with the old
`windows` being an alias for it) and `windows_slash`.
4e4883e1f394f7c47ff3adee48039aa8374bb8d0 added helpers for
inspecting path styles.

The newly added windows_slash path style doesn't end up used in
LLDB yet anyway, as LLDB is quite decoupled from most of
llvm::sys::path and uses its own FileSpec class. To take it in
use, it could be hooked up in `FileSpec::Style::GetNativeStyle`
(in lldb/source/Utility/FileSpec.cpp) just like in the `real_style`
function in llvm/lib/Support/Path.cpp in
df0ba47c36f6bd0865e3286853b76d37e037c2d7.

It is not currently clear whether there's a real need for using
the Windows path style with forward slashes in LLDB (if there's any
other applications interacting with it, expecting that style), and
what other changes in LLDB are needed for that to work, but this
at least makes some of the checks more ready for the new style,
simplifying code a bit.

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

2 years ago[unittests] [DWARF] Generalize path separator expectations
Martin Storsjö [Thu, 7 Oct 2021 11:31:32 +0000 (11:31 +0000)]
[unittests] [DWARF] Generalize path separator expectations

This fixes unit tests if running on Windows with a build configured
to prefer forward slashes.

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

2 years ago[DebugInfo] [PDB] Force injected source paths to use backslashes
Martin Storsjö [Thu, 7 Oct 2021 10:36:46 +0000 (10:36 +0000)]
[DebugInfo] [PDB] Force injected source paths to use backslashes

This fixes lld/COFF/pdb-natvis.test (which only is run on Windows)
when using paths with forward slashes on Windows.

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

2 years ago[fir] Remove getModel<Fortran::ISO::CFI_dim_t> in DescriptorModel.h
Valentin Clement [Fri, 5 Nov 2021 19:49:09 +0000 (20:49 +0100)]
[fir] Remove getModel<Fortran::ISO::CFI_dim_t> in DescriptorModel.h

A windows buildbot complains about previous definiton after D112961.

Remove the extra definition until we can figure out if really needed.

2 years agoAutogen tests for ease of future update
Philip Reames [Fri, 5 Nov 2021 19:34:08 +0000 (12:34 -0700)]
Autogen tests for ease of future update

2 years ago[libcxx] [test] Narrow down XFAILs regarding a MSVC mode specific bug to "windows...
Martin Storsjö [Fri, 22 Oct 2021 21:48:54 +0000 (00:48 +0300)]
[libcxx] [test] Narrow down XFAILs regarding a MSVC mode specific bug to "windows-dll && msvc"

These tests don't fail when only windows-dll is set in mingw mode, as the
bug is specific to MSVC mode.

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

2 years ago[DAGCombiner] add fold for vselect based on mask of signbit, part 2
Sanjay Patel [Fri, 5 Nov 2021 17:28:35 +0000 (13:28 -0400)]
[DAGCombiner] add fold for vselect based on mask of signbit, part 2

This is the 'or' sibling for the fold added with:
D113212

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

Note that neither of these transforms is poison-safe,
but it does not seem to matter at this level. We have
had the scalar version of D113212 for a long time, so
this is just making optimizer behavior consistent.

We do not have the scalar version of *this* fold,
however, so that is another follow-up.

2 years ago[AArch] add tests for vselect; NFC
Sanjay Patel [Fri, 5 Nov 2021 16:46:56 +0000 (12:46 -0400)]
[AArch] add tests for vselect; NFC

These are copy/pasted from the related test patterns in D113212.

2 years ago[x86] add tests for vector select; NFC
Sanjay Patel [Fri, 5 Nov 2021 16:42:22 +0000 (12:42 -0400)]
[x86] add tests for vector select; NFC

2 years ago[mlir][DialectConversion] Legalize all live argument conversions
River Riddle [Fri, 5 Nov 2021 18:43:26 +0000 (18:43 +0000)]
[mlir][DialectConversion] Legalize all live argument conversions

Previously we didn't materialize conversions for arguments in certain
cases as the implicit type propagation was being heavily relied on
by many patterns. Now that those patterns have been fixed to
properly handle type conversions, we can drop the special behavior.

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

2 years agoReland "[Attr] support btf_type_tag attribute"
Yonghong Song [Fri, 5 Nov 2021 18:01:31 +0000 (11:01 -0700)]
Reland "[Attr] support btf_type_tag attribute"

This is to revert commit f95bd18b5faa (Revert "[Attr] support
btf_type_tag attribute") plus a bug fix.

Previous change failed to handle cases like below:
    $ cat reduced.c
    void a(*);
    void a() {}
    $ clang -c reduced.c -O2 -g

In such cases, during clang IR generation, for function a(),
CGCodeGen has numParams = 1 for FunctionType. But for
FunctionTypeLoc we have FuncTypeLoc.NumParams = 0. By using
FunctionType.numParams as the bound to access FuncTypeLoc
params, a random crash is triggered. The bug fix is to
check against FuncTypeLoc.NumParams before accessing
FuncTypeLoc.getParam(Idx).

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