platform/upstream/llvm.git
23 months ago[BoundsChecking] Fix merging of sizes
Arthur Eubanks [Tue, 2 Aug 2022 17:43:30 +0000 (10:43 -0700)]
[BoundsChecking] Fix merging of sizes

BoundsChecking uses ObjectSizeOffsetEvaluator to keep track of the
underlying size/offset of pointers in allocations.  However,
ObjectSizeOffsetVisitor (something ObjectSizeOffsetEvaluator
uses to check for constant sizes/offsets)
doesn't quite treat sizes and offsets the same way as
BoundsChecking.  BoundsChecking wants to know the size of the
underlying allocation and the current pointer's offset within
it, but ObjectSizeOffsetVisitor only cares about the size
from the pointer to the end of the underlying allocation.

This only comes up when merging two size/offset pairs. Add a new mode to
ObjectSizeOffsetVisitor which cares about the underlying size/offset
rather than the size from the current pointer to the end of the
allocation.

Fixes a false positive with -fsanitize=bounds.

Reviewed By: vitalybuka, asbirlea

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

23 months ago[NFC][Inliner] Add cl::opt<int> to tune InstrCost
Vitaly Buka [Tue, 2 Aug 2022 02:59:59 +0000 (19:59 -0700)]
[NFC][Inliner] Add cl::opt<int> to tune InstrCost

The plan is tune this for sanitizers.

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

23 months ago[LoopInterchange][PR56275] Fix legality with negative dependence vectors
Congzhe Cao [Wed, 3 Aug 2022 23:37:30 +0000 (19:37 -0400)]
[LoopInterchange][PR56275] Fix legality with negative dependence vectors

