platform/upstream/llvm.git
2 years ago[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]
Chris Jackson [Thu, 28 Apr 2022 11:52:03 +0000 (12:52 +0100)]
[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]

Reland commit 74273d575f9938d751a1c67862cffe553fe2de8b following a fix
for a memory leak. The DVIRecoveryRecord vectors now use unique_ptr.

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

2 years agore-roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".""
Devin Jeanpierre [Thu, 28 Apr 2022 12:02:36 +0000 (14:02 +0200)]
re-roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".""

This reverts commit b0bc93da926a943cdc2d8b04f8dcbe23a774520c.

Changes: `s/_WIN32/_WIN64/g` in clang/test/SemaCXX/attr-trivial-abi.cpp.

The calling convention is specific to 64-bit windows. It's even in the name: `CCK_MicrosoftWin64`.

After this, the test passes with both `-triple i686-pc-win32` and `-triple x86_64-pc-win32`. Phew!

Reviewed By: gribozavr2

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

2 years ago[InstCombine] Add tests for or of icmp trunc/and (NFC)
Nikita Popov [Thu, 28 Apr 2022 12:40:42 +0000 (14:40 +0200)]
[InstCombine] Add tests for or of icmp trunc/and (NFC)

2 years ago[Sema][SVE2] Move/simplify Sema testing for SVE2 ACLE builtins
Rosie Sumpter [Tue, 12 Apr 2022 12:17:49 +0000 (13:17 +0100)]
[Sema][SVE2] Move/simplify Sema testing for SVE2 ACLE builtins

Currently for SVE2 ACLE builtins, single tests are used to verify both
clang code generation (when the feature is available) and semantic
error/warning messages (when the feature is unavailable). This WIP
patch moves the semantic testing for the values of immediate arguments
into dedicated Sema tests.

2 years ago[gn build] (manually) port 0f1b5f115a7f
Nico Weber [Thu, 28 Apr 2022 12:39:12 +0000 (08:39 -0400)]
[gn build] (manually) port 0f1b5f115a7f

2 years ago[clangd] Record latency for ASTSignal derivation
Kadir Cetinkaya [Thu, 28 Apr 2022 12:27:43 +0000 (14:27 +0200)]
[clangd] Record latency for ASTSignal derivation

2 years agoUse `-text` git attribute instead of `text eol=...`
Michael Forster [Thu, 28 Apr 2022 10:54:49 +0000 (12:54 +0200)]
Use `-text` git attribute instead of `text eol=...`

These automatic conversions lead to issues in various workflows, and all
we want here are files that retain their line endings under all
circumstances. `-text` captures that perfectly well and leads to fewer
issues.

It is preferable to `binary`, because with `-text` we still get textual
diffs.

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

2 years ago[mlir][spirv] Remove layout decoration on unneeded storage classes
Lei Zhang [Thu, 28 Apr 2022 12:18:08 +0000 (08:18 -0400)]
[mlir][spirv] Remove layout decoration on unneeded storage classes

Per SPIR-V validation rules, explict layout decorations are only
needed for StorageBuffer, PhysicalStorageBuffer, Uniform, and
PushConstant storage classes. (And even that is for Shader
capabilities). So we don't need such decorations on the rest.

Reviewed By: hanchung

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

2 years ago[mlir][spirv] Convert memref.alloca to spv.Variable
Lei Zhang [Thu, 28 Apr 2022 12:13:22 +0000 (08:13 -0400)]
[mlir][spirv] Convert memref.alloca to spv.Variable

Reviewed By: hanchung

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

2 years ago[X86] Add test case for Issue #55158
Simon Pilgrim [Thu, 28 Apr 2022 12:06:48 +0000 (13:06 +0100)]
[X86] Add test case for Issue #55158

2 years ago[NVPTX] Integrate ptxas to LIT tests
Andrew Savonichev [Wed, 27 Apr 2022 19:43:55 +0000 (22:43 +0300)]
[NVPTX] Integrate ptxas to LIT tests

ptxas is a proprietary compiler from Nvidia that can compile PTX to
machine code (SASS). It has a lot of diagnostics to catch errors
in PTX, which can be used to verify PTX output from llc.

Set -DPXTAS_EXECUTABLE=/path/to/ptxas CMake option to enable it.
If this option is not set, then ptxas is substituted to true which
effectively disables all ptxas RUN lines.

LLVM_PTXAS_EXECUTABLE environment variable takes precedence over
the CMake option, and allows to override ptxas executable that is used for LIT
without complete re-configuration.

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

2 years ago[clang-tidy] support --load in clang-tidy-diff.py/run-clang-tidy.py
Bernhard Manfred Gruber [Fri, 8 Apr 2022 12:45:00 +0000 (14:45 +0200)]
[clang-tidy] support --load in clang-tidy-diff.py/run-clang-tidy.py

Support for loading shared objects as plugins into clang-tidy was added
in http://reviews.llvm.org/D111100. Unfortunately, the utility scripts
`clang-tidy-diff.py` and `run-clang-tidy.py` did not receive
corresponding arguments to forward such plugins to clang-tidy.
This diff adds a `-load=plugin` option to both scripts.

Differential Revision: http://reviews.llvm.org/D12306

Reviewed By: aaron.ballman

2 years ago[X86] getFauxShuffle - don't assume an UNDEF src element for AND/ANDNP results in...
Simon Pilgrim [Thu, 28 Apr 2022 11:32:58 +0000 (12:32 +0100)]
[X86] getFauxShuffle - don't assume an UNDEF src element for AND/ANDNP results in an UNDEF shuffle mask index

The other src element might be zero, guaranteeing zero.

Fixes #55157

