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

2 years ago[AArch64][GISel] Optimize 8 and 16 bit variants of uaddo.
Florian Hahn [Fri, 5 Nov 2021 16:45:49 +0000 (17:45 +0100)]
[AArch64][GISel] Optimize 8 and 16 bit variants of uaddo.

Try simplify G_UADDO with 8 or 16 bit operands to wide G_ADD and TBNZ if
result is only used in the no-overflow case. It is restricted to cases
where we know that the high-bits of the operands are 0. If there's an
overflow, then the the 9th or 17th bit must be set, which can be checked
using TBNZ.

Reviewed By: paquette

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

2 years ago[mlir] Add callback to provide a pass pipeline to MlirOptMain
Deepak Panickal [Fri, 5 Nov 2021 17:39:57 +0000 (17:39 +0000)]
[mlir] Add callback to provide a pass pipeline to MlirOptMain

The callback can be used to provide a default pass pipeline.

Reviewed By: mehdi_amini, rriddle

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

2 years ago[RISCV] Support Zfhmin extension
Shao-Ce SUN [Fri, 5 Nov 2021 17:39:14 +0000 (01:39 +0800)]
[RISCV] Support Zfhmin extension

According to RISC-V Unprivileged ISA 15.6.

Reviewed By: asb

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

2 years ago[libomptarget] Drop remote plugin cmake version requirement to match llvm
Jon Chesterfield [Fri, 5 Nov 2021 17:34:27 +0000 (17:34 +0000)]
[libomptarget] Drop remote plugin cmake version requirement to match llvm

LLVM docs at https://llvm.org/docs/CMake.html#quick-start state 3.13.4

Reviewed By: atmnpatel

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

2 years ago[AIX][Clang] Fix XL product name in AIX XL compatibility warning
Zarko Todorovski [Fri, 5 Nov 2021 16:37:42 +0000 (12:37 -0400)]
[AIX][Clang] Fix XL product name in AIX XL compatibility warning

Correct the XLC/C++ version in the warning message to use the information from
XL's -qversion output.

Reviewed By: rzurob

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

2 years ago[mlir][sparse] test for SIMD reduction chaining in consecutive vector loops
Aart Bik [Thu, 4 Nov 2021 16:22:34 +0000 (09:22 -0700)]
[mlir][sparse] test for SIMD reduction chaining in consecutive vector loops

Reviewed By: bixia

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

2 years agosanitizer: Fix -Wpedantic GCC warning
Martin Liska [Fri, 5 Nov 2021 16:04:12 +0000 (17:04 +0100)]
sanitizer: Fix -Wpedantic GCC warning

Fixes:
sanitizer_stacktrace.h:212:5: warning: ISO C++ forbids braced-groups within expressions [-Wpedantic]

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

2 years ago[llvm-readobj] Display DT_RELRSZ/DT_RELRENT as " (bytes)"
Fangrui Song [Fri, 5 Nov 2021 17:02:49 +0000 (10:02 -0700)]
[llvm-readobj] Display DT_RELRSZ/DT_RELRENT as " (bytes)"

to match RELSZ/RELENT.

Reviewed By: jhenderson

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

2 years ago[gn build] Use `=` for of -fdebug-compilation-dir
Nico Weber [Fri, 5 Nov 2021 16:43:06 +0000 (12:43 -0400)]
[gn build] Use `=` for of -fdebug-compilation-dir

-f flags usually use the `=` form. -fdebug-compilation-dir= has been
around for a few months now (since 0c2bb6b446c584ab, both LLVM 12.0
and 13.0 have it), so using it shouldn't be a big problem -- especially
since use_relative_paths_in_debug_info is opt-in anyways.

2 years ago[polly] Properly create and initialize new PM analysis managers
Arthur Eubanks [Fri, 5 Nov 2021 16:31:14 +0000 (09:31 -0700)]
[polly] Properly create and initialize new PM analysis managers

If we don't properly initialize all the analysis managers, we may be
missing analyses that other analyses depend on.

Fixes broken polly test, e.g.
https://lab.llvm.org/buildbot/#/builders/10/builds/7501.

2 years ago[clang] [Objective C] Inclusive language: use objcmt-allowlist-dir-path=<arg> instead...
Zarko Todorovski [Fri, 5 Nov 2021 15:27:59 +0000 (11:27 -0400)]
[clang] [Objective C] Inclusive language: use objcmt-allowlist-dir-path=<arg> instead of objcmt-white-list-dir-path=<arg>

Trying to update some options that don't at least have an inclusive language version.
This patch adds `objcmt-allowlist-dir-path` as a default alternative.

Reviewed By: akyrtzi

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

2 years ago[NFCI] InstructionTest: trim `InstructionsTest.ShuffleMaskIsReplicationMask_*` complexity
Roman Lebedev [Fri, 5 Nov 2021 16:22:27 +0000 (19:22 +0300)]
[NFCI] InstructionTest: trim `InstructionsTest.ShuffleMaskIsReplicationMask_*` complexity

These tests have pretty high O() complexity due to their nature,
which leads to potentially-long runtimes.

While in release build for me they took ~1 and ~2 sec,
as noted in https://reviews.llvm.org/D113214#inline-1080479
they take minutes in debug build.

Fine-tune the amount of permutations they deal with,
without affecting the test coverage. After this,
they take <~10ms each for me (in release build),
hopefully that is good-enough for debug build too.

2 years ago[NFC] Fix typo in comment for `isReplicationMask()`
Roman Lebedev [Fri, 5 Nov 2021 16:13:06 +0000 (19:13 +0300)]
[NFC] Fix typo in comment for `isReplicationMask()`

This was mentioned in https://reviews.llvm.org/D113214#inline-1080385
but i forgot to stage the change before committing.