This is the 2nd patch of the two-patch series (D130188, D130189) that
fix PR56275 (https://github.com/llvm/llvm-project/issues/56275) which
is a missed opportunity for loop interchange.

As follow-up on the dependence analysis (DA) patch D130188, this patch
normalizes DA results in loop interchange, such that negative dependence
vectors queried by loop interchange are reversed to be non-negative.

Now all tests in PR56275 can get interchanged. Those tests are added
in lit test as `pr56275.ll`.

Reviewed By: kawashima-fj, bmahjour, Meinersbur, #loopoptwg

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

23 months ago[DependenceAnalysis][PR56275] Normalize negative dependence analysis results
Congzhe Cao [Wed, 3 Aug 2022 23:37:30 +0000 (19:37 -0400)]
[DependenceAnalysis][PR56275] Normalize negative dependence analysis results

This patch is the first of the two-patch series (D130188, D130179) that
resolve PR56275 (https://github.com/llvm/llvm-project/issues/56275)
which is a missed opportunity, where a perfrectly valid case for loop
interchange failed interchange legality.

If the distance/direction vector produced by dependence analysis (DA) is
negative, it needs to be normalized (reversed). This patch provides helper
functions `isDirectionNegative()` and `normalize()` in DA that does the
normalization, and clients can query DA to do normalization if needed.

A pass option `<normalized-results>` is added to DependenceAnalysisPrinterPass,
and we leverage it to update DA test cases to make sure of test coverage. The
test cases added in `Banerjee.ll` shows that negative vectors are normalized
with `print<da><normalized-results>`.

Reviewed By: bmahjour, Meinersbur, #loopoptwg

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

23 months ago[CostModel][RISCV] Add test coverage of floating point rounding intrinsics
Philip Reames [Wed, 3 Aug 2022 23:27:44 +0000 (16:27 -0700)]
[CostModel][RISCV] Add test coverage of floating point rounding intrinsics

These costs are fairly bogus, but at least we have baseline coverage now.

23 months agoAdd switch to use "source_filename" instead of a hash ID for globally promoted local
Bill Wendling [Mon, 18 Jul 2022 19:05:53 +0000 (12:05 -0700)]
Add switch to use "source_filename" instead of a hash ID for globally promoted local

During LTO a local promoted to a global gets a unique suffix based on
a hash of the module IR. This means that changes in the local's module
can affect the contents in another module that imported it (because the name
of the imported promoted local is changed, but that doesn't reflect a
real change in the importing module). So any tool that's
validating changes to the importing module will see a superficial change.

Instead of using the module hash, we can use the "source_filename" if it
exists to generate a unique identifier that doesn't change due to LTO
shenanigans.

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

23 months ago[gn build] Port 0cb9746a7d85
LLVM GN Syncbot [Wed, 3 Aug 2022 23:20:59 +0000 (23:20 +0000)]
[gn build] Port 0cb9746a7d85

23 months ago[nfc][mlgo] Separate logger and training-mode model evaluator
Mircea Trofin [Wed, 3 Aug 2022 21:32:42 +0000 (14:32 -0700)]
[nfc][mlgo] Separate logger and training-mode model evaluator

This just shuffles implementations and declarations around. Now the
logger and the TF C API-based model evaluator are separate.

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

23 months ago[gn build] Port 36c746ca2d5b
LLVM GN Syncbot [Wed, 3 Aug 2022 23:08:51 +0000 (23:08 +0000)]
[gn build] Port 36c746ca2d5b

23 months ago[LLDB][NFC] Fix potential div by 0 "count" can be zero potentially causing div by 0
Slava Gurevich [Mon, 1 Aug 2022 20:53:54 +0000 (13:53 -0700)]
[LLDB][NFC] Fix potential div by 0 "count" can be zero potentially causing div by 0

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

23 months ago[libc++][ranges] Implement `ranges::rotate`.
Konstantin Varlamov [Wed, 3 Aug 2022 23:04:14 +0000 (16:04 -0700)]
[libc++][ranges] Implement `ranges::rotate`.

Also fix `ranges::stable_sort` and `ranges::inplace_merge` to support
proxy iterators now that their internal implementations can correctly
dispatch `rotate`.

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

23 months ago[TSAN][Darwin] x86_64 specific tests requiring weak symbols
Blue Gaston [Wed, 3 Aug 2022 22:09:50 +0000 (15:09 -0700)]
[TSAN][Darwin] x86_64 specific tests requiring weak symbols

Additional tests requiring weak symbol attribute work around for macOS 12.0

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

23 months ago[lldb] Make LLDB resilient against failing dyld introspection SPIs
Jonas Devlieghere [Wed, 3 Aug 2022 22:45:18 +0000 (15:45 -0700)]
[lldb] Make LLDB resilient against failing dyld introspection SPIs

Make LLDB resilient against failing dyld introspection SPIs:

 - dyld_process_create_for_current_task
 - dyld_process_snapshot_create_for_process
 - dyld_process_snapshot_get_shared_cache

These can all fail and return a nullptr. Instead of having an assert,
which doesn't really make sense, as we have no control over whether
these calls succeed or not, bail out gracefully and use the fallback
logic.

rdar://98070414

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

23 months ago[AMDGPU] Precommit test case for D130729
jeff [Wed, 3 Aug 2022 21:53:02 +0000 (14:53 -0700)]
[AMDGPU] Precommit test case for D130729

Change-Id: I23396655880b5732ad991d47e51900408f5bc5ee

23 months ago[RISCV] Prevent infinite loop after D129980.
Craig Topper [Wed, 3 Aug 2022 22:19:03 +0000 (15:19 -0700)]
[RISCV] Prevent infinite loop after D129980.

D129980 converts (seteq (i64 (and X, 0xffffffff)), C1) into
(seteq (i64 (sext_inreg X, i32)), C1). If bit 31 of X is 0, it
will be turned back into an 'and' by SimplifyDemandedBits which
can cause an infinite loop.

To prevent this, check if bit 31 is 0 with computeKnownBits before
doing the transformation.

Fixes PR56905.

Reviewed By: reames

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

23 months ago[NFC][Inliner] Simplify clamping in addCost
Vitaly Buka [Tue, 2 Aug 2022 02:53:09 +0000 (19:53 -0700)]
[NFC][Inliner] Simplify clamping in addCost

23 months agoRevert "[X86][MC] Always emit `rep` prefix for `bsf`"
Craig Topper [Wed, 3 Aug 2022 21:50:41 +0000 (14:50 -0700)]
Revert "[X86][MC] Always emit `rep` prefix for `bsf`"

This reverts commit c2066d19cda20d0e98b95da1493e6c3f26fd9618.

It's causing failures on the build bots.

23 months agoRevert "Revert "[lldb][modules] Disable Clang Modules in source/Host directory on...
Jonas Devlieghere [Wed, 3 Aug 2022 21:37:48 +0000 (14:37 -0700)]
Revert "Revert "[lldb][modules] Disable Clang Modules in source/Host directory on macOS""

This reverts commit c7bd61d4a79b88dbd97028bb0a73a73b2d6aca89 because it
breaks the underlying issue is apparently not yet resolved. This only
affects the modules build.

23 months ago[X86] Add a test for missed opportunity combine AND32rm+TEST32rr.
Craig Topper [Wed, 3 Aug 2022 21:28:24 +0000 (14:28 -0700)]
[X86] Add a test for missed opportunity combine AND32rm+TEST32rr.

If the chain output of the AND32rm is used, the post isel peephole
won't fold it. We should be able to fold it by replacing the chain
use with the chain from a TEST32rm.

23 months ago[lldb] Make TestModuleLoadedNotifys work with dyld from the shared cache
Jonas Devlieghere [Wed, 3 Aug 2022 20:41:33 +0000 (13:41 -0700)]
[lldb] Make TestModuleLoadedNotifys work with dyld from the shared cache

Make TestModuleLoadedNotifys work with a dyld from the expanded shared
cache in the DeviceSupport directory. In that case the module path is:

  ~/Library/Developer/Xcode/iOS DeviceSupport/<...>/Symbols/usr/lib/dyld

instead of just:

  /usr/lib/dyld

This makes the test pass when running against an embedded Darwin device.

23 months ago[lldb] Mark TestRosetta as skipIfDarwinEmbedded
Jonas Devlieghere [Wed, 3 Aug 2022 20:39:31 +0000 (13:39 -0700)]
[lldb] Mark TestRosetta as skipIfDarwinEmbedded

This test only makes sense on the host.

23 months agoNFC. Require DirectX backend for these tests
Chris Bieneman [Wed, 3 Aug 2022 20:54:14 +0000 (15:54 -0500)]
NFC. Require DirectX backend for these tests

Should have added this when I added the test directory. This just
requires the DirectX target for running these tests.

23 months ago[DX] [NFC] Move hasSection check up
Chris Bieneman [Wed, 3 Aug 2022 17:09:07 +0000 (12:09 -0500)]
[DX] [NFC] Move hasSection check up

Juming out earlier if the global doesn't have a section is just a
cleaner early out.

23 months ago[NFC][inline] Add const to an argument
Vitaly Buka [Tue, 2 Aug 2022 02:24:52 +0000 (19:24 -0700)]
[NFC][inline] Add const to an argument

23 months ago[X86] Promote i16 CTTZ/CTTZ_ZERO_UNDEF always.
Craig Topper [Wed, 3 Aug 2022 16:37:33 +0000 (09:37 -0700)]
[X86] Promote i16 CTTZ/CTTZ_ZERO_UNDEF always.

If we're going to emit a rep prefix before bsf as proposed in
D130956, it makes sense to promote i16 operations to i32 to avoid
the false depedency of tzcntw.

Reviewed By: skan, pengfei

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

23 months ago[BOLT] Remove always true if statement
Rafael Auler [Wed, 3 Aug 2022 02:04:29 +0000 (19:04 -0700)]
[BOLT] Remove always true if statement

Got a warning from GCC when building this.

Reviewed By: Amir

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

23 months agoDocument why test is disabled on macOS Ventura
Adrian Prantl [Wed, 3 Aug 2022 20:05:21 +0000 (13:05 -0700)]
Document why test is disabled on macOS Ventura

Starting with macOS 13 CoreFoundation pulls in Foundation, so we
always get the Foundation object description.

rdar://96224141

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

23 months agoFix LDV InstrRefBasedImpl to not crash when encountering unreachable MBBs.
Adrian Prantl [Tue, 2 Aug 2022 17:27:45 +0000 (10:27 -0700)]
Fix LDV InstrRefBasedImpl to not crash when encountering unreachable MBBs.

The testcase was delta-reduced from an LTO build with sanitizer
coverage and the MIR tail duplication pass caused a machine basic
block to become unreachable in MIR. This caused the MBB to be invisible
to the reverse post-order traversal used to initialize the MBB <->
RPONumber lookup tables.

rdar://97226240

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

23 months ago[clang][Darwin] Always set the default C++ Standard Library to libc++
Louis Dionne [Wed, 3 Aug 2022 18:20:02 +0000 (14:20 -0400)]
[clang][Darwin] Always set the default C++ Standard Library to libc++

Newer SDKs don't even provide libstdc++ headers, so it's effectively
never valid to build for libstdc++ unless the user explicitly asks
for it (in which case they will need to provide include paths and more).

23 months ago[Libomptarget][NFC] Clang format the AMDGPU plugin
Joseph Huber [Wed, 3 Aug 2022 19:17:30 +0000 (15:17 -0400)]
[Libomptarget][NFC] Clang format the AMDGPU plugin

Summary:
A previous patch did not format the plugin again after making changes.
Ensure that libomptarget stays formatted.

23 months ago[libc] Disable the loader init_fini_array_test for non-x86_64 targets.
Siva Chandra [Wed, 3 Aug 2022 19:04:21 +0000 (12:04 -0700)]
[libc] Disable the loader init_fini_array_test for non-x86_64 targets.

Loader for aarch64 will be extended in a future pass and this test will
be enabled back again.

23 months agoRevert "[Clang][C++20] Support capturing structured bindings in lambdas"
Corentin Jabot [Wed, 3 Aug 2022 18:59:36 +0000 (20:59 +0200)]
Revert "[Clang][C++20] Support capturing structured bindings in lambdas"

This reverts commit 44f2baa3804a62ca793f0ff3e43aa71cea91a795.

Breaks self builds and seems to have conformance issues.

23 months ago[lldb] Fix 'FileCheck' spelling on symtab regex tests
Augusto Noronha [Wed, 3 Aug 2022 18:57:33 +0000 (11:57 -0700)]
[lldb] Fix 'FileCheck' spelling on symtab regex tests

23 months ago[lldb] Add assertStopReason helper function
Jonas Devlieghere [Wed, 3 Aug 2022 18:42:12 +0000 (11:42 -0700)]
[lldb] Add assertStopReason helper function

Add a function to make it easier to debug a test failure caused by an
unexpected stop reason. This is similar to the assertState helper that
was added in ce825e46743b.

Before:

  self.assertEqual(stop_reason, lldb.eStopReasonInstrumentation)
  AssertionError: 5 != 10

After:

  self.assertStopReason(stop_reason, lldb.eStopReasonInstrumentation)
  AssertionError: signal (5) != instrumentation (10)

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

23 months ago[NFC][intel pt] Improve troubleshooting message
Walter Erquinigo [Wed, 3 Aug 2022 18:33:40 +0000 (11:33 -0700)]
[NFC][intel pt] Improve troubleshooting message

23 months ago[RISCV][test] Add test for ability to tailcall libcalls
Alex Bradbury [Wed, 3 Aug 2022 18:27:59 +0000 (19:27 +0100)]
[RISCV][test] Add test for ability to tailcall libcalls

Although there's good coverage of the libcalls within llvm/test/CodeGen,
it's useful to have tests for all ABI and hard/soft-float combinations
in order to properly test the logic that enables libcall tail calls
(which will be implemented in a follow-up patch).

23 months ago[CMake] Fix runtimes cross-compilation when using LLVM_USE_LINKER
Vincent Lee [Wed, 3 Aug 2022 07:00:02 +0000 (00:00 -0700)]
[CMake] Fix runtimes cross-compilation when using LLVM_USE_LINKER

This is motivated by https://reviews.llvm.org/D115852#3226050 where passing
`LLVM_USE_LINKER` in PASSTHROUGH_PREFIXES breaks cross-compilation
(e.g. targeting Windows on a Linux host). As suggested on that diff, implement
an override for it by allowing users to pass `RUNTIMES_${target}_LLVM_USE_LINKER`
to specify the linker for runtimes. Defaults to host linker if not specified.

Reviewed By: phosek, smeenai

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

23 months ago[SelectionDAG] Handle IntToPtr constants in dbg.value
Felipe de Azevedo Piovezan [Wed, 3 Aug 2022 18:09:04 +0000 (14:09 -0400)]
[SelectionDAG] Handle IntToPtr constants in dbg.value

The function `handleDebugValue` has custom logic to handle certain kinds
constants, namely integers, floats and null pointers. However, it does
not handle constant pointers created from IntToPtr ConstantExpressions.
This patch addresses the issue by replacing the Constant with its
integer operand.

A similar bug was addressed for GlobalISel in D130642.

Reviewed By: aprantl, #debug-info

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

23 months agoError instead of assert when making a _BitInt vector
Aaron Ballman [Wed, 3 Aug 2022 18:05:09 +0000 (14:05 -0400)]
Error instead of assert when making a _BitInt vector

We already correctly rejected:
typedef __attribute__((vector_size(16))) _BitInt(4) Ty;

but we would assert with:
typedef __attribute__((ext_vector_type(4))) _BitInt(4) Ty;

Now we issue the same error in both cases.

23 months ago[ubsan] Make TypeCheckKinds const. NFC
Fangrui Song [Wed, 3 Aug 2022 18:02:22 +0000 (11:02 -0700)]
[ubsan] Make TypeCheckKinds const. NFC

Move it from .data to .data.rel.ro

23 months ago[Clang][C++20] Support capturing structured bindings in lambdas
Corentin Jabot [Wed, 30 Mar 2022 12:27:44 +0000 (14:27 +0200)]
[Clang][C++20] Support capturing structured bindings in lambdas

This completes the implementation of P1091R3 and P1381R1.

This patch allow the capture of structured bindings
both for C++20+ and C++17, with extension/compat warning.

In addition, capturing an anonymous union member,
a bitfield, or a structured binding thereof now has a
better diagnostic.

We only support structured bindings - as opposed to other kinds
of structured statements/blocks. We still emit an error for those.

In addition, support for structured bindings capture is entirely disabled in
OpenMP mode as this needs more investigation - a specific diagnostic indicate the feature is not yet supported there.

Note that the rest of P1091R3 (static/thread_local structured bindings) was already implemented.

at the request of @shafik, i can confirm the correct behavior of lldb wit this change.

Fixes https://github.com/llvm/llvm-project/issues/54300
Fixes https://github.com/llvm/llvm-project/issues/54300
Fixes https://github.com/llvm/llvm-project/issues/52720

Reviewed By: aaron.ballman

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

23 months ago[lldb] Allow SymbolTable regex search functions to match mangled name
Augusto Noronha [Fri, 29 Jul 2022 22:19:17 +0000 (15:19 -0700)]
[lldb] Allow SymbolTable regex search functions to match mangled name

It may be useful to search symbol table entries by mangled instead
of demangled names. Add this optional functionality in the SymbolTable
functions.

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

23 months ago[libc] Add init and fini array iteration to the loader.
Siva Chandra Reddy [Tue, 2 Aug 2022 00:13:17 +0000 (00:13 +0000)]
[libc] Add init and fini array iteration to the loader.

Reviewed By: lntue

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

23 months ago[lldb] Add missing newlines after LLDB_INSTRUMENT_VA
Jonas Devlieghere [Wed, 3 Aug 2022 17:49:45 +0000 (10:49 -0700)]
[lldb] Add missing newlines after LLDB_INSTRUMENT_VA

Add a newline after LLDB_INSTRUMENT_VA to match the output of lldb-instr
and keep everything consistent.

23 months ago[analyzer] Fix for the crash in #56873
isuckatcs [Tue, 2 Aug 2022 09:28:15 +0000 (11:28 +0200)]
[analyzer] Fix for the crash in #56873

In ExprEngine::bindReturnValue() we cast an SVal to DefinedOrUnknownSVal,
however this SVal can also be Undefined, which leads to an assertion failure.

Fixes: #56873

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

23 months agoRevert "[lldb] [gdb-remote] Send interrupt packets from async thread"
Michał Górny [Wed, 3 Aug 2022 17:09:35 +0000 (19:09 +0200)]
Revert "[lldb] [gdb-remote] Send interrupt packets from async thread"

This reverts commit 446b61cff4ea0cb7e7fcc5e0fec7bc749d379b08.  Of course
it does not work on Windows.

23 months agoReplace pdb file used in llvm-symbolizer test with a smaller file.
Amy Huang [Tue, 2 Aug 2022 21:33:32 +0000 (14:33 -0700)]
Replace pdb file used in llvm-symbolizer test with a smaller file.

Reduce the size of the test-columns.pdb file from 6MB to 72KB by not
including standard libraries when building. Also update the instructions
for building the exe/pdb files.

context https://reviews.llvm.org/D81950#3692893

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

23 months ago[clang] Add FileEntryRef::getNameAsRequested()
Ben Langmuir [Tue, 2 Aug 2022 01:08:24 +0000 (18:08 -0700)]
[clang] Add FileEntryRef::getNameAsRequested()

As progress towards having FileManager::getFileRef() return the path
as-requested by default, return a FileEntryRef that can use
getNameAsRequested() to retrieve this path, with the ultimate goal that
this should be the behaviour of getName() and clients should explicitly
request the "external" name if they need to (see comment in
FileManager::getFileRef). For now, getName() continues to return the
external path by looking through the redirects.

For now, the new function is only used in unit tests.

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

23 months ago[lldb] [gdb-remote] Send interrupt packets from async thread
Michał Górny [Wed, 3 Aug 2022 15:39:24 +0000 (17:39 +0200)]
[lldb] [gdb-remote] Send interrupt packets from async thread

Refactor the mechanism for sending interrupt packets to send them
from async thread (i.e. the same thread that sends the continue packet
preceding them and that waits for the response), rather than from
the thread requesting the interrupt.  This is going to become especially
important when using the vCtrlC packet as part of the non-stop protocol,
as -- unlike the simple ^c sent in the all-stop mode -- this packet
involves an explicit reply.

Suggested by Pavel Labath in D126614.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.llvm.org/D131075

23 months ago[libc++] Implement `operator<=>` for `shared_ptr`
Adrian Vogelsgesang [Wed, 3 Aug 2022 16:28:48 +0000 (18:28 +0200)]
[libc++] Implement `operator<=>` for `shared_ptr`

Implements part of:

* P1614R2 The Mothership has Landed

Fixes LWG3427

Reviewed By: #libc, Mordante

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

23 months ago[libc++] Mark -fexperimental-library test as unsupported on another AppleClang
Louis Dionne [Wed, 3 Aug 2022 16:23:53 +0000 (12:23 -0400)]
[libc++] Mark -fexperimental-library test as unsupported on another AppleClang

23 months agoFix assert during the call to getCanonicalDecl.
Jennifer Yu [Tue, 2 Aug 2022 19:23:12 +0000 (12:23 -0700)]
Fix assert during the call to getCanonicalDecl.
https://github.com/llvm/llvm-project/issues/56884

The root problem is in isOpenMPRebuildMemberExpr, it is only need to rebuild
for field expression.  No need for member function call.

The fix is to check field for member expression and skip rebuild for member
function call.

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

23 months ago[libcxx][test] Silence narrowing warning
Casey Carter [Wed, 3 Aug 2022 16:10:47 +0000 (09:10 -0700)]
[libcxx][test] Silence narrowing warning

23 months agoprevent llvm-reduce from duplicating values in switch cases when turning operands...
John Regehr [Wed, 3 Aug 2022 16:06:45 +0000 (10:06 -0600)]
prevent llvm-reduce from duplicating values in switch cases when turning operands into zero or one

23 months agoRevert "ManagedStatic: remove from DynamicLibrary"
Nicolai Hähnle [Wed, 3 Aug 2022 15:55:53 +0000 (17:55 +0200)]
Revert "ManagedStatic: remove from DynamicLibrary"

This reverts commit 38817af6a7271aee0581c56eaea44b8c4cf5ecc7.

Buildbots report a Windows build error. Revert until I can look at it
more carefully.

23 months ago[LV] Move definition of isPredicatedInst out of line and make it const [nfc]
Philip Reames [Wed, 3 Aug 2022 15:52:57 +0000 (08:52 -0700)]
[LV] Move definition of isPredicatedInst out of line and make it const [nfc]

23 months agoManagedStatic: remove from DynamicLibrary
Nicolai Hähnle [Wed, 29 Jun 2022 14:47:51 +0000 (16:47 +0200)]
ManagedStatic: remove from DynamicLibrary

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

23 months ago[clang][dataflow] Add cache of `ControlFlowContext`s for function decls.
Yitzhak Mandelbaum [Wed, 3 Aug 2022 00:46:06 +0000 (00:46 +0000)]
[clang][dataflow] Add cache of `ControlFlowContext`s for function decls.

This patch modifies context-sensitive analysis of functions to use a cache,
rather than recreate the `ControlFlowContext` from a function decl on each
encounter. However, this is just step 1 (of N) in adding support for a
configurable map of "modeled" function decls (see issue #56879). The map will go
from the actual function decl to the `ControlFlowContext` used to model it. Only
functions pre-configured in the map will be modeled in a context-sensitive way.

We start with a cache because it introduces the desired map, while retaining the
current behavior. Here, functions are mapped to their actual implementations
(when available).

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

23 months ago[LV] Use cost base decision for uniform mem op strategy [nfc-ish]
Philip Reames [Wed, 3 Aug 2022 14:44:39 +0000 (07:44 -0700)]
[LV] Use cost base decision for uniform mem op strategy [nfc-ish]

This is mostly a stylistic change to make the uniform memop widening cost
code fit more naturally with the sourounding code.  Its not strictly
speaking NFC as I added in the store with invariant value case, and we
could in theory have a target where a gather/scatter is cheaper than a
single load/store... but it's probably NFC in practice.  Note that the
scatter/gather result can still be overriden later if the result is
uniform-by-parts.

23 months agoFix char8_t in C mode regression from fb65b179
Erich Keane [Wed, 3 Aug 2022 14:14:11 +0000 (07:14 -0700)]
Fix char8_t in C mode regression from fb65b179

When doing that NFC refactor, I'd messed up how char8_t was reported,
which resulted in it being considered a 'future' keyword, without the
corresponding diagnostic, which lead to an assert.  This patch corrects
the char8_t to ONLY be future in C++ mode.

23 months ago[gn build] Set LLVM_TOOLS_INSTALL_DIR to bin for llvm-config
Nico Weber [Wed, 3 Aug 2022 13:42:21 +0000 (09:42 -0400)]
[gn build] Set LLVM_TOOLS_INSTALL_DIR to bin for llvm-config

Matches the CMake build, and might help with a flaky test on Windows.
See https://bugs.chromium.org/p/chromium/issues/detail?id=1348730#c2
for details.

23 months ago[lldb] Fix TestDeletedExecutable on linux
Pavel Labath [Tue, 2 Aug 2022 11:34:24 +0000 (13:34 +0200)]
[lldb] Fix TestDeletedExecutable on linux

Currently, lldb-server was opening the executable file to determine the
process architecture (to differentiate between 32 and 64 bit
architecture flavours). This isn't a particularly trustworthy source of
information (the file could have been changed since the process was
started) and it is not always available (file could be deleted or
otherwise inaccessible).

Unfortunately, ptrace does not give us a direct API to access the
process architecture, but we can still infer it via some of its
responses -- given that the general purpose register set of 64-bit
applications is larger [citation needed] than the GPR set of 32-bit
ones, we can just ask for the application GPR set and check its size.

This is what this patch does.

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

23 months ago[NFCI] Refactor how KeywordStatus is calculated
Erich Keane [Tue, 2 Aug 2022 18:42:49 +0000 (11:42 -0700)]
[NFCI] Refactor how KeywordStatus is calculated

The getKeywordStatus function is a horrible mess of inter-dependent 'if'
statements that depend significantly on the ORDER of the checks.  This
patch removes the dependency on order by checking each set-flag only
once.

It does this by looping through each of the set bits, and checks each
individual flag for its effect, then combines them at the end.

This might slow down startup performance slightly, as there are only a
few hundred keywords, and a vast majority will only get checked 1x
still.

This patch ALSO removes the KEYWORD_CONCEPTS flag, because it has since
become synonymous with C++20.

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

23 months ago[SystemZ] Make 128 bit integers be aligned to 8 bytes.
Jonas Paulsson [Fri, 1 Jul 2022 15:17:19 +0000 (17:17 +0200)]
[SystemZ] Make 128 bit integers be aligned to 8 bytes.

The SystemZ ABI says that 128 bit integers should be aligned to only 8 bytes.

Reviewed By: Ulrich Weigand, Nikita Popov

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

23 months ago[libc++] Simplify how we define the linker script for libc++
Louis Dionne [Wed, 3 Aug 2022 00:30:28 +0000 (20:30 -0400)]
[libc++] Simplify how we define the linker script for libc++

Trying to be generic didn't work properly because we had to special-case
some interface libraries that we didn't want in the linker script. Instead,
only look at the ABI and the unwinding libraries explicitly.

This should solve the issue reported by @dim in [1].

[1]: https://discourse.llvm.org/t/15-0-0-rc1-has-been-tagged/64174/22

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

23 months ago[libunwind] Remove unused substitution in AIX libunwind config
Louis Dionne [Tue, 2 Aug 2022 23:20:54 +0000 (19:20 -0400)]
[libunwind] Remove unused substitution in AIX libunwind config

It must have been a copy-paste error, since cxx-include is never defined
by the libunwind config.

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

23 months ago[libc++] More documentation improvements about running tests
Louis Dionne [Wed, 3 Aug 2022 13:24:54 +0000 (09:24 -0400)]
[libc++] More documentation improvements about running tests

23 months ago[llvm] Always use TargetConstant for FP_ROUND ISD Nodes
David Truby [Wed, 3 Aug 2022 12:39:48 +0000 (13:39 +0100)]
[llvm] Always use TargetConstant for FP_ROUND ISD Nodes

This patch ensures consistency in the construction of FP_ROUND nodes
such that they always use ISD::TargetConstant instead of ISD::Constant.

This additionally fixes a bug in the AArch64 SVE backend where patterns
were matching against TargetConstant nodes and sometimes failing when
passed a Constant node.

Reviewed By: paulwalker-arm

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

23 months ago[RISCV] Teach ComputeNumSignBitsForTargetNode about masked atomic intrinsics
Alex Bradbury [Wed, 3 Aug 2022 12:41:58 +0000 (13:41 +0100)]
[RISCV] Teach ComputeNumSignBitsForTargetNode about masked atomic intrinsics

An unnecessary sext.w is generated when masking the result of the
riscv_masked_cmpxchg_i64 intrinsic. Implementing handling of the
intrinsic in ComputeNumSignBitsForTargetNode allows it to be removed.

Although this isn't a particularly important optimisation, removing the
sext.w simplifies implementation of an additional cmpxchg-related
optimisation in D130192.

Although I can't produce a test with different codegen for the other
atomics intrinsics, these are added as well for completeness.

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

23 months agoManagedStatic: remove from CrashRecoveryContext
Nicolai Hähnle [Wed, 29 Jun 2022 14:31:35 +0000 (16:31 +0200)]
ManagedStatic: remove from CrashRecoveryContext

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

23 months ago[AMDGPU][MC][GFX11] Correct v_dot2_f16_f16 and v_dot2_bf16_bf16
Dmitry Preobrazhensky [Wed, 3 Aug 2022 12:08:23 +0000 (15:08 +0300)]
[AMDGPU][MC][GFX11] Correct v_dot2_f16_f16 and v_dot2_bf16_bf16

Enable SGPRs for the following operands of these opcodes:

- src operands of VOP3 variant.
- src2 operand of DPP variants.

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

23 months ago[AMDGPU][MC][GFX10] Correct encoding of VOP3 v_cmpx* opcodes
Dmitry Preobrazhensky [Wed, 3 Aug 2022 11:05:44 +0000 (14:05 +0300)]
[AMDGPU][MC][GFX10] Correct encoding of VOP3 v_cmpx* opcodes

Encode dst=EXEC but allow disassembler accept any dst value.

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

23 months ago[MLIR] Reconciliation of chains of unrealized casts
Michele Scuttari [Wed, 3 Aug 2022 11:52:21 +0000 (11:52 +0000)]
[MLIR] Reconciliation of chains of unrealized casts

The reconciliation pass has been improved to introduce the support for chains of casts, thus not limiting anymore the reconciliation to just consider pairs of unrealized casts.

Reviewed By: ftynse

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

23 months agoManagedStatic: remove from Interpreter/ExternalFunctions
Nicolai Hähnle [Wed, 29 Jun 2022 14:20:03 +0000 (16:20 +0200)]
ManagedStatic: remove from Interpreter/ExternalFunctions

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

23 months ago[mlir] Fix Analysis/Presburger/Utils.cpp compilation with GCC 11
Rainer Orth [Wed, 3 Aug 2022 09:48:44 +0000 (11:48 +0200)]
[mlir] Fix Analysis/Presburger/Utils.cpp compilation with GCC 11

As reported in Issue #56850, mlir/lib/Analysis/Presburger/Utils.cpp doesn't
compile on Solaris 11.4/SPARC with the bundled GCC 11, as seen when testing
LLVM 15.0.0 rc1:

  /var/llvm/reltest/llvm-15.0.0-rc1/rc1/llvm-project/mlir/include/mlir/Analysis/Presburger/MPInt.h:260:47:
error: inlining failed in call to ‘always_inline’ ‘int64_t
mlir::presburger::int64FromMPInt(const mlir::presburger::MPInt&)’: indirect
function call with a yet undetermined callee

This patch hacks around this and allowed the build to finish.

Tested on `sparcv9-sun-solaris2.11`.

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

23 months agoFix compiler error: init-statements in if/switch.
Johannes Reifferscheid [Wed, 3 Aug 2022 09:34:51 +0000 (11:34 +0200)]
Fix compiler error: init-statements in if/switch.

Reviewed By: pifon2a

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

23 months ago[VP] Rename VP int<->float conversion ISD opcodes
Fraser Cormack [Tue, 2 Aug 2022 07:32:34 +0000 (08:32 +0100)]
[VP] Rename VP int<->float conversion ISD opcodes

These should be named like the non-VP versions for consistency.

Reviewed By: reames

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

23 months ago[X86][MC] Always emit `rep` prefix for `bsf`
Phoebe Wang [Wed, 3 Aug 2022 08:38:34 +0000 (16:38 +0800)]
[X86][MC] Always emit `rep` prefix for `bsf`

`BMI` new instruction `tzcnt` has better performance than `bsf` on new
processors. Its encoding has a mandatory prefix '0xf3' compared to
`bsf`. If we force emit `rep` prefix for `bsf`, we will gain better
performance when the same code run on new processors.

GCC has already done this way: https://c.godbolt.org/z/6xere6fs1

Fixes #34191

Reviewed By: skan

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

23 months agoFix a stack overflow in ScalarEvolution.
Johannes Reifferscheid [Wed, 3 Aug 2022 05:07:55 +0000 (07:07 +0200)]
Fix a stack overflow in ScalarEvolution.

Unfortunately, this overflow is extremely hard to reproduce reliably (in fact, I was unable to do so). The issue is that:

- getOperandsToCreate sometimes skips creating an SCEV for the LHS
- then, createSCEV is called for the BinaryOp
- ... which calls getNoWrapFlagsFromUB
- ... which under certain circumstances calls isSCEVExprNeverPoison
- ... which under certain circumstances requires the SCEVs of all operands

For certain deep dependency trees, this causes a stack overflow.

Reviewed By: bkramer, fhahn

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

23 months ago[clang][NFC] Try to fix the docs build
Timm Bäder [Wed, 3 Aug 2022 08:51:34 +0000 (10:51 +0200)]
[clang][NFC] Try to fix the docs build

23 months ago[CMake] Make split-file an utility instead of tool
Markus Böck [Wed, 3 Aug 2022 08:46:52 +0000 (10:46 +0200)]
[CMake] Make split-file an utility instead of tool

`split-file` is essentially a development tool used for writing tests. Other related tooling for this purpose such as `FileCheck`, `count`, `not` and more are already created via `add_llvm_utility` instead of `add_llvm_tool`. The later is more meant as LLVM tools used as part of a toolchain (eg. `llvm-ar`), not for tools for the development of LLVM itself.

The main semantic difference this makes is that `split-file` is now built and installed via the `LLVM_INSTALL_UTILS` and `LLVM_BUILD_UTILS` instead of `LLVM_BUILD_TOOLS` and `LLVM_INSTALL_TOOLS` cmake flags. That way one can use `LLVM_BUILD_TOOLS=OFF LLVM_INSTALL_UTILS=ON` and have `split-file` installed along side the other testing tools.

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

23 months agoManagedStatic: remove from PluginLoader
Nicolai Hähnle [Wed, 29 Jun 2022 14:14:55 +0000 (16:14 +0200)]
ManagedStatic: remove from PluginLoader

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

23 months agoManagedStatic: remove from TimeProfiler
Nicolai Hähnle [Wed, 29 Jun 2022 13:58:18 +0000 (15:58 +0200)]
ManagedStatic: remove from TimeProfiler

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

23 months ago[clang] Short-circuit trivial constructors when evaluating arrays
Timm Bäder [Fri, 29 Jul 2022 14:12:49 +0000 (16:12 +0200)]
[clang] Short-circuit trivial constructors when evaluating arrays

VisitCXXConstructExpr() will later do something similar, but for large
arrays, we should try to do it once an not for every element.

Fixes #56774

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

23 months ago[NFC] Remove some boilerplate from SmallVector unit tests
Dawid Jurczak [Wed, 3 Aug 2022 07:07:25 +0000 (09:07 +0200)]
[NFC] Remove some boilerplate from SmallVector unit tests

In SmallVector unit test, referring test suite members every time using 'this'
(due to how non-dependent name lookups works) is quite cumbersome and can be improved with aliases.
Some test cases already use this approach, in this change we expand that approach to whole test file.

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

23 months ago[Docs] Improve cycle and closed path definitions
Jannik Silvanus [Mon, 1 Aug 2022 09:46:02 +0000 (11:46 +0200)]
[Docs] Improve cycle and closed path definitions

Improve the cycle definition, by avoiding usage of not yet defined
or only vaguely defined terminology inside definitions.
More precisely, the existing definition defined "outermost cycles",
and then proceeded to use the term "cycles" for further definitions,
which in turn were used to actually define "cycles".

Now, instead only define "cycles". This does not change the meaning
of a cycle, which depends on the chosen surrounding (subgraph) of a CFG.

Also mention the function CFG in the first definition, because later
later definitions require it anyways.

Also slightly improve the definition of a closed path, by explicitly
requiring the inner nodes to be distinct.

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

23 months ago[mlir] Disable `misc-const-correctness` clang-tidy check.
Alexander Belyaev [Wed, 3 Aug 2022 08:18:18 +0000 (10:18 +0200)]
[mlir] Disable `misc-const-correctness` clang-tidy check.

https://clang.llvm.org/extra/clang-tidy/checks/misc/const-correctness.html

23 months ago[X86] Using `X86MemOperand` instead of `Operand` for `i32mem_TC` and `i64mem_TC`
Liu, Chen3 [Wed, 3 Aug 2022 06:39:29 +0000 (14:39 +0800)]
[X86] Using `X86MemOperand` instead of `Operand` for `i32mem_TC` and `i64mem_TC`

To fix build fail when X86_GEN_FOLD_TABLES is enabled.

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

23 months ago[AA] Make ModRefInfo a bitmask enum (NFC)
Nikita Popov [Mon, 1 Aug 2022 06:16:54 +0000 (08:16 +0200)]
[AA] Make ModRefInfo a bitmask enum (NFC)

Mark ModRefInfo as a bitmask enum, which allows using normal
& and | operators on it. This supersedes various functions like
unionModRef() and intersectModRef(). I think this makes the code
cleaner than going through helper functions...

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

23 months ago[SCEV] Use context to strengthen flags of BinOps
Max Kazantsev [Wed, 3 Aug 2022 06:10:56 +0000 (13:10 +0700)]
[SCEV] Use context to strengthen flags of BinOps

Sometimes SCEV cannot infer nuw/nsw from something as simple as
```
  len in [0, MAX_INT]
...
  iv = phi(0, iv.next)
  guard(iv <s len)
  guard(iv <u len)
  iv.next = iv + 1
```
just because flag strenthening only relies on definition and does not use local facts.
This patch adds support for the simplest case: inference of flags of `add(x, constant)`
if we can contextually prove that `x <= max_int - constant`.

In case if it has negative CT impact, we can add an option to switch it off. I woudln't
expect that though.

Differential Revision: https://reviews.llvm.org/D129643
Reviewed By: apilipenko

23 months ago[clang][dataflow] Rename member to make it clear that it isn't stable
Stanislav Gatev [Tue, 2 Aug 2022 21:05:48 +0000 (21:05 +0000)]
[clang][dataflow] Rename member to make it clear that it isn't stable

Rename `DataflowAnalysisContext::getStableStorageLocation(QualType)`
to `createStorageLocation`, to make it clear that it doesn't return
a stable storage location.

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

Reviewed-by: ymandel, xazax.hun, gribozavr2
23 months agoAdd foldings for multi-line comment.
Utkarsh Saxena [Tue, 19 Jul 2022 12:42:10 +0000 (14:42 +0200)]
Add foldings for multi-line comment.

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

23 months ago[mlir][Math] Add constant folder for AtanOp.
jacquesguan [Tue, 2 Aug 2022 11:49:11 +0000 (19:49 +0800)]
[mlir][Math] Add constant folder for AtanOp.

This patch adds constant folder for AtanOp which only supports single and double precision floating-point.

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

23 months ago[clang][dataflow] Make the type of the post visit callback consistent
Stanislav Gatev [Tue, 2 Aug 2022 19:33:47 +0000 (19:33 +0000)]
[clang][dataflow] Make the type of the post visit callback consistent

Make the types of the post visit callbacks in `transferBlock` and
`runTypeErasedDataflowAnalysis` consistent.

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

Reviewed-by: ymandel, xazax.hun, gribozavr2
23 months ago[gn build] Port 68264b649461
LLVM GN Syncbot [Wed, 3 Aug 2022 05:46:25 +0000 (05:46 +0000)]
[gn build] Port 68264b649461

23 months ago[libc++][ranges] Implement `ranges::{prev, next}_permutation`.
Nikolas Klauser [Wed, 3 Aug 2022 05:40:13 +0000 (22:40 -0700)]
[libc++][ranges] Implement `ranges::{prev, next}_permutation`.

Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D129859

23 months ago[libc++][test] Replace `_LIBCPP_STD_VER` with `TEST_STD_VER`
cpplearner [Tue, 2 Aug 2022 10:38:17 +0000 (18:38 +0800)]
[libc++][test] Replace `_LIBCPP_STD_VER` with `TEST_STD_VER`

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

23 months ago[gn build] Port 6bdb64223473
LLVM GN Syncbot [Wed, 3 Aug 2022 05:36:28 +0000 (05:36 +0000)]
[gn build] Port 6bdb64223473

23 months ago[libc++][ranges] Implement `ranges::sample`.
Konstantin Varlamov [Wed, 3 Aug 2022 05:33:12 +0000 (22:33 -0700)]
[libc++][ranges] Implement `ranges::sample`.

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

23 months ago[libc++][ranges] Implement `ranges::replace_copy{,_if}`.
Nikolas Klauser [Wed, 3 Aug 2022 05:25:00 +0000 (22:25 -0700)]
[libc++][ranges] Implement `ranges::replace_copy{,_if}`.

Co-authored-by: Konstantin Varlamov <varconst@apple.com>
Differential Revision: https://reviews.llvm.org/D129806