2 years agoRevert rG8680dd5117b0c36f807fecc4360122ae1dd73b6d "[X86] getFauxShuffle - don't assum...
Simon Pilgrim [Thu, 28 Apr 2022 11:25:14 +0000 (12:25 +0100)]
Revert rG8680dd5117b0c36f807fecc4360122ae1dd73b6d "[X86] getFauxShuffle - don't assume an UNDEF src element for AND/ANDNP results in an UNDEF shuffle mask index"

I screwed up the merge somehow.

2 years ago[X86] getFauxShuffle - don't assume an UNDEF src element for AND/ANDNP results in...
Simon Pilgrim [Thu, 28 Apr 2022 10:54:18 +0000 (11:54 +0100)]
[X86] getFauxShuffle - don't assume an UNDEF src element for AND/ANDNP results in an UNDEF shuffle mask index

The other src element might be zero, guaranteeing zero.

Fixes #55157

2 years agoRevert "[llvm-pdbutil] Add options to only dump symbol record at specified offset...
Michael Forster [Thu, 28 Apr 2022 10:38:03 +0000 (12:38 +0200)]
Revert "[llvm-pdbutil] Add options to only dump symbol record at specified offset and its parents or children with spcified depth."

This reverts commit a3b7cb015fd5fd2aa98afda8ae22759576ce2888.

symbol-offset.test fails under MSAN:

[  1] ; RUN: llvm-pdbutil yaml2pdb %p/Inputs/symbol-offset.yaml --pdb=%t.pdb [FAIL]
llvm-pdbutil yaml2pdb <REDACTED>/llvm/test/tools/llvm-pdbutil/Inputs/symbol-offset.yaml --pdb=<REDACTED>/tmp/symbol-offset.test/symbol-offset.test.tmp.pdb
==9283==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x55f975e5eb91 in __libcpp_tls_set <REDACTED>/include/c++/v1/__threading_support:428:12
    #1 0x55f975e5eb91 in set_pointer <REDACTED>/include/c++/v1/thread:196:5
    #2 0x55f975e5eb91 in void* std::__msan::__thread_proxy<std::__msan::tuple<std::__msan::unique_ptr<std::__msan::__thread_struct, std::__msan::default_delete<std::__msan::__thread_struct> >, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()> >(void*) <REDACTED>/include/c++/v1/thread:285:27
    #3 0x7f74a1e55b54 in start_thread (<REDACTED>/libpthread.so.0+0xbb54) (BuildId: 64752de50ebd1a108f4b3f8d0d7e1a13)
    #4 0x7f74a1dc9f7e in clone (<REDACTED>/libc.so.6+0x13cf7e) (BuildId: 7cfed7708e5ab7fcb286b373de21ee76)

2 years ago[flang][driver] Fix spelling (nfc)
Andrzej Warzynski [Thu, 28 Apr 2022 10:07:13 +0000 (10:07 +0000)]
[flang][driver] Fix spelling (nfc)

Merely making sure that we use consistent spelling.

2 years ago[X86] Add test case for Issue #55157
Simon Pilgrim [Thu, 28 Apr 2022 10:18:37 +0000 (11:18 +0100)]
[X86] Add test case for Issue #55157

2 years ago[RS4GC] Add tests showing cases in which we could find a better base (NFC)
Dmitry Makogon [Thu, 28 Apr 2022 10:01:58 +0000 (17:01 +0700)]
[RS4GC] Add tests showing cases in which we could find a better base (NFC)

2 years ago[flang] Support FINDLOC/MAXLOC/MINLOC with scalar mask
Mike Kashkarov [Thu, 28 Apr 2022 09:57:51 +0000 (18:57 +0900)]
[flang] Support FINDLOC/MAXLOC/MINLOC with scalar mask

Previously MASK= elements were accessed in assumption that mask is an array of
input argument rank (and in combination with explicit DIM= argument we had
out-of-bounds access), but for MAXLOC/MINLOC/FINDLOC mask should be be
conformable and could be scalar.

Add new regression tests with scalar mask for verification.

Reviewed By: klausler

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

2 years ago[flang] Fix UBOUND() constant folding for parentheses expr
Mike Kashkarov [Thu, 28 Apr 2022 09:56:16 +0000 (18:56 +0900)]
[flang] Fix UBOUND() constant folding for parentheses expr

Similarly to LBOUND((x)) in https://reviews.llvm.org/D123838 - fix UBOUND((x))
folding for constant arrays to return shape instead of recurse scan.

Depends on D123520

Reviewed By: jeanPerier

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

2 years ago[Analyzer] Remove undefined function
Marco Antognini [Wed, 20 Apr 2022 09:56:19 +0000 (11:56 +0200)]
[Analyzer] Remove undefined function

This getLValue function was declared in 98db1f990fc2 ([Analyzer] [NFC]
Parameter Regions, 2020-05-11) but was never implemented.

Reviewed By: NoQ

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

2 years ago[ARM] add Armv9 build attribute
Ties Stuij [Thu, 28 Apr 2022 09:23:54 +0000 (10:23 +0100)]
[ARM] add Armv9 build attribute

The build attribute number can be found in the Arm ABI addenda32 document:
https://github.com/ARM-software/abi-aa/blob/main/addenda32/addenda32.rst#335target-related-attributes

Reviewed By: tmatheson

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

2 years ago[AST] Improve traversal of concepts and concept requirements
Ilya Biryukov [Thu, 28 Apr 2022 08:39:47 +0000 (08:39 +0000)]
[AST] Improve traversal of concepts and concept requirements

- Do not traverse concept decl inside `AutoType`. We only traverse
  declaration and definitions, not references to a declaration.
- Do not visit implicit AST node the relevant traversal mode.
- Add traversal extension points for concept requirements.
- Renamed `TraverseConceptReference` to mark as helper to share
  the code. Having an extension point there seems confusing given that
  there are many concept refences in the AST that do not call the
  helper. Those are `AutoType`, `AutoTypeLoc` and constraint requirements.

