platform/upstream/llvm.git
13 months agoValueTracking: Handle constrained_sqrt in computeKnownFPClass
Matt Arsenault [Thu, 13 Apr 2023 14:25:18 +0000 (10:25 -0400)]
ValueTracking: Handle constrained_sqrt in computeKnownFPClass

With this, the body of CannotBeNegativeZero can be dropped.

13 months agoAMDGPU: Drop FP_ROUND second value check
Matt Arsenault [Tue, 23 May 2023 10:04:39 +0000 (11:04 +0100)]
AMDGPU: Drop FP_ROUND second value check

This doesn't mean what I thought it meant and is an optimization
hint flag.

13 months agoInline: Convert test to generated checks
Matt Arsenault [Tue, 23 May 2023 14:48:38 +0000 (15:48 +0100)]
Inline: Convert test to generated checks

13 months agoConvert unit test to opaque pointers
Matt Arsenault [Tue, 23 May 2023 09:36:07 +0000 (10:36 +0100)]
Convert unit test to opaque pointers

13 months agoRecommit [C++20] [Modules] Serialize the evaluated constant values for VarDecl
Chuanqi Xu [Wed, 24 May 2023 02:13:31 +0000 (10:13 +0800)]
Recommit [C++20] [Modules] Serialize the evaluated constant values for VarDecl

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

Previously, we didn't serialize the evaluated result for VarDecl. This
caused the compilation of template metaprogramming become slower than
expect. This patch fixes the issue.

This is a recommit tested with asan built clang.

13 months ago[mlir] [sroa] Add support for MemRef.
Théo Degioanni [Wed, 24 May 2023 07:25:02 +0000 (07:25 +0000)]
[mlir] [sroa] Add support for MemRef.

This patch implements SROA interfaces for MemRef, up to a given fixed
size.

Reviewed By: gysit, Dinistro

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

13 months ago[AMDGPU] Check if register is non-null before calling isSubRegisterEq (NFCI)
Sergei Barannikov [Wed, 24 May 2023 05:10:35 +0000 (08:10 +0300)]
[AMDGPU] Check if register is non-null before calling isSubRegisterEq (NFCI)

D151036 adds an assertions that prohibits iterating over sub- and
super-registers of a null register. This is already the case when
iterating over register units of a null register, and worked by
accident for sub- and super-registers.

Reviewed By: foad

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

13 months ago[IR] Use LLVMContext::MD_nontemporal (NFC)
Kazu Hirata [Wed, 24 May 2023 06:37:38 +0000 (23:37 -0700)]
[IR] Use LLVMContext::MD_nontemporal (NFC)

13 months ago[clang][X86] Add __cpuidex function to cpuid.h
Aiden Grossman [Wed, 24 May 2023 02:46:38 +0000 (02:46 +0000)]
[clang][X86] Add __cpuidex function to cpuid.h

MSVC has a `__cpuidex` function implemented to call the underlying cpuid
instruction which accepts a leaf, subleaf, and data array that the output
data is written into. This patch adds this functionality into clang
under the cpuid.h header. This also makes clang match GCC's behavior.
GCC has had `__cpuidex` in its cpuid.h since 2020.

Reviewed By: craig.topper

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

13 months ago[gn build] Port bea2ff655068
LLVM GN Syncbot [Wed, 24 May 2023 05:58:04 +0000 (05:58 +0000)]
[gn build] Port bea2ff655068

13 months agoRevert "[C++20] [Modules] Serialize the evaluated constant values for VarDecl"
Chuanqi Xu [Wed, 24 May 2023 05:55:45 +0000 (13:55 +0800)]
Revert "[C++20] [Modules] Serialize the evaluated constant values for VarDecl"

This reverts commit c0d6f85e3ae8bcfdb7217d165314f01c1a4af9ae. The asan
bot detected a memory leak after this patch. Revert it for now.

13 months ago[libc++] Untangles invoke.
Mark de Wever [Thu, 20 Apr 2023 19:03:40 +0000 (21:03 +0200)]
[libc++] Untangles invoke.

The type traits parts are moved to a type_traits detail header.
This was discovered while working on modules.

Reviewed By: #libc, ldionne

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

13 months ago[libc++] Adds C++26 support.
Mark de Wever [Sat, 20 May 2023 10:38:57 +0000 (12:38 +0200)]
[libc++] Adds C++26 support.

Clang has been updated to support C++26, this adds the same support for
libc++. At the moment C++23 and C++26 are identical. During the next
plenary in June the first C++26 papers will be voted on.

Note like Clang this patch uses C++26 is the internal part and C++2c in
the user visible part.

Depends on D150795

Reviewed By: ldionne, #libc

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

13 months agoRevert "[clang-format] Fix indentation for selective formatting"
Owen Pan [Wed, 24 May 2023 05:11:45 +0000 (22:11 -0700)]
Revert "[clang-format] Fix indentation for selective formatting"

This reverts commit 72ab89e3197cc1bee3b9774edb504690e3e43ed0.

Reverted due to bots failures e.g.
https://lab.llvm.org/buildbot/#/builders/139/builds/41339.

13 months ago[lldb] Fix typos in documentation
Kazu Hirata [Wed, 24 May 2023 05:10:59 +0000 (22:10 -0700)]
[lldb] Fix typos in documentation

13 months ago[libc++][NFC] Refactor helper method into the Lit test format
Louis Dionne [Tue, 23 May 2023 18:39:37 +0000 (11:39 -0700)]
[libc++][NFC] Refactor helper method into the Lit test format

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

13 months ago[libc++] Complete refactor of tests for operator new
Louis Dionne [Thu, 11 May 2023 14:05:25 +0000 (10:05 -0400)]
[libc++] Complete refactor of tests for operator new

I stumbled upon the `operator new` and `operator new[]` tests while
investigating an issue with `operator new` when exceptions are disabled,
and I realized that our test coverage was incomplete. This patch refactors
all the `operator new` and `operator new[]` tests to add consistency and
better coverage for scenarios in which it should be possible to override
an operator indirectly by defining another one (for example new(size_t, nothrow)
should use new(size_t) if it has been provided).

This is intended to be a NFC setting up the terrain for some refactoring
work and bug fix in operator new.

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

13 months ago[TableGen] Unify the priority of variables
wangpc [Wed, 24 May 2023 03:32:25 +0000 (11:32 +0800)]
[TableGen] Unify the priority of variables

In D148197, we have made `defvar` statement able to refer to class
template arguments. However, the priority of class/multiclass
template argument is higher than variables defined by `defvar`, which
is a little counterintuitive.

In this patch, we unify the priority of variables. Each pair of
braces introduces a new scope, which may contain some additional
variables like template arguments, loop iterators, etc. We can
define local variables inside this scope via `defvar` and these
variables are of higher priority than additional variables. This
means that `defvar` will shadow additional variables with the same
name. The scope can be nested, and we use the innermost variable.

This make variables defined by `defvar` prior to class/multiclass
template arguments, loop iterators, etc. The shadow rules now are:

* `V` in a record body shadows a global `V`.

* `V` in a record body shadows template argument `V`.

* `V` in template arguments shadows a global `V`.

* `V` in a `foreach` statement list shadows any `V` in surrounding record or global scopes.

Reviewed By: tra

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

13 months ago[BBUtils][NFC] Delete SplitBlockAndInsertIfThen with DT.
Joshua Cao [Fri, 28 Apr 2023 06:43:01 +0000 (23:43 -0700)]
[BBUtils][NFC] Delete SplitBlockAndInsertIfThen with DT.

The method is marked for deprecation. Delete the method and move all of
its consumers to use the DomTreeUpdater version.

Reviewed By: foad

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

13 months ago[NFC] Fix the warning for dangling pointer for c0d6f85e3ae8bc
Chuanqi Xu [Wed, 24 May 2023 03:41:26 +0000 (11:41 +0800)]
[NFC] Fix the warning for dangling pointer for c0d6f85e3ae8bc

The bot notes a warning-converted-error for the dangling pointer. And
the patch fixes that.

13 months ago[clang-format] Fix indentation for selective formatting
Sedenion [Wed, 24 May 2023 02:10:14 +0000 (19:10 -0700)]
[clang-format] Fix indentation for selective formatting

The problem was that the LevelIndentTracker remembered
the indentation level of previous deeper levels when
leaving a scope. Afterwards, when it entered again a
deeper level, it blindly reused the the previous
indentation level. In case of the --lines option
configured such that the previous deeper level was not
formatted, that previous level was whatever happened
to be there in the source code. The formatter simply
believed it.

This is fixed by letting the LevelIndentTracker forget
the previous deeper levels when stepping out of them
(=> change in LevelIndentTracker::nextLine()).
Note that this used to be the case until LLVM 14.0.6,
but was changed in
https://github.com/llvm/llvm-project/issues/56352 to
fix a crash. Our commit here essentially reverts that
crash fix. It seemed to have been incorrect. The proper
fix is to set the AnnotedLine::Level of joined lines
correctly (=> change in LineJoiner::join()).

See
https://github.com/llvm/llvm-project/issues/59178#issuecomment-1542637781
for some more details.

Fixes #58464.
Fixes #59178.

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

13 months ago[C++20] [Modules] Serialize the evaluated constant values for VarDecl
Chuanqi Xu [Wed, 24 May 2023 02:13:31 +0000 (10:13 +0800)]
[C++20] [Modules] Serialize the evaluated constant values for VarDecl

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

Previously, we didn't serialize the evaluated result for VarDecl. This
caused the compilation of template metaprogramming become slower than
expect. This patch fixes the issue.

13 months ago[LegalizeType][X86] Support WidenVecRes_AssertZext and SplitVecRes_AssertZext for...
Bing1 Yu [Wed, 24 May 2023 02:15:23 +0000 (10:15 +0800)]
[LegalizeType][X86] Support WidenVecRes_AssertZext and SplitVecRes_AssertZext for ISD::AssertZext during LegalizeType procedure

Reviewed By: craig.topper

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

13 months ago[Propeller] Add HasIndirectBranch to BBEntry::Metadata.
Rahman Lavaee [Wed, 24 May 2023 01:44:10 +0000 (01:44 +0000)]
[Propeller] Add HasIndirectBranch to BBEntry::Metadata.

This information helps to avoid considering cloning for blocks with indirect branches.

Reviewed By: jhenderson

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

13 months ago[clang-format] Adjust braced list detection (reland 6dcde65)
Galen Elias [Tue, 23 May 2023 03:11:17 +0000 (20:11 -0700)]
[clang-format] Adjust braced list detection (reland 6dcde65)

This is a retry of https://reviews.llvm.org/D114583, which was backed
out for regressions.

Clang Format is detecting a nested scope followed by another open brace
as a braced initializer list due to incorrectly thinking it's matching a
braced initializer at the end of a constructor initializer list which is
followed by the body open brace.

Unfortunately, UnwrappedLineParser isn't doing a very detailed parse, so
it's not super straightforward to distinguish these cases given the
current structure of calculateBraceTypes. My current hypothesis is that
these can be disambiguated by looking at the token preceding the
l_brace, as initializer list parameters will be preceded by an
identifier, but a scope block generally will not (barring the MACRO
wildcard).

To this end, I am adding tracking of the previous token to the LBraceStack
to help scope this particular case.

TokenAnnotatorTests cherry picked from https://reviews.llvm.org/D150452.

Fixes #33891.
Fixes #52911.

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

13 months ago[clang-format] Revert 6dcde65 due to missing commit message title
Owen Pan [Wed, 24 May 2023 01:33:37 +0000 (18:33 -0700)]
[clang-format] Revert 6dcde65 due to missing commit message title

This reverts commit 6dcde658b2380d7ca1451ea5d1099af3e294ea16.

13 months ago[mlir][sparse][gpu] fix F32 bug for SpMV and SpMM
Aart Bik [Tue, 23 May 2023 20:47:10 +0000 (13:47 -0700)]
[mlir][sparse][gpu] fix F32 bug for SpMV and SpMM

The alpha/beta variables, residing on the host, should have the
32-bit or 64-bit width of the result type. It was formerly always
passed as double.

Reviewed By: Peiming

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

13 months ago[compiler-rt] Allow 64-bit sanitizer allocator to be used if using RISCV64 and Fuchsia
Leonard Chan [Tue, 23 May 2023 23:38:29 +0000 (23:38 +0000)]
[compiler-rt] Allow 64-bit sanitizer allocator to be used if using RISCV64 and Fuchsia

This way, Fuchsia can use the 64-bit allocator settings in D151157 without changing the default behavior for others.

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

13 months ago[CodeGen] Fix the type of the constant that is used to zero-initialize a
Akira Hatanaka [Tue, 23 May 2023 23:32:19 +0000 (16:32 -0700)]
[CodeGen] Fix the type of the constant that is used to zero-initialize a
flexible array member

A zero-element array type was incorrectly being used when an incomplete
array was being initialized with a non-empty initializer.

This fixes an assertion failure in AddInitializerToStaticVarDecl. See
the discussion here: https://reviews.llvm.org/D123649#4362210

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

13 months ago[RISCV] Expand rotate by non-constant for XTHeadBb during lowering.
Craig Topper [Tue, 23 May 2023 23:31:22 +0000 (16:31 -0700)]
[RISCV] Expand rotate by non-constant for XTHeadBb during lowering.

Avoids multi instruction isel patterns and enables mask optimizations
on shift amount.

Reviewed By: philipp.tomsich

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

13 months agoRevert "[lldb] Move PassthroughScriptedProcess to `lldb.scripted_process` module"
Med Ismail Bennani [Tue, 23 May 2023 23:01:39 +0000 (16:01 -0700)]
Revert "[lldb] Move PassthroughScriptedProcess to `lldb.scripted_process` module"

