platform/upstream/llvm.git
21 months ago[ConstraintElimination] Add test for regression after 3771310eede.
Florian Hahn [Fri, 7 Oct 2022 19:42:15 +0000 (20:42 +0100)]
[ConstraintElimination] Add test for regression after 3771310eede.

21 months agoRecommit "[SCEV] Support clearing Block/LoopDispositions for a single value."
Florian Hahn [Fri, 7 Oct 2022 19:15:44 +0000 (20:15 +0100)]
Recommit "[SCEV] Support clearing Block/LoopDispositions for a single value."

This reverts commit 92f698f01fa0bb8967233a6391ada2d51849fa68.

The updated version of the patch includes handling for non-SCEVable
types. A test case has been added in ec86e9a99bca802.

21 months ago[llvm-reduce] Fix di-metadata pass test failures
Matthew Voss [Fri, 7 Oct 2022 19:00:22 +0000 (12:00 -0700)]
[llvm-reduce] Fix di-metadata pass test failures

We're seeing intermittent failures in upstream bots. See:

https://lab.llvm.org/buildbot/#/builders/139/builds/29185
https://lab.llvm.org/buildbot/#/builders/238/builds/295

This appears to be due to the unstable iteration order of DenseSet.
Since we're trying to reduce a tree, it makes sense to attempt
reductions from the top down.

This also addresses post-review comments from @MatzeB.

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

21 months ago[LoopUnroll] Add test for crash exposed by 9e931439.
Florian Hahn [Fri, 7 Oct 2022 19:02:57 +0000 (20:02 +0100)]
[LoopUnroll] Add test for crash exposed by 9e931439.

21 months ago[opt] Remove -passes=asan-pipeline
Arthur Eubanks [Fri, 7 Oct 2022 18:55:36 +0000 (11:55 -0700)]
[opt] Remove -passes=asan-pipeline

It was obsoleted when the asan pass was changed to just be one module pass.

21 months agoRemove PlaceSafepoints pass
Philip Reames [Thu, 6 Oct 2022 15:40:09 +0000 (08:40 -0700)]
Remove PlaceSafepoints pass

This patch was added way back in the beginning of the work which became the statepoint infrastructure. The idea was that safepoints could be inserted late in the optimization pipeline. This is true if the only concern is garbage collection, but this approach turned out to be incompatible with the requirement to also support deoptimization at safepoints.

In theory, this pass would still be quite useful for an AOT compiled language which wants to support garbage collection, but we have no known users, and haven't for over 5 years. Time to remove unused code. If someone wants to use this, restoring it would not be hard. The immediate motivation for removal is that this is one of the last passes remaining which hasn't been ported to the new pass manager and the (straight forward) work to do so is not justified for unused code.

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

21 months ago[opt] Stop treating alias analysis specially when translating legacy opt syntax
Arthur Eubanks [Fri, 7 Oct 2022 18:49:10 +0000 (11:49 -0700)]
[opt] Stop treating alias analysis specially when translating legacy opt syntax

I've attempted to keep AA tests as close to their original intent as possible.

21 months ago[llvm-profdata] Rename show flag to --show-format
Ellis Hoag [Fri, 7 Oct 2022 17:29:59 +0000 (10:29 -0700)]
[llvm-profdata] Rename show flag to --show-format

In https://reviews.llvm.org/D135127 we created the show flag
`--output-format` which was confusing because it behaved differently
than the same flag in the merge command. So, rename the flag to
`--show-format`. This also allows us to add the `text` option to mean
"normal text output" rather than "text-encoded profiles" like it does
for the merge command.

Reviewed By: wenlei

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

21 months ago[BOLT] Testcase to repro dyn reloc bug
Rafael Auler [Fri, 7 Oct 2022 18:26:51 +0000 (11:26 -0700)]
[BOLT] Testcase to repro dyn reloc bug

Add a new testcase that shows a bug in BOLT when writing out
dynamic relocations. This is currently marked as XFAIL as we work on
solving it. This bug happens when the current strategy fails to
recognize that the original dynamic relocation in the input should
reference the original .bolt.org.rodata section instead of the new one
.rodata created by BOLT after moving jump tables. This bug started
happening after 729d29e167a5.

Reviewed By: Amir

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

21 months ago[libc] add printf decimal float conversion
Michael Jones [Tue, 12 Jul 2022 23:35:09 +0000 (16:35 -0700)]
[libc] add printf decimal float conversion

This patch adds support for converting doubles to string in the %f/F
format specifier. It does not yet support long doubles outside of the
double range. This implementation is based on the work of Ulf Adams,
specifically the Ryu Printf algorithm.

See:
Ulf Adams. 2019. RyĆ« revisited: printf floating point conversion.
Proc. ACM Program. Lang. 3, OOPSLA, Article 169 (October 2019), 23 pages.
https://doi.org/10.1145/3360595

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

21 months ago[BOLT] Change order of new sections
Maksim Panchenko [Wed, 5 Oct 2022 00:12:02 +0000 (17:12 -0700)]
[BOLT] Change order of new sections

While the order of new sections in the output binary was deterministic
in the past (i.e. there was no run-to-run variation), it wasn't always
rational as we used size to define the precedence of allocatable
sections within "code" or "data" groups (probably unintentionally).
Fix that by defining stricter section-ordering rules.

Other than the order of sections, this should be NFC.

Reviewed By: rafauler

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

21 months ago[BOLT] Fix writing out unmarked .eh_frame section
Maksim Panchenko [Tue, 4 Oct 2022 01:50:18 +0000 (18:50 -0700)]
[BOLT] Fix writing out unmarked .eh_frame section

When BOLT updates .eh_frame section, it concatenates newly-generated
contents (from CFI directives) with the original .eh_frame that has
relocations applied to it. However, if no new content is generated,
the original .eh_frame has to be left intact. In that case, BOLT was
still writing out the relocatable copy of the original .eh_frame section
to the new segment, even though this copy was never used and was not
even marked in the section header table.

