platform/upstream/llvm.git
14 months ago[analyzer][CStringChecker] Adjust the invalidation operation on the super region...
Ella Ma [Thu, 8 Jun 2023 12:22:58 +0000 (20:22 +0800)]
[analyzer][CStringChecker] Adjust the invalidation operation on the super region of the destination buffer during string copy

Fixing GitHub issue: https://github.com/llvm/llvm-project/issues/55019
Following the previous fix https://reviews.llvm.org/D12571 on issue https://github.com/llvm/llvm-project/issues/23328

The two issues report false memory leaks after calling string-copy APIs with a buffer field in an object as the destination.
The buffer invalidation incorrectly drops the assignment to a heap memory block when no overflow problems happen.
And the pointer of the dropped assignment is declared in the same object of the destination buffer.

The previous fix only considers the `memcpy` functions whose copy length is available from arguments.
In this issue, the copy length is inferable from the buffer declaration and string literals being copied.
Therefore, I have adjusted the previous fix to reuse the copy length computed before.

Besides, for APIs that never overflow (strsep) or we never know whether they can overflow (std::copy),
new invalidation operations have been introduced to inform CStringChecker::InvalidateBuffer whether or not to
invalidate the super region that encompasses the destination buffer.

Reviewed By: steakhal

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

14 months ago[dfsan] Support Linux loongarch64
zhanglimin [Mon, 3 Jul 2023 08:05:00 +0000 (16:05 +0800)]
[dfsan] Support Linux loongarch64

Make minor changes to enable DFSAN and its tests on
loongarch64. And port Linux loongarch64 memory mappings
from msan.

Reviewed By: MaskRay

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

14 months ago[Tooling][Rewriter] Remove the redundant AtomicallyMovedFile Implementation.
Haojian Wu [Mon, 3 Jul 2023 07:34:19 +0000 (09:34 +0200)]
[Tooling][Rewriter] Remove the redundant AtomicallyMovedFile Implementation.

Replace it with llvm::writeToOutput.

Reviewed By: avl

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

14 months ago[ADT] Add deduction guide for iterator_range
Balazs Benics [Mon, 3 Jul 2023 07:29:37 +0000 (09:29 +0200)]
[ADT] Add deduction guide for iterator_range

This commit also enhances the container overload constructor so that it
now considers the `begin` and `end` free functions, and performs ADL
lookups to find the best match.

To make this possible, I had to split-off the ADL helper functions from
the STLExtras header so that the iterator_range still remains pretty
cheap to include.

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

14 months ago[analyzer] Fix false negative when using a nullable parameter directly without bindin...
tripleCC [Mon, 3 Jul 2023 07:28:41 +0000 (09:28 +0200)]
[analyzer] Fix false negative when using a nullable parameter directly without binding to a variable

If a parameter has a nullability annotation, the nullability information
of the parameter should be set as a NullabilityState trait at the
beginning of the function.

Patch By tripleCC!

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

14 months ago[mlir][linalg] LinalgOp-anchored empty tensor elimination
Matthias Springer [Mon, 3 Jul 2023 07:15:22 +0000 (09:15 +0200)]
[mlir][linalg] LinalgOp-anchored empty tensor elimination

This revision adds a pre-bufferization transform that can reduce the number of allocation. It is similar to `bufferization.eliminate_empty_tensors`, but specific to LinalgOp.

The transform looks for `tensor.empty` ops where the SSA use-def chain ends in an "ins" operand of a `LinalgOp`. If the same `LinalgOp` has an unused "outs" operand (and some other conditions are met), this "outs" operand can be used instead of the `tensor.empty` and the "ins" operand can be turned into an "outs" operand.

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

14 months ago[mlir][vector] Clean up some dimension size checks
Matthias Springer [Mon, 3 Jul 2023 07:09:09 +0000 (09:09 +0200)]
[mlir][vector] Clean up some dimension size checks

* Add `memref::getMixedSize` (same as in the tensor dialect).
* Simplify in-bounds check in `VectorTransferSplitRewritePatterns.cpp` and fix off-by-one error in the static in-bounds check.
* Use "memref::DimOp" instead of `createOrFoldDimOp` when possible.

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

14 months ago[mlir][linalg] Remove redundant dimension size helper functions
Matthias Springer [Mon, 3 Jul 2023 06:59:19 +0000 (08:59 +0200)]
[mlir][linalg] Remove redundant dimension size helper functions

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

14 months ago[CSKY] Optimize conditional branch with BLZ32/BLSZ32/BHZ32/BHSZ32
Ben Shi [Fri, 23 Jun 2023 04:23:30 +0000 (12:23 +0800)]
[CSKY] Optimize conditional branch with BLZ32/BLSZ32/BHZ32/BHSZ32

Add more `Pat`s to generate BLZ32/BLSZ32/BHZ32/BHSZ32.

Reviewed By: zixuan-wu

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

14 months ago[CSKY] Optimize IR pattern icmp-select with DECT32/DECF32
Ben Shi [Thu, 22 Jun 2023 10:39:08 +0000 (18:39 +0800)]
[CSKY] Optimize IR pattern icmp-select with DECT32/DECF32

Reviewed By: zixuan-wu

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

14 months ago[mlir][transform] Add `transform.apply_cse` op
Matthias Springer [Mon, 3 Jul 2023 06:49:59 +0000 (08:49 +0200)]
[mlir][transform] Add `transform.apply_cse` op

This op applies CSE to the targeted op. This is similar to `transform.apply_registered_pass "cse"`, but it retains handles in the body of the targeted op.

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