Only clangd code requires an update.

There are no use-cases for concept requirement traversals yet, but
I added them in the earlier version of the patch and decided to keep
them for completeness.

Reviewed By: sammccall

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

2 years ago[clang-format] add a regression test for include sorting
Krasimir Georgiev [Thu, 28 Apr 2022 09:01:27 +0000 (11:01 +0200)]
[clang-format] add a regression test for include sorting

This adds a regression test from the comments
on https://reviews.llvm.org/D121370.

Reviewed By: MyDeveloperDay, curdeius

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

2 years agoRevert "[clang-format] SortIncludes should support "@import" lines in Objective-C"
Krasimir Georgiev [Thu, 28 Apr 2022 08:58:46 +0000 (10:58 +0200)]
Revert "[clang-format] SortIncludes should support "@import" lines in Objective-C"

This reverts commit d46fa023caa2db5a9f1e21dd038bcb626261d958.
Regressed include order in some cases with trailing comments, see the
comments on https://reviews.llvm.org/D121370. Will add a regression test
in a follow-up commit.

2 years ago[lldb] Reduce duplication in DWARFASTParserClang::CopyUniqueClassMethodTypes
Pavel Labath [Thu, 28 Apr 2022 08:57:35 +0000 (10:57 +0200)]
[lldb] Reduce duplication in DWARFASTParserClang::CopyUniqueClassMethodTypes

Use lambdas to replace identical bits of code.

2 years ago[RISCV] Support VP_SETCC mask operations
Lian Wang [Tue, 26 Apr 2022 01:46:27 +0000 (01:46 +0000)]
[RISCV] Support VP_SETCC mask operations

Support VP_SETCC mask operations, turn it to logical operation.

Reviewed By: craig.topper

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

2 years ago[mlir][SparseTensor] Enable VLA ops in index value generation
Javier Setoain [Tue, 26 Apr 2022 13:39:29 +0000 (14:39 +0100)]
[mlir][SparseTensor] Enable VLA ops in index value generation

Current index value generation uses fixed-length vector ops, this patch
adds an alterantive codegen path compatible with scalable vectors by
using `LLVM::StepVectorOp`.

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

2 years ago[CodeGen] Remove an outdated comment in MachinePointerInfo
Jay Foad [Thu, 28 Apr 2022 08:06:36 +0000 (09:06 +0100)]
[CodeGen] Remove an outdated comment in MachinePointerInfo

This comment has been untrue since D39758 changed
MachinePointerInfo to store AddrSpace separately from V.

2 years ago[GVN] Encode GEPs in offset representation
Nikita Popov [Wed, 27 Apr 2022 12:40:07 +0000 (14:40 +0200)]
[GVN] Encode GEPs in offset representation

When using opaque pointers, convert GEPs into offset representation
of the form P + V1 * Scale1 + V2 * Scale2 + ... + ConstantOffset.
This allows us to recognize equivalent address calculations even if
the GEPs don't use the same source element type.

This fixes an opaque pointer codegen regression seen in rustc.

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

2 years ago[X86][AMX] combine tile cast and load/store instruction.
Luo, Yuanke [Mon, 25 Apr 2022 11:23:28 +0000 (19:23 +0800)]
[X86][AMX] combine tile cast and load/store instruction.

The `llvm.x86.cast.tile.to.vector` intrinsic is lowered to
`llvm.x86.tilestored64.internal` and `load <256 x i32>`. The
`llvm.x86.cast.vector.to.tile` is lowered to `store <256 x i32>` and
`llvm.x86.tileloadd64.internal`. When `llvm.x86.cast.tile.to.vector` is
used by `store <256 x i32>` or `load <256 x i32>` is used by
`llvm.x86.cast.vector.to.tile`, they can be combined by
`llvm.x86.tilestored64.internal` and `llvm.x86.tileloadd64.internal`.

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

2 years ago[Driver][Solaris] -r: imply -nostdlib like GCC
Brad Smith [Thu, 28 Apr 2022 04:17:48 +0000 (00:17 -0400)]
[Driver][Solaris] -r: imply -nostdlib like GCC

Similar to D116843 for Gnu.cpp

Reviewed By: MaskRay

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

2 years ago[JumpThreading][NFC][CompileTime] Do not recompute BPI/BFI analyzes
Max Kazantsev [Thu, 28 Apr 2022 03:46:08 +0000 (10:46 +0700)]
[JumpThreading][NFC][CompileTime] Do not recompute BPI/BFI analyzes

They can already be available, and even if not, DT/LI can be available.
We should not recompute them. Old PM is unchanged because it would
require changing dependencies, and we don't care enough about it.

Differential Revision: https://reviews.llvm.org/D124439
Reviewed By: nikic, aeubanks

2 years ago[InferAddressSpaces] Check if AS are the same in isNoopPtrIntCastPair
Wenju He [Thu, 28 Apr 2022 02:47:26 +0000 (10:47 +0800)]
[InferAddressSpaces] Check if AS are the same in isNoopPtrIntCastPair

isNoopAddrSpaceCast is expecting SrcAS is different from DestAS.
If the two AS are the same, consider ptrtoint/inttoptr as noop cast.

Reviewed By: arsenm

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

2 years ago[XCORE][CodeGen][NFC] Use ArrayRef in TargetLowering functions
Liqin.Weng [Thu, 28 Apr 2022 02:06:27 +0000 (02:06 +0000)]
[XCORE][CodeGen][NFC] Use ArrayRef in TargetLowering functions

Reviewed By: nigelp-xmos

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

2 years ago[X86] Check the address in machine verifier
Shengchen Kan [Tue, 26 Apr 2022 14:29:09 +0000 (22:29 +0800)]
[X86] Check the address in machine verifier

