platform/upstream/llvm.git
2 years ago[ODRHash diagnostics] Split `err_module_odr_violation_mismatch_decl_diff` into per...
Volodymyr Sapsai [Thu, 23 Jun 2022 03:18:42 +0000 (20:18 -0700)]
[ODRHash diagnostics] Split `err_module_odr_violation_mismatch_decl_diff` into per-entity diagnostics. NFC.

We'll need to add more cases for Objective-C entities and adding
everything to `err_module_odr_violation_mismatch_decl_diff` makes it
harder to work with over time.

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

2 years ago[mlir][tblgen] Improving error messages
wren romano [Mon, 27 Jun 2022 23:28:45 +0000 (16:28 -0700)]
[mlir][tblgen] Improving error messages

This differential improves two error conditions, by detecting them earlier and by providing better messages to help users understand what went wrong.

Reviewed By: jpienaar

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

2 years ago[ISel] Match all bits when merge undefs for DAG combine
Xiang1 Zhang [Fri, 1 Jul 2022 01:05:36 +0000 (09:05 +0800)]
[ISel] Match all bits when merge undefs for DAG combine

Reviewed By: RKSimon

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

2 years agoRevert "[ISel] Match all bits when merge undef(s) for DAG combine"
Xiang1 Zhang [Fri, 1 Jul 2022 00:59:04 +0000 (08:59 +0800)]
Revert "[ISel] Match all bits when merge undef(s) for DAG combine"

This reverts commit 5fe5aa284efed1ee1492e1f266351b35f0a8bb69.

2 years ago[ISel] Match all bits when merge undef(s) for DAG combine
Xiang1 Zhang [Thu, 30 Jun 2022 11:07:25 +0000 (19:07 +0800)]
[ISel] Match all bits when merge undef(s) for DAG combine

2 years ago[SLP][NFC]Cleanup up operands of the removed insertelements, NFC.
Alexey Bataev [Fri, 1 Jul 2022 00:10:04 +0000 (17:10 -0700)]
[SLP][NFC]Cleanup up operands of the removed insertelements, NFC.

Replace all operands of the insertelement instruction, replaced by
shuffles, by poisons to avoid false-positive reports about incorrect function.

2 years ago[X86] Pre-commit tests for D128769. NFC
Craig Topper [Tue, 28 Jun 2022 23:10:22 +0000 (16:10 -0700)]
[X86] Pre-commit tests for D128769. NFC

2 years ago[RISCV] Avoid repeated code in SelectAddrRegImm. NFC
Craig Topper [Fri, 1 Jul 2022 00:15:55 +0000 (17:15 -0700)]
[RISCV] Avoid repeated code in SelectAddrRegImm. NFC

2 years ago[SVE] Use CPY to zero active lanes of a floating point vector.
Paul Walker [Fri, 24 Jun 2022 08:21:28 +0000 (09:21 +0100)]
[SVE] Use CPY to zero active lanes of a floating point vector.

Patterns exist for the integer case that are trivially expandable
to cover 0.0f.

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

2 years ago[SVE] Extend "and(ipg,cmp(x,y))" patterns to cover the case when y is an immediate.
Paul Walker [Wed, 22 Jun 2022 15:05:17 +0000 (16:05 +0100)]
[SVE] Extend "and(ipg,cmp(x,y))" patterns to cover the case when y is an immediate.

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

2 years ago[BOLT][DWARF] Support mix mode DWARF
Alexander Yermolovich [Thu, 30 Jun 2022 23:50:49 +0000 (16:50 -0700)]
[BOLT][DWARF] Support mix mode DWARF

Added support for mixing monolithic DWARF5 with legacy DWARF, and monolithic legacy and DWARF5 split dwarf.

Reviewed By: maksfb

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

2 years ago[runtimes] adds llvm-libgcc to the list of runtimes to be sorted
Christopher Di Bella [Sat, 25 Jun 2022 00:17:30 +0000 (00:17 +0000)]
[runtimes] adds llvm-libgcc to the list of runtimes to be sorted

llvm-libgcc is not a part of `LLVM_ALL_RUNTIMES` because llvm-libgcc is
incompatible with an explicit libunwind and compiler-rt. This meant that
it was being filtered out and not built.

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

2 years ago[MC][Mips] Support .reloc *, BFD_RELOC_{NONE,16,32,64}, *
Fangrui Song [Thu, 30 Jun 2022 23:39:23 +0000 (16:39 -0700)]
[MC][Mips] Support .reloc *, BFD_RELOC_{NONE,16,32,64}, *

... to match most other common architectures which already support BFD_RELOC_*.
BFD_RELOC_NONE provides a generic way indicating a dependency between two
sections and is useful for some instrumentations which encode symbol index
information (e.g. `.cg_profile`).

2 years ago[VE] Support load/store vm regsiters
Kazushi (Jam) Marukawa [Sat, 25 Jun 2022 02:34:08 +0000 (11:34 +0900)]
[VE] Support load/store vm regsiters

Support load/store vm registers to memory location as a first step.
As a next step, support load/store vm registers to stack location.
This patch also adds several regression tests for not only load/store
vm registers but also missing load/store for vr registers.

Reviewed By: efocht

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

2 years ago[Sanitizer][Darwin] Lookup dyld image header via shared cache
Julian Lettner [Thu, 30 Jun 2022 19:13:15 +0000 (12:13 -0700)]
[Sanitizer][Darwin] Lookup dyld image header via shared cache