14 months ago[mlir][Transforms][NFC] CSE: Add C++ entry point
Matthias Springer [Mon, 3 Jul 2023 06:42:14 +0000 (08:42 +0200)]
[mlir][Transforms][NFC] CSE: Add C++ entry point

* All IR modifications are done with a rewriter.
* The new C++ entry point takes a `RewriterBase &`, which may have a listener attached to it.

This revision is useful because it allows users to run CSE and track IR modifications via a listener that can be attached to the rewriter.

This is a reupload. The original CL was reverted (9979417d4db4) due to a memory leak. The memory leak is unrelated to this change and fixed with D154185.

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

14 months ago[mlir][IR] Fix memory leak in DominanceInfo
Matthias Springer [Mon, 3 Jul 2023 06:35:20 +0000 (08:35 +0200)]
[mlir][IR] Fix memory leak in DominanceInfo

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

14 months ago[flang] Fix -Wstring-conversion in PPCIntrinsicCall.cpp (NFC)
Jie Fu [Mon, 3 Jul 2023 06:14:48 +0000 (14:14 +0800)]
[flang] Fix -Wstring-conversion in PPCIntrinsicCall.cpp (NFC)

/Users/jiefu/llvm-project/flang/lib/Optimizer/Builder/PPCIntrinsicCall.cpp:617:14: error: implicit conversion turns string literal into bool: 'const char[39]' to 'bool' [-Werror,-Wstring-conversion]
      assert("Invalid vector operation for generator");
      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

14 months ago[flang] Add PowerPC vec_cmpge, vec_cmpgt, vec_cmple, vec_cmplt and vec_any_ge intrinsic
Kelvin Li [Mon, 26 Jun 2023 15:45:35 +0000 (11:45 -0400)]
[flang] Add PowerPC vec_cmpge, vec_cmpgt, vec_cmple, vec_cmplt and vec_any_ge intrinsic

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

14 months ago[Coroutines] Prevent infinite loop in simplifyTerminatorLeadingToRet
Chuanqi Xu [Mon, 3 Jul 2023 02:39:07 +0000 (10:39 +0800)]
[Coroutines] Prevent infinite loop in simplifyTerminatorLeadingToRet

Close https://github.com/llvm/llvm-project/issues/63639

This comes from the oversight the refactoring that we missed a `return
false;` in the loop.

14 months ago[X86] Add missing features for ivybridge, sandybridge and knl in X86TargetParser...
Freddy Ye [Mon, 3 Jul 2023 00:12:25 +0000 (08:12 +0800)]
[X86] Add missing features for ivybridge, sandybridge and knl in X86TargetParser.def.

This is also a pre-commit change for D151696

Reviewed By: RKSimon

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

14 months ago[libc] Correct usage of __unix__ and __linux__
Alfred Persson Forsberg [Mon, 3 Jul 2023 00:07:59 +0000 (01:07 +0100)]
[libc] Correct usage of __unix__ and __linux__

Reviewed By: michaelrj, thesamesam

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

14 months ago[mlir] Use reinterpret cast to construct TypedValue from a pointer
Eugene Zhulenev [Sun, 2 Jul 2023 23:11:28 +0000 (16:11 -0700)]
[mlir] Use reinterpret cast to construct TypedValue from a pointer

Value is not convertible to TypedValue<T>, use explicit constructor from a pointer

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

14 months ago[mlir] Specialize DenseMapInfo and PointerLikeTypeTraits for mlir::TypedValue
Eugene Zhulenev [Sun, 2 Jul 2023 22:47:30 +0000 (15:47 -0700)]
[mlir] Specialize DenseMapInfo and PointerLikeTypeTraits for mlir::TypedValue

Reviewed By: mehdi_amini

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

14 months ago[ARM] Adjust strd/ldrd codegen alignment requirements
Maurice Heumann [Sun, 2 Jul 2023 19:18:50 +0000 (12:18 -0700)]
[ARM] Adjust strd/ldrd codegen alignment requirements

In change https://reviews.llvm.org/D152790, it was discovered that the
alignment requirement calculation for LDRD/STRD codegen was suboptimal
and the calculation for volatile loads and stores was adjusted.

This change here adopts the calculation for the remaining non-volatile
occurances.

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

14 months ago[clang][CodeGen] Fix global variables initialized with an inheriting constructor.
Eli Friedman [Fri, 30 Jun 2023 22:31:47 +0000 (15:31 -0700)]
[clang][CodeGen] Fix global variables initialized with an inheriting constructor.

For inheriting constructors which have to be emitted inline, we use
CodeGenFunction::EmitInlinedInheritingCXXConstructorCall to emit the
required code.  This code uses EmitParmDecl to emit the "this" argument
of the call.  EmitParmDecl then helpfully calls llvm::Value::setName to
name the parameter... which renames the global variable to "this".

To fix the issue, skip the setName call on globals.

The renaming still has slightly weird results in other cases (it renames
all local variables initialized with an inlined inheriting constructor
to "this"), but the result isn't actually wrong in those cases, so I'm
just going to leave it for now.

Fixes https://github.com/llvm/llvm-project/issues/63618

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

14 months ago[LV] Add test case for #63602.
Florian Hahn [Sun, 2 Jul 2023 21:17:16 +0000 (22:17 +0100)]
[LV] Add test case for #63602.

14 months ago[C11] Correct global atomic pointer initialization from an integer constant
Aaron Ballman [Sun, 2 Jul 2023 18:40:21 +0000 (14:40 -0400)]
[C11] Correct global atomic pointer initialization from an integer constant