1. The scale factor must be 1, 2, 4, 8
2. The displacement must fit in 32-bit signed integer

Noticed by: https://github.com/llvm/llvm-project/issues/55091

Reviewed By: pengfei

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

2 years ago[OpaquePtr][GlobalOpt] Don't attempt to evaluate global constructors with arguments
Arthur Eubanks [Wed, 27 Apr 2022 20:44:50 +0000 (13:44 -0700)]
[OpaquePtr][GlobalOpt] Don't attempt to evaluate global constructors with arguments

Previously all entries in global_ctors had to have the void()* type and
we'd skip evaluating bitcasted functions. With opaque pointers we may
see the function directly.

Fixes #55147.

Reviewed By: #opaque-pointers, nikic

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

2 years ago[flang] Add lowering stubs for OpenMP/OpenACC declarative constructs
Peixin-Qiao [Thu, 28 Apr 2022 01:40:30 +0000 (09:40 +0800)]
[flang] Add lowering stubs for OpenMP/OpenACC declarative constructs

This patch provides the basic infrastructure for lowering declarative
constructs for OpenMP and OpenACC.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: kiranchandramohan, shraiysh, clementval

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

2 years agoDrop '* text=auto' from .gitattributes and normalize
Aaron Puchert [Thu, 28 Apr 2022 01:05:09 +0000 (03:05 +0200)]
Drop '* text=auto' from .gitattributes and normalize

Git wants to check in 'text' files with LF endings, so this changes them
in the repository but not in the checkout, where they keep CRLF endings.

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

2 years agoFix test fail-file-open.test on Windows to hopefully fix the Windows buildbots.
Douglas Yung [Thu, 28 Apr 2022 00:28:57 +0000 (17:28 -0700)]
Fix test fail-file-open.test on Windows to hopefully fix the Windows buildbots.

2 years ago[lldb] Fix escaping when launching in terminal with AppleScript
Jonas Devlieghere [Wed, 27 Apr 2022 23:37:42 +0000 (16:37 -0700)]
[lldb] Fix escaping when launching in terminal with AppleScript

Fix escaping when launching in terminal with AppleScript. The invocation
we're building up is wrapped in single quotes when passed to bash and
wrapped in double quotes for AppleScript.

Here's an example invocation with the new escaping:

  tell application "Terminal"
    activate
          do script "/bin/bash -c 'arch -arch arm64 'darwin-debug'
            --unix-socket=/tmp/dL2jSh --arch=arm64 --working-dir
            \"/private/tmp/with spaces\" --disable-aslr --  \"foo\"
            \"bar\" \"baz\" ; echo Process exited with status $?';exit"
  end tell

Previously we were using unescaped single quotes which resulted in the
whole bash invocation being passed in pieces. That works most of the
time but breaks when you have a space in your current working directory
for example.

rdar://91870763

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

2 years ago[dsymutil] Fix memory issue in the BinaryHolder
Jonas Devlieghere [Wed, 27 Apr 2022 23:32:38 +0000 (16:32 -0700)]
[dsymutil] Fix memory issue in the BinaryHolder

The BinaryHolder has two caches for object and archive entries. These
are implemented as StringMaps of ObjectEntry and ArchiveEntry
respectively. The fact that they're stored by value is problematic
because the BinaryHolder hands out references that become invalidate
when the data structure grows. This patch wraps those object instances
in unique pointers and changes the interface to hand out pointers. This
resulted in transient failures.

rdar://90412671

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

2 years ago[LegacyPM] Remove ThreadSanitizerLegacyPass
Fangrui Song [Wed, 27 Apr 2022 23:25:41 +0000 (16:25 -0700)]
[LegacyPM] Remove ThreadSanitizerLegacyPass

Using the legacy PM for the optimization pipeline was deprecated in 13.0.0.
Following recent changes to remove non-core features of the legacy
PM/optimization pipeline, remove ThreadSanitizerLegacyPass.

Reviewed By: #sanitizers, vitalybuka

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

2 years agoRevert "[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]"
Kirill Stoimenov [Wed, 27 Apr 2022 23:10:36 +0000 (23:10 +0000)]
Revert "[Debuginfo][LSR] Add salvaging variadic dbg.value intrinsics [2/2]"

This reverts commit 74273d575f9938d751a1c67862cffe553fe2de8b.

Buildbot: https://lab.llvm.org/buildbot/#/builders/5/builds/22795
Failing with memory leak.

2 years ago[llvm-symbolizer][native-pdb] Don't reset CurLineOffset if NextLineOffset is none
Zequan Wu [Wed, 27 Apr 2022 23:05:09 +0000 (16:05 -0700)]
[llvm-symbolizer][native-pdb] Don't reset CurLineOffset if NextLineOffset is none

2 years agoRevert "BranchFolder: Assert on SSA functions"
Matt Arsenault [Wed, 27 Apr 2022 23:01:24 +0000 (19:01 -0400)]
Revert "BranchFolder: Assert on SSA functions"

This reverts commit 6ff91d17d66da46572e97f9a0b042182762cbe9e.