Detect the scenario above and skip allocating extra space for .eh_frame.

Reviewed By: rafauler

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

21 months ago[BOLT] Properly set _end symbol
Maksim Panchenko [Mon, 3 Oct 2022 23:01:01 +0000 (16:01 -0700)]
[BOLT] Properly set _end symbol

To properly set the "_end" symbol, we need to track the last allocatable
address. Simply emitting "_end" at the end of some section is not
sufficient since the order of section allocation is unknown during the
emission step.

Reviewed By: rafauler

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

21 months ago[BOLT][NFC] Remove text section assertion
Maksim Panchenko [Mon, 3 Oct 2022 23:53:34 +0000 (16:53 -0700)]
[BOLT][NFC] Remove text section assertion

We can emit a binary without a new text section. Hence, the text section
assertion is not needed.

Reviewed By: rafauler

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

21 months ago[libc] add strsignal and refactor message mapping
Michael Jones [Wed, 5 Oct 2022 20:27:04 +0000 (13:27 -0700)]
[libc] add strsignal and refactor message mapping

The logic for strsignal and strerror is very similar, so I've moved them
both to use a shared utility (MessageMapper) for the basic
functionality.

Reviewed By: sivachandra

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

21 months ago[clangd] Fix buildbots after d1f13c54f172875d9a14c46c09afb1f22d78cdf8
Kadir Cetinkaya [Fri, 7 Oct 2022 18:05:47 +0000 (20:05 +0200)]
[clangd] Fix buildbots after d1f13c54f172875d9a14c46c09afb1f22d78cdf8

21 months ago[opt] Remove temporary legacy pass name translations
Arthur Eubanks [Fri, 7 Oct 2022 18:04:11 +0000 (11:04 -0700)]
[opt] Remove temporary legacy pass name translations

And update corresponding tests.

21 months ago[libc] add strerror_r function
Michael Jones [Tue, 4 Oct 2022 23:47:24 +0000 (16:47 -0700)]
[libc] add strerror_r function

I've implemente the gnu variant of strerror_r since that seems to be the
one more relevant to what we're trying to do.

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

21 months ago[Docs] [HLSL] Add note about PCH support
Xiang Li [Wed, 5 Oct 2022 16:26:25 +0000 (09:26 -0700)]
[Docs] [HLSL] Add note about PCH support

PCH supported for HLSL is added when compile in -cc1 mode using -include-pch for test AST.
This change add some notes about the support of PCH for HLSL.

Reviewed By: beanz

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

21 months ago[NFC] Remove trailing white space in openmp/libomptarget/src/CMakeLists.txt
Shilei Tian [Fri, 7 Oct 2022 17:42:31 +0000 (13:42 -0400)]
[NFC] Remove trailing white space in openmp/libomptarget/src/CMakeLists.txt

21 months ago[Clang][OpenMP] Add one missing form of atomic compare capture
Shilei Tian [Fri, 7 Oct 2022 17:30:31 +0000 (13:30 -0400)]
[Clang][OpenMP] Add one missing form of atomic compare capture

Two another atomic compare capture forms, `{ v = x; expr-stmt }` and `{ expr-stmt; v = x; }`
where `expr-stmt` could be `cond-expr-stmt` are missing.

Reviewed By: ABataev

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

21 months ago[InstCombine] propagate 'exact' when converting ashr to lshr
Sanjay Patel [Fri, 7 Oct 2022 17:05:39 +0000 (13:05 -0400)]
[InstCombine] propagate 'exact' when converting ashr to lshr

The shift amount is not changing, so if we guaranteed
shifting out zeros before, those bits are still zeros.

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

21 months ago[InstCombine] add tests for ashr exact; NFC
Sanjay Patel [Fri, 7 Oct 2022 17:03:56 +0000 (13:03 -0400)]
[InstCombine] add tests for ashr exact; NFC

21 months ago[InstCombine] add tests for sdiv-of-shl-1; NFC
Sanjay Patel [Fri, 7 Oct 2022 15:38:25 +0000 (11:38 -0400)]
[InstCombine] add tests for sdiv-of-shl-1; NFC

21 months ago[flang][nfc] Relocate a few driver tests
Andrzej Warzynski [Wed, 27 Jul 2022 13:54:45 +0000 (13:54 +0000)]
[flang][nfc] Relocate a few driver tests

When the work on the Flang driver started, we created 2 test
directories:
  * flang/test/Frontend/
  * flang/test/Driver/
That was mostly done to model what Clang was doing. In practice, we
stopped using "flang/test/Frontend/" early on and most Flang driver
tests are currently located in "flang/test/Driver/". This patch moves
the remaining tests from the latter into the former directory.

This change also means that we can re-use test input files, i.e.
flang/test/Frontend/Inputs/hello-world.f90 can be replaced with
flang/test/Driver/Inputs/hello.f90. To this end, the affected test is
updated (multiple-input-files.f90).

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

21 months agoRevert "[SCEV] Support clearing Block/LoopDispositions for a single value."
Florian Hahn [Fri, 7 Oct 2022 16:58:53 +0000 (17:58 +0100)]
Revert "[SCEV] Support clearing Block/LoopDispositions for a single value."

This reverts commit 9e931439ddb9b6b8f655940b9d8ed6db50c2a7e2.

This commit causes a crash when TSan, e.g. with
https://lab.llvm.org/buildbot/#/builders/70/builds/28309/steps/10/logs/stdio

Reverting while I extract a reproducer and submit a fix.

21 months ago[InstrProf][llvm-profdata] Dump profile correlation data as YAML
Ellis Hoag [Fri, 7 Oct 2022 16:27:40 +0000 (09:27 -0700)]
[InstrProf][llvm-profdata] Dump profile correlation data as YAML

