platform/upstream/llvm.git
2 years ago[lldb][trace] Add a basic function call dump [2] - Implement the reconstruction algorithm
Walter Erquinigo [Mon, 10 Oct 2022 19:57:13 +0000 (12:57 -0700)]
[lldb][trace] Add a basic function call dump [2] - Implement the reconstruction algorithm

This diff implements the reconstruction algorithm for the call tree and
add tests.

See TraceDumper.h for documentation and explanations.

One important detail is that the tree objects are in TraceDumper, even
though Trace.h is a better home. I'm leaving that as future work.

Another detail is that this code is as slow as dumping the entire
symolicated trace, which is not that bad tbh. The reason is that we use
symbols throughout the algorithm and we are not being careful about
memory and speed. This is also another area for future improvement.

Lastly, I made sure that incomplete traces work, i.e. you start tracing
very deep in the stack or failures randomly appear in the trace.

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

2 years ago[lldb][trace] Add a basic function call dumpdump [1] - Add the command scaffolding
Walter Erquinigo [Sat, 8 Oct 2022 21:06:44 +0000 (14:06 -0700)]
[lldb][trace] Add a basic function call dumpdump [1] - Add the command scaffolding

The command is thread trace dump function-calls and as minimum will
require printing to a file in json and non-json format

I added a test

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

2 years ago[libc] Add termios.h and the implementation of functions declared in it.
Siva Chandra Reddy [Mon, 17 Oct 2022 16:27:45 +0000 (16:27 +0000)]
[libc] Add termios.h and the implementation of functions declared in it.

Reviewed By: lntue, michaelrj

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

2 years ago[BOLT] Fix instruction encoding validation
Maksim Panchenko [Mon, 17 Oct 2022 23:15:59 +0000 (16:15 -0700)]
[BOLT] Fix instruction encoding validation

Always use non-symbolizing disassembler for instruction encoding
validation as symbols will be treated as undefined/zeros be the encoder
and causing byte sequence mismatches.

Reviewed By: Amir

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

2 years agoFix incorrect check for running out of source locations.
Paul Pluzhnikov [Tue, 18 Oct 2022 20:47:55 +0000 (20:47 +0000)]
Fix incorrect check for running out of source locations.

When CurrentLoadedOffset is less than TotalSize, current code will
trigger unsigned overflow and will not return an "allocation failed"
indicator.

Google ref: b/248613299

Reviewed By: dblaikie

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

2 years ago[mlir][sparse] Use the runtime DimLevelType instead of a separate tablegen enum
wren romano [Fri, 14 Oct 2022 23:40:28 +0000 (16:40 -0700)]
[mlir][sparse] Use the runtime DimLevelType instead of a separate tablegen enum

This differential replaces all uses of SparseTensorEncodingAttr::DimLevelType with DimLevelType.  The next differential will break out a separate library for the DimLevelType enum, so that the Dialect code doesn't need to depend on the rest of the runtime

Depends On D135995

Reviewed By: aartbik

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

2 years ago[clang] Move variable declaration closer to use
Nico Weber [Tue, 18 Oct 2022 20:39:55 +0000 (16:39 -0400)]
[clang] Move variable declaration closer to use

...and add some whitespace to delimit the three logical steps done in this
function.

No behavior change.

2 years ago[SystemZ][z/OS][libcxx]: fix the mask in stage2_float_loop function
Nancy Wang [Tue, 18 Oct 2022 19:53:03 +0000 (15:53 -0400)]
[SystemZ][z/OS][libcxx]: fix the mask in stage2_float_loop function

This patch is to fix issue related to __stage2_float_loop function, float point value comparison is not working on EBCDIC mode because the mask is hard-coded and assumes character is ASCII, fix is to use toupper function when do the comparison.

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

2 years ago[mlir][MemRef] Fix the simplification of extract_strided_metadata(subview)
Quentin Colombet [Mon, 17 Oct 2022 19:40:19 +0000 (19:40 +0000)]
[mlir][MemRef] Fix the simplification of extract_strided_metadata(subview)

Prior to this patch we were wrongly applying the sub-strides to the
computation of the final offset of the subview.

Put differently, we were computing the offset as:
```
offset = baseOffset + sum(subOffset#i * baseStrides#i * subSizes#i)
```
Whereas we should be doing:
```
offset = baseOffset + sum(subOffset#i * baseStrides#i)
```
I.e., drop the subSizes#i term from the sum.

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

2 years ago[gn build] Port 594fa1474f0c
LLVM GN Syncbot [Tue, 18 Oct 2022 19:15:31 +0000 (19:15 +0000)]
[gn build] Port 594fa1474f0c

2 years ago[mlir][sparse] rename the values of the runtime DimLevelType
wren romano [Fri, 14 Oct 2022 23:36:14 +0000 (16:36 -0700)]
[mlir][sparse] rename the values of the runtime DimLevelType

This change is to make way for reusing the DimLevelType enum in lieu of the SparseTensorEncodingAttr::DimLevelType enum, but broken out to make it quick and easy to review

Reviewed By: aartbik

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