On macOS 13+, dyld itself has moved into the shared cache.  Looking it
up via vm_region_recurse_64() now causes spins/hangs/crashes.  We use a
different set of dyld APIs to find the image header in the shared cache.

rdar://92131949

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

2 years agoAdds AST matcher for ObjCStringLiteral
Rashmi Mudduluru [Wed, 29 Jun 2022 21:21:42 +0000 (14:21 -0700)]
Adds AST matcher for ObjCStringLiteral

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

2 years ago[RISCV] Remove an unnecessary copy of X0 in selectShiftMask.
Craig Topper [Thu, 30 Jun 2022 22:10:31 +0000 (15:10 -0700)]
[RISCV] Remove an unnecessary copy of X0 in selectShiftMask.

We know which instruction we're emitting so its ok to directly
encode X0 into the instruction. We only need to create a copy when
a constant 0 is selected without context of what instructions uses it.

2 years ago[NFC] Switch a few uses of undef to poison as placeholders for unreachble code
Nuno Lopes [Thu, 30 Jun 2022 22:01:27 +0000 (23:01 +0100)]
[NFC] Switch a few uses of undef to poison as placeholders for unreachble code

2 years agoImprove the formatting of static_assert messages
Corentin Jabot [Wed, 29 Jun 2022 17:13:19 +0000 (19:13 +0200)]
Improve the formatting of static_assert messages

Display 'static_assert failed: message' instead of
'static_assert failed "message"' to be consistent
with other implementations and be slightly more
readable.

Reviewed By: #libc, aaron.ballman, philnik, Mordante

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

2 years ago[fix/build] Fix bazel build rule.
rdzhabarov [Thu, 30 Jun 2022 21:43:09 +0000 (21:43 +0000)]
[fix/build] Fix bazel build rule.

2 years ago[LLDB][NativePDB] Return LLDB_INVALID_ADDRESS in PdbIndex::MakeVirtualAddress when...
Zequan Wu [Thu, 30 Jun 2022 21:32:31 +0000 (14:32 -0700)]
[LLDB][NativePDB] Return LLDB_INVALID_ADDRESS in PdbIndex::MakeVirtualAddress when input is invalid due to missing address info in symbol/public records.

2 years ago[flang] Expand semantics test coverage of collective subroutines
Naje George [Thu, 30 Jun 2022 21:26:54 +0000 (14:26 -0700)]
[flang] Expand semantics test coverage of collective subroutines

Add non-standard conforming calls that violate the intent(inout)
of errmsg argument for co_sum, co_max, co_min, and co_broadcast.
Add non-standard conforming calls that violate the argument
typing of errmsg argument for co_max, co_min, and co_broadcast.
Add standard conforming calls that reorder keyword arguments
for co_sum and co_reduce.

Reviewed By: ktras

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

2 years ago[InstCombine] Changing constant-indexed GEP of GEP to i8* for merging
William Huang [Thu, 30 Jun 2022 18:12:20 +0000 (18:12 +0000)]
[InstCombine] Changing constant-indexed GEP of GEP to i8* for merging

When merging GEP of GEP with constant indices, if the second GEP's offset is not divisible by the first GEP's element size, convert both type to i8* and merge.

Reviewed By: nikic

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

2 years ago[RISCV] Make custom isel for (add X, imm) used by load/stores more selective.
Craig Topper [Thu, 30 Jun 2022 21:11:09 +0000 (14:11 -0700)]
[RISCV] Make custom isel for (add X, imm) used by load/stores more selective.

Only handle immediates that would produce an ADDI or ADDIW of Lo12
as the final instruction in their materialization.

As the test change show this removes immediates that materialize
with lui+addiw that is not the same as lui+addi.

2 years ago[gn build] Port 0f94d2b385e7
LLVM GN Syncbot [Thu, 30 Jun 2022 21:13:26 +0000 (21:13 +0000)]
[gn build] Port 0f94d2b385e7

2 years ago[AMDGPU] Make v16i16/v16f16 legal
Piotr Sobczak [Thu, 30 Jun 2022 19:58:57 +0000 (21:58 +0200)]
[AMDGPU] Make v16i16/v16f16 legal

There are upcoming intrinsics to use the new types.

Reviewed By: rampitec

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

2 years agoFix test expectation positioning relative to FIXME comment
Reid Kleckner [Thu, 30 Jun 2022 21:07:46 +0000 (14:07 -0700)]
Fix test expectation positioning relative to FIXME comment

This new test was failing because the line number delta wasn't right.

2 years ago[flang] Add new semantics test for team_number function
Naje George [Thu, 30 Jun 2022 20:59:14 +0000 (13:59 -0700)]
[flang] Add new semantics test for team_number function

Add new semantics test for team_number and rename existing
team_number semantics test.

Reviewed By: ktras

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

2 years ago[mlir] Add Dead Code Analysis
Mogball [Thu, 23 Jun 2022 19:02:45 +0000 (19:02 +0000)]
[mlir] Add Dead Code Analysis

This patch implements the analysis state classes needed for sparse data-flow analysis and implements a dead-code analysis using those states to determine liveness of blocks, control-flow edges, region predecessors, and function callsites.

Depends on D126751

Reviewed By: rriddle, phisiart

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