Change the behavior of the `llvm-profdata show --debug-info=` command to dump a YAML file when using debug info correlation since it provides more information in a parseable format.

Reviewed By: yozhu, phosek

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

21 months ago[llvm-profdata] Add --output-format option
Ellis Hoag [Tue, 4 Oct 2022 00:48:50 +0000 (17:48 -0700)]
[llvm-profdata] Add --output-format option

Add `--output-format` option for the `llvm-profdata show` command to select the type of output. The existing `--text` flag is used to emit text encoded profiles. To avoid confusion, `--output-format=text-encoding` indicates that the output will be profiles encoded in the text format, and `--output-format=text` indicates the default text output that doesn't necessarily represent a profile.
`--output-format=json` is an alias for `--json` and `--output-format=yaml` will be used in D134770.

Reviewed By: phosek

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

21 months ago[mlir][Linalg] Retire LinalgStrategyPadPass and filter-based pattern.
Nicolas Vasilache [Fri, 7 Oct 2022 16:00:48 +0000 (09:00 -0700)]
[mlir][Linalg] Retire LinalgStrategyPadPass and filter-based pattern.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

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

21 months ago[Libomptarget] Remove debug definitions DeviceRTL's CMake
Joseph Huber [Fri, 7 Oct 2022 15:43:34 +0000 (10:43 -0500)]
[Libomptarget] Remove debug definitions DeviceRTL's CMake

These debugging definitions are no longer used in the new runtime. The
old runtime has been removed since Clang-14 so we can safely get rid of
these leftover variables.

Reviewed By: tianshilei1992

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

21 months ago[Hexagon] Formatting changes, NFC
Krzysztof Parzyszek [Thu, 6 Oct 2022 23:09:50 +0000 (16:09 -0700)]
[Hexagon] Formatting changes, NFC

21 months ago[Hexagon] Add couple of helper functions in HexagonVectorCombine
Krzysztof Parzyszek [Thu, 6 Oct 2022 23:02:10 +0000 (16:02 -0700)]
[Hexagon] Add couple of helper functions in HexagonVectorCombine

1. `length(value/type)`: return the number of elements in the vector
   input,
2. `getHvxTy(elem_type)`: return the HVX vector type with the element
   type provided.

These will help write things more succintly.

21 months ago[mlir][doc] Remove trailing whitespace (NFC)
Jacques Pienaar [Fri, 7 Oct 2022 16:05:49 +0000 (09:05 -0700)]
[mlir][doc] Remove trailing whitespace (NFC)

21 months ago[mlir][Linalg] Retire LinalgStrategyDecomposePass and filter-based pattern.
Nicolas Vasilache [Fri, 7 Oct 2022 15:27:17 +0000 (08:27 -0700)]
[mlir][Linalg] Retire LinalgStrategyDecomposePass and filter-based pattern.

Context: https://discourse.llvm.org/t/psa-retire-linalg-filter-based-patterns/63785

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

21 months ago[mlir][Transform] Add a transform.split_handles operation and fix general silenceable...
Nicolas Vasilache [Fri, 7 Oct 2022 08:43:38 +0000 (01:43 -0700)]
[mlir][Transform] Add a transform.split_handles operation and fix general silenceable bugs.

The transform.split_handles op is useful for ensuring a statically known number of operations are
tracked by the source `handle` and to extract them into individual handles
that can be further manipulated in isolation.

In the process of making the op robust wrt to silenceable errors and the suppress mode, issues were
uncovered and fixed.

The main issue was that silenceable errors were short-circuited too early and the payloads were not
set. This resulted in suppressed silenceable errors not propagating correctly.
Fixing the issue triggered a few test failures: silenceable error returns now must properly set the results state.

Reviewed By: springerm

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

21 months ago[Hexagon] Add default parameter to HexagonVectorCombine::getIntTy, NFC
Krzysztof Parzyszek [Thu, 6 Oct 2022 22:58:47 +0000 (15:58 -0700)]
[Hexagon] Add default parameter to HexagonVectorCombine::getIntTy, NFC

21 months ago[Hexagon] Make HexagonSubtarget::isHVXVectorType take EVT instead of MVT
Krzysztof Parzyszek [Thu, 6 Oct 2022 22:51:15 +0000 (15:51 -0700)]
[Hexagon] Make HexagonSubtarget::isHVXVectorType take EVT instead of MVT

EVT can be created for any Type, and so this function can now be used to
check if given Type, as-is, is an HVX type (as opposed to a type that may
be subject to legalization to an HVX type).

21 months ago[InstCombine] refactor sdiv by (negative) power-of-2 folds; NFCI
Sanjay Patel [Fri, 7 Oct 2022 15:21:28 +0000 (11:21 -0400)]
[InstCombine] refactor sdiv by (negative) power-of-2 folds; NFCI

It's probably better to try harder on this kind of
pattern by using ValueTracking.

21 months ago[InstCombine] add tests for udiv with common factor; NFC
Sanjay Patel [Thu, 6 Oct 2022 20:19:56 +0000 (16:19 -0400)]
[InstCombine] add tests for udiv with common factor; NFC

21 months ago[InstCombine] add tests for udiv with shift-left divisor; NFC
Sanjay Patel [Thu, 6 Oct 2022 19:01:08 +0000 (15:01 -0400)]
[InstCombine] add tests for udiv with shift-left divisor; NFC

issue #58137

21 months ago[AMDGPU] Fix a warning
Kazu Hirata [Fri, 7 Oct 2022 15:27:02 +0000 (08:27 -0700)]
[AMDGPU] Fix a warning

This patch fixes:

  llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp:800:17:
  error: unused variable 'DST_IDX' [-Werror,-Wunused-variable]