This reverts commit 273a2d337f675f3ee050f281b1fecc3e806b9a3c, since it
might be the cause for `TestStackCoreScriptedProcess` and
`TestInteractiveScriptedProcess` failures on GreenDragon:

https://green.lab.llvm.org/green/job/lldb-cmake/55460/`

13 months ago[flang][runtime] Complete partial output records when positioning/closing after non...
Peter Klausler [Mon, 22 May 2023 18:56:14 +0000 (11:56 -0700)]
[flang][runtime] Complete partial output records when positioning/closing after non-advancing output

Before positioning or closing a unit after a non-advancing output statement
has left a partial record in its buffer, complete the record by calling
AdvanceRecord().  Fixes https://github.com/llvm/llvm-project/issues/59761.

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

13 months ago[mlir][sparse] extend unpack operation to unpack arbitrary encodings.
Peiming Liu [Sat, 20 May 2023 00:55:44 +0000 (00:55 +0000)]
[mlir][sparse] extend unpack operation to unpack arbitrary encodings.

Reviewed By: aartbik

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

13 months agoAdd support for salvaging debug info from icmp instrcuctions.
Shubham Sandeep Rastogi [Fri, 5 May 2023 00:48:19 +0000 (17:48 -0700)]
Add support for salvaging debug info from icmp instrcuctions.

salvageDebugInfo is a function that allows us to reatin debug info for
instructions that have been optimized out. Currently, it doesn't support
salvaging the debug information from icmp instrcutions, but DWARF
expressions can emulate an icmp by using the DWARF conditional
expressions. This patch adds support for salvaging debug information
from icmp instructions.

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

13 months ago[bazel] Add clang-offload-packager and clang-linker-wrapper
Aaron Siddhartha Mondal [Tue, 23 May 2023 22:24:05 +0000 (00:24 +0200)]
[bazel] Add clang-offload-packager and clang-linker-wrapper

Reviewed By: MaskRay

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

13 months ago[lldb][NFCI] Remove unused member from ObjectFileMachO
Alex Langford [Tue, 23 May 2023 17:35:32 +0000 (10:35 -0700)]
[lldb][NFCI] Remove unused member from ObjectFileMachO

From what I can see, `m_mach_segments` is completely unused. Let's
remove it.

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

13 months ago[flang][openacc][NFC] Add API to create acc.private.recipe from FIR type
Valentin Clement [Tue, 23 May 2023 22:08:27 +0000 (15:08 -0700)]
[flang][openacc][NFC] Add API to create acc.private.recipe from FIR type

Simply make the creation of acc.private.recipe accesible through an API.
This will be useful when we will implement passes like the implicit
privatization.

Reviewed By: razvanlupusoru

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

13 months ago[flang] Do not omit fir.ref in getTypeAsString
Valentin Clement [Tue, 23 May 2023 22:07:19 +0000 (15:07 -0700)]
[flang] Do not omit fir.ref in getTypeAsString

Do not omit fir.ref when creating the string representation to we can
have different representation for `!fir.ref<i32>` and `i32`.

Reviewed By: razvanlupusoru

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

13 months agoReland: [clang][ExprConstant] fix __builtin_object_size for flexible array members
Nick Desaulniers [Tue, 23 May 2023 21:41:43 +0000 (14:41 -0700)]
Reland: [clang][ExprConstant] fix __builtin_object_size for flexible array members

As reported by @kees, GCC treats __builtin_object_size of structures
containing flexible array members (aka arrays with incomplete type) not
just as the sizeof the underlying type, but additionally the size of the
members in a designated initializer list.

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

Reviewed By: erichkeane, efriedma

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

13 months ago[flang] Add IndexType support in getTypeAsString
Valentin Clement [Tue, 23 May 2023 21:14:59 +0000 (14:14 -0700)]
[flang] Add IndexType support in getTypeAsString

Reviewed By: razvanlupusoru

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

13 months ago[mlir][Vector] Extend xfer drop unit dim patterns
Diego Caballero [Tue, 23 May 2023 20:51:09 +0000 (20:51 +0000)]
[mlir][Vector] Extend xfer drop unit dim patterns