2 years ago[C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions
Yuanfang Chen [Tue, 18 Oct 2022 18:51:02 +0000 (11:51 -0700)]
[C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

This implementation matches GCC behavior in that [[ https://eel.is/c++draft/temp.func.order#6.2.1 | temp.func.order p6.2.1 ]] is not implemented [1]. I reached out to the GCC author to confirm that some changes elsewhere to overload resolution are probably needed, but no solution has been developed sufficiently [3].

Most of the wordings are implemented straightforwardly. However,
for [[ https://eel.is/c++draft/temp.func.order#6.2.2 | temp.func.order p6.2.2 ]] "... or if the function parameters that positionally correspond between the two templates are not of the same type", the "same type" is not very clear ([2] is a bug related to this). Here is a quick example
```
template <C T, C U>        int f(T, U);
template <typename T, C U> int f(U, T);

int x = f(0, 0);
```
Is the `U` and `T` from different `f`s the "same type"? The answer is NO even though both `U` and `T` are deduced to be `int` in this case. The reason is that `U` and `T` are dependent types, according to [[ https://eel.is/c++draft/temp.over.link#3 |  temp.over.link p3 ]], they can not be the "same type".

To check if two function parameters are the "same type":
* For //function template//: compare the function parameter canonical types and return type between two function templates.
* For //class template/partial specialization//: by [[ https://eel.is/c++draft/temp.spec.partial.order#1.2 | temp.spec.partial.order p1.2 ]], compare the injected template arguments between two templates using hashing(TemplateArgument::Profile) is enough.

[1] https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=57b4daf8dc4ed7b669cc70638866ddb00f5b7746
[2] https://github.com/llvm/llvm-project/issues/49308
[3] https://lists.isocpp.org/core/2020/06/index.php#msg9392

Fixes https://github.com/llvm/llvm-project/issues/54039
Fixes https://github.com/llvm/llvm-project/issues/49308 (PR49964)

Reviewed By: royjacobson, #clang-language-wg, mizvekov

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

2 years ago[libc++][chrono] Fixes build.
Mark de Wever [Tue, 18 Oct 2022 18:57:54 +0000 (20:57 +0200)]
[libc++][chrono] Fixes build.

Changes in D134742 were not properly propagated to D136037 before
landing.

2 years ago[SLP]Generalize cost model.
Alexey Bataev [Thu, 18 Nov 2021 23:59:30 +0000 (15:59 -0800)]
[SLP]Generalize cost model.

Generalized the cost model estimation. Improved cost model estimation
for repeated scalars (no need to count their cost anymore), improved
  cost model for extractelement instructions.

cpu2017
   511.povray_r             0.57
   520.omnetpp_r           -0.98
   521.wrf_r               -0.01
   525.x264_r               3.59 <+
   526.blender_r           -0.12
   531.deepsjeng_r         -0.07
   538.imagick_r           -1.42
Geometric mean:  0.21

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

2 years ago[Clang] update cxx_dr_status.html by running make_cxx_dr_status
Yuanfang Chen [Tue, 18 Oct 2022 18:24:38 +0000 (11:24 -0700)]
[Clang] update cxx_dr_status.html by running make_cxx_dr_status

For https://github.com/llvm/llvm-project/issues/58382

Reviewed By: erichkeane

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

2 years ago[AArch64][Windows] Add MC support for save_any_reg.
Eli Friedman [Tue, 18 Oct 2022 18:44:01 +0000 (11:44 -0700)]
[AArch64][Windows] Add MC support for save_any_reg.

Representing this as 12 separate operations is a bit ugly, but
trying to represent the different modes using a bitfield seemed worse.

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

2 years ago[libc++][chrono] Implements formatter weekday.
Mark de Wever [Sun, 20 Mar 2022 12:40:02 +0000 (13:40 +0100)]
[libc++][chrono] Implements formatter weekday.

Partially implements:
- P1361 Integration of chrono with text formatting
- P2372 Fixing locale handling in chrono formatters

Depends on D134742

Reviewed By: ldionne, #libc

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

2 years ago[libc++][chrono] Implements formatter duration.
Mark de Wever [Sun, 20 Mar 2022 12:40:02 +0000 (13:40 +0100)]
[libc++][chrono] Implements formatter duration.

Partially implements:
- P1361 Integration of chrono with text formatting
- P2372 Fixing locale handling in chrono formatters
- LWG3270 Parsing and formatting %j with durations

Completes:
- P1650R0 std::chrono::days with 'd' suffix
- LWG3262 Formatting of negative durations is not specified
- LWG3314 Is stream insertion behavior locale dependent when Period::type is micro?

Reviewed By: ldionne, #libc

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

2 years ago[libc++][ranges] implement `std::ranges::drop_while_view`
Hui Xie [Fri, 7 Oct 2022 17:07:54 +0000 (18:07 +0100)]
[libc++][ranges] implement `std::ranges::drop_while_view`

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

2 years agoRevert "[SLP]Generalize cost model."
Alexey Bataev [Tue, 18 Oct 2022 18:23:43 +0000 (11:23 -0700)]
Revert "[SLP]Generalize cost model."

This reverts commit f12fb91188b836e1bddb36bacbbdb8e4ab70b9b6 and
f5c747bfbe36b8f53e6fe2d85ffcaecba6d7153c to fix detected non-initialized
var use.

2 years agoRevert "Recommit "[LoopFlatten] Enable it by default""
Sjoerd Meijer [Tue, 18 Oct 2022 17:54:04 +0000 (23:24 +0530)]
Revert "Recommit "[LoopFlatten] Enable it by default""

This reverts commit 5b9597f59a445523bd59b5251ab1c2865e74919f.

A miscompilation was reported:
https://github.com/llvm/llvm-project/issues/58441

Reverting this while I look at that.

2 years agoRevert "[lldb-tests] Remove dubious standard library flag"
Felipe de Azevedo Piovezan [Tue, 18 Oct 2022 17:59:29 +0000 (13:59 -0400)]
Revert "[lldb-tests] Remove dubious standard library flag"

This reverts commit f477412685fe6bac49d3d080ba91896c28e62116.

2 years ago[flang] Add getTypeDescriptorBindingTableName function
Valentin Clement [Tue, 18 Oct 2022 17:52:20 +0000 (19:52 +0200)]
[flang] Add getTypeDescriptorBindingTableName function

Type descriptor and its binding table are defined as fir.global in FIR.
Their names are derived from the derived-type name. This patch adds a new
function `getTypeDescriptorBindingTableName` in the NameUniquer and
refactor the `GetTypeDescriptorName` function to reuse the same code.
This will be used in the fir.dispatch code generation.

Reviewed By: jeanPerier

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

2 years ago[lldb-tests] Remove dubious standard library flag
Felipe de Azevedo Piovezan [Tue, 18 Oct 2022 13:22:20 +0000 (09:22 -0400)]
[lldb-tests] Remove dubious standard library flag

The test currently sets `USE_LIBSTDCPP = 0`, which is curious given the
behavior of `and` and `or` in Makefiles (the contents of the variables
are not important). In particular, this causes the tests to not use the
standard libraries appropriately.

To capture the actual intent of the test, we're changing this to
`USE_LIBCXX=1`.

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

2 years ago[lldb-tests] Add libcxx version check for regex tests
Felipe de Azevedo Piovezan [Tue, 18 Oct 2022 13:13:45 +0000 (09:13 -0400)]
[lldb-tests] Add libcxx version check for regex tests

Regex requires the c++20 flag, which was not introduced available prior
to Clang 11.

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

2 years ago[lldb-tests] Add compiler version check in TestFunctionStarts
Felipe de Azevedo Piovezan [Tue, 18 Oct 2022 15:01:38 +0000 (11:01 -0400)]
[lldb-tests] Add compiler version check in TestFunctionStarts

This test requires compiling its input program without debug
information. To do so, it uses certain Makefile variables that are never
populated with custom libcxx paths (if present). Doing so would not
necessarily be correct: we cannot guarantee that said standard library
has no debug symbols.

As such, we keep using the system libraries but disable the tests in
clang versions that are too old to work with more modern system
libraries, as in the case of the lldb-matrix bot.

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

2 years ago[ELF] Restore AArch64Relaxer after 685b21255315e699aa839d93fe71b37d806c90c2
Fangrui Song [Tue, 18 Oct 2022 17:28:11 +0000 (10:28 -0700)]
[ELF] Restore AArch64Relaxer after 685b21255315e699aa839d93fe71b37d806c90c2

relocateAlloc may be parallel so we should avoid sharing AArch64 states.

2 years ago[flang] Add atomic_cas to the list of intrinsics
Katherine Rasmussen [Thu, 13 Oct 2022 00:32:14 +0000 (17:32 -0700)]
[flang] Add atomic_cas to the list of intrinsics

Add the atomic subroutine, atomic_cas, to the list of intrinsic
subroutines and check one of its arguments for a coindexed object.
Create a new function, CheckAtomicKind, that will be used for the
atomic subroutines that have arguments that can be either of type
int and of kind atomic_int_kind or of type logical and of kind
atomic_logical_kind.

Reviewed By: jeanPerier

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

2 years ago[SLP][NFC]Fix a warning for ?: with enum/unsigned, NFC.
Alexey Bataev [Tue, 18 Oct 2022 17:07:25 +0000 (10:07 -0700)]
[SLP][NFC]Fix a warning for ?: with enum/unsigned, NFC.

2 years ago[flang] Restrict __float128 support for some build configurations.
Slava Zakharin [Tue, 18 Oct 2022 00:48:05 +0000 (17:48 -0700)]
[flang] Restrict __float128 support for some build configurations.

This change is intended to resolve build issues reported in D134503.
A compiler supporting __float128 must define either __FLOAT128__ or
__SIZEOF_FLOAT128__ (or both). Additional check for _LIBCPP_VERSION
was added to disable __float128 for builds with libc++, because
__float128 support is incomplete there.

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

2 years ago[test] Remove redundant -passes flags
Arthur Eubanks [Tue, 18 Oct 2022 16:56:42 +0000 (09:56 -0700)]
[test] Remove redundant -passes flags

2 years ago[mlir][sparse] improve push_back type checking, printing, parsing
Aart Bik [Tue, 18 Oct 2022 06:08:09 +0000 (23:08 -0700)]
[mlir][sparse] improve push_back type checking, printing, parsing

Rationale:
Enforces type consistency on parsed and generated IR.

Reviewed By: bixia

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

2 years ago[ObjCARC][test] Use `opt -passes=` syntax
Arthur Eubanks [Sun, 2 Oct 2022 20:20:21 +0000 (13:20 -0700)]
[ObjCARC][test] Use `opt -passes=` syntax

2 years ago[Hexagon] Use shifts by scalar for funnel shifts by scalar
Krzysztof Parzyszek [Fri, 14 Oct 2022 23:07:50 +0000 (16:07 -0700)]
[Hexagon] Use shifts by scalar for funnel shifts by scalar

HVX has vector shifts by a scalar register. Use those in the expansions
of funnel shifts where profitable.

2 years ago[DX] Create globals for DXContainer parts
Chris Bieneman [Tue, 18 Oct 2022 16:42:09 +0000 (11:42 -0500)]
[DX] Create globals for DXContainer parts

DXContainer files have a handful of sections that need to be written.
This adds a pass to write the section data into IR globals, and writes
the shader flag data into a global.

The test cases here verify that the shader flags are correctly written
from the IR into the global and emitted to the DXContainer.

This change also fixes a bug in the MCDXContainerWriter, where the size
of the dxbc::ProgramHeader was not being included in the part offset
calcuations. This is verified to be working by the new testcases where
obj2yaml can properly dump part data for parts after the DXIL part.

Resolves issue #57742 (https://github.com/llvm/llvm-project/issues/57742)

Reviewed By: python3kgae

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

2 years ago[clang testing] Unbreak read-only source builds
David Zarzycki [Tue, 18 Oct 2022 16:32:12 +0000 (12:32 -0400)]
[clang testing] Unbreak read-only source builds

2 years ago[libc++] Improves modular build.
Mark de Wever [Sun, 16 Oct 2022 18:48:12 +0000 (20:48 +0200)]
[libc++] Improves modular build.

Makes sure headers having a std::ranges::less as default argument export
the proper header. Without exporting these modularized headers are not
self contained.

Reviewed By: #libc, ldionne

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

2 years ago[libc++][format] Move iterators when needed.
Mark de Wever [Sat, 23 Oct 2021 17:11:02 +0000 (19:11 +0200)]
[libc++][format] Move iterators when needed.

LWG-3539 was already implemented but not marked as done.
LWG-3567 is implemented in this commit.

Reviewed By: ldionne, #libc

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

2 years ago[IndVars] Forget SCEV for instruction and users before replacing it.
Florian Hahn [Tue, 18 Oct 2022 16:38:14 +0000 (17:38 +0100)]
[IndVars] Forget SCEV for instruction and users before replacing it.

Extra invalidation is needed here to clear stale values to fix a
verification failure.

Fixes #58440.

2 years ago[mlir][sparse] Add options to sparse-tensor-rewrite to disable rewriting rules for...
bixia1 [Mon, 17 Oct 2022 17:02:17 +0000 (10:02 -0700)]
[mlir][sparse] Add options to sparse-tensor-rewrite to disable rewriting rules for operators foreach and convert.

This is to help simplify FileCheck tests for sparse-tensor-rewrite.

Reviewed By: aartbik

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

2 years ago[include-cleaner] Add include-cleaner tool, with initial HTML report
Sam McCall [Fri, 14 Oct 2022 10:56:41 +0000 (12:56 +0200)]
[include-cleaner] Add include-cleaner tool, with initial HTML report

The immediate goal is to start producing an HTML report to debug and explain
include-cleaner recommendations.
For now, this includes only the lowest-level piece: a list of the references
found in the source code.

How this fits into future ideas:
 - under refs we can also show the headers providing the symbol, which includes
   match those headers etc
 - we can also annotate the #include lines with which symbols they cover, and
   add whichever includes we're suggesting too
 - the include-cleaner tool will likely have modes where it emits diagnostics
   and/or applies edits, so the HTML report is behind a flag

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

2 years ago[AArch64] Enhance bit-field-positioning op matcher to see through 'any_extend' for...
Mingming Liu [Sat, 15 Oct 2022 18:50:56 +0000 (11:50 -0700)]
[AArch64] Enhance bit-field-positioning op matcher to see through 'any_extend' for pattern 'and(any_extend(shl(val, N)), shifted-mask)'

Before this patch (and refactor patch D135843), isBitfieldPositioningOp won't handle "and(any_extend(shl(val, N), shifted-mask)" (bail out if AND op is not SHL)

After this patch, isBitfieldPositioningOp will see through "any_extend" to find "shl" to find possible bit-field-positioning nodes.

https://gcc.godbolt.org/z/3ncGKbGW6 is a four-liner LLVM IR that could be optimized to UBFIZ (see added test case test_and_extended_shift_with_imm in llvm/test/CodeGen/AArch64/bitfield-insert.ll). One existing test case also improves.

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

2 years ago[RISCV] Lower VECTOR_SHUFFLE to VSLIDEDOWN_VL.
Han-Kuan Chen [Tue, 18 Oct 2022 06:32:12 +0000 (23:32 -0700)]
[RISCV] Lower VECTOR_SHUFFLE to VSLIDEDOWN_VL.

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

2 years ago[RISCV] Pre-commit tests for lowering VECTOR_SHUFFLE to VSLIDEDOWN_VL.
Han-Kuan Chen [Tue, 18 Oct 2022 04:39:20 +0000 (21:39 -0700)]
[RISCV] Pre-commit tests for lowering VECTOR_SHUFFLE to VSLIDEDOWN_VL.

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

2 years ago[MachineCombiner][RISCV] Enable MachineCombiner for RISCV
Anton Sidorenko [Mon, 17 Oct 2022 09:06:08 +0000 (12:06 +0300)]
[MachineCombiner][RISCV] Enable MachineCombiner for RISCV

Initial implementation to match basic FP reassociation patterns.

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

2 years ago[SLP]Generalize cost model.
Alexey Bataev [Thu, 18 Nov 2021 23:59:30 +0000 (15:59 -0800)]
[SLP]Generalize cost model.

Generalized the cost model estimation. Improved cost model estimation
for repeated scalars (no need to count their cost anymore), improved
  cost model for extractelement instructions.

cpu2017
   511.povray_r             0.57
   520.omnetpp_r           -0.98
   521.wrf_r               -0.01
   525.x264_r               3.59 <+
   526.blender_r           -0.12
   531.deepsjeng_r         -0.07
   538.imagick_r           -1.42
Geometric mean:  0.21

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

2 years agoPort print-cfg-sccs to new pass manager
Arthur Eubanks [Tue, 11 Oct 2022 22:07:13 +0000 (15:07 -0700)]
Port print-cfg-sccs to new pass manager

This is actually used, see https://discourse.llvm.org/t/use-print-callgrapg-sccs-from-opt/65782.

Reviewed By: asbirlea

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

2 years ago[win][compiler-rt] Make tests use lld-link instead of link
Arthur Eubanks [Tue, 18 Oct 2022 15:46:14 +0000 (08:46 -0700)]
[win][compiler-rt] Make tests use lld-link instead of link

Git bash ships with a link.exe. We try to add git bash to the beginning
of PATH (see D84380). These tests end up executing the wrong link.exe.

As a workaround, use lld-link. Note that `REQUIRES: lld-available` tests currently aren't running, see D128567. I did manually verify that these tests pass with lld-link.

Reviewed By: rnk, hans

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

2 years ago[ubsan][test] Make some tests have shorter file names
Arthur Eubanks [Tue, 18 Oct 2022 15:45:15 +0000 (08:45 -0700)]
[ubsan][test] Make some tests have shorter file names

We're hitting path size limits on Windows on these tests. As a
workaround, make the file names shorter.

Reviewed By: vitalybuka

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

2 years ago[Bazel] Add target for llvm-debuginfo-analyzer binary
Jordan Rupprecht [Tue, 18 Oct 2022 15:45:10 +0000 (08:45 -0700)]
[Bazel] Add target for llvm-debuginfo-analyzer binary

2 years ago[SROA] Don't speculate phis with different load user types
Arthur Eubanks [Tue, 18 Oct 2022 00:03:35 +0000 (17:03 -0700)]
[SROA] Don't speculate phis with different load user types

Fixes an SROA crash.

Fallout from opaque pointers since with typed pointers we'd bail out at the bitcast.

Reviewed By: nikic

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

2 years ago[llvm-reduce] Check if reduction fails/is redundant before invoking oracle
Arthur Eubanks [Tue, 18 Oct 2022 04:14:05 +0000 (21:14 -0700)]
[llvm-reduce] Check if reduction fails/is redundant before invoking oracle

So we don't over count the number of chunks and do unnecessary work reducing more chunks than exist.

This lowers some random reduction I tested with locally from 250s to 232s.

Reviewed By: arsenm

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

2 years agoMake llvm-config test resilliant
Chris Bieneman [Tue, 18 Oct 2022 15:43:12 +0000 (10:43 -0500)]
Make llvm-config test resilliant

Add explicit library list to match a4b010034f57.

2 years ago[llvm-reduce] Unify pass logging
Arthur Eubanks [Tue, 18 Oct 2022 04:43:08 +0000 (21:43 -0700)]
[llvm-reduce] Unify pass logging

We randomly use outs() or errs(), which makes test logs confusing.
We also randomly add/don't add a line afterward.

Reviewed By: arsenm

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

2 years ago[mlir][interfaces][NFC] Move DestinationStyleOpInterface to mlir/Interfaces
Matthias Springer [Tue, 18 Oct 2022 15:23:42 +0000 (17:23 +0200)]
[mlir][interfaces][NFC] Move DestinationStyleOpInterface to mlir/Interfaces

This is the second (and final) step of making "destination style" usable without depending on the Linalg dialect. (The first step was D135129.)

This change allows us to provide default bufferization implementations for all destination-style ops. It also allows us to simplify `TilingInterface`. (E.g., `getDestinationOperands` can be removed.)

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

2 years ago[mlir][GPU] Prevent adding duplicate async tokens
Krzysztof Drewniak [Mon, 17 Oct 2022 17:47:56 +0000 (17:47 +0000)]
[mlir][GPU] Prevent adding duplicate async tokens

If, in the GPU async transformation, the operation being given an
async dependency already depended on the token in question, we
would add duplicate tokens, creating issues in GPU to LLVM lowering.

To resolve this issue, add a check to addAsyncDependency() to ensure
that duplicate tokens are not present in the token list.

(I'm open to a different approach here, this is just what I went with
initially)

Reviewed By: Mogball

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

2 years ago[InstCombine] fmul nnan X, 0.0 --> copysign(0.0, X)
Sanjay Patel [Tue, 18 Oct 2022 15:20:53 +0000 (11:20 -0400)]
[InstCombine] fmul nnan X, 0.0 --> copysign(0.0, X)

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

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

2 years ago[InstCombine] reduce code duplication in visitBranchInst(); NFCI
Sanjay Patel [Tue, 18 Oct 2022 14:35:12 +0000 (10:35 -0400)]
[InstCombine] reduce code duplication in visitBranchInst(); NFCI

2 years ago[clang] fix typo in unit test
Susana Monteiro [Tue, 18 Oct 2022 15:31:53 +0000 (16:31 +0100)]
[clang] fix typo in unit test

2 years ago[clang][Lexer] Speed up HeaderSearch when there are many HeaderMaps
Troy Johnson [Tue, 18 Oct 2022 15:03:10 +0000 (08:03 -0700)]
[clang][Lexer] Speed up HeaderSearch when there are many HeaderMaps

HeaderSearch already uses a caching system to avoid duplicate searches,
but the initial cold miss can take a long time if a build system has
supplied thousands of HeaderMaps. For this case, the SearchDirs vector
begins with those HeaderMaps, so a cache miss requires testing if the
sought filename is present in each of those maps. Instead, we can
consolidate the keys of those HeaderMaps into one StringMap and then
each cache miss can skip directly to the correct HeaderMap or continue
its search beyond the initial sequence of HeaderMaps. In testing on TUs
with ~15000 SearchDirs where the initial 99% are HeaderMaps, time spent
in Clang was reduced by 15%. This patch is expected to be neutral for
SearchDir vectors that do not begin with HeaderMaps.

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

2 years ago[IndVarSimplify] Clear block and loop dispositions after moving instr.
Florian Hahn [Tue, 18 Oct 2022 15:17:49 +0000 (16:17 +0100)]
[IndVarSimplify] Clear block and loop dispositions after moving instr.

Moving an instruction can invalidate the cached block dispositions of
the corresponding SCEV. Invalidate the cached dispositions.

Also fixes a copy-paste error in forgetBlockAndLoopDispositions where
the start expression S was removed from BlockDispositions in the loop
but not the current values. This was also exposed by the new test case.

Fixes #58439.

2 years ago[ADT] Extend EnumeratedArray
Jannik Silvanus [Mon, 10 Oct 2022 15:39:51 +0000 (17:39 +0200)]
[ADT] Extend EnumeratedArray

EnumeratedArray is essentially a wrapper around a fixed-size
array that uses enum values instead of integers as indices.

 * Add iterator support (begin/end/rbegin/rend), which enables
   the use of iterator/range based algorithms on EnumeratedArrays.
 * Add common container typedefs (value_type etc.), allowing
   drop-in replacements of other containers in cases relying on these.
 * Add a constructor that takes an std::initializer_list<T>.
 * Make the size() function const.
 * Add empty().

Iterator support slightly lowers the protection non-type-safe accesses,
because iterator arithmetic is not enum-based, and one can now use
*(begin() + IntIndex). However, it is and was also always possible to
just cast arbitrary indices to the enum type.

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

2 years ago[llvm-config] Make tests more resiliant
Chris Bieneman [Tue, 18 Oct 2022 14:50:24 +0000 (09:50 -0500)]
[llvm-config] Make tests more resiliant

In some modes llvm-config issues an error if a requested library is not
available on the system. The in-tree lit tests do not add explicit
dependencies on all component libraries, instead relying on the
transitive dependencies of tools and other libraries.

This can result in some configurations where a component library may not
be used by any of the test dependencies, so it may not be generated
before the tests run. This occurs when optional components of the LLVM
build are excluded, or not included.

In the case where a component library is not generated two test caess
are currently failing. One which tests the shared library boolean flag,
and one which tests the system library requirements. Neither test
require the full set of LLVM libraries to be specifed, so in both cases
I've limited the requested library set to Support to make the tests more
robust.

2 years ago[mlir][sparse] Change getUnorderedCOOFromType to propagate the overhead types.
bixia1 [Mon, 17 Oct 2022 21:09:44 +0000 (14:09 -0700)]
[mlir][sparse] Change getUnorderedCOOFromType to propagate the overhead types.

Reviewed By: aartbik

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

2 years ago[NFC][AMDGPU] Add tests for dependent v_bfi instructions.
Thomas Symalla [Tue, 18 Oct 2022 14:54:01 +0000 (16:54 +0200)]
[NFC][AMDGPU] Add tests for dependent v_bfi instructions.

This commit adds a few tests which are used to test the codegen
of nested v_bfi instructions. These instruction sequences are
being generated when using the canonical form for bitfieldInsert
and having the sequences being transformed by SimplifyDemandedBits.

This is a pre-commit for a change which enables the backend to
lower these instruction sequences into v_bfi instructions.

2 years ago[LangRef][FMF] Clarify ambiguity.
Kevin P. Neal [Tue, 18 Oct 2022 14:53:02 +0000 (10:53 -0400)]
[LangRef][FMF] Clarify ambiguity.

This should eliminate some ambiguous grammer that tripped me up when
reviewing D136097.

2 years ago[AST] Pass BatchAA to mergeSetIn() (NFCI)
Nikita Popov [Tue, 18 Oct 2022 14:51:47 +0000 (16:51 +0200)]
[AST] Pass BatchAA to mergeSetIn() (NFCI)

2 years ago[Hexagon] Fix MULHS lowering for HVX v60
Krzysztof Parzyszek [Mon, 17 Oct 2022 23:29:02 +0000 (16:29 -0700)]
[Hexagon] Fix MULHS lowering for HVX v60

The carry bit from an intermediate addition was not properly propagated.
For example mulhs(7fffffff7fffffff) was evaluated as 3ffeffff, while
the correct result is 3fffffff.

2 years ago[SLP][NFC]Try to fix MSVC buildbots with a workaround, NFC.
Alexey Bataev [Tue, 18 Oct 2022 14:36:22 +0000 (07:36 -0700)]
[SLP][NFC]Try to fix MSVC buildbots with a workaround, NFC.

2 years ago[clang][LTO] Setting Desired Default AIX Debugging Options
Qiongsi Wu [Tue, 18 Oct 2022 14:35:44 +0000 (10:35 -0400)]
[clang][LTO] Setting Desired Default AIX Debugging Options

On AIX, `strict-dwarf` defaults to `true`.  This patch implement this default behaviour. Additionally, it adds debug tuning tests.

Reviewed By: shchenz

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

2 years agoAdd test for combinations of four i8-loads spliced into a 32-bit value
bipmis [Tue, 18 Oct 2022 14:40:31 +0000 (15:40 +0100)]
Add test for combinations of four i8-loads spliced into a 32-bit value

2 years ago[libc] Fix missing bazel dependency
Guillaume Chatelet [Tue, 18 Oct 2022 14:37:08 +0000 (16:37 +0200)]
[libc] Fix missing bazel dependency

This fixes breakage introduced in a786096f9dd20acf29d8297e706ad96de063f612

2 years ago[SimplifyLibCalls] Add NoUndef/NonNull/Dereferenceable attributes to iprintf/siprintf
uabkaka [Tue, 18 Oct 2022 13:48:26 +0000 (15:48 +0200)]
[SimplifyLibCalls] Add NoUndef/NonNull/Dereferenceable attributes to iprintf/siprintf

When SimplifyLibCalls fail to optimize printf and sprintf it add
NoUndef/NonNull/Dereferenceable attributes. This patch add the same attributes
if SimplifyLibCalls optimize printf/sprintf into the integer only
iprintf/siprintf.

Reviewed By: nikic

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

2 years ago[libc][NFC] Cleanup and document utils.h
Guillaume Chatelet [Tue, 18 Oct 2022 14:32:21 +0000 (14:32 +0000)]
[libc][NFC] Cleanup and document utils.h

2 years ago[libc][NFC] Use ASSERT instead of EXPECT in tests
Guillaume Chatelet [Tue, 18 Oct 2022 14:30:04 +0000 (14:30 +0000)]
[libc][NFC] Use ASSERT instead of EXPECT in tests

2 years ago[InstCombine] add tests for fmul nnan with 0.0; NFC
Sanjay Patel [Tue, 18 Oct 2022 12:52:34 +0000 (08:52 -0400)]
[InstCombine] add tests for fmul nnan with 0.0; NFC

2 years ago[SLP][NFC]Formatting of the getEntryCost function, NFC.
Alexey Bataev [Tue, 18 Oct 2022 13:42:00 +0000 (06:42 -0700)]
[SLP][NFC]Formatting of the getEntryCost function, NFC.

2 years ago[LoopUnroll] Forget exit values when making changes.
Florian Hahn [Tue, 18 Oct 2022 14:12:23 +0000 (15:12 +0100)]
[LoopUnroll] Forget exit values when making changes.

When unrolling, the exit values in LCSSA phis will get updated.
Invalidate cached SCEV values for those phis in case SCEV looked through
a exit phi.

Fixes #58340.

2 years ago[NFC][PowerPC] Add a test to check power 10 features.
Stefan Pintilie [Tue, 18 Oct 2022 13:45:50 +0000 (08:45 -0500)]
[NFC][PowerPC] Add a test to check power 10 features.

This patch only adds a single test for Power 10 features.

2 years ago[clang] Fix crash upon stray coloncolon token in C2x mode
Jialun Hu [Tue, 18 Oct 2022 13:56:13 +0000 (21:56 +0800)]
[clang] Fix crash upon stray coloncolon token in C2x mode

The parser assumes that the lexer never emits coloncolon token for C code, but this assumption no longer holds in C2x attribute namespaces. As a result, stray coloncolon tokens out of attributes cause assertion failures and hangs in release build, which this patch tries to handle.

Crash input minimal example: `T n::v`

Reviewed By: aaron.ballman

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

2 years ago[LoopUnroll] Add test for mis-compile due to missing SCEV invalidation.
Florian Hahn [Tue, 18 Oct 2022 13:56:44 +0000 (14:56 +0100)]
[LoopUnroll] Add test for mis-compile due to missing SCEV invalidation.

Test for #58340.

2 years agoAdd an additional time for monthly office hours
Aaron Ballman [Tue, 18 Oct 2022 13:39:17 +0000 (09:39 -0400)]
Add an additional time for monthly office hours

Office hours have gone so well for me that I've had requests to add a
second time slot which is later in the day so that folks on the US west
coast have a more reasonable time to meet. So now meeting at 10am and
2pm on the 2nd Monday of each month.

2 years ago[clang][ARM] follow GCC behavior for defining __SOFTFP__
Ties Stuij [Tue, 18 Oct 2022 12:47:03 +0000 (13:47 +0100)]
[clang][ARM] follow GCC behavior for defining __SOFTFP__

GCC behavior regarding defining __SOFTFP__ when (implicitly) specifying
-mfloat-abi=softfp:
- compile without (implicit) FP: define __SOFTFP__
- compile with (implicit) FP: don't define __SOFTFP__

Currently Clang doesn't define __SOFTFP__ when softfp is specified, either with
or without FP. This patch brings Clang in line with GCC behavior.

This was raised by itaig1 over on Github:
https://github.com/llvm/llvm-project/issues/55755

Reviewed By: pratlucas

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

2 years ago[OpenMP] Make device functions have hidden visibility
Joseph Huber [Mon, 17 Oct 2022 20:53:31 +0000 (15:53 -0500)]
[OpenMP] Make device functions have hidden visibility

In OpenMP target offloading an in other offloading languages, we
maintain a difference between device functions and kernel functions.
Kernel functions must be visible to the host and act as the entry point
to the target device. Device functions however cannot be called directly
by the host and must be called by a kernel function. Currently, we make
all definitions on the device protected by default. Because device
functions cannot be called or used by the host they should have hidden
visibility. This allows for the definitions to be better optimized via
LTO or other passes.

This patch marks every device function in the AST as having `hidden`
visibility. The kernel function is generated later at code-gen and we
set its visibility explicitly so it should not be affected. This
prevents the user from overriding the visibility, but since the user
can't do anything with these symbols anyway there is no point exporting
them right now.

Reviewed By: jdoerfert

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

2 years ago[lldb] Fix m_hwp_regs size for ppc64le (PR54520)
Nikita Popov [Tue, 18 Oct 2022 09:11:20 +0000 (11:11 +0200)]
[lldb] Fix m_hwp_regs size for ppc64le (PR54520)

The size of the m_hwp_regs array should match the default value of
m_max_hwp_supported. This ensures that no out-of-bounds accesses
occur, even if the array is accessed prior to a call to
ReadHardwareDebugInfo().

Fixes https://github.com/llvm/llvm-project/issues/54520, see also
there for additional background.

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

2 years agoStop evaluating trailing requires clause after overload resolution
Erich Keane [Tue, 11 Oct 2022 13:16:41 +0000 (06:16 -0700)]
Stop evaluating trailing requires clause after overload resolution

Reported as it showed up as a constriants failure after the deferred
instantiation patch, we were checking constraints TWICE after overload
resolution.  The first is during overload resolution, the second is when
diagnosing a use.

This patch modifies DiagnoseUseOfDecl to skip the trailing requires
clause check in some cases. First, of course, after choosing a candidate
after overload resolution.

The second is when evaluating a shadow using constructor, which had its
constraints checked when picking a constructor (as this is ALWAYS an
overload situation!).

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

2 years ago[Clang] Fix crash when checking misaligned member with dependent type
Jun Zhang [Tue, 18 Oct 2022 12:38:30 +0000 (20:38 +0800)]
[Clang] Fix crash when checking misaligned member with dependent type

If the type is dependent, we should just discard it and not checking its
alignment as it doesn't exisit yet.
Fixes https://github.com/llvm/llvm-project/issues/58370

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

2 years agoRevert "[MachineCombiner][RISCV] Enable MachineCombiner for RISCV"
Anton Afanasyev [Tue, 18 Oct 2022 12:56:39 +0000 (15:56 +0300)]
Revert "[MachineCombiner][RISCV] Enable MachineCombiner for RISCV"

This reverts commit 3112cf3b00fe45a0911ec0c2e6706ef1f8a9b972.
Test breakage: https://lab.llvm.org/buildbot/#/builders/16/builds/36631

2 years ago[CMake] Add Python script to generate version script symbol exports
Andrew Ng [Mon, 26 Sep 2022 14:10:13 +0000 (15:10 +0100)]
[CMake] Add Python script to generate version script symbol exports

Using a Python script instead of the various shell commands means that
it is now possible to cross compile LLVM for Linux on Windows.

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

2 years ago[LoongArch] Fix codegen of atomicrmw nand
Weining Lu [Tue, 18 Oct 2022 09:33:50 +0000 (17:33 +0800)]
[LoongArch] Fix codegen of atomicrmw nand

Fix invalid RISCV-like MI being emitted for performing the `not`
operation: the LoongArch `xori` zero-extends the immediate, hence is
not equivalent to RISCV `xori`. The LoongArch `not` is a `nor` with
zero.

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

2 years ago[NFC][ADT] Clean up EnumeratedArray.h
Jannik Silvanus [Tue, 18 Oct 2022 11:26:32 +0000 (13:26 +0200)]
[NFC][ADT] Clean up EnumeratedArray.h

As discussed in D135594, remove superfluous inline
attributes, and remove top-level consts on function arguments.

2 years ago[MachineCombiner][RISCV] Enable MachineCombiner for RISCV
Anton Sidorenko [Mon, 17 Oct 2022 09:06:08 +0000 (12:06 +0300)]
[MachineCombiner][RISCV] Enable MachineCombiner for RISCV

Initial implementation to match basic FP reassociation patterns.

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

2 years ago[llvm-debuginfo-analyzer] Fix linking errors in buildbots.
Carlos Alberto Enciso [Tue, 18 Oct 2022 11:02:36 +0000 (12:02 +0100)]
[llvm-debuginfo-analyzer] Fix linking errors in buildbots.

The tool used the 'old' LLVM build information (LLVMBuild.txt),
which caused linking errors in:

https://lab.llvm.org/buildbot/#/builders/177/builds/10125
https://lab.llvm.org/buildbot/#/builders/196/builds/19699

Update the CMake configuration to support the new LLVM build
system that uses only CMakeLists.txt.

Reviewed By: jryans

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

2 years ago[LLD][ELF] --wrap: __real_foo references should trigger archive extraction for foo
Ben Dunbobbin [Tue, 18 Oct 2022 11:47:56 +0000 (12:47 +0100)]
[LLD][ELF] --wrap: __real_foo references should trigger archive extraction for foo

A reference to __real_foo should trigger archive extraction of the input file that defines foo, otherwise a link using --wrap=foo might fail to link with an undefined reference to foo.
This matches bfd linker behaviour.

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

2 years ago[CMake] Fix Findzstd module for shared DLL on Windows
Andrew Ng [Fri, 14 Oct 2022 15:06:34 +0000 (16:06 +0100)]
[CMake] Fix Findzstd module for shared DLL on Windows

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

2 years ago[AArch64] add test case for pattern ((X >> C) - Y) + Z; NFC
chenglin.bi [Tue, 18 Oct 2022 11:18:23 +0000 (19:18 +0800)]
[AArch64] add test case for pattern ((X >> C) - Y) + Z; NFC

2 years ago[gn build] port fe7a3cedf771 (llvm-debuginfo-analyzer)
Nico Weber [Mon, 17 Oct 2022 13:26:23 +0000 (09:26 -0400)]
[gn build] port fe7a3cedf771 (llvm-debuginfo-analyzer)

2 years ago[flang] Reconstruct binding tables for fir.dispatch codegen
Valentin Clement [Tue, 18 Oct 2022 10:12:11 +0000 (12:12 +0200)]
[flang] Reconstruct binding tables for fir.dispatch codegen

Binding tables are needed to perform the fir.dispatch code generation.
The binding tables are defined as fir.global from the initial lowering.
This patch adds the ability to reconstruct the binding tables information
and store the procedure name and binding index for later use by the
fir.dispatch code generation.
Tests will come with follow up patch that makes full use of this information.

Reviewed By: jeanPerier

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

2 years ago[MachineCombiner][RISCV] Precommit test for D135264
Anton Sidorenko [Thu, 15 Sep 2022 12:00:05 +0000 (15:00 +0300)]
[MachineCombiner][RISCV] Precommit test for D135264

2 years ago[flang][NFC] Simplify mapSymbolAttributes in symbol lowering
Jean Perier [Tue, 18 Oct 2022 09:07:47 +0000 (11:07 +0200)]
[flang][NFC] Simplify mapSymbolAttributes in symbol lowering

mapSymbolAttributes currently has a lot of very similar code for
each kind of explicit shape and scalar symbols.

Refactor it so that the change to lower symbols with fir.declare
can be added in centralized places instead of being scattered.
This is a preparation patch and fir.declare is not yet added.

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