21 months ago[Hexagon] Replace llvm::Optional with std::optional, NFC
Krzysztof Parzyszek [Wed, 28 Sep 2022 21:58:15 +0000 (14:58 -0700)]
[Hexagon] Replace llvm::Optional with std::optional, NFC

21 months ago[Hexagon] Constify member refererence, NFC
Krzysztof Parzyszek [Tue, 27 Sep 2022 17:58:26 +0000 (10:58 -0700)]
[Hexagon] Constify member refererence, NFC

21 months agoFix test bool-range.cu
Yaxun (Sam) Liu [Fri, 7 Oct 2022 15:17:08 +0000 (11:17 -0400)]
Fix test bool-range.cu

Promoting kernel arg pointer to global addr space is only
available with registered amdgcn target.

Fix test so that it does not require registered amdgcn target.

21 months ago[LICM] Add test for single thread model promotion (NFC)
Nikita Popov [Fri, 7 Oct 2022 15:11:28 +0000 (17:11 +0200)]
[LICM] Add test for single thread model promotion (NFC)

Tests for D130466.

21 months ago[Libomptarget] Clean up DeviceRTL CMake and remove unused flags
Joseph Huber [Fri, 7 Oct 2022 14:53:14 +0000 (09:53 -0500)]
[Libomptarget] Clean up DeviceRTL CMake and remove unused flags

Summary:
This patch just cleans up the unused flags in the DeviceRTL. These
should no longer be necessary or are redundant. Also add the extract
tool and packager to the check and error message if not found. This will
make it easier to tell if they are not present.

21 months ago[SCEV] Support clearing Block/LoopDispositions for a single value.
Florian Hahn [Fri, 7 Oct 2022 15:07:17 +0000 (16:07 +0100)]
[SCEV] Support clearing Block/LoopDispositions for a single value.

Extend forgetBlockAndLoopDisposition to allow clearing information for a
single value. This can be useful when only a single value is changed,
e.g. because the instruction is moved.

We also need to clear the cached values for all SCEV users, because they
may depend on the starting value's disposition.

Reviewed By: nikic

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

21 months ago[analyzer] Fix static code analysis concerns
Soumi Manna [Fri, 7 Oct 2022 14:43:19 +0000 (16:43 +0200)]
[analyzer] Fix static code analysis concerns

ProcessMemberDtor(), ProcessDeleteDtor(), and ProcessAutomaticObjDtor():
Fix static analyzer warnings with suspicious dereference of pointer
'Pred' in function call before NULL checks - NFCI

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

21 months ago[Flang] Use the ultimate symbol in a DeallocateStmt check
Kiran Chandramohan [Fri, 7 Oct 2022 14:40:26 +0000 (14:40 +0000)]
[Flang] Use the ultimate symbol in a DeallocateStmt check

Use the ultimate symbol while calling the `IsAllocatableOrPointer`
function to ensure that the check works as expected for
host-associated symbols.

Fixes #58178

Reviewed By: PeteSteinfeld

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

21 months ago[AMDGPU] Disable bool range metadata to workaround backend issue
Yaxun (Sam) Liu [Tue, 6 Sep 2022 23:20:09 +0000 (19:20 -0400)]
[AMDGPU] Disable bool range metadata to workaround backend issue

Currently there is a middle-end or backend issue
https://github.com/llvm/llvm-project/issues/58176
which causes values loaded from bool pointer incorrect when
bool range metadata is emitted. Temporarily
disable bool range metadata until the backend issue
is fixed.

Reviewed by: Artem Belevich

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

Fixes: SWDEV-344137

21 months ago[CMake] Small fix to HLSL header install paths
Chris Bieneman [Fri, 7 Oct 2022 14:43:56 +0000 (09:43 -0500)]
[CMake] Small fix to HLSL header install paths

HLSL headers were being installed in two locations, one correct and one
incorrect, and they were always being installed (even when
CLANG_ENABLE_HLSL=Off). This corrects both issues by ensuring that the
HLSL headers aren't added to the universal header list.

21 months ago[mlir][doc] clarify (ir)recoverable failures in transform dialect
Alex Zinenko [Fri, 7 Oct 2022 14:39:52 +0000 (14:39 +0000)]
[mlir][doc] clarify (ir)recoverable failures in transform dialect

21 months agoFix typos - show in the binary
Sylvestre Ledru [Fri, 7 Oct 2022 13:56:21 +0000 (15:56 +0200)]
Fix typos - show in the binary

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1018770

21 months ago[OpenMP] Convert more tests to opaque pointers (NFC)
Nikita Popov [Fri, 7 Oct 2022 13:28:44 +0000 (15:28 +0200)]
[OpenMP] Convert more tests to opaque pointers (NFC)

These were converted using the script at
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34
followed by a re-run of update_cc_test_checks.py.

21 months ago[test][ExpandMemCmp] Convert test cases to opaque pointers. NFC
Bjorn Pettersson [Fri, 7 Oct 2022 13:08:04 +0000 (15:08 +0200)]
[test][ExpandMemCmp] Convert test cases to opaque pointers. NFC

Conversion performed using the script at:
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

21 months ago[ValueTracking][SimplifyLibCalls] Fix bug in getConstantDataArrayInfo for wchar_t
Bjorn Pettersson [Tue, 4 Oct 2022 19:31:44 +0000 (21:31 +0200)]
[ValueTracking][SimplifyLibCalls] Fix bug in getConstantDataArrayInfo for wchar_t

When SimplifyLibCalls is dealing with wchar_t (e.g. optimizing wcslen)
it uses ValueTracking helpers with a CharSize/ElementSize that isn't
8, but rather 16 or 32 (to match with the size in bits of a wchar_t).