This is a follow-up to 2e275e24355cb224981f9beb2b026a3169fc7232 and
1395cde24b3641e284bb1daae7d56c189a2635e3 which corrects a missed case:
initializing an _Atomic(T *) from a null pointer constant in the form
of the integer literal 0.

Fixes https://github.com/llvm/llvm-project/issues/63550
Differential Revision: https://reviews.llvm.org/D154284

14 months agoRevert "[MC] Allow conversion between ParseStatus and MatchOperandResultTy"
Sergei Barannikov [Sun, 2 Jul 2023 15:38:53 +0000 (18:38 +0300)]
Revert "[MC] Allow conversion between ParseStatus and MatchOperandResultTy"

This reverts commit 15ef9b26adeb8c9dd98228fc26757966d8355986.

Going to put it for review with larger set of differences.

14 months ago[AMDGPU] Rename predefined macro __AMDGCN_WAVEFRONT_SIZE
Yaxun (Sam) Liu [Fri, 30 Jun 2023 12:36:26 +0000 (08:36 -0400)]
[AMDGPU] Rename predefined macro __AMDGCN_WAVEFRONT_SIZE

rename it to __AMDGCN_WAVEFRONT_SIZE__ for consistency.

__AMDGCN_WAVEFRONT_SIZE will be deprecated in the future.

Reviewed by: Matt Arsenault, Johannes Doerfert

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

14 months agoFix typo "__is_parititioned_impl" to "__is_partitioned_impl"
Amirreza Ashouri [Sun, 2 Jul 2023 14:54:20 +0000 (16:54 +0200)]
Fix typo "__is_parititioned_impl" to "__is_partitioned_impl"

A typo has been fixed

Reviewed By: #libc, Mordante

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

14 months ago[clang] Remove CGBuilderTy::CreateElementBitCast
Youngsuk Kim [Sun, 2 Jul 2023 14:40:00 +0000 (10:40 -0400)]
[clang] Remove CGBuilderTy::CreateElementBitCast

`CGBuilderTy::CreateElementBitCast()` no longer does what its name suggests.

Remove remaining in-tree uses by one of the following methods.

* drop the call entirely
* fold it to an `Address` construction
* replace it with `Address::withElementType()`

This is a NFC cleanup effort.

Reviewed By: barannikov88, nikic, jrtc27

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

14 months ago[DAG][AArch64] Handle vector types when expanding sdiv/udiv into mulh
David Green [Sun, 2 Jul 2023 14:02:52 +0000 (15:02 +0100)]
[DAG][AArch64] Handle vector types when expanding sdiv/udiv into mulh

The aarch64 backend will benefit from expanding 64vector sdiv/udiv into mulh
using shift(mul(ext, ext)), as the larger type size is legal and the mul(ext,
ext) can efficiently use smull/umull instructions. This extends the existing
code in GetMULHS to handle vector types for it.

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

14 months ago[GlobalIsel][X86] Add initial scalar G_MUL/G_SMULH/G_UMULH instruction selection...
Simon Pilgrim [Sun, 2 Jul 2023 11:43:44 +0000 (12:43 +0100)]
[GlobalIsel][X86] Add initial scalar G_MUL/G_SMULH/G_UMULH instruction selection handling

Reuse the existing div/rem selection code to also handle mul/imul to support G_MUL/G_SMULH/G_UMULH, as they have a similar pattern using rDX/rAX for mulh/mul results, plus the AH/AL support for i8 multiplies.

14 months ago[AArch64] Expand typesizes of tests for constant srem/urem. NFC
David Green [Sun, 2 Jul 2023 11:44:15 +0000 (12:44 +0100)]
[AArch64] Expand typesizes of tests for constant srem/urem. NFC

See D154049.

14 months ago[sanitizer_common][test] Fix huge_malloc.c UNSUPPORTED syntax
Rainer Orth [Sun, 2 Jul 2023 11:27:04 +0000 (13:27 +0200)]
[sanitizer_common][test] Fix huge_malloc.c UNSUPPORTED syntax

`lit` doesn't accept arbitrary substrings of the target triple any longer,
so d5a779b5a39b655ed9fafedaacbb017c46f5dbfe
<https://reviews.llvm.org/rGd5a779b5a39b655ed9fafedaacbb017c46f5dbfe> has
no effect.

Instead, this patch uses the `target=` syntax as all other tests in
`compiler-rt`.

Tested on `amd64-pc-solaris2.11`.

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

14 months ago[AArch64] Ensure BICi and ORRi have same input and output types. NFC
David Green [Sun, 2 Jul 2023 10:17:59 +0000 (11:17 +0100)]
[AArch64] Ensure BICi and ORRi have same input and output types. NFC

14 months ago[llvm][NFC] Stop plenking in an assertion message
Timm Bäder [Fri, 30 Jun 2023 09:50:22 +0000 (11:50 +0200)]
[llvm][NFC] Stop plenking in an assertion message

Remove whitespace before an exclamation mark.

14 months ago[clang][Sema][NFC] Make worklist in CheckForIntOverflow const
Timm Bäder [Sat, 1 Jul 2023 14:54:10 +0000 (16:54 +0200)]
[clang][Sema][NFC] Make worklist in CheckForIntOverflow const

14 months ago[clang][Interp][NFC] Fix a test to actually test something
Timm Bäder [Fri, 30 Jun 2023 19:09:16 +0000 (21:09 +0200)]
[clang][Interp][NFC] Fix a test to actually test something

This was always meant to test the values of c2, not c.

14 months ago[Driver][MSVC] Move lld specific flags before inputs
Haohai Wen [Sun, 2 Jul 2023 01:28:30 +0000 (09:28 +0800)]
[Driver][MSVC] Move lld specific flags before inputs