2 years ago[NFC] Switch a few uses of undef to poison as placeholders for unreachble code
Nuno Lopes [Thu, 30 Jun 2022 20:46:19 +0000 (21:46 +0100)]
[NFC] Switch a few uses of undef to poison as placeholders for unreachble code

2 years ago[Kaleidoscope] Remove unused function argument
Marc Auberer [Thu, 30 Jun 2022 20:46:25 +0000 (20:46 +0000)]
[Kaleidoscope] Remove unused function argument

Removes an unused function argument from a code listing in the Kaleidoscope turorial in step 9.

Reviewed By: dblaikie, MaskRay

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

2 years ago[libFuzzer] Extend the fuzz target intarface to allow -1 return value.
Kostya Serebryany [Tue, 28 Jun 2022 18:36:30 +0000 (11:36 -0700)]
[libFuzzer] Extend the fuzz target intarface to allow -1 return value.

With this change, fuzz targets may choose to return -1
to indicate that the input should not be added to the corpus
regardless of the coverage it generated.

Reviewed By: morehouse

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

2 years ago[InstCombine] Fix a Wparentheses warning in an assert. NFC
Craig Topper [Thu, 30 Jun 2022 20:03:32 +0000 (13:03 -0700)]
[InstCombine] Fix a Wparentheses warning in an assert. NFC

2 years ago[RISCV] Replace some uses of XLenVT in RISCVDAGToDAGISel::Select with the original...
Craig Topper [Thu, 30 Jun 2022 19:27:46 +0000 (12:27 -0700)]
[RISCV] Replace some uses of XLenVT in RISCVDAGToDAGISel::Select with the original Node VT. NFCI

These should contain the same thing, but we aren't consistent about
which we use.

Since we call ReplaceNode, it seems more correct to use the initial VT.

2 years ago[AMDGPU] GFX11: automatically release VGPRs at the end of the shader
Jay Foad [Thu, 30 Jun 2022 15:31:49 +0000 (16:31 +0100)]
[AMDGPU] GFX11: automatically release VGPRs at the end of the shader

GFX11 has a new message type MSG_DEALLOC_VGPRS which can be used to
release a shader's VGPRs. Sending this at the end of a shader (just
before the s_endpgm) can help overall system performance in cases where
the s_endpgm would have to wait for outstanding VMEM stores to complete
before releasing the VGPRs.

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

2 years ago[InstCombine] canonicalize 'icmp (trunc X), C' to 'icmp (X & Mask), C'
Sanjay Patel [Thu, 30 Jun 2022 19:00:12 +0000 (15:00 -0400)]
[InstCombine] canonicalize 'icmp (trunc X), C' to 'icmp (X & Mask), C'

I looked at canonicalizing in the other direction, but that causes
many potential regressions and infinite loops because we already
(possibly wrongly) canonicalize "trunc X to i1" into an and+icmp.

This has a data layout restriction to avoid creating illegal
mask instructions, but we could remove that if we can show
that the backend can undo this when needed.

The motivating example from issue #56119 is modeled by the
PhaseOrdering test.

2 years ago[InstCombine] add tests for icmp (trunc X), C; NFC
Sanjay Patel [Thu, 30 Jun 2022 18:06:19 +0000 (14:06 -0400)]
[InstCombine] add tests for icmp (trunc X), C; NFC

2 years ago[PhaseOrdering] add test to show missing folds from PR56119; NFC
Sanjay Patel [Thu, 30 Jun 2022 17:58:23 +0000 (13:58 -0400)]
[PhaseOrdering] add test to show missing folds from PR56119; NFC

issue #56119

2 years ago[AMDGPU] add alternate tests for max-offset codegen; NFC
Sanjay Patel [Thu, 30 Jun 2022 12:10:51 +0000 (08:10 -0400)]
[AMDGPU] add alternate tests for max-offset codegen; NFC

As discussed in D128123, the existing test shows a possible
regression when converting sub to xor. This adds tests that
avoid that pattern but still has a offset near 65535. Also,
add a test with the canonical IR for the existing test to show
if the transform is happening with the expected pattern in IR.

2 years agoTest and document some C99 DRs
Aaron Ballman [Thu, 30 Jun 2022 19:46:13 +0000 (15:46 -0400)]
Test and document some C99 DRs

This captures the first 15 or so DRs in C99

2 years ago[SLP][X86] Add 32-bit vector stores to help vectorization opportunities
Simon Pilgrim [Thu, 30 Jun 2022 19:25:41 +0000 (20:25 +0100)]
[SLP][X86] Add 32-bit vector stores to help vectorization opportunities

Building on the work on D124284, this patch tags v4i8 and v2i16 vector loads as custom, enabling SLP to try to vectorize these types ending in a partial store (using the SSE MOVD instruction) - we already do something similar for 64-bit vector types.

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

2 years ago[Interpreter] Pass target features to JIT
Jonas Hahnfeld [Wed, 29 Jun 2022 20:30:56 +0000 (22:30 +0200)]
[Interpreter] Pass target features to JIT

This is required to support RISC-V where the '+d' target feature
indicates the presence of the D instruction set extension, which
changes to the Hard-float 'd' ABI.

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