Problem I've seen is that llvm::getConstantDataArrayInfo is taking
both an "ElementSize" argument (basically indicating size of a
char/element in bits) and an "Offset" which afaict is an offset
in the unit "number of elements". Then it also use
stripAndAccumulateConstantOffsets to get a "StartIdx" which afaict
is calculated in bytes. The returned Slice.Length is based on
arithmetics that add/subtract variables that are having different
units (bytes vs elements). Most notably I think the "StartIdx" must
be scaled using the "ElementSize" to get correct results.

The symptom of the above problem was seen in the wcslen-1.ll test
case which miscompiled.

This patch is supposed to resolve the bug by converting between
bytes and elements when needed.

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

21 months ago[SimplifyLibCalls] Pre-commit test case showing bug with wide char support
Bjorn Pettersson [Tue, 4 Oct 2022 19:21:14 +0000 (21:21 +0200)]
[SimplifyLibCalls] Pre-commit test case showing bug with wide char support

The ValueTracking support for getting the string length of a wchar_t
string (e.g. using wcslen) seem to be having some bugs.

Problem I've seen is that llvm::getConstantDataArrayInfo is taking
both a "ElementSize" argument (basically indicating size of a
char/element in bits) and an "Offset" which afaict is an offset
in the unit "number of elements". Then it also use
stripAndAccumulateConstantOffsets to get a "StartIdx" which afaict
is calculated in bytes. The returned Slice.Length is based on
arithmetics that add/subtract variables that are having different
units (bytes vs elements). Most notably I think the "StartIdx" must
be scaled using the "ElementSize" to get correct results.

This patch just adds a new test case showing that we get a wrong
result when doing wcslen(x + c). The actual fix to the above problem
will be done in a follow up commit.

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

21 months ago[AMDGPU][MC][GFX11] Correct v_fmac_.*_e64_dpp
Dmitry Preobrazhensky [Fri, 7 Oct 2022 13:18:49 +0000 (16:18 +0300)]
[AMDGPU][MC][GFX11] Correct v_fmac_.*_e64_dpp

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

21 months ago[Concepts] Fix friend duplicate detection when referencing containing Record
Erich Keane [Fri, 7 Oct 2022 13:12:03 +0000 (06:12 -0700)]
[Concepts] Fix friend duplicate detection when referencing containing Record

As another regression from the Deferred Concepts Instantiation patch, we
weren't properly detecting that a friend referenced its containing
Record when it referred to it without its template parameters.  This
patch makes sure that we do.

21 months ago[AMDGPU][GFX11][NFC] Refactor VOPD handling in codegen
Dmitry Preobrazhensky [Fri, 7 Oct 2022 13:07:40 +0000 (16:07 +0300)]
[AMDGPU][GFX11][NFC] Refactor VOPD handling in codegen

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

21 months ago[OpenMP][OMPIRBuilder] Remove calls to dump in test
Jan Sjodin [Fri, 7 Oct 2022 13:03:00 +0000 (08:03 -0500)]
[OpenMP][OMPIRBuilder] Remove calls to dump in test

This removes the calls to dump tyupes introduced in commit
4627cef1134f99f3802a5ebfe26188d2c66da22f.

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

21 months ago[OpenMP] Convert tests to opaque pointers (NFC)
Nikita Popov [Fri, 7 Oct 2022 12:56:02 +0000 (14:56 +0200)]
[OpenMP] Convert tests to opaque pointers (NFC)

Conversion performed using the script at:
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

These are only tests where no manual fixup was required.

21 months ago[AMDGPU][MC][GFX11] Add VOPD VGPR bank access validation
Dmitry Preobrazhensky [Fri, 7 Oct 2022 12:46:55 +0000 (15:46 +0300)]
[AMDGPU][MC][GFX11] Add VOPD VGPR bank access validation

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

21 months ago[MachineInstr] Use unsigned int for opcode (NFC)
Christudasan Devadasan [Tue, 4 Oct 2022 11:00:05 +0000 (16:30 +0530)]
[MachineInstr] Use unsigned int for opcode (NFC)

The opcode field in most places uses unsigned type.
InstrInfoEmitter still uses signed int for the
custom opcodes like CFSetupOpcode.

Reviewed By: arsenm

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

21 months ago[clang] Make variables of undeduced types to have dependent alignment
Aleksandr Platonov [Fri, 7 Oct 2022 12:38:49 +0000 (20:38 +0800)]
[clang] Make variables of undeduced types to have dependent alignment

Without this patch `VarDecl::hasDependent()` checks only undeduced auto types, so can give false negatives result for other undeduced types.
This lead to crashes in sequence `!VarDecl::hasDepentent()` => `getDeclAlign()`.

It seems this problem appeared since D105380

Reviewed By: mizvekov

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

21 months agoRevert "Thread safety analysis: Support copy-elided production of scoped capabilities...
Hans Wennborg [Fri, 7 Oct 2022 12:23:47 +0000 (14:23 +0200)]
Revert "Thread safety analysis: Support copy-elided production of scoped capabilities through arbitrary calls"

This caused false positives, see comment on the code review.