Check linker earlier so that lld specific flags can be append before
inputs. Just like position of other flags. The intention is to make
expanded cmd more consistent and elegent so that user can easily
look for inputs when using -###.

Reviewed By: mstorsjo

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

14 months ago[clang] P1816R0 and P2082R1 should work for cxx20 and after only
Yuanfang Chen [Sun, 2 Jul 2023 00:19:38 +0000 (17:19 -0700)]
[clang] P1816R0 and P2082R1 should work for cxx20 and after only

For commit 632dd6a4ca0036009f

14 months ago[AArch64] Emit fewer CFI instructions for synchronous unwind tables
Igor Kudrin [Sat, 1 Jul 2023 21:45:59 +0000 (14:45 -0700)]
[AArch64] Emit fewer CFI instructions for synchronous unwind tables

The instruction-precise, or asynchronous, unwind tables usually take up
much more space than the synchronous ones. If a user is concerned about
the load size of the program and does not need the features provided
with the asynchronous tables, the compiler should be able to generate
the more compact variant.

This patch changes the generation of CFI instructions for these cases so
that they all come in one chunk in the prolog; it emits only one
`.cfi_def_cfa*` instruction followed by `.cfi_offset` ones after all
stack adjustments and register spills, and avoids generating CFI
instructions in the epilog(s) as well as any other exceeding CFI
instructions like `.cfi_remember_state` and `.cfi_restore_state`.
Effectively, it reverses the effects of D111411 and D114545 on functions
with the `uwtable(sync)` attribute. As a side effect, it also restores
the behavior on functions that have neither `uwtable` nor `nounwind`
attributes.

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

14 months ago[MC] Allow conversion between ParseStatus and MatchOperandResultTy
Sergei Barannikov [Sat, 1 Jul 2023 21:43:16 +0000 (00:43 +0300)]
[MC] Allow conversion between ParseStatus and MatchOperandResultTy

This allows a smooth transition to ParseStatus.

14 months ago[AArch64] Treat the icmp in icmp(and(..), 0) as free
David Green [Sat, 1 Jul 2023 20:59:54 +0000 (21:59 +0100)]
[AArch64] Treat the icmp in icmp(and(..), 0) as free

As in https://godbolt.org/z/4dafd9Geq, the icmp from an And may use an Ands to
set flags, meaning the icmp is free.

This could also be done for add/sub, but those patterns often happen in the
induction variable of a loop, making them quite performance sensitive.

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

14 months agoRevert "[msan] Intercept dladdr1, and refactor dladdr"
Thurston Dang [Sat, 1 Jul 2023 20:27:11 +0000 (20:27 +0000)]
Revert "[msan] Intercept dladdr1, and refactor dladdr"

Reverting my commit because of buildbot breakage.

This reverts commit d0b0dbeae17756f7ba99e0867cfb867fcb375066.

14 months ago[msan] Intercept dladdr1, and refactor dladdr
Thurston Dang [Fri, 30 Jun 2023 23:08:20 +0000 (23:08 +0000)]
[msan] Intercept dladdr1, and refactor dladdr

This patch adds an msan interceptor for dladdr1 (with support
for RTLD_DL_LINKMAP and RTLD_DL_SYMENT) and an accompanying
test. It also adds a helper file, msan_dl.cpp, that contains
UnpoisonDllAddrInfo (refactored out of the dladdr interceptor)
and UnpoisonDllAddr1ExtraInfo.

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

14 months ago[AArch64] Remove duplicate code (NFC)
Evandro Menezes [Sat, 1 Jul 2023 18:26:14 +0000 (13:26 -0500)]
[AArch64] Remove duplicate code (NFC)

Remove multiple versions of the predicate that checks if the
instruction operand is shifted by up to 4.

14 months ago[libc] Missing FEnvImpl.h dependency on math.h
Petr Hosek [Thu, 29 Jun 2023 06:48:10 +0000 (06:48 +0000)]
[libc] Missing FEnvImpl.h dependency on math.h

FEnvImpl.h includes math.h and so needs an explicit dependency.

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

14 months ago[RISCV] Add a test with unknown argument of .attribute directive
Sergei Barannikov [Sat, 1 Jul 2023 02:11:31 +0000 (05:11 +0300)]
[RISCV] Add a test with unknown argument of .attribute directive

14 months ago[AArch64] Add scheduling model for Neoverse N1
Evandro Menezes [Thu, 22 Jun 2023 23:40:53 +0000 (18:40 -0500)]
[AArch64] Add scheduling model for Neoverse N1

Add the scheduling model for Neoverse N1.

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