This patch extends the transfer drop unit dim patterns to support cases where the vector shape should also be reduced
(e.g., transfer_read(memref<1x4x1xf32>, vector<1x4x1xf32>) -> transfer_read(memref<4xf32>, vector<4xf32>).

Reviewed By: hanchung, pzread

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

13 months ago[llvm-debuginfo-analyzer] Support both Reference and Type attrs in single DIE
Scott Linder [Tue, 23 May 2023 20:31:18 +0000 (20:31 +0000)]
[llvm-debuginfo-analyzer] Support both Reference and Type attrs in single DIE

Relax the assumption that at most one Reference-or-Type-like attribute is
present on a DWARF DIE.

Add support for at most one Type attribute (i.e. DW_AT_import xor
DW_AT_type) and separately at most one Reference attribute (i.e.
DW_AT_specification xor DW_AT_abstract_origin xor ...).

Update comment describing old assumption and tag it as a "FIXME" to
reflect the fact that this is perhaps still not general enough.

Add a test based on the case which led me to encounter the bug in the
wild.

Reviewed By: CarlosAlbertoEnciso

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

13 months ago[lld-macho] Add support for .so file discovery
Keith Smiley [Mon, 22 May 2023 20:28:42 +0000 (13:28 -0700)]
[lld-macho] Add support for .so file discovery

While not the recommended extension on macOS .so is supported by ld64.
This mirrors that behavior.

Related report: https://github.com/bazelbuild/bazel/issues/18464

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

13 months ago[lld][ELF] Do not emit warning for NOLOAD output sections
Leonard Chan [Tue, 23 May 2023 20:40:22 +0000 (20:40 +0000)]
[lld][ELF] Do not emit warning for NOLOAD output sections

Much of NOLOAD's intended use is to explicitly change the type of an
output section, so we shouldn't flag these as warnings.

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

13 months ago[libc++] Apply _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION only in classes that we...
Nikolas Klauser [Tue, 23 May 2023 15:45:52 +0000 (08:45 -0700)]
[libc++] Apply _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION only in classes that we have instantiated externally

To make sure all member functions that require it are marked `_LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION` I compared the output of `objdump --syms lib/libc++.1.0.dylib` before and after, ignoring addresses.

Reviewed By: #libc, ldionne

Spies: Mordante, libcxx-commits, ldionne, arichardson, mstorsjo

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

13 months ago[TableGen] Filter duplicate predicates in PatternToMatch::getPredicateRecords.
Craig Topper [Tue, 23 May 2023 20:32:18 +0000 (13:32 -0700)]
[TableGen] Filter duplicate predicates in PatternToMatch::getPredicateRecords.

Recent changes to RISC-V cause the same predicate to appear in the
predicate list multiple times in some cases. This patch filters the
duplicates to reduce the number of predicate string variations.

13 months ago[X86] Use the CFA when appropriate for better variable locations around calls.
Kyle Huey [Tue, 23 May 2023 17:44:25 +0000 (17:44 +0000)]
[X86] Use the CFA when appropriate for better variable locations around calls.

Without frame pointers, the locations of variables on the stack are emitted
relative to the stack pointer (via the stack pointer being the value of
DW_AT_frame_base on the subprogram). If a call modifies the stack pointer
this results in the locations being wrong and the debugger displaying the
wrong values for variables.

By using DW_OP_call_frame_cfa in these situations the emitted location for
the variable will automatically handle changes in the stack pointer
(provided LLVM is emitting the correct CFI directives elsewhere, of course).
The CFA needs to be adjusted for the size of the stack frame (including the
return address) to allow the variable locations themselves to remain
unchanged by this patch.

Certain LLDB features cannot cope with DW_OP_call_frame_cfa, so this change
is heuristically limited to the cases where it's necessary for correctness
to minimize the fallout there.

Reviewed By: #debug-info, scott.linder, jryans, jmorse

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

13 months ago[Sema] `setInvalidDecl` for error deduction declaration
Congcong Cai [Tue, 23 May 2023 20:14:10 +0000 (22:14 +0200)]
[Sema] `setInvalidDecl` for error deduction declaration

Fixed: https://github.com/llvm/llvm-project/issues/62408
`setInvalidDecl` for invalid `CXXDeductionGuideDecl` to
avoid crashes during semantic analysis.

Reviewed By: aaron.ballman

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

13 months ago[MLIR] Update Bazel build to remove references to PybindUtils.cpp
Eugene Burmako [Tue, 23 May 2023 19:34:12 +0000 (12:34 -0700)]
[MLIR] Update Bazel build to remove references to PybindUtils.cpp

This file has been removed in https://reviews.llvm.org/D151167.

Reviewed By: aartbik

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

13 months ago[VPlan] Print IR flags for VPRecipeWithIRFlags.
Florian Hahn [Tue, 23 May 2023 19:36:15 +0000 (20:36 +0100)]
[VPlan] Print IR flags for VPRecipeWithIRFlags.

Now that IR flags are modeled as part of VPRecipeWithIRFlags, include
the flags when printing recipes.

Depends on D150027.

Reviewed By: Ayal

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

13 months ago[clang-tidy] Ignore implicit code in bugprone-branch-clone
Piotr Zegar [Tue, 23 May 2023 18:45:22 +0000 (18:45 +0000)]
[clang-tidy] Ignore implicit code in bugprone-branch-clone

Implicit code like, template instances, compiler generated
code are not excluded in this check by using
TK_IgnoreUnlessSpelledInSource.

Fixes #62693

Reviewed By: donat.nagy

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

13 months ago[clang-tidy] Improve bugprone-branch-clone with support for fallthrough attribute
Piotr Zegar [Tue, 23 May 2023 18:44:55 +0000 (18:44 +0000)]
[clang-tidy] Improve bugprone-branch-clone with support for fallthrough attribute

Ignore duplicated switch cases with [[fallthrough]] attribute to reduce false positives.

Fixes: #47588

Reviewed By: donat.nagy

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

13 months ago[RISCV] Add scalable vector cast cost model tests. NFC
Craig Topper [Tue, 23 May 2023 19:14:07 +0000 (12:14 -0700)]
[RISCV] Add scalable vector cast cost model tests. NFC

Reviewed By: fakepaper56

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

13 months ago[CodeGen] Fix crash in CodeGenPrepare::optimizeGatherScatterInst.
Joshua Cranmer [Tue, 23 May 2023 19:00:19 +0000 (15:00 -0400)]
[CodeGen] Fix crash in CodeGenPrepare::optimizeGatherScatterInst.

Reviewed By: craig.topper

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

13 months ago[ValueTracking] Use `select` condition to help determine if `select` is non-zero
Noah Goldstein [Tue, 23 May 2023 16:18:01 +0000 (11:18 -0500)]
[ValueTracking] Use `select` condition to help determine if `select` is non-zero

In `select c, x, y` the condition `c` dominates the resulting `x` or
`y` chosen by the `select`. This adds logic to `isKnownNonZero` to try
and use the `icmp` for the `c` condition to see if it implies the
select `x` or `y` are known non-zero.

For example in:
    ```
    %c = icmp ugt i8 %x, %C
    %r = select i1 %c, i8 %x, i8 %y
    ```
    The true arm of select `%x` is non-zero (when "returned" by the
    `select`) because `%c` being true implies `%x` is non-zero.

Alive2 Links (with `x {pred} C`):
    - EQ  iff `C != 0`:
        - https://alive2.llvm.org/ce/z/umLabn
    - NE  iff `C == 0`:
        - https://alive2.llvm.org/ce/z/DQvy8Y
    - UGT [always]:
        - https://alive2.llvm.org/ce/z/HBkjgQ
    - UGE iff `C != 0`:
        - https://alive2.llvm.org/ce/z/LDNifB
    - SGT iff `C s>= 0`:
        - https://alive2.llvm.org/ce/z/QzWDj3
    - SGE iff `C s> 0`:
        - https://alive2.llvm.org/ce/z/rR4g3D
    - SLT iff `C s<= 0`:
        - https://alive2.llvm.org/ce/z/uysayx
    - SLE iff `C s< 0`:
        - https://alive2.llvm.org/ce/z/2jYc7e

Reviewed By: nikic

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

13 months ago[ValueTracking] Add tests for using condition in select for non-zero analysis; NFC
Noah Goldstein [Sun, 30 Apr 2023 15:44:35 +0000 (10:44 -0500)]
[ValueTracking] Add tests for using condition in select for non-zero analysis; NFC

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

13 months ago[ValueTracking] Use `KnownBits` functions for `computeKnownBits` of saturating add...
Noah Goldstein [Tue, 23 May 2023 16:11:23 +0000 (11:11 -0500)]
[ValueTracking] Use `KnownBits` functions for `computeKnownBits` of saturating add/sub functions

The knownbits implementation covers all the cases previously handled
by `uadd.sat`/`usub.sat` as well some additional ones. We previously
were not handling the `ssub.sat`/`sadd.sat` cases at all.

Reviewed By: RKSimon

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

13 months ago[KnownBits] Add implementations for saturating add/sub functions
Noah Goldstein [Tue, 23 May 2023 16:13:13 +0000 (11:13 -0500)]
[KnownBits] Add implementations for saturating add/sub functions

These where previously missing. Even in the case where overflow is
indeterminate we can still deduce some of the low/high bits.

Reviewed By: RKSimon

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

13 months ago[ValueTracking] Add tests for knownbits of saturating add/sub functions; NFC
Noah Goldstein [Tue, 23 May 2023 16:11:14 +0000 (11:11 -0500)]
[ValueTracking] Add tests for knownbits of saturating add/sub functions; NFC

Reviewed By: RKSimon

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

13 months ago[KnownBits] Improve implementation of `KnownBits::abs`
Noah Goldstein [Tue, 23 May 2023 16:11:09 +0000 (11:11 -0500)]
[KnownBits] Improve implementation of `KnownBits::abs`

`abs` preserves the lowest set bit, so if we know the lowest set bit,
set it in the output.

As well, implement the case where the operand is known negative.

Reviewed By: foad, RKSimon

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

13 months ago[NFC][CLANG] Fix issue with dereference null return value found by Coverity static...
Manna, Soumi [Tue, 23 May 2023 18:41:28 +0000 (11:41 -0700)]
[NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

Reported by Coverity static analyzer tool:

Inside "ItaniumCXXABI.cpp" file, in <unnamed>::ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(clang::CodeGen::CodeGenFunction &, clang::Expr const *, clang::CodeGen::Address, llvm::Value *&, llvm::Value *, clang::MemberPointerType const *): Return value of function which returns null is dereferenced without checking.

   //returned_null: getAs returns nullptr (checked 130 out of 156 times).
   //var_assigned: Assigning: FPT = nullptr return value from getAs.
   const FunctionProtoType *FPT =
     MPT->getPointeeType()->getAs<FunctionProtoType>();
  auto *RD =
     cast<CXXRecordDecl>(MPT->getClass()->castAs<RecordType>()->getDecl());

  // Dereference null return value (NULL_RETURNS)
  //dereference: Dereferencing a pointer that might be nullptr FPT when calling arrangeCXXMethodType.
   llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(
       CGM.getTypes().arrangeCXXMethodType(RD, FPT, /*FD=*/nullptr));

This patch uses castAs instead of getAs which will assert if the type doesn't match.

Reviewed By: erichkeane

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

13 months ago[gn build] Port f237513cda8e
LLVM GN Syncbot [Tue, 23 May 2023 18:40:17 +0000 (18:40 +0000)]
[gn build] Port f237513cda8e

13 months ago[LLDB] Add some declarations related to REPL support for mojo
walter erquinigo [Wed, 10 May 2023 20:41:07 +0000 (15:41 -0500)]
[LLDB] Add some declarations related to REPL support for mojo

This simple diff declares some enum values needed to create a REPL for the mojo language.

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

13 months ago[RISCV][GlobalISel] Add lowerReturn for calling conv
Nitin John Raj [Tue, 23 May 2023 17:47:53 +0000 (10:47 -0700)]
[RISCV][GlobalISel] Add lowerReturn for calling conv

Add minimal support to lower return, and introduce an OutgoingValueHandler and an OutgoingValueAssigner for returns.

Supports return values with integer, pointer and aggregate types.

(Update of D69808 - avoiding commandeering that revision)

Co-authored By: lewis-revill

Reviewed By: arsenm

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

13 months agohwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]
Thurston Dang [Fri, 19 May 2023 23:19:44 +0000 (23:19 +0000)]
hwasan: lay groundwork for importing subset of sanitizer_common interceptors [NFC]

This patch does the bare minimum to import sanitizer_common_interceptors, but
without actually enabling any interceptors or meaningfully defining the
COMMON_INTERCEPT macros.

This will allow selectively enabling sanitizer_common interceptors (if the
appropriate macros are defined), as suggested by Vitaly in D149701.

Reviewed By: vitalybuka

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

13 months ago[libc] Change UInt integer conversion operators to use standard types.
Tue Ly [Tue, 23 May 2023 17:34:12 +0000 (13:34 -0400)]
[libc] Change UInt integer conversion operators to use standard types.

This fixes an issue with missing `unsigned long` conversion on macOS.

Reviewed By: michaelrj

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

13 months agoRevert "[HWASan] unflake test"
Vitaly Buka [Tue, 23 May 2023 17:42:39 +0000 (10:42 -0700)]
Revert "[HWASan] unflake test"

https://reviews.llvm.org/D150742 is the fix.

This reverts commit edd0981e71af87a686365d40e6410a8a377c153d.

13 months agoReland "[clang] Add tests for CWG issues 977, 1482, 2516"
Vlad Serebrennikov [Tue, 23 May 2023 18:03:10 +0000 (21:03 +0300)]
Reland "[clang] Add tests for CWG issues 977, 1482, 2516"

Now with support for MSVC-specific triples.

CWG977 focus on point of /completeness/ of enums. Wording provided in CWG1482.
CWG1482 and CWG2516 focus on locus (point) of /declaration/. Wording provided in CWG2516.

Reviewed By: clang-language-wg, shafik

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

13 months ago[mlir][python] Bump min pybind11 version to 2.9.0
Rahul Kayaith [Tue, 23 May 2023 17:40:00 +0000 (13:40 -0400)]
[mlir][python] Bump min pybind11 version to 2.9.0

2.9.0 was released on December 28, 2021, and some following changes
require at least this version.

Reviewed By: stellaraccident

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

13 months agoAdd a reminder to update docs when updating default; NFC
Aaron Ballman [Tue, 23 May 2023 17:38:35 +0000 (13:38 -0400)]
Add a reminder to update docs when updating default; NFC

13 months ago[llvm][ADT] Fix invalid `reference` type of depth-first, breadth-first and post order...
Markus Böck [Tue, 23 May 2023 17:11:43 +0000 (19:11 +0200)]
[llvm][ADT] Fix invalid `reference` type of depth-first, breadth-first and post order iterators

C++s iterator concept requires operator* to return the same type as is specified by the iterators reference type. This functionality is especially important for older generic code that did not yet make use of auto.
An example from within LLVM is iterator_adaptor_base which uses the reference type of the iterator it is wrapping as its return type for operator* (this class is used as base for a lot of other functionality like filter iterators and so on).
Using any of the graph traversal iterators listed above with it would previously fail to compile due to reference being non-const while operator* returned a const reference.

This patch fixes that by correctly specifying reference and using it as the return type of operator* explicitly to prevent further issues in the future.

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

13 months ago[libcxx][tests] Introduce 32-bit feature and use it for stringstream gcount test
Azat Khuzhin [Tue, 23 May 2023 17:28:30 +0000 (19:28 +0200)]
[libcxx][tests] Introduce 32-bit feature and use it for stringstream gcount test

This will avoid hardcoding all unsupported targets, since even after one
more follow up fix [1], there is one more failure.

  [1]: https://reviews.llvm.org/D150886

Plus, if you want to run it locally on some target that CI does not
covers, it could also false-positively fail, which is not good.

Reviewed By: #libc, ldionne

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

13 months ago[lldb][NFCI] Merge implementations of ObjectFileMachO::GetMinimumOSVersion and Object...
Alex Langford [Sat, 20 May 2023 00:51:08 +0000 (17:51 -0700)]
[lldb][NFCI] Merge implementations of ObjectFileMachO::GetMinimumOSVersion and ObjectFileMachO::GetSDKVersion

These functions do the exact same thing (even if they look slightly
different). I yanked the common implementation, cleaned it up, and
shoved it into its own function.

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

13 months ago[mlir][Vector] Add 0-d vector support to 'vector.shape_cast`
Diego Caballero [Mon, 22 May 2023 22:59:46 +0000 (22:59 +0000)]
[mlir][Vector] Add 0-d vector support to 'vector.shape_cast`

This patch adds support to shape cast a vector<1x1x1...1xElemenType> to
a vector<ElementType> and the other way around.

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

13 months ago[libc][obvious] Correctly hoist mask out of the loop
Joseph Huber [Tue, 23 May 2023 17:19:56 +0000 (12:19 -0500)]
[libc][obvious] Correctly hoist mask out of the loop

Summry:
This was accidentally dropped from a previous patch following a rebase.
Fix it to where it's consistent.

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

13 months agoCorrect stale documentation for default MSVC version numbers
Aaron Ballman [Tue, 23 May 2023 17:11:19 +0000 (13:11 -0400)]
Correct stale documentation for default MSVC version numbers

We documented -fmsc-version as defaulting to 1300 and
-fms-compatibility-version as defaulting to 1800, neither of which
were accurate. We currently default to 1920.

See MSVCToolChain::computeMSVCVersion() for details.

13 months ago[hwasan] Move RunFreeHooks call
Jin Xin Ng [Mon, 22 May 2023 19:20:55 +0000 (19:20 +0000)]
[hwasan] Move RunFreeHooks call

Ensures a subsequent call (via an external caller) to
__sanitizer_get_allocated_size via hooks will return a valid size.

This allows a faster version of __sanitizer_get_allocated_size
to be implemented, which can skip checks.

Test to ensure RunFreeHooks' call order will come with
__sanitizer_get_allocated_size_fast

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

13 months ago[libc++][doc] Updates the tasks to do for a release.
Mark de Wever [Sun, 7 May 2023 17:50:41 +0000 (19:50 +0200)]
[libc++][doc] Updates the tasks to do for a release.

This is a followup of the review comments in D144499.

Reviewed By: ldionne, philnik, #libc

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

13 months ago[NFC][libc++][format] Uses stringstream::view.
Mark de Wever [Wed, 17 May 2023 15:38:13 +0000 (17:38 +0200)]
[NFC][libc++][format] Uses stringstream::view.

This member has been added in D148641 so it can be used in the formatter
to avoid creating a "temporary" string.

Reviewed By: #libc, ldionne

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

13 months ago[libc++][modules] Adds std module cppm files.
Mark de Wever [Tue, 28 Feb 2023 19:29:26 +0000 (20:29 +0100)]
[libc++][modules] Adds std module cppm files.

This adds the cppm files of D144994. These files by themselves will do
nothing. The goal is to reduce the size of D144994 and making it easier
to review the real changes of the patch.

Implements parts of
- P2465R3 Standard Library Modules std and std.compat

Reviewed By: ldionne, ChuanqiXu, aaronmondal, #libc

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

13 months ago[IR] Make stack protector symbol dso_local according to -f[no-]direct-access-external...
Fangrui Song [Tue, 23 May 2023 16:49:57 +0000 (09:49 -0700)]
[IR] Make stack protector symbol dso_local according to -f[no-]direct-access-external-data

There are two motivations.

`-fno-pic -fstack-protector -mstack-protector-guard=global` created
`__stack_chk_guard` is referenced directly on all ELF OSes except FreeBSD.
This patch allows referencing the symbol indirectly with
-fno-direct-access-external-data.

Some Linux kernel folks want
`-fno-pic -fstack-protector -mstack-protector-guard-reg=gs -mstack-protector-guard-symbol=__stack_chk_guard`
created `__stack_chk_guard` to be referenced directly, avoiding
R_X86_64_REX_GOTPCRELX (even if the relocation may be optimized out by the linker).
https://github.com/llvm/llvm-project/issues/60116
Why they need this isn't so clear to me.

---

Add module flag "direct-access-external-data" and set the dso_local property of
the stack protector symbol. The module flag can benefit other LLVMCodeGen
synthesized symbols that are not represented in LLVM IR.

Nowadays, with `-fno-pic` being uncommon, ideally we should set
"direct-access-external-data" when it is true. However, doing so would require
~90 clang/test tests to be updated, which are too much.

As a compromise, we set "direct-access-external-data" only when it's different
from the implied default value.

Reviewed By: nickdesaulniers

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

13 months ago[libc++] Updates C++2b to C++23.
Mark de Wever [Wed, 17 May 2023 15:54:53 +0000 (17:54 +0200)]
[libc++] Updates C++2b to C++23.

During the ISO C++ Committee meeting plenary session the C++23 Standard
has been voted as technical complete.

This updates the reference to c++2b to c++23 and updates the __cplusplus
macro.

Note since we use clang-tidy 16 a small work-around is needed. Clang
knows -std=c++23 but clang-tidy not so for now force the lit compiler
flag to use -std=c++2b instead of -std=c++23.

Reviewed By: #libc, philnik, jloser, ldionne

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

13 months ago[lsan] Invoke hooks on realloc
Jin Xin Ng [Mon, 22 May 2023 21:13:46 +0000 (21:13 +0000)]
[lsan] Invoke hooks on realloc

Previously lsan would not invoke hooks on reallocations.
An accompanying regression test is included in sanitizer_common.

This change also moves hook calls to a location where subsequent
calls (via an external caller) to __sanitizer_get_allocated_size
via hooks will return a valid size.

This allows a faster version of __sanitizer_get_allocated_size
to be implemented, which can skip checks.

Test to ensure RunFreeHooks' call order will come with
__sanitizer_get_allocated_size_fast

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

13 months ago[flang] Fixed managing copy-in/copy-out temps.
Slava Zakharin [Tue, 23 May 2023 16:10:26 +0000 (09:10 -0700)]
[flang] Fixed managing copy-in/copy-out temps.

There are several observations regarding the copy-in/copy-out:
  * Actual argument associated with INTENT(OUT) dummy argument that
    requires finalization (7.5.6.3 p. 7) may be read by the finalization
    function, so a copy-in is required.
  * A temporary created for the copy-in/copy-out must be destroyed
    without finalization after the call (or after the corresponding copy-out),
    otherwise, memory leaks may occur.
  * The copy-out assignment must not perform finalization for the LHS.
  * The copy-out assignment from the temporary to the actual argument
    may or may not need to initialize the LHS.

This change-set introduces new runtime methods: CopyOutAssign and
DestroyWithoutFinalization. They are called by the compiler generated
code to match the behavior described above.

Reviewed By: jeanPerier

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

13 months ago[MLIR][python bindings] use pybind C++ APIs for throwing python errors.
max [Mon, 22 May 2023 22:30:12 +0000 (17:30 -0500)]
[MLIR][python bindings] use pybind C++ APIs for throwing python errors.

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

13 months ago[AArch64][FMV] Prevent target attribute using for multiversioning.
Pavel Iliin [Thu, 18 May 2023 11:02:04 +0000 (12:02 +0100)]
[AArch64][FMV] Prevent target attribute using for multiversioning.

On AArch64 for function multiversioning target_version/target_clones
attributes should be used. The patch fixes the defect allowing target
attribute to cause multiversioning.

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

13 months ago[LegalizeTypes][ARM][AArch6][RISCV][VE][WebAssembly] Add special case for smin(X...
Craig Topper [Tue, 23 May 2023 16:19:37 +0000 (09:19 -0700)]
[LegalizeTypes][ARM][AArch6][RISCV][VE][WebAssembly] Add special case for smin(X, -1) and smax(X, 0) to ExpandIntRes_MINMAX.

We can compute a simpler expression for Lo for these cases. This
is an alternative for the test cases in D151180 that works for
more targets.

This is similar to some of the special cases we have for expanding
setcc operands.

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

13 months ago[OpenMP][NFC] clang-format the OpenMP device runtime
Joseph Huber [Tue, 23 May 2023 16:09:16 +0000 (11:09 -0500)]
[OpenMP][NFC] clang-format the OpenMP device runtime

These files aren't fully formatted. I'm guessing this was a holdover
from when `clang-format` was totally broken for OpenMP offloading.
Format the files to be more consistent.

Reviewed By: tianshilei1992

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

13 months ago[libc] More efficiently send bytes via `send_n` and `recv_n`
Joseph Huber [Fri, 19 May 2023 16:17:42 +0000 (11:17 -0500)]
[libc] More efficiently send bytes via `send_n` and `recv_n`

Currently we have the `send_n` and `recv_n` routines to stream data,
such as a string to print, to the other side. The first operation is to
send the size so the other side knows the number of bytes to recieve.
However, this wasted 56 bytes that could've been sent. This meant that
small values, like the arguments to a function to call on the host for
example, needed to perform an extra send. This patch sends the first 56
bytes in the first packet and continues if necessary.

Depends on D150992

Reviewed By: JonChesterfield

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

13 months ago[libc] Fix the `send_n` and `recv_n` utilities under divergent lanes
Joseph Huber [Fri, 19 May 2023 19:58:32 +0000 (14:58 -0500)]
[libc] Fix the `send_n` and `recv_n` utilities under divergent lanes

We provide the `send_n` and `recv_n` utilities as a generic way to
stream data between both sides of the process. This was previously
tested and performed as expected when using a string of constant size.
However, when the size was allowed to diverge between the threads in the
warp or wavefront this could deadlock. This did not occur on NVPTX
because of the use of the explicit warp sync. However, on AMD one of the
work items in the wavefront could continue executing and hit the next
`recv` call before the other threads, then we would deadlock as we
violated the RPC invariants.

This patch replaces the for loop with a thread ballot. This will cause
every thread in the warp or wavefront to continue executing the loop
until all of them can exit. This acts as a more explicit wavefront sync.

Reviewed By: JonChesterfield

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

13 months ago[libc++] Remove tests from ranges.pass.cpp which violate semantic requirements
Nikolas Klauser [Tue, 23 May 2023 15:59:13 +0000 (08:59 -0700)]
[libc++] Remove tests from ranges.pass.cpp which violate semantic requirements

This also removes some tests which we have grouped together into robust_from_*.pass.cpp tests.

Specifically, checking that
- `ranges::dangling` is returned is done in `libcxx/test/std/algorithms/ranges_robust_against_dangling.pass.cpp`
- `std::invoke` is used is done in `libcxx/test/std/algorithms/ranges_robust_against_omitting_invoke.pass.cpp`.
- implicit conversion to bool works is done in `libcxx/test/std/algorithms/ranges_robust_against_nonbool_predicates.pass.cpp`

Checking the comparison order is invalid because the `operator==` isn't symmetric.
Checking what the exact type of `operator==` is, is invalid because comparing the same object has to yield the same results if the objects are not modified.

Reviewed By: ldionne, #libc

Spies: EricWF, libcxx-commits

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

13 months ago[libc++][NFC] Move basic_ios extern instantiations into <ios>
Nikolas Klauser [Tue, 23 May 2023 15:58:14 +0000 (08:58 -0700)]
[libc++][NFC] Move basic_ios extern instantiations into <ios>

`basic_ios` is defined in `<ios>`, so it seems weird that we declare the explicit instantiation for it i `<streambuf>`, which is technically unrelated.

Reviewed By: #libc, EricWF, ldionne

Spies: ldionne, EricWF, libcxx-commits

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

13 months ago[HIP] Allow std::malloc in device function
Yaxun (Sam) Liu [Thu, 11 May 2023 16:57:21 +0000 (12:57 -0400)]
[HIP] Allow std::malloc in device function

D106463 caused a regression that prevents std::malloc to be
called in the device function, which is allowed with nvcc.

Basically the standard C++ header introducing malloc in
std namespace by using ::malloc. The device ::malloc
function needs to be declared before using ::malloc
to be introduced into std namespace.

Revert D106463 and add a test.

Reviewed by: Artem Belevich

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

13 months ago[libc++][NFC] Fix whitespace problems in the files added to ignore_format.txt in...
Nikolas Klauser [Tue, 23 May 2023 15:40:47 +0000 (08:40 -0700)]
[libc++][NFC] Fix whitespace problems in the files added to ignore_format.txt in D151115

Reviewed By: ldionne, #libc, Mordante

Spies: arichardson, Mordante, libcxx-commits

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

13 months ago[lldb][NFCI] Use llvm's libDebugInfo for DebugRanges
Felipe de Azevedo Piovezan [Thu, 11 May 2023 13:01:12 +0000 (09:01 -0400)]
[lldb][NFCI] Use llvm's libDebugInfo for DebugRanges

In an effort to unify the different dwarf parsers available in the codebase,
this commit removes LLDB's custom parsing for the `.debug_ranges` DWARF section,
instead calling into LLVM's parser.

Subsequent work should look into unifying `llvm::DWARDebugRangeList` (whose
entries are pairs of (start, end) addresses) with `lldb::DWARFRangeList` (whose
entries are pairs of (start, length)). The lists themselves are also different
data structures, but functionally equivalent.

Depends on D150363

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

13 months ago[libc][math] Implement double precision log1p correctly rounded to all rounding modes.
Tue Ly [Sun, 21 May 2023 05:27:38 +0000 (01:27 -0400)]
[libc][math] Implement double precision log1p correctly rounded to all rounding modes.

Implement double precision log1p function correctly rounded to all
rounding modes.

**Performance**

  - For `0.5 <= x <= 2`, the fast pass hitting rate is about 99.93%.
  - Benchmarks with `./perf.sh` tool from the CORE-MATH project, unit is (CPU clocks / call).
  - Reciprocal throughput from CORE-MATH's perf tool on Ryzen 5900X:
```
$ ./perf.sh log1p
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH reciprocal throughput -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 39.792 + 1.011 clc/call; Median-Min = 0.940 clc/call; Max = 41.373 clc/call;

-- CORE-MATH reciprocal throughput -- without FMA (-march=x86-64-v2)
[####################] 100 %
Ntrial = 20 ; Min = 87.285 + 1.135 clc/call; Median-Min = 1.299 clc/call; Max = 89.715 clc/call;

-- System LIBC reciprocal throughput --
[####################] 100 %
Ntrial = 20 ; Min = 20.666 + 0.123 clc/call; Median-Min = 0.125 clc/call; Max = 20.828 clc/call;

-- LIBC reciprocal throughput -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 20.928 + 0.771 clc/call; Median-Min = 0.725 clc/call; Max = 22.767 clc/call;

-- LIBC reciprocal throughput -- without FMA
[####################] 100 %
Ntrial = 20 ; Min = 31.461 + 0.528 clc/call; Median-Min = 0.602 clc/call; Max = 36.809 clc/call;

```
  - Latency from CORE-MATH's perf tool on Ryzen 5900X:
```
$ ./perf.sh log1p --latency
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH latency -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 77.875 + 0.062 clc/call; Median-Min = 0.051 clc/call; Max = 78.003 clc/call;

-- CORE-MATH latency -- without FMA (-march=x86-64-v2)
[####################] 100 %
Ntrial = 20 ; Min = 101.958 + 1.202 clc/call; Median-Min = 1.325 clc/call; Max = 104.452 clc/call;

-- System LIBC latency --
[####################] 100 %
Ntrial = 20 ; Min = 60.581 + 1.443 clc/call; Median-Min = 1.611 clc/call; Max = 62.285 clc/call;

-- LIBC latency -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 48.817 + 1.108 clc/call; Median-Min = 1.300 clc/call; Max = 50.282 clc/call;

-- LIBC latency -- without FMA
[####################] 100 %
Ntrial = 20 ; Min = 61.121 + 0.599 clc/call; Median-Min = 0.761 clc/call; Max = 62.020 clc/call;
```
  - Accurate pass latency:
```
$ ./perf.sh log1p --latency --simple_stat
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH latency -- with FMA
760.444

-- CORE-MATH latency -- without FMA (-march=x86-64-v2)
827.880

-- LIBC latency -- with FMA
711.837

-- LIBC latency -- without FMA
764.317
```

Reviewed By: zimmermann6

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

13 months ago[InstCombine] Add droppable users back to worklist (NFCI)
Nikita Popov [Tue, 23 May 2023 14:59:02 +0000 (16:59 +0200)]
[InstCombine] Add droppable users back to worklist (NFCI)

When sinking and users are dropped, add the using instructions
to the worklist, as they can likely be removed as well.

This should be NFC apart from worklist order effects.

13 months ago[flang][NFC] Move Array constructor inlined temp management into a utility
Jean Perier [Tue, 23 May 2023 15:00:15 +0000 (17:00 +0200)]
[flang][NFC] Move Array constructor inlined temp management into a utility

This patch moves the counter and storage management part of the array
constructor inlined temporary strategy into its own utility so that it
can be reused for the simple cases of temporary creations inside WHERE
and FORALL.

It actually fixes a bug where the counter first value  used for addressing
was "2" leading to read/write after the allocated storage... It seems
I ran the tests end-to-end without the HLFIR flag when previously testing
this. So this may clear some segfaults.

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

13 months ago[flang] use greedy mlir driver for stack arrays pass
Tom Eccles [Wed, 17 May 2023 16:07:41 +0000 (16:07 +0000)]
[flang] use greedy mlir driver for stack arrays pass

In upstream mlir, the dialect conversion infrastructure is used for
lowering from one dialect to another: the passes are of the form
XToYPass. Whereas, transformations within the same dialect tend to use
applyPatternsAndFoldGreedily.

In this case, the full complexity of applyPatternsAndFoldGreedily isn't
needed so we can get away with the simpler applyOpPatternsAndFold.

This change was suggested by @jeanPerier

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

13 months ago[libc][math] Implement double precision log2 function correctly rounded to all roundi...
Tue Ly [Thu, 11 May 2023 15:10:02 +0000 (11:10 -0400)]
[libc][math] Implement double precision log2 function correctly rounded to all rounding modes.

Implement double precision log2 function correctly rounded to all
rounding modes.

See https://reviews.llvm.org/D150014 for a more detail description of the algorithm.

**Performance**

  - For `0.5 <= x <= 2`, the fast pass hitting rate is about 99.91%.

  - Reciprocal throughput from CORE-MATH's perf tool on Ryzen 5900X:
```
$ ./perf.sh log2
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH reciprocal throughput -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 15.458 + 0.204 clc/call; Median-Min = 0.224 clc/call; Max = 15.867 clc/call;

-- CORE-MATH reciprocal throughput -- without FMA (-march=x86-64-v2)
[####################] 100 %
Ntrial = 20 ; Min = 23.711 + 0.524 clc/call; Median-Min = 0.443 clc/call; Max = 25.307 clc/call;

-- System LIBC reciprocal throughput --
[####################] 100 %
Ntrial = 20 ; Min = 14.807 + 0.199 clc/call; Median-Min = 0.211 clc/call; Max = 15.137 clc/call;

-- LIBC reciprocal throughput -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 17.666 + 0.274 clc/call; Median-Min = 0.298 clc/call; Max = 18.531 clc/call;

-- LIBC reciprocal throughput -- without FMA
[####################] 100 %
Ntrial = 20 ; Min = 26.534 + 0.418 clc/call; Median-Min = 0.462 clc/call; Max = 27.327 clc/call;

```
  - Latency from CORE-MATH's perf tool on Ryzen 5900X:
```
$ ./perf.sh log2 --latency
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH latency -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 46.048 + 1.643 clc/call; Median-Min = 1.694 clc/call; Max = 48.018 clc/call;

-- CORE-MATH latency -- without FMA (-march=x86-64-v2)
[####################] 100 %
Ntrial = 20 ; Min = 62.333 + 0.138 clc/call; Median-Min = 0.119 clc/call; Max = 62.583 clc/call;

-- System LIBC latency --
[####################] 100 %
Ntrial = 20 ; Min = 45.206 + 1.503 clc/call; Median-Min = 1.467 clc/call; Max = 47.229 clc/call;

-- LIBC latency -- with FMA
[####################] 100 %
Ntrial = 20 ; Min = 43.042 + 0.454 clc/call; Median-Min = 0.484 clc/call; Max = 43.912 clc/call;

-- LIBC latency -- without FMA
[####################] 100 %
Ntrial = 20 ; Min = 57.016 + 1.636 clc/call; Median-Min = 1.655 clc/call; Max = 58.816 clc/call;
```
  - Accurate pass latency:
```
$ ./perf.sh log2 --latency --simple_stat
GNU libc version: 2.35
GNU libc release: stable

-- CORE-MATH latency -- with FMA
177.632

-- CORE-MATH latency -- without FMA (-march=x86-64-v2)
231.332

-- LIBC latency -- with FMA
459.751

-- LIBC latency -- without FMA
463.850
```

Reviewed By: zimmermann6

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