> When support for copy elision was initially added in e97654b2f2807, it
> was taking attributes from a constructor call, although that constructor
> call is actually not involved. It seems more natural to use attributes
> on the function returning the scoped capability, which is where it's
> actually coming from. This would also support a number of interesting
> use cases, like producing different scope kinds without the need for tag
> types, or producing scopes from a private mutex.
>
> Changing the behavior was surprisingly difficult: we were not handling
> CXXConstructorExpr calls like regular calls but instead handled them
> through the DeclStmt they're contained in. This was based on the
> assumption that constructors are basically only called in variable
> declarations (not true because of temporaries), and that variable
> declarations necessitate constructors (not true with C++17 anymore).
>
> Untangling this required separating construction from assigning a
> variable name. When a call produces an object, we use a placeholder
> til::LiteralPtr for `this`, and we collect the call expression and
> placeholder in a map. Later when going through a DeclStmt, we look up
> the call expression and set the placeholder to the new VarDecl.
>
> The change has a couple of nice side effects:
> * We don't miss constructor calls not contained in DeclStmts anymore,
>   allowing patterns like
>     MutexLock{&mu}, requiresMutex();
>   The scoped lock temporary will be destructed at the end of the full
>   statement, so it protects the following call without the need for a
>   scope, but with the ability to unlock in case of an exception.
> * We support lifetime extension of temporaries. While unusual, one can
>   now write
>     const MutexLock &scope = MutexLock(&mu);
>   and have it behave as expected.
> * Destructors used to be handled in a weird way: since there is no
>   expression in the AST for implicit destructor calls, we instead
>   provided a made-up DeclRefExpr to the variable being destructed, and
>   passed that instead of a CallExpr. Then later in translateAttrExpr
>   there was special code that knew that destructor expressions worked a
>   bit different.
> * We were producing dummy DeclRefExprs in a number of places, this has
>   been eliminated. We now use til::SExprs instead.
>
> Technically this could break existing code, but the current handling
> seems unexpected enough to justify this change.
>
> Reviewed By: aaron.ballman
>
> Differential Revision: https://reviews.llvm.org/D129755

This reverts commit 0041a69495f828f6732803cfb0f1e3fddd7fbf2a and the follow-up
warning fix in 83d93d3c11ac9727bf3d4c5c956de44233cc7f87.

21 months ago[SourceManager] Fix the incorrect counting stats in getFileIDLoaded.
Haojian Wu [Fri, 7 Oct 2022 12:04:54 +0000 (14:04 +0200)]
[SourceManager] Fix the incorrect counting stats in getFileIDLoaded.

We were double-counting the number of binary search FileID scans.

21 months ago[flang] Allow fir.class in AnyRefOrBox
Valentin Clement [Fri, 7 Oct 2022 12:22:36 +0000 (14:22 +0200)]
[flang] Allow fir.class in AnyRefOrBox

Some operations are using `AnyRefOrBox` to specify the type of the
operands or attribute. This is the case for the `fir.coordinate_of`
operation. This patch updates the `AnyRefOrBox` to accept `BaseBoxType`
instead of only `BoxType`.

Reviewed By: jeanPerier

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

21 months ago[CodeGen] Convert tests to opaque pointers (NFC)
Nikita Popov [Fri, 7 Oct 2022 12:09:44 +0000 (14:09 +0200)]
[CodeGen] Convert tests to opaque pointers (NFC)

Conversion performed using the script at:
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34

These are only tests where no manual fixup was required.

21 months ago[OpenMP][OMPIRBuilder] Migrate emitOffloadingArraysArgument from clang
Jan Sjodin [Thu, 29 Sep 2022 14:26:25 +0000 (09:26 -0500)]
[OpenMP][OMPIRBuilder] Migrate emitOffloadingArraysArgument from clang

This patch moves the emitOffloadingArraysArgument function and
supporting data structures to OpenMPIRBuilder. This will later be used
in flang as well. The TargetDataInfo class was split up into generic
information and clang-specific data, which remain in clang. Further
migration will be done in in the future.

Reviewed By: jdoerfert

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

21 months ago[clang][CodeGen] Use poison instead of undef as placeholder in ARM builtins [NFC]
Manuel Brito [Fri, 7 Oct 2022 11:48:08 +0000 (12:48 +0100)]
[clang][CodeGen] Use poison instead of undef as placeholder in ARM builtins [NFC]

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

21 months ago[mlir][Bazel] Port d85f6e5d57f38f0cbbc756484e3a93ae89b11195
Adrian Kuegel [Fri, 7 Oct 2022 11:49:28 +0000 (13:49 +0200)]
[mlir][Bazel] Port d85f6e5d57f38f0cbbc756484e3a93ae89b11195

21 months agoRevert "[lld/mac] Port typo correction for undefined symbols from ELF port"
Hans Wennborg [Fri, 7 Oct 2022 11:37:28 +0000 (13:37 +0200)]
Revert "[lld/mac] Port typo correction for undefined symbols from ELF port"

This caused crashes/assert failures for some Chromium developers, see comment
on the code review.

> Ports:
> - core feature: https://reviews.llvm.org/D67039
> - case mismatch: https://reviews.llvm.org/D70506
> - extern "C" suggestions: https://reviews.llvm.org/D69592,
>   https://reviews.llvm.org/D69650
>
> Does not port https://reviews.llvm.org/D71735 since I believe that that doesn't
> apply to lld/Mach-O.
>
> Differential Revision: https://reviews.llvm.org/D135038

This reverts commit 8c45e80298f4e3eb6d9cfbafcb099bc087e4668e.

21 months ago[AArch64] Lower multiplication by a constant int to madd
zhongyunde [Fri, 7 Oct 2022 11:31:48 +0000 (19:31 +0800)]
[AArch64] Lower multiplication by a constant int to madd

Lower a = b * C -1 into madd
  a) instcombine change b * C -1 --> b * C + (-1)
  b) machine-combine change b * C + (-1) --> madd

Assembler will transform the neg immedate of sub to add, see https://gcc.godbolt.org/z/cTcxePPf4
Fixes AArch64 part of https://github.com/llvm/llvm-project/issues/57255.

Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D134336

21 months ago[mlir][llvmir] Import intrinsics with attributes from LLVMIR.
Tobias Gysi [Fri, 7 Oct 2022 11:13:24 +0000 (14:13 +0300)]
[mlir][llvmir] Import intrinsics with attributes from LLVMIR.