2 years ago[pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node stats.
Sam McCall [Thu, 30 Jun 2022 17:50:40 +0000 (19:50 +0200)]
[pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node stats.

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

2 years agoApparently you need a special makefile flag to use threads on Linux.
Jim Ingham [Thu, 30 Jun 2022 19:09:31 +0000 (12:09 -0700)]
Apparently you need a special makefile flag to use threads on Linux.

This is a follow-up to https://reviews.llvm.org/D128776.

2 years ago[OpenMP] Initial parsing and sema support for 'parallel masked taskloop' construct
Fazlay Rabbi [Thu, 30 Jun 2022 17:59:33 +0000 (10:59 -0700)]
[OpenMP] Initial parsing and sema support for 'parallel masked taskloop' construct

This patch gives basic parsing and semantic support for
"parallel masked taskloop" construct introduced in
OpenMP 5.1 (section 2.16.9)

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

2 years agoThreads which hit a breakpoint but fail the condition are considered
Jim Ingham [Wed, 29 Jun 2022 01:06:30 +0000 (18:06 -0700)]
Threads which hit a breakpoint but fail the condition are considered
not to be hit.  But another thread might be hit at the same time and
actually stop.  So we have to be sure to switch the first thread's
stop info to eStopReasonNone or we'll report a hit when the condition
failed, which is confusing.

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

2 years agoRevert "Deferred Concept Instantiation Implementation"
Jonas Devlieghere [Thu, 30 Jun 2022 18:35:12 +0000 (11:35 -0700)]
Revert "Deferred Concept Instantiation Implementation"

This reverts commit 2f207439521d62d9551b2884158368e8b34084e5 because it
triggers an assertion when building an LLDB test program:

  Assertion failed: (InstantiatingSpecializations.empty() && "failed to
  clean up an InstantiatingTemplate?"), function ~Sema, file
  /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Sema/Sema.cpp,
  line 458.

More details in https://reviews.llvm.org/D126907.

2 years ago[RISCV] Use getVTList to simplify creation of vleff MachineSDNode. NFC
Craig Topper [Thu, 30 Jun 2022 18:28:02 +0000 (11:28 -0700)]
[RISCV] Use getVTList to simplify creation of vleff MachineSDNode. NFC

We don't need to pass the 3 VTs separately, we already have a list
available to us.

2 years ago[llvm-objdump] Default to --mcpu=future for PPC64
Fangrui Song [Thu, 30 Jun 2022 18:30:34 +0000 (11:30 -0700)]
[llvm-objdump] Default to --mcpu=future for PPC64

GNU objdump disassembles all unknown instructions by default. Match this user
friendly behavior with the cpu value `future`.

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

2 years ago[llvm-objdump] Default to --mattr=+all for AArch64
Fangrui Song [Thu, 30 Jun 2022 18:17:55 +0000 (11:17 -0700)]
[llvm-objdump] Default to --mattr=+all for AArch64

GNU objdump disassembles all unknown instructions by default. Match this user
friendly behavior with the target feature "all" (D128029) designed for disassemblers.

Reviewed By: jhenderson

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

2 years ago[RISCV] Use the VT passed into selectImm instead of XLenVT. NFCI
Craig Topper [Thu, 30 Jun 2022 18:05:18 +0000 (11:05 -0700)]
[RISCV] Use the VT passed into selectImm instead of XLenVT. NFCI

I think the VT pased in will always be XLen.

2 years ago[flang] Add semantics test for `get_team`
Katherine Rasmussen [Wed, 22 Jun 2022 19:01:04 +0000 (12:01 -0700)]
[flang] Add semantics test for `get_team`

Add a semantics test for the intrinsic function `get_team`.

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

2 years ago[mlir][Inliner] Support recursion in Inliner
Javed Absar [Sun, 5 Jun 2022 12:42:13 +0000 (13:42 +0100)]
[mlir][Inliner] Support recursion in Inliner

This fixes  Bug https://github.com/llvm/llvm-project/issues/53492
 and uses InlineHistory to track recursive inlining.

Reviewed By: rriddle

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

2 years agoUseful error when input dim is unused by LHS/RHS.
Benoit Jacob [Thu, 30 Jun 2022 15:56:15 +0000 (15:56 +0000)]
Useful error when input dim is unused by LHS/RHS.

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

2 years agoRevert "[clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface"
Aaron Ballman [Thu, 30 Jun 2022 17:38:42 +0000 (13:38 -0400)]
Revert "[clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface"

This reverts commit 329fae7103d355e728cc326a0a9abef889ccc577.

This should fix failing test bots like:
https://lab.llvm.org/buildbot/#/builders/91/builds/11328

2 years ago[AArch64] Add target feature "all"
Fangrui Song [Thu, 30 Jun 2022 17:37:58 +0000 (10:37 -0700)]
[AArch64] Add target feature "all"

This is used by disassemblers: `llvm-mc -disassemble -mattr=` and `llvm-objdump --mattr=`.
The main use case is for llvm-objdump to disassemble all known instructions
(D128030).

In user-facing tools, "all" is intentionally not supported in producers:
integrated assembler (`.arch_extension all`), clang -march (`-march=armv9.3a+all`).
Due to the code structure, `llvm-mc -mattr=+all` `llc -mattr=+all` are not
rejected (they are internal tool). Add `llvm/test/CodeGen/AArch64/mattr-all.ll`
to catch behavior changes.

AArch64SysReg::SysReg::haveFeatures: check `FeatureAll` to print
`AArch64SysReg::SysReg::AltName` for some system registers (e.g. `ERRIDR_EL1, RNDR`).

AArch64.td: add `AssemblerPredicateWithAll` to additionally test `FeatureAll`.
Change all `AssemblerPredicate` (except `UseNegativeImmediates`) to `AssemblerPredicateWithAll`.

utils/TableGen/{DecoderEmitter,SubtargetFeatureInfo}.cpp: support arbitrarily
nested all_of, any_of, and not.

Note: A predicate supports all_of, any_of, and not. For a target (though
currently not for AArch64) an encoding may be disassembled differently with
different target features.
Note: AArch64MCCodeEmitter::computeAvailableFeatures is not available to
the disassembler.

Reviewed By: peter.smith, lenary

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

2 years ago[InstCombine] Fix memrchr logic error that prevents folding
Martin Sebor [Thu, 30 Jun 2022 17:22:28 +0000 (11:22 -0600)]
[InstCombine] Fix memrchr logic error that prevents folding

Correct a logic bug in the memrchr enhancement added in D123629 that
makes it ineffective in a subset of cases.

Reviewed By: nikic

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

2 years ago[AArch64] Make FeatureFuseAdrpAdd a tune feature
Fangrui Song [Thu, 30 Jun 2022 17:32:38 +0000 (10:32 -0700)]
[AArch64] Make FeatureFuseAdrpAdd a tune feature

Update D120104 to add FeatureFuseAdrpAdd to Processor#TuneFeatures
instead of Processor#Features, similar to FeatureFuseAES, and matching
Tune*.

This enables FeatureFuseAdrpAdd for `clang -mcpu=xxx -mtune=generic` even
if xxx does not set FeatureFuseAdrpAdd.

Reviewed By: alexander-shaposhnikov, peter.smith

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

2 years ago[clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface
Vaibhav Yenamandra [Thu, 30 Jun 2022 17:23:15 +0000 (13:23 -0400)]
[clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

Create an interface for writing SARIF documents from within clang:

The primary intent of this change is to introduce the interface
clang::SarifDocumentWriter, which allows incrementally adding
diagnostic data to a JSON backed document. The proposed interface is
not yet connected to the compiler internals, which will be covered in
future work. As such this change will not change the input/output
interface of clang.

This change also introduces the clang::FullSourceRange type that is
modeled after clang::SourceRange + clang::FullSourceLoc, this is useful
for packaging a pair of clang::SourceLocation objects with their
corresponding SourceManagers.

Previous discussions:

RFC for this change: https://lists.llvm.org/pipermail/cfe-dev/2021-March/067907.html
https://lists.llvm.org/pipermail/cfe-dev/2021-July/068480.html
SARIF Standard (2.1.0):

https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html

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

2 years ago[llvm-reduce] Change initialization order to fix bots. NFC
Matthew Voss [Thu, 30 Jun 2022 16:44:23 +0000 (09:44 -0700)]
[llvm-reduce] Change initialization order to fix bots. NFC

Fixes this error:
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/
llvm-project/llvm/tools/llvm-reduce/TestRunner.cpp:20:7:
error: field 'TM' will be initialized after field 'ToolName'
[-Werror,-Wreorder-ctor]
      TM(std::move(TM)), ToolName(ToolName) {
      ^~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~~~~
      Program(std::move(Program)) TM(std::move(TM))
1 error generated.

https://lab.llvm.org/buildbot/\#/builders/77/builds/19154

2 years ago[llvm-dwarfdump] --show-sources option to show all sources
Daniel Thornburgh [Wed, 16 Feb 2022 00:46:54 +0000 (00:46 +0000)]
[llvm-dwarfdump] --show-sources option to show all sources

This option allows printing all sources used by an object file.

Reviewed By: dblaikie, jhenderson

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

2 years ago[SystemZ] Add support for tune-cpu attribute
Kai Nacke [Thu, 30 Jun 2022 15:29:44 +0000 (11:29 -0400)]
[SystemZ] Add support for tune-cpu attribute

clang (like gcc) has the `-mtune=` command line option. This option
adds the `"tune-cpu"` attribute to a function. The intended functionality
is that the scheduling model of that cpu is used. E.g. `-mtune=z15 -march=z14`
generates only instructions supported on z14 but uses the scheduling model
of z15 for it.
This PR adds the infrastructure to support this.

Reviewed By: uweigand

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

2 years ago[mlir][VectorToGPU] Fix support for i4, col-major operand support
Christopher Bate [Fri, 17 Jun 2022 17:40:28 +0000 (11:40 -0600)]
[mlir][VectorToGPU] Fix support for i4, col-major operand support

For the conversion to nvgpu `mma.sync` and `ldmatrix` pathways, the code
was missing support for the `i4` data type. While fixing this, another
bug was discoverd that caused the number of ldmatrix tiles calculated for
certain operand types and configurations to be incorrect. This change
fixes both issues and adds additional tests.

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

2 years ago[lldb] XFAIL TestObjCXXBridgedPO on macOS Ventura
Jonas Devlieghere [Thu, 30 Jun 2022 16:18:31 +0000 (09:18 -0700)]
[lldb] XFAIL TestObjCXXBridgedPO on macOS Ventura

TestObjCXXBridgedPO is broken on macOS Ventura (but not on macOS
Monterey). I took a look but it doesn't seem trivial. I'm XFAILing the
test until Adrian, who wrote the test, can take a look.

rdar://96224141

2 years ago[AMDGPU] Check for CopyToReg PhysReg clobbers in pre-RA-sched
jeff [Mon, 27 Jun 2022 20:17:00 +0000 (20:17 +0000)]
[AMDGPU] Check for CopyToReg PhysReg clobbers in pre-RA-sched

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

2 years ago[flang] Fix "not yet implemented" message for CHARACTER MIN/MAX
Valentin Clement [Thu, 30 Jun 2022 16:10:53 +0000 (18:10 +0200)]
[flang] Fix "not yet implemented" message for CHARACTER MIN/MAX

The check to see if the arguments for the MIN/MAX intrinsics were of CHARACTER
type was not handling assumed length characters.  In this case, the FIR type is
"!fir.ref<!fir.char<1,?>>".

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

Reviewed By: PeteSteinfeld

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

Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
2 years ago[clang][dataflow] Replace TEST_F with TEST where possible
Sam Estep [Thu, 30 Jun 2022 16:03:23 +0000 (16:03 +0000)]
[clang][dataflow] Replace TEST_F with TEST where possible

Many of our tests are currently written using `TEST_F` where the test fixture class doesn't have any `SetUp` or `TearDown` methods, and just one helper method. In those cases, this patch deletes the class and pulls its method out into a standalone function, using `TEST` instead of `TEST_F`.

There are still a few test files leftover in `clang/unittests/Analysis/FlowSensitive/` that use `TEST_F`:

- `DataflowAnalysisContextTest.cpp` because the class contains a `Context` field which is used
- `DataflowEnvironmentTest.cpp` because the class contains an `Environment` field which is used
- `SolverTest.cpp` because the class contains a `Vals` field which is used
- `TypeErasedDataflowAnalysisTest.cpp` because there are several different classes which all share the same method name

Reviewed By: ymandel, sgatev

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

2 years ago[RISCV] Fold (sra (add (shl X, 32), C1), 32 - C) -> (shl (sext_inreg (add X, C1), C)
Craig Topper [Thu, 30 Jun 2022 15:52:57 +0000 (08:52 -0700)]
[RISCV] Fold (sra (add (shl X, 32), C1), 32 - C) -> (shl (sext_inreg (add X, C1), C)

Similar for a subtract with a constant left hand side.

(sra (add (shl X, 32), C1<<32), 32) is the canonical IR from InstCombine
for (sext (add (trunc X to i32), 32) to i32).

For RISCV, we should lower this as addiw which means turning it into
(sext_inreg (add X, C1)).

There is an existing DAG combine to convert back to (sext (add (trunc X
to i32), 32) to i32), but it requires isTruncateFree to return true
and for i32 to be a legal type as it used sign_extend and truncate
nodes. So that doesn't work for RISCV.

If the outer sra happens be used by a shl by constant, it will be
folded and the shift amount of the sra will be changed before we
can do our own DAG combine. This requires us to match the more
general pattern and restore the shl.

I had wanted to do this as a separate (add (shl X, 32), C1<<32) ->
(shl (add X, C1), 32) combine, but that hit an infinite loop for some
values of C1.

Reviewed By: asb

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

2 years ago[RISCV] DAG combine (sra (shl X, 32), 32 - C) -> (shl (sext_inreg X, i32), C).
Craig Topper [Thu, 30 Jun 2022 15:52:43 +0000 (08:52 -0700)]
[RISCV] DAG combine (sra (shl X, 32), 32 - C) -> (shl (sext_inreg X, i32), C).

The sext_inreg can often be folded into an earlier instruction by
using a W instruction. The sext_inreg also works better with our ABI.

This is one of the steps to improving the generated code for this https://godbolt.org/z/hssn6sPco

Reviewed By: asb

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

2 years ago[RISCV] Pre-commit tests for D128869. NFC
Craig Topper [Wed, 29 Jun 2022 23:23:41 +0000 (16:23 -0700)]
[RISCV] Pre-commit tests for D128869. NFC

2 years ago[llvm] Fix the modules build
Jonas Devlieghere [Thu, 30 Jun 2022 15:55:51 +0000 (08:55 -0700)]
[llvm] Fix the modules build

Fixes error: missing '#include "llvm/IR/FMF.h"'; 'FastMathFlags' must be
defined before it is used in llvm/include/llvm/IR/NoFolder.h.

2 years ago[llvm-reduce] Add support for LTO bitcode files
Matthew Voss [Thu, 30 Jun 2022 15:53:00 +0000 (08:53 -0700)]
[llvm-reduce] Add support for LTO bitcode files

Adds support for reading and writing LTO bitcode files.

  - Emit a summary if the original bitcode file had a summary
  - Use split LTO units if the original bitcode file used them.

Reviewed By: arsenm

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

2 years ago[flang] Fix one corner case in reshape intrinsic
Peixin Qiao [Thu, 30 Jun 2022 15:52:44 +0000 (23:52 +0800)]
[flang] Fix one corner case in reshape intrinsic

As Fortran 2018 16.9.163, the reshape is the only intrinsic which
requires the shape argument to be rank-one integer array and the SIZE
of it to be one constant expression. The current expression lowering
converts the shape expression with slice in intrinsic into one box value
with the box element type of unknown extent. However, the genReshape
requires the box element type to be constant size. So, convert the box
value into one with box element type of sequence of 1 x constant. This
corner case is found in cam4 in SPEC 2017
https://github.com/llvm/llvm-project/issues/56140.

Reviewed By: Jean Perier

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

2 years ago[ARM] Add Thumb-1 CTTZ codegen tests. NFC
David Green [Thu, 30 Jun 2022 15:45:00 +0000 (16:45 +0100)]
[ARM] Add Thumb-1 CTTZ codegen tests. NFC

2 years ago[AMDGPU] gfx11 WMMA instruction support
Piotr Sobczak [Tue, 28 Jun 2022 18:00:03 +0000 (14:00 -0400)]
[AMDGPU] gfx11 WMMA instruction support

gfx11 introduces new WMMA (Wave Matrix Multiply-accumulate)
instructions.

Reviewed By: arsenm, #amdgpu

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

2 years ago[flang][NFC] Fix warning
Valentin Clement [Thu, 30 Jun 2022 14:56:29 +0000 (16:56 +0200)]
[flang][NFC] Fix warning

2 years ago[pseudo] Forest dump ascii art isn't broken by large indices
Sam McCall [Thu, 30 Jun 2022 14:52:55 +0000 (16:52 +0200)]
[pseudo] Forest dump ascii art isn't broken by large indices

2 years ago[libc++] Remove dead code and unneeded C++03 specializations from type_traits
Nikolas Klauser [Thu, 30 Jun 2022 12:11:26 +0000 (14:11 +0200)]
[libc++] Remove dead code and unneeded C++03 specializations from type_traits

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years ago[libc++] Implement P0618R0 (Deprecating <codecvt>)
Nikolas Klauser [Thu, 30 Jun 2022 11:47:26 +0000 (13:47 +0200)]
[libc++] Implement P0618R0 (Deprecating <codecvt>)

Reviewed By: ldionne, #libc

Spies: cfe-commits, llvm-commits, libcxx-commits

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

2 years ago[libc][Obvious] Do not add __NO_ to targets with FLAG__NO suffix.
Tue Ly [Thu, 30 Jun 2022 14:44:08 +0000 (10:44 -0400)]
[libc][Obvious] Do not add __NO_ to targets with FLAG__NO suffix.

2 years ago[lldb] Fix libc++ string formatter for the "unstable" layout
Pavel Labath [Thu, 30 Jun 2022 14:30:51 +0000 (16:30 +0200)]
[lldb] Fix libc++ string formatter for the "unstable" layout

D128285 only changed the stable (v1) layout, so the matching change in
D128694 broke the formatting of the unstable strings. This fixes that,
and ensures compatibility with all older layouts as well.

2 years ago[IRBuilder] Migrate all binops to folding API
Nikita Popov [Thu, 30 Jun 2022 10:52:31 +0000 (12:52 +0200)]
[IRBuilder] Migrate all binops to folding API

Migrate all binops to use FoldXYZ rather than CreateXYZ APIs,
which are compatible with InstSimplifyFolder and fallible constant
folding.

Rather than continuing to add one method for every single operator,
add a generic FoldBinOp (plus variants for nowrap, exact and fmf
operators), which we would need anyway for CreateBinaryOp.

This change is not NFC because IRBuilder with InstSimplifyFolder
may perform more folding. However, this patch changes SCEVExpander
to not use the folder in InsertBinOp to minimize practical impact
and keep this change as close to NFC as possible.

2 years agoFix PDB/func-symbols.test for Arm/Windows
Muhammad Omair Javaid [Wed, 29 Jun 2022 09:22:56 +0000 (13:22 +0400)]
Fix PDB/func-symbols.test for Arm/Windows

PDB/func-symbols.test was orignally written for 32bit x86, keeping in
mind cdecl and stdcall calling conventions which does name mangling for
example like adding "_" underscore before function name.
This is only x86 specific but purpose of pointers.test is NOT to test
calling convention.
I have made a minor change to make this test pass on Windows/Arm.

2 years agoadd testcases for D128647, NFC
Chen Zheng [Mon, 27 Jun 2022 10:24:41 +0000 (06:24 -0400)]
add testcases for D128647, NFC

2 years agoFix TestCommandScript.py for Arm/Windows
Muhammad Omair Javaid [Wed, 29 Jun 2022 09:34:36 +0000 (13:34 +0400)]
Fix TestCommandScript.py for Arm/Windows

TestCommandScript.py fails on Arm/Windows due following issues:
https://llvm.org/pr56288
https://llvm.org/pr56292

LLDB fails to skip prologue and also step over library function or
nodebug functions fails due to PDB/DWARF mismatch.

This patch replace function breakpoint with line breakpoint so that we
can expect LLDB to stop on desired line. Also replace dwarf with PDB
debug info for this test only.

2 years agoDeferred Concept Instantiation Implementation
Erich Keane [Thu, 19 May 2022 13:44:34 +0000 (06:44 -0700)]
Deferred Concept Instantiation Implementation

This is a continuation of D119544.  Based on @rsmith 's feed back
showing me https://eel.is/c++draft/temp#friend-9, We should properly
handle friend functions now.

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

2 years ago[flang] Convert assertion to a TODO
Valentin Clement [Thu, 30 Jun 2022 13:45:39 +0000 (15:45 +0200)]
[flang] Convert assertion to a TODO

The original assertion is not necessarily correct since the shape
argument may involve a slice of an array (an expression) and not a whole
vector with constant length. In the presence of a slice operation, the
size must be computed (left as a TODO for now).

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

Reviewed By: jeanPerier

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

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2 years ago[gn build] Port a591c7ca0d9f
LLVM GN Syncbot [Thu, 30 Jun 2022 13:27:00 +0000 (13:27 +0000)]
[gn build] Port a591c7ca0d9f

2 years ago[VNCoercion] Separate constant/non-constant mem intrinsic implementations (NFCI)
Nikita Popov [Thu, 30 Jun 2022 13:19:26 +0000 (15:19 +0200)]
[VNCoercion] Separate constant/non-constant mem intrinsic implementations (NFCI)

This means we no longer need to have the same API between IRBuilder
and IRBuilderFolder.

The constant case is substantially simpler, so implementing it
separately isn't an undue burden.

2 years ago[HLSL] Change WaveActiveCountBits to wrapper of __builtin_hlsl_wave_active_count_bits
Xiang Li [Wed, 29 Jun 2022 21:00:28 +0000 (14:00 -0700)]
[HLSL] Change WaveActiveCountBits to wrapper of __builtin_hlsl_wave_active_count_bits

Change WaveActiveCountBits from builtin into wrapper of __builtin_hlsl_wave_active_count_bits.
For comment at
https://reviews.llvm.org/D126857#inline-1235949

Reviewed By: beanz

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

2 years agoCorrect -Winfinite-recursion warning on potentially-unevaluated operand
Prathit Aswar [Thu, 30 Jun 2022 13:07:49 +0000 (09:07 -0400)]
Correct -Winfinite-recursion warning on potentially-unevaluated operand

Fixing issue "incorrect -Winfinite-recursion warning on potentially-
unevaluated operand".

We add a dedicated visit function (VisitCXXTypeidExpr) for typeid,
instead of using the default (VisitStmt). In this new function we skip
over building the CFG for unevaluated operands of typeid.

Fixes #21668

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

2 years ago[VNCoercion] Use ConstantFoldLoadFromConst API (NFCI)
Nikita Popov [Thu, 30 Jun 2022 12:49:44 +0000 (14:49 +0200)]
[VNCoercion] Use ConstantFoldLoadFromConst API (NFCI)

Nowdays we have a generic constant folding API to load a type from
an offset. It should be able to do anything that VNCoercion can do.

This avoids the weird templating between IRBuilder and ConstantFolder
in one function, which is will stop working as the IRBuilderFolder
moves from CreateXYZ to FoldXYZ APIs.

Unfortunately, this doesn't eliminate this pattern from VNCoercion
entirely yet.

2 years ago[libTooling][NFC] Add a comment about comment parsing to getAssociatedRange.
Aaron Jacobs [Thu, 30 Jun 2022 12:45:42 +0000 (12:45 +0000)]
[libTooling][NFC] Add a comment about comment parsing to getAssociatedRange.

It took me multiple hours of debugging plus asking an expert for help to
figure out why this function didn't do what it promised to do. It turns
out there is a flag that needs to be set. Document this, in an attempt
to save the next person the surprise.

Reviewed By: ymandel

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

2 years ago[libc++] Disentangle _If, _Or and _And
Nikolas Klauser [Thu, 30 Jun 2022 10:57:51 +0000 (12:57 +0200)]
[libc++] Disentangle _If, _Or and _And

Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, libcxx-commits

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

2 years ago[LV] Move LoopVersioning creation to LVP::execute.
Florian Hahn [Thu, 30 Jun 2022 11:14:31 +0000 (12:14 +0100)]
[LV] Move LoopVersioning creation to LVP::execute.

At the moment LoopVersioning is only created for inner-loop
vectorization. This patch moves it to LVP::execute, which means it will
also be added for epilogue vectorization. As a consequence, the proper
noalias metadata is now also added to epilogue vector loops.

LVer will be moved to VPTransformState as follow-up.

Reviewed By: Ayal

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

2 years ago[test] Add a lit test fshl-splat-undef.ll
Xiang1 Zhang [Thu, 30 Jun 2022 10:25:01 +0000 (18:25 +0800)]
[test] Add a lit test fshl-splat-undef.ll

2 years ago[NFC][XCOFF] remove an unused global variable.
esmeyi [Thu, 30 Jun 2022 10:55:49 +0000 (06:55 -0400)]
[NFC][XCOFF] remove an unused global variable.

2 years agoUglify __support/xlocale
Michael Platings [Tue, 28 Jun 2022 09:42:20 +0000 (10:42 +0100)]
Uglify __support/xlocale

This allows including the headers without risk of conflict with
user-defined macros e.g. max

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

2 years ago[IR] Fix typo in comment. NFC
Fraser Cormack [Thu, 30 Jun 2022 10:30:12 +0000 (11:30 +0100)]
[IR] Fix typo in comment. NFC

2 years ago[mlir][Linalg] Uniformize SplitReduction transforms and add option to use Bufferizati...
Nicolas Vasilache [Tue, 28 Jun 2022 12:17:32 +0000 (05:17 -0700)]
[mlir][Linalg] Uniformize SplitReduction transforms and add option to use Bufferization::AllocTensor

This revision merges the 2 split_reduction transforms and adds extra control by using attributes.

SplitReduction is known to require a concrete additional buffer to store tempoaray information.
Add an option to introduce a `bufferization.alloc_tensor` instead of `linalg.init_tensor`.
This behaves better with subset-based tiling and bufferization.

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