2 years ago[Target] Use make_early_inc_range (NFC)
Kazu Hirata [Fri, 5 Nov 2021 16:14:32 +0000 (09:14 -0700)]
[Target] Use make_early_inc_range (NFC)

2 years agoAdd NoOpLoopNestPass and LOOPNEST_PASS macro
Whitney Tsang [Fri, 5 Nov 2021 15:19:56 +0000 (15:19 +0000)]
Add NoOpLoopNestPass and LOOPNEST_PASS macro

Having a NoOpLoopNestPass can ensure that only outermost loop is invoked
for a LoopNestPass with a lit test.

There are some existing passes that are implemented as LoopNestPass, but
they are still using LOOP_PASS macro.
It would be easier to identify LoopNestPasses with a LOOPNEST_PASS
macro.

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

2 years ago[RISCV] Enable FP extensions and ABI on fixed-vectors-bitcast.ll.
Craig Topper [Thu, 4 Nov 2021 21:55:22 +0000 (14:55 -0700)]
[RISCV] Enable FP extensions and ABI on fixed-vectors-bitcast.ll.

This improves our type coverage. We were only testing integer
insert and extract before due to the FP types not being enabled for
arguments and returns.

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

2 years ago[BranchRelaxation] Fix warning on unused variable. NFC.
Michael Liao [Fri, 5 Nov 2021 14:47:10 +0000 (10:47 -0400)]
[BranchRelaxation] Fix warning on unused variable. NFC.

2 years ago[InstCombine] Generalize sadd.sat combine to compute sign bits.
David Green [Fri, 5 Nov 2021 15:05:09 +0000 (15:05 +0000)]
[InstCombine] Generalize sadd.sat combine to compute sign bits.

There is a combine in instcombine to transform a saturated add/sub into
a saddsat/ssubsat, currently handling inputs which are both sign
extended (https://alive2.llvm.org/ce/z/68qpTn). This can generalize to,
for example ashr of at least the bitwidth (https://alive2.llvm.org/ce/z/4TFyX-
and https://alive2.llvm.org/ce/z/qDWzFs for example). Which means it
generalizes further to "the number of sign bits", needing to be enough
to truncate to the size of the saturate. (An example using `or` for
instance: https://alive2.llvm.org/ce/z/EI_h_A).

So this patch makes use of ComputeNumSignBits (with the newly added
ComputeMinSignedBits) in matchSAddSubSat to generalize the fold to any
inputs with enough sign bits known, truncating the inputs to the new
size of the saturate.

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

2 years ago[fir] Add fir.extract_value and fir.insert_value conversion
Valentin Clement [Fri, 5 Nov 2021 14:52:50 +0000 (15:52 +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.

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[gn build] Reformat all files
Nico Weber [Fri, 5 Nov 2021 14:50:24 +0000 (10:50 -0400)]
[gn build] Reformat all files

Ran `git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format`.
No behavior change.

2 years ago[clang] 'unused-but-set-variable' warning should not apply to __block objective-c...
Alex Lorenz [Fri, 5 Nov 2021 05:01:33 +0000 (22:01 -0700)]
[clang] 'unused-but-set-variable' warning should not apply to __block objective-c pointers

The __block Objective-C pointers can be set but not used due to a commonly used lifetime extension pattern in Objective-C.

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

2 years ago[gn build] Use build-machine-independent paths in coverage information
Nico Weber [Fri, 5 Nov 2021 14:42:07 +0000 (10:42 -0400)]
[gn build] Use build-machine-independent paths in coverage information

This is possible after D106314 / 8773822c578a.

Makes the required prepare-code-coverage-artifact.py invocation a bit longer,
but that seems like a good tradeoff.

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

2 years agoExtend timeout of llvm/unittests:ir_tests
Tres Popp [Fri, 5 Nov 2021 14:42:47 +0000 (15:42 +0100)]
Extend timeout of llvm/unittests:ir_tests

This test became much slower after 01d8759ac9

2 years ago[ValueTracking][InstCombine] Introduce and use ComputeMinSignedBits
David Green [Fri, 5 Nov 2021 14:41:37 +0000 (14:41 +0000)]
[ValueTracking][InstCombine] Introduce and use ComputeMinSignedBits

This introduces a new ComputeMinSignedBits method for ValueTracking that
returns the BitWidth - SignBits + 1 from ComputeSignBits, and represents
the minimum bit size for the value as a signed integer.  Similar to the
existing APInt::getMinSignedBits method, this can make some of the
reasoning around ComputeSignBits more natural.

See https://reviews.llvm.org/D112298

2 years ago[DAG] FoldConstantVectorArithmetic - remove SDNodeFlags argument
Simon Pilgrim [Fri, 5 Nov 2021 14:36:17 +0000 (14:36 +0000)]
[DAG] FoldConstantVectorArithmetic - remove SDNodeFlags argument

Another minor step towards merging FoldConstantVectorArithmetic into FoldConstantArithmetic.

We don't use SDNodeFlags in any constant folding inside DAG, so passing the Flags argument is a waste of time - an alternative would be to wire up FoldConstantArithmetic to take SDNodeFlags just-in-case we someday start using it, but we don't have any way to test it and I'd prefer to avoid dead code.

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

2 years ago[X86] `X86TTIImpl::getInterleavedMemoryOpCostAVX512()`: mask is i8 not i1
Roman Lebedev [Fri, 5 Nov 2021 14:26:21 +0000 (17:26 +0300)]
[X86] `X86TTIImpl::getInterleavedMemoryOpCostAVX512()`: mask is i8 not i1

Even though AVX512's masked mem ops (unlike AVX1/2) have a mask
that is a `VF x i1`, replication of said masks happens after
promotion of it to `VF x i8`, so we should use `i8`, not `i1`,
when calculating the cost of mask replication.