The revision adds support to specify custom import functions for
LLVM IR intrinsics with immediate arguments that translate to MLIR
attributes. It takes an approach similar to the MLIR to LLVM translation
that uses a tablegen defined build method. The default implementation
of this newly introduced "mlirBuilder" assumes all intrinsic arguments
translate to operands. Specific intrinsics, such as
llvm.lifetime.start/stop then define a custom builder that converts
their immediate arguments to MLIR attributes.

Depends on D135349

Reviewed By: ftynse

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

21 months ago[ConstraintElimination] Convert to unsigned Pred if possible.
Florian Hahn [Fri, 7 Oct 2022 11:27:35 +0000 (12:27 +0100)]
[ConstraintElimination] Convert to unsigned Pred if possible.

Convert SLE/SLT predicates to unsigned equivalents if both operands are
known to be signed-positive.

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

21 months ago[mlir][bufferize][NFC] Address review comments of D135420
Matthias Springer [Fri, 7 Oct 2022 10:47:29 +0000 (19:47 +0900)]
[mlir][bufferize][NFC] Address review comments of D135420

These changes should have been landed as part of D135420.

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

21 months ago[MLIR][Affine] Fix crash in normalizeMemRefType
Uday Bondhugula [Fri, 7 Oct 2022 08:21:57 +0000 (13:51 +0530)]
[MLIR][Affine] Fix crash in normalizeMemRefType

Fix crash in normalizeMemRefType. Correctly handle scenario and replace
assertion with a failure.

Reviewed By: dcaballe

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

21 months ago[LoopPeeling] Support peeling loops with non-latch exits
Nikita Popov [Tue, 27 Sep 2022 16:30:32 +0000 (18:30 +0200)]
[LoopPeeling] Support peeling loops with non-latch exits

Loop peeling currently requires that a) the latch is exiting
b) a branch and c) other exits are unreachable/deopt. This patch
removes all of these limitations, and adds the necessary branch
weight updating support. It essentially works the same way as
before with latch -> exiting terminator and
loop trip count -> per exit trip count.

It's worth noting that there are still other limitations in
profitability heuristics: This patch enables peeling of loops to
make conditions invariant (which is pretty much always highly
profitable if possible), while peeling to make loads dereferenceable
still checks that non-latch exits are unreachable and PGO-based
peeling has even more conditions. Those checks could be relaxed
later if we consider those cases profitable.

The motivation for this change is that loops using iterator adaptors
in Rust often optimize very badly, and end up with a loop phi of the
form phi(true, false) in the final result. Peeling eliminates that
phi and conditions based on it, which enables a lot of follow-on
simplification.

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

21 months agoKeep inherited dllimport/export attrs for explicit specialization of class template...
Hans Wennborg [Sun, 18 Sep 2022 23:05:56 +0000 (01:05 +0200)]
Keep inherited dllimport/export attrs for explicit specialization of class template member functions

Previously we were stripping these normally inherited attributes during
explicit specialization. However for class template member functions
(but not function templates), MSVC keeps the attribute.

This makes Clang match that behavior, and fixes GitHub issue #54717

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

21 months ago[clangd][Tweak] Make sure enclosing function doesnt have invalid children
Kadir Cetinkaya [Wed, 5 Oct 2022 11:27:53 +0000 (13:27 +0200)]
[clangd][Tweak] Make sure enclosing function doesnt have invalid children

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

21 months ago[ValueTracking] Remove unused Offset argument in getConstantStringInfo() (NFC)
Nikita Popov [Fri, 7 Oct 2022 09:32:58 +0000 (11:32 +0200)]
[ValueTracking] Remove unused Offset argument in getConstantStringInfo() (NFC)

21 months ago[LLDB] Add "frame select" as equivalent of GDB's "frame" command
David Spickett [Thu, 29 Sep 2022 13:03:43 +0000 (13:03 +0000)]
[LLDB] Add "frame select" as equivalent of GDB's "frame" command

This is useful for answering the question "where am I?" and is surprisingly
difficult to figure out without just doing another step command.

Reviewed By: awarzynski

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

21 months ago[LangRef] Fix too short title underline
eopXD [Fri, 7 Oct 2022 09:24:56 +0000 (02:24 -0700)]
[LangRef] Fix too short title underline

21 months ago[VP][RISCV] Add vp.roundtozero and its RISC-V support
eopXD [Wed, 5 Oct 2022 01:10:14 +0000 (18:10 -0700)]
[VP][RISCV] Add vp.roundtozero and its RISC-V support

The scalar instruction of this is `llvm.trunc`. However the naming of
ISD::VP_TRUNC is already taken by `trunc` of the LLVM IR. Naming this as
`vp.ftrunc` would likely cause confusion with `vp.fptrunc`. So adding
`vp.roundtozero` that will look similar to `vp.roundeven`.

Reviewed By: frasercrmck

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

21 months ago[LLDB] Fix crash when printing a struct with a static signed char member
David Spickett [Wed, 5 Oct 2022 11:30:05 +0000 (11:30 +0000)]
[LLDB] Fix crash when printing a struct with a static signed char member

As with static bool for whatever reason printing them on their own
worked fine but wasn't handled when you printed the whole type.

I don't see a good way to test this from clang's side so our existing
tests will have to do.

We can now print all of the struct "A", so there's no need for a separate
one for static bool testing. I've not checked the output, just that it
succeeds. This saves us having to handle different min/max between systems.

Depends on D135169

Reviewed By: aeubanks, shafik

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

21 months ago[LoopPredication] Insert assumes of conditions of predicated guards
Dmitry Makogon [Thu, 6 Oct 2022 09:30:48 +0000 (16:30 +0700)]
[LoopPredication] Insert assumes of conditions of predicated guards

As LoopPredication performs non-equivalent transforms removing some
checks from loops, other passes may not be able to perform transforms
they'd be able to do if the checks were left in loops.

This patch makes LoopPredication insert assumes of the replaced
conditions either after a guard call or in the true block of
widenable condition branch.

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