2 years ago[modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions...
Volodymyr Sapsai [Wed, 2 Mar 2022 04:08:01 +0000 (20:08 -0800)]
[modules] Merge equivalent extensions and diagnose ivar redeclarations for extensions loaded from different modules.

Emitting metadata for the same ivar multiple times can lead to
miscompilations. Objective-C runtime adds offsets to calculate ivar
position in memory and presence of duplicate offsets causes wrong final
position thus overwriting unrelated memory.

Such a situation is impossible with modules disabled as clang diagnoses
ivar redeclarations during sema checks after parsing
(`Sema::ActOnFields`). Fix the case with modules enabled by checking
during deserialization if ivar is already declared. We also support
a use case where the same category ends up in multiple modules. We
don't want to treat this case as ivar redeclaration and instead merge
corresponding ivars.

rdar://83468070

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

2 years agollvm-reduce: Fix incorrect cloning of MachineMemOperands
Matt Arsenault [Tue, 19 Apr 2022 17:51:20 +0000 (13:51 -0400)]
llvm-reduce: Fix incorrect cloning of MachineMemOperands

There were two problems with directly copying the MMOs from the old
function. The MMOs are owned by the function's Allocator, so need to
be reallocated anyways (surprisingly I didn't notice breakage on
this). Second, the PseudoSourceValues are also allocated per function
and need to be reallocated.

2 years agoBranchFolder: Assert on SSA functions
Matt Arsenault [Mon, 25 Apr 2022 12:12:32 +0000 (08:12 -0400)]
BranchFolder: Assert on SSA functions

We probably should have the opposite of getRequiredProperties for this

2 years ago[PS5] Enable dead-stripping globals in ASan
Paul Robinson [Wed, 27 Apr 2022 22:44:22 +0000 (15:44 -0700)]
[PS5] Enable dead-stripping globals in ASan

2 years ago[X86] Move target-generic code into CodeGen [NFC]
Bill Wendling [Wed, 27 Apr 2022 22:37:08 +0000 (15:37 -0700)]
[X86] Move target-generic code into CodeGen [NFC]

This code is the same for all platforms.

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

2 years agollvm-reduce: Fix crashing on file opening error for mir path
Matt Arsenault [Fri, 22 Apr 2022 21:40:25 +0000 (17:40 -0400)]
llvm-reduce: Fix crashing on file opening error for mir path

2 years agollvm-reduce: Support multiple MachineFunctions
Matt Arsenault [Tue, 19 Apr 2022 02:19:57 +0000 (22:19 -0400)]
llvm-reduce: Support multiple MachineFunctions

The current testcase I'm trying to reduce only reproduces with IPRA
enabled and requires handling multiple functions.

The only real difference vs. the IR is the extra indirect to look for
the underlying MachineFunction, so treat the ReduceWorkItem as the
module instead of the function.

The ugliest piece of this is really the ugliness of
MachineModuleInfo. It not only tracks actual module state, but has a
number of transient fields used for isel and/or the asm printer. These
shouldn't do any harm for the use here, though they should be
separated out.

2 years agollvm-reduce: Try to fix test on windows buildbots
Matt Arsenault [Wed, 27 Apr 2022 21:56:46 +0000 (17:56 -0400)]
llvm-reduce: Try to fix test on windows buildbots

2 years ago[flang] Fix MAXLOC/MINLOC when MASK is scalar .FALSE.
Peter Steinfeld [Tue, 26 Apr 2022 22:21:03 +0000 (15:21 -0700)]
[flang] Fix MAXLOC/MINLOC when MASK is scalar .FALSE.

When passing a scalar .FALSE. as the MASK argument to MAXLOC, we were getting
bad memory references.  We were falling into the code intended when the MASK
argument was missing.

I fixed this by checking for a scalar MASK with a .FALSE. value and
setting the result to all zeroes in that case.  I also added tests for
MAXLOC and MINLOC with scalar values of .TRUE. and .FALSE. for the MASK
argument.

I also special cased situations where the MASK argument is a scalar with
a .TRUE. value and passed along a nullptr in such cases.

Along the way, I eliminated the unused "chars" argument from the constructor
for ExtremumLocAccumulator.

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

2 years agollvm-reduce: Try to parse triple/datalayout from module
Matt Arsenault [Mon, 18 Apr 2022 22:57:43 +0000 (18:57 -0400)]
llvm-reduce: Try to parse triple/datalayout from module

This saves needing to specify -mtriple on nearly every use for MIR
reduction.

2 years agoDWP parsing: Use the index by hash when available
David Blaikie [Wed, 27 Apr 2022 21:45:05 +0000 (21:45 +0000)]
DWP parsing: Use the index by hash when available

Rather than looking up by offset - actually use the hash table to
perform faster lookup where possible. (for DWARFv4 DWP compilation units
the hash isn't in the header - it's in the root DIE, but to parse the
DIE you need the abbrev section and to get the abbrev section you need
the index - so in that case lookup by offset is required)

2 years ago[llvm-pdbutil] Add options to only dump symbol record at specified offset and its...
Zequan Wu [Sat, 23 Apr 2022 01:35:00 +0000 (18:35 -0700)]
[llvm-pdbutil] Add options to only dump symbol record at specified offset and its parents or children with spcified depth.

Right now, if we want to dump symbol at specified offset, we need to use `grep`.
And it can only show surrounding symbols in layout (not in lexical scope sense).

This adds similar options to `dump` command as `llvm-dwarfdump` to allow users
to dump symbol record at specified offset and its parents or children with
spcified depth.

`--symbol-offset=` must be used with `--modi` to dump only one symbol at given
offset.

`--show-parents`/`--show-children` must be used with `--symbol-offset` to
dump all symbols that are parents/children of the symbol at given offset.

`--parent-recurse-depth`/`--children-recurse-depth` must be used with
`--show-parents`/`--show-children` to specify the max up/down depth.

Reviewed By: rnk

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

2 years agollvm-reduce: Fix not cloning MachineInstr flags
Matt Arsenault [Wed, 27 Apr 2022 21:15:57 +0000 (17:15 -0400)]
llvm-reduce: Fix not cloning MachineInstr flags

2 years ago[clang-format] Adjust editor cursor position past #include blocks
owenca [Tue, 26 Apr 2022 13:47:36 +0000 (06:47 -0700)]
[clang-format] Adjust editor cursor position past #include blocks

Fixes #55027.

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

2 years agoDebugInfo: Use hash-based unit lookup when available in dwp files
David Blaikie [Wed, 27 Apr 2022 21:17:01 +0000 (21:17 +0000)]
DebugInfo: Use hash-based unit lookup when available in dwp files

Fix a test case that had a bogus (probably I hand crafted it at some
point) index that didn't point to the right data in the process.

2 years ago[PS5] Test sanitizer options/lib names
Paul Robinson [Wed, 27 Apr 2022 20:45:15 +0000 (13:45 -0700)]
[PS5] Test sanitizer options/lib names

The functionality was added in 7726ad0, catching up on the tests now.

2 years ago[SimpleLoopUnswitch] Fix CHECK lines of tests added in 93182c9ff4c.
Florian Hahn [Wed, 27 Apr 2022 20:36:53 +0000 (21:36 +0100)]
[SimpleLoopUnswitch] Fix CHECK lines of tests added in 93182c9ff4c.

When generating the tests I accidentally had some other changes applied.
Fix the CHECK lines for current main.

2 years ago[SimpleLoopUnswitch] Add test cases where freeze of OR/AND cons needed.
Florian Hahn [Wed, 27 Apr 2022 20:19:13 +0000 (21:19 +0100)]
[SimpleLoopUnswitch] Add test cases where freeze of OR/AND cons needed.

Freezing just the result of the AND/OR here is not enough.

2 years ago[X86] setcc.ll - add bmi2 + tbm test coverage
Simon Pilgrim [Wed, 27 Apr 2022 20:09:53 +0000 (21:09 +0100)]
[X86] setcc.ll - add bmi2 + tbm test coverage

As discussed on Issue #55138 - BMI2 (fast shrx) shouldn't always fold to BT

2 years ago[X86] setcc.ll - remove unnecessary cpu attributes
Simon Pilgrim [Wed, 27 Apr 2022 20:06:02 +0000 (21:06 +0100)]
[X86] setcc.ll - remove unnecessary cpu attributes

2 years ago[X86] Add test case for Issue #55138
Simon Pilgrim [Wed, 27 Apr 2022 20:03:47 +0000 (21:03 +0100)]
[X86] Add test case for Issue #55138

2 years ago[X86] Use is128BitLaneRepeatedShuffleMask wrapper. NFC.
Simon Pilgrim [Wed, 27 Apr 2022 20:03:25 +0000 (21:03 +0100)]
[X86] Use is128BitLaneRepeatedShuffleMask wrapper. NFC.

We don't need to know the actual repeated mask.

2 years agoUpdate PGO and 3-stage cache files
Chris Bieneman [Wed, 27 Apr 2022 14:26:56 +0000 (09:26 -0500)]
Update PGO and 3-stage cache files

These files are out of date and haven't been updated to work within the
monorepo. This change updates them appropriately so that they build
using the monorepo build infrastructure.

2 years ago[flang] Downgrade a fatal error to a warning
Peter Klausler [Tue, 26 Apr 2022 20:29:55 +0000 (13:29 -0700)]
[flang] Downgrade a fatal error to a warning

A non-CHARACTER expression in a CASE statement is allowed to have
a distinct kind (not type) from the expression in its SELECT CASE.
If a value in a CASE statement is out of range for the SELECT CASE
type, emit a warning, but it should not be a fatal error.

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

2 years ago[flang] Allow for host association in ConvertTo(Object|Proc)Entity
Peter Klausler [Tue, 26 Apr 2022 20:01:00 +0000 (13:01 -0700)]
[flang] Allow for host association in ConvertTo(Object|Proc)Entity

Name resolution fails with a bogus "is not a variable" error message
when a host-associated object appears in a NAMELIST group.  The root
cause is that ConvertToObjectEntity() returns false for host-associated
objects.  Fix that, and also apply a similar fix to ConvertToProcEntity()
nearby.

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

2 years ago[Darwin][UBSan][Sanitizer] abort_on_error ubsan test fix for arm64
Blue Gaston [Tue, 26 Apr 2022 21:33:08 +0000 (14:33 -0700)]
[Darwin][UBSan][Sanitizer] abort_on_error ubsan test fix for arm64

The current darwin abort_on_error test specifically tests for a division
by zero undefined behavior. However arm does not trap by default for this
behavior. x86 signals the abort, which is why the test passes on x86.
This patch updates the test to test for a case where the ubsan runtime
specifically calls Die() to trigger an abort by default.

rdar://92108564

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

2 years agoRevert "[Driver] Support for compressed debug info on Fuchsia"
Petr Hosek [Wed, 27 Apr 2022 18:41:41 +0000 (11:41 -0700)]
Revert "[Driver] Support for compressed debug info on Fuchsia"

This reverts commit 2d0c897212d0551966b26eae986209ea31c4f032 which
is still breaking on the sanitizer bots.

2 years agollvm-reduce: Fix mangling types of generic registers
Matt Arsenault [Tue, 19 Apr 2022 18:59:32 +0000 (14:59 -0400)]
llvm-reduce: Fix mangling types of generic registers

2 years ago[Driver] Support for compressed debug info on Fuchsia
Petr Hosek [Wed, 17 Nov 2021 19:06:03 +0000 (11:06 -0800)]
[Driver] Support for compressed debug info on Fuchsia

Pass the --compress-debug-sections=zlib argument to the linker when
the use of compressed debug info is requested.

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

2 years agollvm-reduce: Preserve subregisters and other fields for top block def
Matt Arsenault [Tue, 19 Apr 2022 14:15:40 +0000 (10:15 -0400)]
llvm-reduce: Preserve subregisters and other fields for top block def

2 years ago[InstCombine] C0 >> (X - C1) --> (C0 << C1) >> X
Nicolas Abram Lujan [Wed, 27 Apr 2022 17:41:25 +0000 (13:41 -0400)]
[InstCombine] C0 >> (X - C1) --> (C0 << C1) >> X

With the right pre-conditions, we can fold the offset
into the shifted constant:
https://alive2.llvm.org/ce/z/drMRBU
https://alive2.llvm.org/ce/z/cUQv-_

Fixes #55016

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

2 years ago[RISCV] Add isCommutable to scalar FMA instructions.
Craig Topper [Wed, 27 Apr 2022 17:32:54 +0000 (10:32 -0700)]
[RISCV] Add isCommutable to scalar FMA instructions.

The default implementation of findCommutedOpIndices picks the
first two source operands. That's exactly what we want for the
scalar FMA instructions.

Reviewed By: reames

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

2 years ago[InstCombine] Fold strnlen calls in equality to zero.
Martin Sebor [Wed, 27 Apr 2022 18:01:35 +0000 (12:01 -0600)]
[InstCombine] Fold strnlen calls in equality to zero.

Reviewed By: nikic

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

2 years ago[COST]Improve cost model for shuffles in SLP.
Alexey Bataev [Wed, 14 Apr 2021 14:49:32 +0000 (07:49 -0700)]
[COST]Improve cost model for shuffles in SLP.

Introduced masks where they are not added and improved target dependent
cost models to avoid returning of the incorrect cost results after
adding masks.

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

2 years ago[LLDB][NativePDB] Minor fix ParseInlinesite.
Zequan Wu [Wed, 27 Apr 2022 17:46:51 +0000 (10:46 -0700)]
[LLDB][NativePDB] Minor fix ParseInlinesite.

- Don't reset cur_line_offset to llvm::None when we don't have next_line_offset, because we may need to reuse it in new range after a code end.
- Don't use CombineConsecutiveEntriesWithEqualData for inline_site_sp->ranges, because that will combine consecutive entries with same data in the vector regardless of the entry's range. Originally, I thought that it only combine consecutive entries if adjacent entries' ranges are adjoining or intersecting with each other.

2 years ago[lit] Support %if ... %else syntax for RUN lines
Andrew Savonichev [Wed, 27 Apr 2022 16:36:54 +0000 (19:36 +0300)]
[lit] Support %if ... %else syntax for RUN lines

This syntax allows to modify RUN lines based on features
available. For example:

    RUN: ... | FileCheck %s --check-prefix=%if windows %{CHECK-W%} %else %{CHECK-NON-W%}
    CHECK-W: ...
    CHECK-NON-W: ...

The whole command can be put under %if ... %else:

    RUN: %if tool_available %{ %tool %} %else %{ true %}

or:

    RUN: %if tool_available %{ %tool %}

If tool_available feature is missing, we'll have an empty command in
this RUN line.  LIT used to emit an error for empty commands, but now
it treats such commands as nop in all cases.

Multi-line expressions are also supported:

    RUN: %if tool_available %{ \
    RUN:   %tool               \
    RUN: %} %else %{           \
    RUN:   true                \
    RUN: %}

Background and motivation:
D121727 [NVPTX] Integrate ptxas to LIT tests
https://reviews.llvm.org/D121727

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

2 years ago[CHR] Skip region containing llvm.coro.id
Wei Wang [Mon, 25 Apr 2022 21:00:41 +0000 (14:00 -0700)]
[CHR] Skip region containing llvm.coro.id

When a block containing llvm.coro.id is cloned during CHR, it inserts an invalid
PHI node with token type to the beginning of the block containing llvm.coro.begin.
To avoid such case, we exclude regions with llvm.coro.id.

Reviewed By: ChuanqiXu

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

2 years ago[mlir][sparse] optimize COO index handling
Aart Bik [Wed, 27 Apr 2022 04:25:32 +0000 (21:25 -0700)]
[mlir][sparse] optimize COO index handling

By using a shared index pool, we reduce the footprint of each "Element"
in the COO scheme and, in addition, reduce the overhead of allocating
indices (trading many allocations of vectors for allocations in a single
vector only). When the capacity is known, this means *all* allocation
can be done in advance.

This is a big win. For example, reading matrix SK-2005, with dimensions
50,636,154 x 50,636,154 and 1,949,412,601 nonzero elements improves
as follows (time in ms), or about 3.5x faster overall

```
SK-2005 before        after      speedup
  ---------------------------------------------
read     305,086.65    180,318.12    1.69
sort   2,836,096.23    510,492.87    5.56
pack     364,485.67    312,009.96    1.17
  ---------------------------------------------
TOTAL  3,505,668.56  1,002,820.95    3.50
```

Reviewed By: bixia

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

2 years ago[NFC] Renamed /test/Analysis/CostModel/X86/splat-load.ll test and added more checks.
Vasileios Porpodas [Tue, 26 Apr 2022 15:31:19 +0000 (08:31 -0700)]
[NFC] Renamed /test/Analysis/CostModel/X86/splat-load.ll test and added more checks.

Renamed test/Analysis/CostModel/X86/splat-load.ll to shuffle-load.ll
to align it with AArch64's similar test.

Also added a complete list of checks for all vector combinations up to 512-bits.

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

2 years ago[mlir][LLVMIR] Do not cache llvm::Constant into instMap
Min-Yih Hsu [Wed, 20 Apr 2022 17:40:37 +0000 (10:40 -0700)]
[mlir][LLVMIR] Do not cache llvm::Constant into instMap

Constants in MLIR are not globally unique, unlike that in LLVM IR.
Therefore, reusing previous-translated constants might cause the user
operations not being dominated by the constant (because the
previous-translated ones can be placed in arbitrary place)

This indeed misses some opportunities where we actually can reuse a
previous-translated constants, but verbosity is not our first priority
here.

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

2 years ago[mlir][LLVMIR] Do not cache Instruction generated on-the-fly
Min-Yih Hsu [Wed, 20 Apr 2022 17:30:43 +0000 (10:30 -0700)]
[mlir][LLVMIR] Do not cache Instruction generated on-the-fly

More specifically, the llvm::Instruction generated by
llvm::ConstantExpr::getAsInstruction. Such Instruction will be deleted
right away, but it's possible that when getAsInstruction is called
again, it will create a new Instruction that has the same address with
the one we just deleted. Thus, we shouldn't keep it in the `instMap` to
avoid a conflicting index that triggers an assertion in
processInstruction.

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

2 years ago[mlir][LLVMIR] Add support for importing struct-type ConstantAggregate(Zero)
Min-Yih Hsu [Wed, 20 Apr 2022 17:48:42 +0000 (10:48 -0700)]
[mlir][LLVMIR] Add support for importing struct-type ConstantAggregate(Zero)

And move importer test files from `test/Target/LLVMIR` into
`test/Target/LLVMIR/Import`.

We simply translate struct-type ConstantAggregate(Zero) into a
serious of `llvm.insertvalue` operations against a `llvm.undef` root.
Note that this doesn't affect the original logics on translating
vector/array-type ConstantAggregate values.

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

2 years ago[flang] Fix UBOUND() folding for constant arrays
Mike Kashkarov [Wed, 27 Apr 2022 13:14:10 +0000 (16:14 +0300)]
[flang] Fix UBOUND() folding for constant arrays

Similarly to LBOUND in https://reviews.llvm.org/D123237, fix UBOUND() folding
for constant arrays (for both w/ and w/o DIM=): convert
GetConstantArrayLboundHelper into common helper class for both lower/upper
bounds.

Reviewed By: jeanPerier

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

2 years ago[mlir] Allow setting operation legality with an OperationName
Mathieu Fehr [Wed, 27 Apr 2022 15:43:37 +0000 (08:43 -0700)]
[mlir] Allow setting operation legality with an OperationName

This is necessary to handle conversions of operations defined at runtime in extensible dialects.

Reviewed By: rriddle

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

2 years ago[DXIL] [NFC] Remove dead attribute code paths
Chris Bieneman [Wed, 27 Apr 2022 15:43:31 +0000 (10:43 -0500)]
[DXIL] [NFC] Remove dead attribute code paths

DXIL doesn't support attributes added after LLVM 3.7. The DXILPrepare
pass removes those attributes so they should never be present by the
time we reach the DXIL bitcode writer.

In the event that we somehow try to write a newer attribute in the DXIL
writer, we should fail hard (crash), because the output would be
invalid. This case should only be possible if the DXIL writer were
called without DXILPrepare being run first, which shouldn't be possible.

This patch also adds a default case to the switch statement over the
attribute list which covers all the removed cases and any new attribute
kinds that may be added in the future. The default case is handled like
other unsupported cases by a call to llvm_unreachable.

2 years agoRemove the Visual Studio/MSBuild integration (llvm/tools/msbuild/)
Hans Wennborg [Wed, 27 Apr 2022 12:14:39 +0000 (14:14 +0200)]
Remove the Visual Studio/MSBuild integration (llvm/tools/msbuild/)

This has been obsolete and abandoned since MS started including an
integration themselves in Visual Studio 2019.

See discussion at
https://discourse.llvm.org/t/building-the-llvm-with-msbuild/62053/

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

2 years agoRemove Python 2 checks from the test suite
Jonas Devlieghere [Wed, 27 Apr 2022 01:23:10 +0000 (18:23 -0700)]
Remove Python 2 checks from the test suite

We dropped downstream support for Python 2 in the previous release. Now
that we have branched for the next release the window where this kind of
change could introduce conflicts is closing too. Remove Python 2 checks
from the test suite.

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

2 years agoRemove Python 2 support from the ScriptInterpreter plugin
Jonas Devlieghere [Tue, 26 Apr 2022 03:14:44 +0000 (20:14 -0700)]
Remove Python 2 support from the ScriptInterpreter plugin

We dropped downstream support for Python 2 in the previous release. Now
that we have branched for the next release the window where this kind of
change could introduce conflicts is closing too. Start by getting rid of
Python 2 support in the Script Interpreter plugin.

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

2 years agotsan: avoid false positives related to epoll
Dmitry Vyukov [Wed, 27 Apr 2022 09:23:41 +0000 (11:23 +0200)]
tsan: avoid false positives related to epoll

An application can use the mere fact of epoll_wait returning an fd
as synchronization with the write on the fd that triggered the notification.
This pattern come up in an internal networking server (b/229276331).

If an fd is added to epoll, setup a link from the fd to the epoll fd
and use it for synchronization as well.

Reviewed By: melver

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

2 years ago[X86] collectConcatOps - add ability to collect from vector 'widening' patterns
Simon Pilgrim [Wed, 27 Apr 2022 14:29:03 +0000 (15:29 +0100)]
[X86] collectConcatOps - add ability to collect from vector 'widening' patterns

Recognise insert_subvector(undef, x, lo/hi) patterns where we double the width of a vector - creating an UNDEF subvector on the fly.

2 years ago[AArch64] Attempt to fix bots by ensuring legalized type is a vector
David Green [Wed, 27 Apr 2022 14:36:15 +0000 (15:36 +0100)]
[AArch64] Attempt to fix bots by ensuring legalized type is a vector

2 years ago[NVPTX] Fix NVPTX DebugInfo tests on Windows
Andrew Savonichev [Tue, 26 Apr 2022 19:41:10 +0000 (22:41 +0300)]
[NVPTX] Fix NVPTX DebugInfo tests on Windows

2 years ago[mlir][spirv] Add conversion from vector.reduction
Lei Zhang [Wed, 27 Apr 2022 14:22:41 +0000 (10:22 -0400)]
[mlir][spirv] Add conversion from vector.reduction

Only supports addition and multiplication for now; other cases
to be implemented.

Reviewed By: hanchung

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