14 months ago[clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression
Piotr Zegar [Sat, 1 Jul 2023 16:20:36 +0000 (16:20 +0000)]
[clang-tidy] Correct sizeof/alignas handling in misc-redundant-expression

Fixed issue with the comparison of UnaryExprOrTypeTraitExpr
objects in which only the argument type was checked, without
considering the kind of expression. This led to false positives when
using sizeof(x) and alignof(x) expressions, as only the
comparison x = x was performed without checking if sizeof
was equal to alignof.

Fixes: https://github.com/llvm/llvm-project/issues/63096

Reviewed By: Izaron

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

14 months ago[libc++] Implement stringbuf members of P0408R7 (Efficient Access to basic_stringbuf...
Piotr Fusik [Sat, 1 Jul 2023 11:33:48 +0000 (13:33 +0200)]
[libc++] Implement stringbuf members of P0408R7 (Efficient Access to basic_stringbuf's Buffer)

Reviewed By: #libc, Mordante

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

14 months ago[libc++][doc] Updates spaceship status.
Mark de Wever [Sat, 1 Jul 2023 10:37:02 +0000 (12:37 +0200)]
[libc++][doc] Updates spaceship status.

Work on the missing chrono parts has started, but their operators will
be added in different patches. So split the remaining chrono part to one
entry per line and mark them in progress.

14 months ago[libc++] Enables constexpr string tests.
Mark de Wever [Fri, 30 Jun 2023 15:33:47 +0000 (17:33 +0200)]
[libc++] Enables constexpr string tests.

These tests were disabled during constant evaluation in D90569. At that
time constexpr string was not implemented. It now is.

Reviewed By: #libc, philnik

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

14 months ago[clang-tidy] Improve documentation for modernize-use-std-print check
Mike Crowe [Sat, 1 Jul 2023 08:40:20 +0000 (08:40 +0000)]
[clang-tidy] Improve documentation for modernize-use-std-print check

Remove incorrect use of double colons so that the code blocks are
rendered correctly to HTML.

Wrap the name of another check in single backticks. Wrap the name of a
macro in double backticks.

Explain that with the default settings the check is only enabled with
C++23 or later standards.

Correct std::string_data() to std::string::data().

Reviewed By: PiotrZSL

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

14 months ago[LTO] Fix a missing comment
Haojian Wu [Sat, 1 Jul 2023 06:33:45 +0000 (08:33 +0200)]
[LTO] Fix a missing comment

Address a missing code-review comment: https://reviews.llvm.org/D154191#inline-1490951

14 months ago[bazel] Port bazel support for 5bf8efd269f8b75b5be40f087f231d71f744885c
Haojian Wu [Sat, 1 Jul 2023 06:27:26 +0000 (08:27 +0200)]
[bazel] Port bazel support for 5bf8efd269f8b75b5be40f087f231d71f744885c

14 months ago[LTO] Replace llvm::writeFileAtomically with llvm::writeToOutput API.
Haojian Wu [Fri, 30 Jun 2023 08:38:59 +0000 (10:38 +0200)]
[LTO] Replace llvm::writeFileAtomically with llvm::writeToOutput API.

14 months ago[FuncSpec] Avoid crashing when SwitchInst doesn't see ConstantInt
Vincent Lee [Thu, 29 Jun 2023 22:05:56 +0000 (15:05 -0700)]
[FuncSpec] Avoid crashing when SwitchInst doesn't see ConstantInt

D150464 updated the cost model for function specialization. Unfortunately, this
also crashes when trying to build stage2 LLD with thinLTO and assertions. It looks
like the issue is caused by a mishandling of the Constant in a SwitchInst since the
Constant cannot always be assumed to safely casted to a ConstantInt. In the case
of the crash, Constant was a ConstantExpr which triggered the assertion.

Reviewed By: ChuanqiXu

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

14 months ago[AArch64] Remove duplicate code (NFC)
Evandro Menezes [Sat, 1 Jul 2023 02:37:12 +0000 (21:37 -0500)]
[AArch64] Remove duplicate code (NFC)

14 months ago[MC] Add three-state parseDirective as a replacement for ParseDirective
Sergei Barannikov [Thu, 29 Jun 2023 14:22:41 +0000 (17:22 +0300)]
[MC] Add three-state parseDirective as a replacement for ParseDirective

Conventionally, parsing methods return false on success and true on
error. However, directive parsing methods need a third state: the
directive is not target specific. AsmParser::parseStatement detected
this case by using a fragile heuristic: if the target parser did not
consume any tokens, the directive is assumed to be not target-specific.

Some targets fail to follow the convention: they return success after
emitting an error or do not consume the entire line and return failure
on successful parsing. This was partially worked around by checking for
pending errors in parseStatement.

This patch tries to improve the situation by introducing parseDirective
method that returns ParseStatus -- three-state class. The new method
should eventually replace the old one returning bool.

ParseStatus is intentionally implicitly constructible from bool to allow
uses like `return Error(Loc, "message")`. It also has a potential to
replace OperandMatchResulTy as it is more convenient to use due to the
implicit construction from bool and more type safe.

Reviewed By: MaskRay

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

14 months agoChange the dyld notification function that lldb puts a breakpoint in
Jason Molenda [Sat, 1 Jul 2023 01:26:06 +0000 (18:26 -0700)]
Change the dyld notification function that lldb puts a breakpoint in

On Darwin systems, the dynamic linker dyld has an empty function
it calls when binaries are added/removed from the process.  lldb puts
a breakpoint on this dyld function to catch the notifications.  The
function arguments are used by lldb to tell what is happening.

The linker has a natural representation when the addresses of
binaries being added/removed are in the pointer size of the process.
There is then a second function where the addresses of the binaries
are in a uint64_t array, which the debugger has been using before -
dyld allocates memory for the array, copies the values in to it,
and calls it for lldb's benefit.

This changes to using the native notifier function, with pointer-sized
addresses.

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

14 months ago[lld/COFF] Add /dwodir to enable DWARF fission with LTO
Haohai Wen [Sat, 1 Jul 2023 00:58:56 +0000 (08:58 +0800)]
[lld/COFF] Add /dwodir to enable DWARF fission with LTO

This patch added /dwodir to lld/COFF which is equivalent to lld/ELF
option -plugin-opt=dwo_dir=. This option tells LTO backend to create
dwo directory and files and all dwo files will be in it. Otherwise all
dwarf sections will be embeded into image even if -gsplit-dwarf is
specified when using LTO.

Reviewed By: MaskRay

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

14 months ago[lldb] Add log indicating which kind of data formatter
Dave Lee [Wed, 28 Jun 2023 22:48:15 +0000 (15:48 -0700)]
[lldb] Add log indicating which kind of data formatter

The `formatter` logs include a function name, but these functions are mostly templates
and the template type parameter is not printed, which is useful context.

This change adds a new log which is printed upon entry of `FormatManager::Get`, which
shows the formatter context as either `format`, `summary`, or `synthetic`.

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

14 months ago[clang] detect integer overflow through temporary values
Lucile Nihlen [Fri, 30 Jun 2023 19:48:40 +0000 (19:48 +0000)]
[clang] detect integer overflow through temporary values

Fixes #63629.

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

14 months ago[clang] Fix leak in LoadFromCommandLineWorkingDirectory unit test
Hamish Knight [Fri, 30 Jun 2023 23:01:20 +0000 (16:01 -0700)]
[clang] Fix leak in LoadFromCommandLineWorkingDirectory unit test

Change `ASTUnit::LoadFromCommandLine` to return a `std::unique_ptr` instead of a +1 pointer, fixing a leak in the unit test `LoadFromCommandLineWorkingDirectory`.

Reviewed By: bnbarham, benlangmuir

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

14 months ago[mlir][NVGPU]: Fix op description of nvgpu.device_async_wait.
Yuan Yao [Wed, 28 Jun 2023 20:50:25 +0000 (13:50 -0700)]
[mlir][NVGPU]: Fix op description of nvgpu.device_async_wait.

According to the NVIDIA documentation on `cp.async.wait_group`
(https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#data-movement-and-conversion-instructions-cp-async-wait-group-cp-async-wait-all),
the `numGroups` attribute in `nvgpu.device_async_wait` should give an upper
bound of pending async group count (instead of a lower bound) when the
executing thread can be unblocked.

Reviewed By: christopherbate

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

14 months ago[mlir][NFC] Sort dialects
Ivan Butygin [Fri, 30 Jun 2023 21:51:01 +0000 (23:51 +0200)]
[mlir][NFC] Sort dialects

Sort dialects cmake and registry.

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

14 months agoExpose DataflowAnalysisContext.querySolver().
Samira Bazuzi [Fri, 30 Jun 2023 21:40:03 +0000 (23:40 +0200)]
Expose DataflowAnalysisContext.querySolver().

This allows for use of the same solver used by the DAC for additional solving post-analysis and thus shared use of MaxIterations in WatchedLiteralsSolver.

Reviewed By: ymandel, gribozavr2, sammccall

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

14 months ago[mlir][sparse][gpu] reuse CUDA environment handle throughout instance lifetime
Kun Wu [Fri, 16 Jun 2023 21:38:40 +0000 (21:38 +0000)]
[mlir][sparse][gpu] reuse CUDA environment handle throughout instance lifetime

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

14 months ago[mlir][sparse] add affine parsing to new surface syntax for STEA
Aart Bik [Fri, 30 Jun 2023 20:05:01 +0000 (13:05 -0700)]
[mlir][sparse] add affine parsing to new surface syntax for STEA

(1) uses the previously introduce API to reuse AffineExpr parser without codedup
(2) solves the look-ahead problem when parsing level spec

Reviewed By: Peiming

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

14 months ago[libc] Fix more inline definitions
Roland McGrath [Fri, 30 Jun 2023 20:20:22 +0000 (13:20 -0700)]
[libc] Fix more inline definitions

Fix a bunch more instances of incorrect use of the `static`
keyword and missing use of LIBC_INLINE and LIBC_INLINE_VAR
macros. Note that even forward declarations and generic template
declarations must follow the prescribed patterns for libc code so
that they match every definition, all template specializations.

Reviewed By: Caslyn

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

14 months ago[lldb] Delete RewriteObjCClassReferences (NFC)
Dave Lee [Mon, 26 Jun 2023 17:34:41 +0000 (10:34 -0700)]
[lldb] Delete RewriteObjCClassReferences (NFC)

The `RewriteObjCClassReferences` pass was applicable only to the code generated for the
fragile ObjC ABI (v1). That ABI is no longer active (last used for i386 macOS), which
means this pass has no effect.

Sources: `OBJC_CLASS_REFERENCES_` is emitted only by `CGObjCMac`, and not by
`CGObjCNonFragileABIMac`.

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

14 months ago[clang] Replace uses of CreateElementBitCast (NFC)
Youngsuk Kim [Fri, 30 Jun 2023 21:33:28 +0000 (17:33 -0400)]
[clang] Replace uses of CreateElementBitCast (NFC)

Partial progress towards replacing uses of CreateElementBitCast, as it
no longer does what its name suggests.

Reviewed By: barannikov88

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

14 months ago[mlir][sparse] make UnpackOp return the actual filled length of unpacked memory
Peiming Liu [Fri, 30 Jun 2023 18:07:21 +0000 (18:07 +0000)]
[mlir][sparse] make UnpackOp return the actual filled length of unpacked memory

This might simplify frontend implementation by avoiding recomputation for the same value.

Reviewed By: aartbik

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

14 months ago[gn build] Port c4e98722ca79
LLVM GN Syncbot [Fri, 30 Jun 2023 21:17:57 +0000 (21:17 +0000)]
[gn build] Port c4e98722ca79

14 months ago[libc] Add missing cast in x86 big_endian_cmp_mask
Roland McGrath [Fri, 30 Jun 2023 20:27:52 +0000 (13:27 -0700)]
[libc] Add missing cast in x86 big_endian_cmp_mask

Implicit narrowing conversions from int to uint16_t
get a compiler warning with the warning settings used
in the Fuchsia build.

Reviewed By: michaelrj

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

14 months ago[LV] Pass bool to requiresScalarEpilogue (NFC).
Florian Hahn [Fri, 30 Jun 2023 21:08:27 +0000 (22:08 +0100)]
[LV] Pass bool to requiresScalarEpilogue (NFC).

requiresScalarEpilogue only checks if the selected VF is vectorizing
(and not scalar). Update it to just take a boolean, to make it clearer
what information is used and to allow callers without a VF (used in a
follow-up patch).

14 months agoAdd Int4 support for tosa::ConstOp
Jerry Ge [Fri, 30 Jun 2023 20:49:58 +0000 (13:49 -0700)]
Add Int4 support for tosa::ConstOp

- Also added Tosa_Weight and Tosa_WeightTensorXD specifically for weights

Signed-off-by: Jerry Ge <jerry.ge@arm.com>
Reviewed By: eric-k256

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

14 months ago[scudo] Improve Secondary Cache Dump
fernandosalas [Fri, 30 Jun 2023 20:55:40 +0000 (20:55 +0000)]
[scudo] Improve Secondary Cache Dump

Exclude cached blocks with invalid start address. Mainly concerned with
cached blocks that are still available/unused.

Reviewed By: Chia-hungDuan, cferris

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

14 months ago[scudo] Restore Freelist when we fail on PageMap creation
Chia-hung Duan [Thu, 29 Jun 2023 04:23:21 +0000 (04:23 +0000)]
[scudo] Restore Freelist when we fail on PageMap creation

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

14 months ago[msan] Add lit test for dladdr
Thurston Dang [Fri, 30 Jun 2023 20:18:53 +0000 (20:18 +0000)]
[msan] Add lit test for dladdr

This adds a simple lit test for dladdr. (There is currently a dladdr testcase in
compiler-rt/lib/msan/tests/msan_test.cpp, but not a stand-alone lit test.)

This is an incremental step towards adding a test case (and, eventually, an interceptor)
for the more complicated dladdr1 function.

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

14 months agocorrect misspelled _LIBCPP___TYPE_TRAITS_IS_EQUAILITY_COMPARABLE_H to _LIBCPP___TYPE_...
Amirreza Ashouri [Fri, 30 Jun 2023 20:50:27 +0000 (13:50 -0700)]
correct misspelled _LIBCPP___TYPE_TRAITS_IS_EQUAILITY_COMPARABLE_H to _LIBCPP___TYPE_TRAITS_IS_EQUALITY_COMPARABLE_H

I just corrected a mistakenly misspelled macro

Reviewed By: philnik, #libc

Spies: libcxx-commits, #llvm, philnik

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

14 months ago[libc++] Fix std::copy and std::move for ranges with potentially overlapping tail...
Nikolas Klauser [Fri, 30 Jun 2023 20:47:39 +0000 (13:47 -0700)]
[libc++] Fix std::copy and std::move for ranges with potentially overlapping tail padding

This fixes thr bug reported in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108846.

Reviewed By: ldionne, #libc

Spies: mstorsjo, libcxx-commits

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

14 months ago[RISCV] Fix vfwcvt/vfncvt pseudos w/ rounding mode lowering
Luke Lau [Fri, 30 Jun 2023 16:44:47 +0000 (17:44 +0100)]
[RISCV] Fix vfwcvt/vfncvt pseudos w/ rounding mode lowering

Some signed opcodes were being lowered to their unsigned counterparts and
vice-versa.

Reviewed By: craig.topper

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

14 months ago[test] Add a couple of missing REQUIRES
Justin Bogner [Fri, 30 Jun 2023 20:41:23 +0000 (14:41 -0600)]
[test] Add a couple of missing REQUIRES

These tests only work if the targets in the input are available.

14 months ago[flang][openmp] Parallel reduction FIR lowering
Ethan Luis McDonough [Fri, 30 Jun 2023 20:32:21 +0000 (15:32 -0500)]
[flang][openmp] Parallel reduction FIR lowering

This patch extends the logic for lowering loop construct reductions to parallel block reductions.

Reviewed By: kiranchandramohan

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

14 months ago[flang][NFC] Fix typos
Valentin Clement [Fri, 30 Jun 2023 20:15:25 +0000 (13:15 -0700)]
[flang][NFC] Fix typos

14 months ago[UBSan] Fix shared library linking in test for Darwin.
usama hameed [Fri, 30 Jun 2023 19:58:55 +0000 (12:58 -0700)]
[UBSan] Fix shared library linking in test for Darwin.

Without rpath information, the test fails on some Darwin platforms since the binary fails to find the shared library.

rdar://110010041

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

14 months ago[OpenMP][NVPTX] Handle additional invalid PTX characters
Jeffrey Sandoval [Fri, 30 Jun 2023 19:57:05 +0000 (14:57 -0500)]
[OpenMP][NVPTX] Handle additional invalid PTX characters

For OpenMP offload, Clang emits global symbols containing the string
'<captured>', which contains characters that are invalid in PTX.
Extend the existing pass that replaces '.'  and '@' characters with
'_$_' to also replace '<' and '>' characters.

Reviewed By: cchen

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

14 months ago[openacc][NFC] Bump parser support number to OpenACC 3.3
Valentin Clement [Fri, 30 Jun 2023 19:56:00 +0000 (12:56 -0700)]
[openacc][NFC] Bump parser support number to OpenACC 3.3

Parser support reached OpenACC 3.3 specification.
Bump the numbers to reflect the latest specs.

Reviewed By: razvanlupusoru, awarzynski

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

14 months ago[llvm-exegesis] Make sure auxiliary memory is unlinked after usage
Aiden Grossman [Fri, 30 Jun 2023 19:42:37 +0000 (12:42 -0700)]
[llvm-exegesis] Make sure auxiliary memory is unlinked after usage

Currently the shm_unlink is never called on the auxiliary memory shared
memory, so it stays around after running llvm-exegesis (including
running the llvm-exegesis tests). This patch adds the auxiliary memory
shared memory name to the SharedMemoryNames list so that it gets
unlinked when the destructor of SubprocessMemory is called.

14 months agoRevert "[SimplifyCFG] Allow dropping block that only contains ephemeral values"
Nikita Popov [Fri, 30 Jun 2023 19:05:59 +0000 (21:05 +0200)]
Revert "[SimplifyCFG] Allow dropping block that only contains ephemeral values"

This reverts commit 20f0c68fd83a0147a8ec1722bd2e848180610288.

https://reviews.llvm.org/D153966#4464594 reports an optimization
regression in Rust.

Additionally this change has caused an unexpected 0.3% compile-time
regression.

14 months ago[mlir][Vector] Update the lowering of `vector.transfer_write` to SCF
Andrzej Warzynski [Fri, 30 Jun 2023 15:04:28 +0000 (16:04 +0100)]
[mlir][Vector] Update the lowering of `vector.transfer_write` to SCF

This change updates the lowering of `vector.transfer_write` to SCF when
scalable vectors are used. Specifically, when lowering
`vector.transfer_write` to a loop of `vector.extractelement` ops, make
sure that the upper bound of the generated loop is scaled by
`vector.vscale`:
```
    %10 = vector.vscale
    %11 = arith.muli %10, %c16 : index
    scf.for %arg2 = %c0 to %11 step %c1
```

For reference, this is the current version (i.e. before this change):
```
    scf.for %arg2 = %c0 to %c16 step %c1
```
Note that this only valid for fixed-width vectors.

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

14 months ago[mlir][sparse][gpu] Add explaining string to three static_assert stmts
Kun Wu [Fri, 30 Jun 2023 18:32:13 +0000 (13:32 -0500)]
[mlir][sparse][gpu] Add explaining string to three static_assert stmts

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

14 months ago[OpenMP] Added memory scope to atomic::inc API and used the device scope in reduction.
Dhruva Chakrabarti [Fri, 30 Jun 2023 18:02:12 +0000 (14:02 -0400)]
[OpenMP] Added memory scope to atomic::inc API and used the device scope in reduction.

With https://reviews.llvm.org/D137524, memory scope and ordering
attributes are being used to generate the required instructions for
atomic inc/dec on AMDGPU. This patch adds the memory scope attribute to
the atomic::inc API and uses the device scope in reduction. Without
the device scope in atomic_inc, the default system scope leads to
unnecessary L2 write-backs/invalidates.

Reviewed By: arsenm

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

14 months agoOpenMP: Don't use target regions in library function test
Matt Arsenault [Tue, 13 Jun 2023 21:22:29 +0000 (17:22 -0400)]
OpenMP: Don't use target regions in library function test

Use pragma omp declare target to reduce the IR noise around the call
we're actually trying to test.

14 months agoAMDGPU: Fix opaque pointer conversion error in test
Matt Arsenault [Mon, 26 Jun 2023 22:36:06 +0000 (18:36 -0400)]
AMDGPU: Fix opaque pointer conversion error in test

The * was in the wrong place so this was missed by the script.

14 months agoAMDGPU: Fold away mbcnt.hi in wave32 mode
Matt Arsenault [Thu, 29 Jun 2023 14:07:28 +0000 (10:07 -0400)]
AMDGPU: Fold away mbcnt.hi in wave32 mode

This will allow libraries to drop some of the special casing based on
wave size.

14 months agoAMDGPU: Add baseline tests for mbcnt.hi combine
Matt Arsenault [Thu, 29 Jun 2023 14:05:20 +0000 (10:05 -0400)]
AMDGPU: Add baseline tests for mbcnt.hi combine

14 months ago[SLP] Fix crash on attempt to access on invalid iterator state.
Valery N Dmitriev [Fri, 30 Jun 2023 01:15:57 +0000 (18:15 -0700)]
[SLP] Fix crash on attempt to access on invalid iterator state.

The patch fixes corner case when no of scalar instructions
required scheduling for vectorized node.

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

14 months ago[WebAssembly] Fix incorrect assertion in SIMD reduction codegen
Thomas Lively [Fri, 30 Jun 2023 18:30:17 +0000 (11:30 -0700)]
[WebAssembly] Fix incorrect assertion in SIMD reduction codegen

The codegen routine introduced in 18077e9fd688 did not account for vectors with
more than 16 lanes. Remove the incorrect assertion and bail out of the
optimization when encountering this case. Add test cases that previously
triggered the assertion. Unfortunately, these test cases now have terrible
codegen, but that is at least better than crashing.

Fixes #63500.

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

14 months ago[flang][hlfir] probe ultimate intrinsic module procedure name
Jean Perier [Fri, 30 Jun 2023 18:26:59 +0000 (20:26 +0200)]
[flang][hlfir] probe ultimate intrinsic module procedure name

HLFIR lowering was currently hitting errors like "not yet implemented:
intrinsic: z0$iso_c_binding$c_associated_c_ptr". These error were caused
by HLFIR lowering using the name with the full context instead of
the ultimate one.
I do not want to change proc.GetName() because I think it may be best
if it retains the full context for its usages in semantics, so I fixed
the helper to get the name in lowering to HLFIR.

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