21 months ago[llvm-reduce] Fix unused variable warning (NFC)
Nikita Popov [Fri, 7 Oct 2022 09:07:17 +0000 (11:07 +0200)]
[llvm-reduce] Fix unused variable warning (NFC)

21 months ago[OpenMP] [OMPD] Build gdb-plugin code only when python3 development files are available.
Vignesh Balasubramanian [Tue, 20 Sep 2022 12:12:26 +0000 (17:42 +0530)]
[OpenMP] [OMPD] Build gdb-plugin code only when python3 development files are available.

gdb-plugin code is a interface between gdb, libompd, gdb and libomp.
Python3 development files are required to build this utility.
This patch will disable the plugin code build when python3 dev files
are not available.

Reviewed By: @mgorny, @aaronpuchert
Differential Revision: https://reviews.llvm.org/D134275

21 months agoReapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify
Nikita Popov [Fri, 30 Sep 2022 10:13:40 +0000 (12:13 +0200)]
Reapply [InstCombine] Switch foldOpIntoPhi() to use InstSimplify

Relative to the previous attempt, this adjusts simplification to
use the correct context instruction: We need to use the terminator
of the incoming block, not the original instruction.

-----

foldOpIntoPhi() currently only folds operations into the phi if all
but one operands constant-fold. The two exceptions to this are freeze
and select, where we allow more general simplification.

This patch makes foldOpIntoPhi() generally simplification based and
removes all the instruction-specific logic. We just try to simplify
the instruction for each operand, and for the (potentially) one
non-simplified operand, we move it into the new block with adjusted
operands.

This fixes https://github.com/llvm/llvm-project/issues/57448, which
was my original motivation for the change.

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

21 months ago[LLDB] Fix printing a static bool struct member when using "image lookup -t"
David Spickett [Tue, 4 Oct 2022 14:56:12 +0000 (14:56 +0000)]
[LLDB] Fix printing a static bool struct member when using "image lookup -t"

Fixes #58135

Somehow lldb was able to print the member on its own but when we try
to print the whole type found by "image lookup -t" lldb would crash.

This is because we'd encoded the initial value of the member as an integer.
Which isn't the end of the world because bool is integral for C++.
However, clang has a special AST node to handle literal bool and it
expected us to use that instead.

This adds a new codepath to handle static bool which uses cxxBoolLiteralExpr
and we get the member printed as you'd expect.

For testing I added a struct with just the bool because trying to print
all of "A" crashes as well. Presumably because one of the other member's
types isn't handled properly either.

So for now I just added the bool case, we can merge it with A later.

Reviewed By: aeubanks

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

21 months ago[InstCombine] Add test for foldOpIntoPhi() context instr (NFC)
Nikita Popov [Fri, 7 Oct 2022 08:59:22 +0000 (10:59 +0200)]
[InstCombine] Add test for foldOpIntoPhi() context instr (NFC)

Reduced test case for the miscompile reported at
https://reviews.llvm.org/D134954#3840475.

21 months ago[GISel] Add Trunc/Lshr/BuildVector Folding
Pierre van Houtryve [Wed, 5 Oct 2022 07:27:24 +0000 (07:27 +0000)]
[GISel] Add Trunc/Lshr/BuildVector Folding

Similar to the current "Trunc/BuildVector" folding - which folds low element extracts of BuildVectors, folds hi element extracts done using bitshifts.

For D134354

Reviewed By: arsenm

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

21 months ago[LLDB] Add missing space in help for frame-format-unique setting
David Spickett [Fri, 7 Oct 2022 08:42:01 +0000 (08:42 +0000)]
[LLDB] Add missing space in help for frame-format-unique setting

21 months agoUpdate RELEASE_TESTERS.TXT
Diana Picus [Fri, 7 Oct 2022 08:35:11 +0000 (10:35 +0200)]
Update RELEASE_TESTERS.TXT

armv7 and AArch64 releases are handled by Linaro.

21 months ago[GISel] Handle G_TRUNC in `matchExtractVecEltBuildVec`
Pierre van Houtryve [Tue, 4 Oct 2022 11:06:15 +0000 (11:06 +0000)]
[GISel] Handle G_TRUNC in `matchExtractVecEltBuildVec`

Spotted some cases in D134354 where this was an issue.

Reviewed By: arsenm

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

21 months ago[ConstraintElimination] Add test that crash in earlier var handling.
Florian Hahn [Fri, 7 Oct 2022 08:31:45 +0000 (09:31 +0100)]
[ConstraintElimination] Add test that crash in earlier var handling.

Add a test that caused a crash in the new variable handling code in
earlier versions.

21 months agoNFC. Remove unnecessary builder argument in Affine Utils helper
Uday Bondhugula [Fri, 7 Oct 2022 08:16:13 +0000 (13:46 +0530)]
NFC. Remove unnecessary builder argument in Affine Utils helper

NFC. Remove unnecessary builder argument in an Affine Utils helper
function: normalizeMemRefType. A builder was never needed. While on
this, fix a clang-tidy warning from the same file.

Reviewed By: dcaballe

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

21 months ago[mlir] fix memory effects of transform::PDLMatchOp
Alex Zinenko [Fri, 7 Oct 2022 08:14:30 +0000 (08:14 +0000)]
[mlir] fix memory effects of transform::PDLMatchOp

The op was declaring the effects associated with payload IR as attached
to its operand since ODS doesn't allow otherwise. Implement the memory
effects query method in C++ instead to make the effect not attached to
the operand.

21 months ago[CodeGenCXX] Convert more tests to opaque pointers (NFC)
Nikita Popov [Thu, 6 Oct 2022 10:38:56 +0000 (12:38 +0200)]
[CodeGenCXX] Convert more tests to opaque pointers (NFC)

Conversion was performed using
https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34
plus manual (but uninteresting) fixups.