platform/upstream/llvm.git
15 months ago[flang][openacc] Keep region when applying data operand conversion
Valentin Clement [Wed, 12 Apr 2023 15:19:11 +0000 (08:19 -0700)]
[flang][openacc] Keep region when applying data operand conversion

Similar to D148039 but for the FIR to LLVM IR
conversion pass.

The inner part of the acc.loop has been removed since the rest of the
pipeline is not ready and would raise an error here. This was passing
until now because the acc.loop was discarded completely.

Reviewed By: PeteSteinfeld

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

15 months agoRevert "[GuardUtils] Add asserts about loop varying widenable conditions"
Anna Thomas [Wed, 12 Apr 2023 14:58:06 +0000 (10:58 -0400)]
Revert "[GuardUtils] Add asserts about loop varying widenable conditions"

This reverts commit 5675757f5fc6e27ce01b3b12bdfd04044df53aa3.

Assert maybe too strict. revert and investigate why assert fires.

15 months ago[AArch64][SVE] Extend predicated fma patterns to negative zero
David Green [Wed, 12 Apr 2023 14:53:22 +0000 (15:53 +0100)]
[AArch64][SVE] Extend predicated fma patterns to negative zero

This extends the patterns added in D130564 for fma to also handle negative 0.0.
-0.0 is the identity element for fadd so comes up in vectorized loops.

The same basic idea applies to D130564, but nsz should no longer be needed for
the fadd case, and is for fsub (which is really only added for completeness).

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

15 months ago[VNCoercion] Drop some redundant functions (NFC)
Nikita Popov [Wed, 12 Apr 2023 14:39:24 +0000 (16:39 +0200)]
[VNCoercion] Drop some redundant functions (NFC)

These load and store APIs now do the same thing, so combine them
into one.

15 months ago[mlir][scf] More WhileOp canonicalizations
Ivan Butygin [Thu, 16 Mar 2023 18:18:07 +0000 (19:18 +0100)]
[mlir][scf] More WhileOp canonicalizations

Remove duplicated ConditonOp args, remove unused init/yield args.

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

15 months ago[TTI][X86] getMinMaxCost - use existing integer min/max intrinsic cost values instead...
Simon Pilgrim [Wed, 12 Apr 2023 14:28:17 +0000 (15:28 +0100)]
[TTI][X86] getMinMaxCost - use existing integer min/max intrinsic cost values instead of maintaining a duplicate cost table

getMinMaxCost has an alternative set of min/max costs to getIntrinsicInstrCost that are only used by getMinMaxReductionCost, but are a lot less thorough and fallback to an expansion in most cases resulting in cost overestimations - we're better off just using getIntrinsicInstrCost.

getIntrinsicInstrCost is still missing complete FMINNUM/FMAXNUM costs, so until then getMinMaxCost will still be used for these, after that we can remove getMinMaxCost and have getMinMaxReductionCost call getIntrinsicInstrCost directly.

Fixes regression noticed in D148036

15 months ago[X86] combinePTESTCC - attempt to use TESTPS/TESTPD instead of MOVMSKPS/MOVMSKPD...
Simon Pilgrim [Wed, 12 Apr 2023 13:53:16 +0000 (14:53 +0100)]
[X86] combinePTESTCC - attempt to use TESTPS/TESTPD instead of MOVMSKPS/MOVMSKPD for all-of cases with all-sign values.

We can probably be more aggressive with TESTPS/TESTPD (instead of relying on the SimplifyMultipleUseDemandedBits call) - I've updated an existing TODO to suggest this for now.

Part of Issue #60007

15 months ago[X86] Cleanup reduction cost table names. NFC.
Simon Pilgrim [Wed, 12 Apr 2023 13:47:38 +0000 (14:47 +0100)]
[X86] Cleanup reduction cost table names. NFC.

We merged the costs for split/pairwise reductions sometime ago.

15 months ago[GVN][VNCoercion] Remove load widening leftovers (NFCI)
Nikita Popov [Wed, 12 Apr 2023 14:29:58 +0000 (16:29 +0200)]
[GVN][VNCoercion] Remove load widening leftovers (NFCI)

GVN load widening was disabled in D24096. This removes various
support code that is no longer relevant.

The way this works nowadays is that we return PartialAlias with
an offset from BasicAA and this gets passed on as a clobber by
MDA. However, PartialAlias will only be returned if the load is
properly nested inside the other load.

This just removes the bulk of the code, but some additional
cleanup can be done here now that we don't need to distinguish
between load and store cases.

15 months ago[clang] Implement CWG 2397
Younan Zhang [Mon, 10 Apr 2023 07:08:45 +0000 (15:08 +0800)]
[clang] Implement CWG 2397

This patch implements CWG 2397, allowing array of placeholder type
to be valid.

See also https://wg21.cmeerw.net/cwg/issue2397.

Reviewed By: aaron.ballman, #clang-language-wg

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

15 months ago[GVN] Regenerate test checks (NFC)
Nikita Popov [Wed, 12 Apr 2023 14:16:15 +0000 (16:16 +0200)]
[GVN] Regenerate test checks (NFC)

15 months ago[AMDGPU] Fix amdgpu_gfx tail-call test
Sebastian Neubauer [Wed, 12 Apr 2023 14:15:09 +0000 (16:15 +0200)]
[AMDGPU] Fix amdgpu_gfx tail-call test

The inreg argument prevented the tail call optimization to kick in.
Remove the inreg, so this test actually uses a tail call.

Note that it now uses s[4:5] for the return address, which is invalid,
because these registers are supposed to be callee-save.
D147096 tried to fix that problem for the C calling convention.

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

15 months ago[Matrix] Fix crash during dot product lowering.
Florian Hahn [Wed, 12 Apr 2023 14:07:48 +0000 (15:07 +0100)]
[Matrix] Fix crash during dot product lowering.

Perform dot-product lowering before instruction fusion to avoid crash in
newly added test. Also update lowerDotProduct to properly mark optimized
matmul as fused.

15 months ago[Flang][Driver][OpenMP] Enable options for selecting offloading phases in flang
Sergio Afonso [Mon, 10 Apr 2023 13:19:11 +0000 (14:19 +0100)]
[Flang][Driver][OpenMP] Enable options for selecting offloading phases in flang

This patch unlocks the "--offload-device-only", "--offload-host-only" and
"--offload-host-device" options available in Clang for use by the Flang driver.
These can be used to modify the behavior of the driver to select which
compilation invocations are triggered during OpenMP offloading.

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

15 months ago[GVN] Add additional metadata adjustment tests (NFC)
Nikita Popov [Wed, 12 Apr 2023 13:46:10 +0000 (15:46 +0200)]
[GVN] Add additional metadata adjustment tests (NFC)

15 months ago[SimpleLoopUnswitch] Do not try to inject pointer conditions. PR62058
Max Kazantsev [Wed, 12 Apr 2023 13:34:56 +0000 (20:34 +0700)]
[SimpleLoopUnswitch] Do not try to inject pointer conditions. PR62058

As shown in https://github.com/llvm/llvm-project/issues/62058, canonicalication
may fail with pointer types (and basically this transform is not expected to
work with pointers).

15 months ago[Test] Add XFAIL test for PR62058
Max Kazantsev [Wed, 12 Apr 2023 13:33:39 +0000 (20:33 +0700)]
[Test] Add XFAIL test for PR62058

Details at https://github.com/llvm/llvm-project/issues/62058

15 months ago[profile] Make __llvm_profile_global_timestamp static to unbreak Darwin
Hans Wennborg [Wed, 12 Apr 2023 13:28:13 +0000 (15:28 +0200)]
[profile] Make __llvm_profile_global_timestamp static to unbreak Darwin

See comments on https://reviews.llvm.org/D147287

15 months ago[gn build] Port e2b15ec235fe
LLVM GN Syncbot [Wed, 12 Apr 2023 13:18:39 +0000 (13:18 +0000)]
[gn build] Port e2b15ec235fe

15 months ago[gn build] Port a6d9730f403a
LLVM GN Syncbot [Wed, 12 Apr 2023 13:18:38 +0000 (13:18 +0000)]
[gn build] Port a6d9730f403a

15 months ago[gn] port a6ba74e471ac
Nico Weber [Wed, 12 Apr 2023 13:18:07 +0000 (09:18 -0400)]
[gn] port a6ba74e471ac

15 months ago[MLIR][OpenMP] Update OpenMPIRBuilderTest to use opaque pointers
Akash Banerjee [Wed, 12 Apr 2023 12:08:37 +0000 (13:08 +0100)]
[MLIR][OpenMP] Update OpenMPIRBuilderTest to use opaque pointers

This patch updates all tests to use to use the opaque pointers.

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

15 months ago[mlir][Linalg] Allow linalg.copy to be vectorized with masking
Nicolas Vasilache [Wed, 12 Apr 2023 09:09:17 +0000 (02:09 -0700)]
[mlir][Linalg] Allow linalg.copy to be vectorized with masking

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

15 months ago[libc++][NFC] rename __is_trivially_equality_comparable to __libcpp_is_trivially_equa...
Nikolas Klauser [Mon, 10 Apr 2023 17:31:22 +0000 (19:31 +0200)]
[libc++][NFC] rename __is_trivially_equality_comparable to __libcpp_is_trivially_equality_comparable

This is required for D147175.

Reviewed By: ldionne, Mordante, #libc

Spies: libcxx-commits

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

15 months ago[libc++] Rename __tuple_dir back to __tuple
Nikolas Klauser [Tue, 4 Apr 2023 11:05:59 +0000 (13:05 +0200)]
[libc++] Rename __tuple_dir back to __tuple

This essentially reverts D139270

Reviewed By: #libc, EricWF

Spies: tahonermann, libcxx-commits, arichardson

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

15 months ago[BOLT] Fix section-end-sym.s test to only run x86/Linux
Muhammad Omair Javaid [Wed, 12 Apr 2023 12:11:58 +0000 (17:11 +0500)]
[BOLT] Fix section-end-sym.s test to only run x86/Linux

section-end-sym.s contains x86_64 assembly instruction execution on target.
I have changed REQURIES: field system-linux --> x86_64-linux
This came up while testing LLVM 16.0.1 release on AArch64 Linux.

15 months ago[LoopUtils] Add isKnownPositiveInLoop and isKnownNonPositiveInLoop functions
Dmitry Makogon [Wed, 12 Apr 2023 11:44:40 +0000 (18:44 +0700)]
[LoopUtils] Add isKnownPositiveInLoop and isKnownNonPositiveInLoop functions

15 months ago[mlir][Linalg] Add support for tiling tensor.pad to scf.forall
Nicolas Vasilache [Wed, 12 Apr 2023 09:12:31 +0000 (02:12 -0700)]
[mlir][Linalg] Add support for tiling tensor.pad to scf.forall

Also, properly propagate the nofold attribute.

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

15 months agoRevert "Move "auto-init" instructions to the dominator of their users"
Hans Wennborg [Wed, 12 Apr 2023 11:28:25 +0000 (13:28 +0200)]
Revert "Move "auto-init" instructions to the dominator of their users"

This could also move initialization of sret args, causing actually
initialized parts of such return values to be uninitialized. See
discussion on the code review.

> As a result of -ftrivial-auto-var-init, clang generates instructions to
> set alloca'd memory to a given pattern, right after the allocation site.
> In some cases, this (somehow costly) operation could be delayed, leading
> to conditional execution in some cases.
>
> This is not an uncommon situation: it happens ~500 times on the cPython
> code base, and much more on the LLVM codebase. The benefit greatly
> varies on the execution path, but it should not regress on performance.
>
> This is a recommit of cca01008cc31a891d0ec70aff2201b25d05d8f1b with
> MemorySSA update fixes.
>
> Differential Revision: https://reviews.llvm.org/D137707

This reverts commit 50b2a113db197a97f60ad2aace8b7382dc9b8c31
and follow-up commit ad9ad3735c4821ff4651fab7537a75b8f0bb60f8.

15 months agoReapply (4) "[Assignment Tracking] Enable by default"
OCHyams [Wed, 12 Apr 2023 11:35:17 +0000 (12:35 +0100)]
Reapply (4) "[Assignment Tracking] Enable by default"

Re-land D146987.

This reverts commit 8af575657b1dc1113640286b3649842c2473c2cf
which reverts D146987.

15 months ago[Assignment Tracking] Fix assertion in AssignmentTrackingPass::runOnFunction
OCHyams [Wed, 12 Apr 2023 11:28:59 +0000 (12:28 +0100)]
[Assignment Tracking] Fix assertion in AssignmentTrackingPass::runOnFunction

The assertion exists to ensure all variables passed into `trackAssignments` end
up with dbg.assigns associated with their backing allocas. The assertion
compared the passed-in and tracked variables using `DebugVariable`, which
includes the fragment as part of the variable identity.

It is possible for the backing alloca to be smaller than a variable (see test
case). In this case the input variable `(Var X, no fragment, no InlinedAt)`
isn't equal to the dbg.assign variable `(Var X, some fragment, no
InlinedAt)`. To cover this case the assertion now ignores fragments through the
use of `DebugVariableAggregate`.

Reviewed By: jmorse

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

15 months ago[lldb] Reduce chances of spurious failures in some build setups
Alexander Kornienko [Wed, 12 Apr 2023 10:30:23 +0000 (12:30 +0200)]
[lldb] Reduce chances of spurious failures in some build setups

The test may fail when running from a directory that contains the string used in
CHECK-NOT. We observe flakiness rate of around 3/100000. Increasing the length
helps reducing the rate of failures.

Reviewed By: DavidSpickett

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

15 months ago[mlir][Linalg] Add a structured transform to materialize a tensor.insert_slice via...
Nicolas Vasilache [Wed, 12 Apr 2023 10:51:08 +0000 (03:51 -0700)]
[mlir][Linalg] Add a structured transform to materialize a tensor.insert_slice via a linalg.copy

This is useful to materialize copies explicitly before bufferization and
transform them, avoiding the need to rediscover them after bufferization.

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

15 months ago[mlir] Add transform.foreach_match
Alex Zinenko [Mon, 3 Apr 2023 12:59:49 +0000 (12:59 +0000)]
[mlir] Add transform.foreach_match

Add a new transform op combinator that implements an "if-then-else"
style of mechanism for applying transformations. Its main purpose is to
serve as a higher-level driver when applying multiple transform scripts
to potentially overlapping pieces of the payload IR. This is similar to
how the various rewrite drivers operate in C++, but at a higher level
and with more declarative expressions. This is not intended to replace
existing pattern-based rewrites, but to to drive more complex
transformations that are exposed in the transform dialect and are too
complex to be expressed as simple declarative rewrites.

Reviewed By: springerm

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

15 months ago[Test] Add ranges for some expressions in some SCEV tests (NFC)
Dmitry Makogon [Wed, 12 Apr 2023 08:55:08 +0000 (15:55 +0700)]
[Test] Add ranges for some expressions in some SCEV tests (NFC)

15 months ago[X86] SimplifyDemandedBitsForTargetNode - add TESTPS/TESTPD support
Simon Pilgrim [Wed, 12 Apr 2023 10:54:18 +0000 (11:54 +0100)]
[X86] SimplifyDemandedBitsForTargetNode - add TESTPS/TESTPD support

We only need the sign bits from these nodes

Another step towards Issue #60007

15 months agoInstCombine: Add some additional is.fpclass tests
Matt Arsenault [Tue, 11 Apr 2023 13:50:11 +0000 (09:50 -0400)]
InstCombine: Add some additional is.fpclass tests

Add some tests to generalize the clearing of known bits using
computeKnownFPClass instead of isKnownNeverNaN/isKnownNeverInfinity.

15 months agounittests: Use opaque pointers in a test
Matt Arsenault [Wed, 12 Apr 2023 02:24:33 +0000 (22:24 -0400)]
unittests: Use opaque pointers in a test

15 months agoValueTracking: Handle no-nan check for computeKnownFPClass for fadd/fsub
Matt Arsenault [Sat, 8 Apr 2023 13:21:31 +0000 (09:21 -0400)]
ValueTracking: Handle no-nan check for computeKnownFPClass for fadd/fsub

Copy the logic from isKnownNeverNaN for fadd/fsub.

15 months agoValueTracking: Remove outdated todo
Matt Arsenault [Sat, 8 Apr 2023 23:06:36 +0000 (19:06 -0400)]
ValueTracking: Remove outdated todo

15 months agoAMDGPU: Push fneg into bitcast of integer select
Matt Arsenault [Thu, 26 Jan 2023 19:55:42 +0000 (15:55 -0400)]
AMDGPU: Push fneg into bitcast of integer select

Avoids some regressions in the math libraries in a future
patch.

15 months agoSet 'rounding_mode' to 'tonearest' with '#pragma STDC FENV_ACCESS OFF'.
Zahira Ammarguellat [Thu, 6 Apr 2023 19:21:14 +0000 (15:21 -0400)]
Set 'rounding_mode' to 'tonearest' with '#pragma STDC FENV_ACCESS OFF'.

In strict mode the 'roundin_mode' is set to 'dynamic'. Using this pragma to
get out of strict mode doesn't have any effect on the 'rounding_mode'.
See https://godbolt.org/z/zoGTf4j1G
This patch fixes that.

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

15 months ago[X86] Add test coverage for TESTPS/TESTPD showing the failure to demand only the...
Simon Pilgrim [Wed, 12 Apr 2023 10:37:41 +0000 (11:37 +0100)]
[X86] Add test coverage for TESTPS/TESTPD showing the failure to demand only the sign bits

Part of Issue #60007

15 months ago[X86] combinePTESTCC - remove unnecessary legal vector type assertion
Simon Pilgrim [Wed, 12 Apr 2023 10:03:45 +0000 (11:03 +0100)]
[X86] combinePTESTCC - remove unnecessary legal vector type assertion

Most of these folds bitcast to the PTEST operand type anyway, and its only relevant for the PTEST->MOVMSK fold, which I'm looking at expanding to attempt to fold to PTEST->TESTP as well.

Noticed while beginning triage of Issue #60007

15 months ago[tsan] Add debugging interfaces into interface header.
Pierre Gousseau [Wed, 12 Apr 2023 09:55:16 +0000 (10:55 +0100)]
[tsan] Add debugging interfaces into interface header.

Reviewed By: vitalybuka, dvyukov

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

15 months ago[AArch64] Extend testing for folding fadd to predicated SVE insinstructions. NFC
David Green [Wed, 12 Apr 2023 10:00:38 +0000 (11:00 +0100)]
[AArch64] Extend testing for folding fadd to predicated SVE insinstructions. NFC

This extends the existing tests to include negative zeros and additional
combinations. See D147724 and D147723.

15 months agoFix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFC
Simon Pilgrim [Wed, 12 Apr 2023 09:37:51 +0000 (10:37 +0100)]
Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFC

15 months ago[SCEV] Add additional tests for finite loop trip counts (NFC)
Nikita Popov [Wed, 12 Apr 2023 09:55:01 +0000 (11:55 +0200)]
[SCEV] Add additional tests for finite loop trip counts (NFC)

Add post-inc variations of tests.

15 months ago[Reland][ADT][ConcurrentHashTable] adapt ConcurrentHashTable and its users to LLVM_EN...
Alexey Lapshin [Wed, 5 Apr 2023 18:45:00 +0000 (20:45 +0200)]
[Reland][ADT][ConcurrentHashTable] adapt ConcurrentHashTable and its users to LLVM_ENABLE_THREADS=0 mode.

This patch hides thread specific handling under LLVM_ENABLE_THREADS guard.
It also removes usages of thread_local variables, since it has a weak
support on some platforms. Instead, the patch uses single mutex for locking
allocator. That may be replaced with more effective allocator later.
f.e. D142318

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

15 months agoFix Mem leak in LLVMTargetMachine.cpp
Wang, Xin10 [Wed, 12 Apr 2023 09:26:00 +0000 (05:26 -0400)]
Fix Mem leak in LLVMTargetMachine.cpp

If we go to line 302, with one of MCE or MAB is not nullptr, then we could
leak mem here.
Use unique_ptr to maintain these 2 pointer can avoid it.

Reviewed By: LuoYuanke

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

15 months ago[mlir] Remove extra ';' outside of a function (NFC)
Jie Fu [Wed, 12 Apr 2023 09:19:06 +0000 (17:19 +0800)]
[mlir] Remove extra ';' outside of a function (NFC)

/data/llvm-project/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp:342:2: error: extra ';' outside of a function is incompatible with C++
98 [-Werror,-Wc++98-compat-extra-semi]
}; // namespace

15 months ago[mlir][bufferization] Make function boundary type convertion logic dynamic.
Oleg Shyshkov [Wed, 12 Apr 2023 08:48:14 +0000 (10:48 +0200)]
[mlir][bufferization] Make function boundary type convertion logic dynamic.

Having to choose from only static or dynamic layout for all function is limiting.

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

15 months ago[clang][analyzer] Improve bug reports of StdLibraryFunctionsChecker.
Balázs Kéri [Wed, 12 Apr 2023 07:33:51 +0000 (09:33 +0200)]
[clang][analyzer] Improve bug reports of StdLibraryFunctionsChecker.

Add an additional explanation of what is wrong if a constraint is
not satisfied, in some cases.
Additionally the bug report generation is changed to use raw_ostream.

Reviewed By: Szelethus, NoQ

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

15 months ago[GVNHoist] Regenerate test checks (NFC)
Nikita Popov [Wed, 12 Apr 2023 08:17:28 +0000 (10:17 +0200)]
[GVNHoist] Regenerate test checks (NFC)

15 months ago[Clang] Fix crash caused by line splicing in doc comment
Corentin Jabot [Tue, 11 Apr 2023 14:32:31 +0000 (16:32 +0200)]
[Clang] Fix crash caused by line splicing in doc comment

Because the comment parser does not support slices,
we emit a warning for comments that do contain
a splice within their delimiter, and do not add them as
documentation comment.

Fixes #62054

Reviewed By: shafik, aaron.ballman

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

15 months ago[IR] Use switch in Instruction::mayThrow() (NFC)
Nikita Popov [Wed, 12 Apr 2023 07:48:01 +0000 (09:48 +0200)]
[IR] Use switch in Instruction::mayThrow() (NFC)

15 months ago[libcxx] Move the private header __std_stream into the src subdir
Martin Storsjö [Sat, 8 Apr 2023 18:51:02 +0000 (21:51 +0300)]
[libcxx] Move the private header __std_stream into the src subdir

This header isn't used by any public header, so there shouldn't
be any need to install it or treat it as a heder.

Once it's part of the src subdirectory, I guess one could consider
giving it a more traditional name too.

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

15 months ago[libcxxabi] [test] Don't cast a pointer to long, fixing the test on Windows
Martin Storsjö [Wed, 5 Apr 2023 11:51:36 +0000 (14:51 +0300)]
[libcxxabi] [test] Don't cast a pointer to long, fixing the test on Windows

Use uintptr_t instead. On Windows, long is 32 bit even on 64 bit
architectures.

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

15 months ago[compiler-rt] [test] Remove a leftover XFAIL
Martin Storsjö [Tue, 11 Apr 2023 08:59:31 +0000 (11:59 +0300)]
[compiler-rt] [test] Remove a leftover XFAIL

This test succeeds on aarch64 windows now (tested both in mingw
mode and with clang-cl), most probably since commit
ccd96b3e03e18653e909852bfef105fc10782acb / D146667 ([builtins][test] Fix
divmodti4_test.c on Windows).

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

15 months ago[libcxx] [test] Check for C++ headers before building a test that uses them
Martin Storsjö [Wed, 29 Mar 2023 21:35:56 +0000 (00:35 +0300)]
[libcxx] [test] Check for C++ headers before building a test that uses them

When the libcxx test framework is executed within libunwind, there
are no standard C++ headers available (libunwind builds with
-nostdinc++, but doesn't add any libcxx headers to the include path).

Check that a test that includes <iostream> can be compiled before trying
to build and execute a test program that includes it.

Previously, the compile error here would block all libunwind tests from
executing altogether.

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

15 months ago[mlir][transform] TrackingListener: Drop mappings of tracked ops when all handles...
Matthias Springer [Wed, 12 Apr 2023 06:50:27 +0000 (15:50 +0900)]
[mlir][transform] TrackingListener: Drop mappings of tracked ops when all handles are dead

No replacement ops are needed for tracked ops who's handles are all dead.

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

15 months agoRemove forward declarations of llvm::Any
Kazu Hirata [Wed, 12 Apr 2023 06:52:05 +0000 (23:52 -0700)]
Remove forward declarations of llvm::Any

This patch removes forward declarations of llvm::Any as they are not
used.  Removing them gets us a bit closer to the world where we use
std::any instead of llvm::Any because we won't forward-declare std::
classes.

15 months agoAdd delete to fix resource leak in llc.cpp
Wang, Xin10 [Wed, 12 Apr 2023 06:49:02 +0000 (02:49 -0400)]
Add delete to fix resource leak in llc.cpp

From line 693 in file llc.cpp, it uses new operator to creates a ModulePass
and assigned to MMIWP. If the condition after take the true branch, it has
chance to go in to line 702 or line 709, the function will return without
cleaning the memory.
The second issue existed for the same reason, the ref TPC get the pointer
created from LLVMTM.createPassConfig, and will leak memory if goes into
line 709.
This patch uses delete in the issued branch.

Reviewed By: craig.topper

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

15 months ago[mlir][transform] Better debugging facilites for invalid API usage
Matthias Springer [Wed, 12 Apr 2023 06:41:40 +0000 (15:41 +0900)]
[mlir][transform] Better debugging facilites for invalid API usage

This revision adds additional "expensive-checks" checks to the transform dialect that detect the most common cases of:

* Missing `consumesHandle` side effects on transform ops.
* Patterns that remove operations but do not notify the transform dialect.

In essence, these additional checks are looking for dangling pointers to erased payload ops in the transform dialect state and crash the program execution (by dereferencing free'd memory) or triggering an assertion failure. It is recommended to run these extra checks with ASAN. Otherwise, certain failures may not be detected. The ASAN error message can also be used to find the faulty transform op/pattern.

This change also fixes a few faulty transform ops.

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

15 months ago[Windows SEH] Fix ehcleanup crash for Windows -EHa
Phoebe Wang [Wed, 12 Apr 2023 06:25:18 +0000 (14:25 +0800)]
[Windows SEH] Fix ehcleanup crash for Windows -EHa

`Builder.GetInsertBlock()` may return null sometimes. https://godbolt.org/z/n1Ph47jP1

Reviewed By: efriedma

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

15 months ago[Test] Regenerate checks in some tests using auto-update script
Max Kazantsev [Wed, 12 Apr 2023 06:41:51 +0000 (13:41 +0700)]
[Test] Regenerate checks in some tests using auto-update script

15 months ago[GVNHoist][NFC] Remove --check-globals in test file
luxufan [Wed, 12 Apr 2023 04:50:46 +0000 (12:50 +0800)]
[GVNHoist][NFC] Remove --check-globals in test file

15 months ago[GVNHoist][NFC] Regenerate test case
luxufan [Tue, 11 Apr 2023 12:59:35 +0000 (20:59 +0800)]
[GVNHoist][NFC] Regenerate test case

15 months ago[mlir][transform] Dump match failures in TrackingListener
Matthias Springer [Wed, 12 Apr 2023 03:54:21 +0000 (12:54 +0900)]
[mlir][transform] Dump match failures in TrackingListener

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

15 months ago[LoongArch] Optimize multiplication with immediates
Ben Shi [Wed, 12 Apr 2023 03:50:21 +0000 (11:50 +0800)]
[LoongArch] Optimize multiplication with immediates

Optimize (mul x, imm) to (ADD (SLLI x, s0), (SLLI x, s1)) or
(SUB (SLLI x, s0), (SLLI x, s1)) if possible.

Reviewed By: SixWeining

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

15 months ago[LoongArch][NFC] Add tests of multiplication with immediates
Ben Shi [Thu, 6 Apr 2023 08:27:06 +0000 (16:27 +0800)]
[LoongArch][NFC] Add tests of multiplication with immediates

Reviewed By: SixWeining

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

15 months ago[AVR] Disable post increment load from program memory space
Ben Shi [Fri, 7 Apr 2023 03:45:05 +0000 (11:45 +0800)]
[AVR] Disable post increment load from program memory space

We temporarily only allow post increment load/store from/to data memory,
and disable post increment load from program space.

Updates https://github.com/llvm/llvm-project/issues/59914

Reviewed By: mzh

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

15 months ago[mlir][sparse] Canonicalizing arguments to genReshapeDstShape and foreachInSparseConstant
wren romano [Tue, 11 Apr 2023 22:16:47 +0000 (15:16 -0700)]
[mlir][sparse] Canonicalizing arguments to genReshapeDstShape and foreachInSparseConstant

These functions don't need a`PatternRewriter`, they only need an `OpBuilder`.  And, the builder should be the first argument, before the `Location`, to match the style used everywhere else in MLIR.

Reviewed By: aartbik

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

15 months agoRevert "[AArch64][DAGCombiner]: combine <2xi64> add/sub."
Hassnaa Hamdi [Tue, 11 Apr 2023 23:04:41 +0000 (23:04 +0000)]
Revert "[AArch64][DAGCombiner]: combine <2xi64> add/sub."

This reverts commit 6a8d8f3e28aed1b77356be74ee5109d7bdd37dd1.

15 months ago[fuzzer] Fix -Wunreachable-code-aggressive warning in FuzzerDriver.cpp
Nico Weber [Tue, 11 Apr 2023 12:21:24 +0000 (08:21 -0400)]
[fuzzer] Fix -Wunreachable-code-aggressive warning in FuzzerDriver.cpp

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

15 months ago[BOLT] Fix creation of invalid CFG in presence of dead code
Rafael Auler [Tue, 11 Apr 2023 21:31:16 +0000 (14:31 -0700)]
[BOLT] Fix creation of invalid CFG in presence of dead code

When there is a direct jump right after an indirect one, in
the absence of code jumpting to this direct jump, this is obviously
dead code. However, BOLT was failing to recognize that by mistakenly
placing both jmp instructions in the same basic block, and creating
wrong successor edges. Fix that, so we can safely run UCE on
that. This bug also causes validateCFG to fail and BOLT to crash if it
is running ICP on that function.

Reviewed By: #bolt, Amir

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

15 months ago[lldb] Parse the crashlog only once
Jonas Devlieghere [Wed, 12 Apr 2023 00:03:49 +0000 (17:03 -0700)]
[lldb] Parse the crashlog only once

Now that we can pass Python objects to the scripted process instance, we
don't need to parse the crashlog twice anymore.

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

15 months ago[ORC] Fix fallout from switch to _objc_map/load_images-based registration.
Lang Hames [Tue, 11 Apr 2023 04:17:37 +0000 (21:17 -0700)]
[ORC] Fix fallout from switch to _objc_map/load_images-based registration.

In f448d44663a we switched to calling _objc_map_images and _objc_load_images
for MachO language metadata registration. This patch fixes some bugs arising
from that change:

(1) __objc_imageinfo processing was moved to a post-allocation pass, but this
    prevents us from discarding the redundant copies. This commit moves
    processing back to a pre-prune pass and inserts a symbol for the uniqued
    __objc_image section. Runtime objects use an edge pointing to this symbol
    to access the address.

(2) We were assuming that _objc_map_images & _objc_load_images were available
    in the Objective-C runtime on 10.15, but these functions didn't become
    available until later. This commit bumps the macOS version requirement to
    13.1 where the functions should be available.

(3) The ORC-RT trivial-swift-types-section.S test was missing an
    __objc_unwindinfo section, which triggered an assert that should have
    been an error. The assert has been turned into an error, and the testcase
    has been updated to include an __objc_imageinfo.

rdar://107846455

15 months ago[scudo] Temporariy dispatch region from `RegionBeg`
Chia-hung Duan [Tue, 11 Apr 2023 22:42:02 +0000 (22:42 +0000)]
[scudo] Temporariy dispatch region from `RegionBeg`

In general, a region is located from region base and has size
`RegionSize`. However, some platforms may not support mapping from
region base. Before we have each platform implements their specific
MemMap to handle the offset. Temporarily dispatch the region from
`RegionBeg` instead.

Reviewed By: cferris, fabio-d

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

15 months ago[test][lsan] Reset pointer to leak memory
Vitaly Buka [Tue, 11 Apr 2023 22:36:55 +0000 (15:36 -0700)]
[test][lsan] Reset pointer to leak memory

15 months ago[mlir][sparse][gpu] put sparse compiler GPU end-to-end tests back
Aart Bik [Tue, 11 Apr 2023 18:42:29 +0000 (11:42 -0700)]
[mlir][sparse][gpu] put sparse compiler GPU end-to-end tests back

SM80 flag guards the test for targets that do not support A100 GPUs

Reviewed By: mehdi_amini

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

15 months ago[lsan] Regression test for 7d328668691a
Vitaly Buka [Tue, 11 Apr 2023 22:32:22 +0000 (15:32 -0700)]
[lsan] Regression test for 7d328668691a

15 months ago[libc] Fix typo in gnu_ext.td
Caslyn Tonelli [Tue, 11 Apr 2023 21:18:29 +0000 (21:18 +0000)]
[libc] Fix typo in gnu_ext.td

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

15 months ago[-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating...
Ziqing Luo [Tue, 11 Apr 2023 22:01:59 +0000 (15:01 -0700)]
[-Wunsafe-buffer-usage] Match unsafe pointers being casted to bool or participating in pointer subtractions

Add two new unique cases to the Unspecified Pointer Context (UPC),
under which we match unsafe operation patterns:
- A pointer being casted to a boolean value is in a UPC;
- A pointer participating in pointer subtraction is in a UPC.

Reviewed by: NoQ (Artem Dergachev), malavikasamak (Malavika Samak)

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

15 months ago[lldb] Parse image high address from JSON crashlogs
Jonas Devlieghere [Tue, 11 Apr 2023 21:45:34 +0000 (14:45 -0700)]
[lldb] Parse image high address from JSON crashlogs

Use the base + size to correctly populate the image high address when
parsing JSON crashlogs.

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

15 months ago[bazel] Disable layering_check for llvm/unittests:mi_tests after D145707
Fangrui Song [Tue, 11 Apr 2023 21:44:43 +0000 (14:44 -0700)]
[bazel] Disable layering_check for llvm/unittests:mi_tests after D145707

15 months ago[clang-format] Don't modify template arguments on the LHS of assignment
Emilia Dreamer [Tue, 11 Apr 2023 21:33:12 +0000 (00:33 +0300)]
[clang-format] Don't modify template arguments on the LHS of assignment

After clang-format has determined that an equals sign starts an
expression, it will also go backwards and modify any star/amp/ampamp
binary operators on the left side of the assignment to be
pointers/references instead.

There already exists logic to skip over contents of parentheses and
square brackets, but this patch also expands that logic to apply to
angle brackets. This is so that binary operators inside of template
arguments would not be touched, primary arguments to non-type template
parameters.

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

Reviewed By: owenpan, MyDeveloperDay, HazardyKnusperkeks

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

15 months agoRevert (4) "[Assignment Tracking] Enable by default"
OCHyams [Tue, 11 Apr 2023 21:25:16 +0000 (22:25 +0100)]
Revert (4) "[Assignment Tracking] Enable by default"

This reverts commit a0525f09ac1eda3fbb74e8708b3aa5b7379df0c2 which
lands D146987.

Buildbot: https://lab.llvm.org/buildbot/#/builders/70/builds/36214

15 months ago[mlir][matchers] Add m_Op(StringRef) and m_Attr matchers
Devajith V S [Tue, 11 Apr 2023 20:55:59 +0000 (13:55 -0700)]
[mlir][matchers] Add m_Op(StringRef) and m_Attr matchers

This patch introduces support for m_Op with a StringRef argument and m_Attr matchers. These matchers will be very useful for mlir-query that is being developed currently.

Submitting this patch separately to reduce the final patch size and make it easier to upstream mlir-query.

Reviewed By: rriddle

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

15 months ago[libc] Add memmem implementation
Caslyn Tonelli [Fri, 7 Apr 2023 22:16:01 +0000 (22:16 +0000)]
[libc] Add memmem implementation

Introduce the `memmem` libc string function.

`memmem_implementation` performs shared logic for `strstr`,
`strcasestr`, and `memmem`; essentially reconfiguring what was the
`strstr_implementation` to support length parameters.

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

15 months ago[PATCH][lldb] Fix dereference of null pointer.
Caroline Tice [Mon, 10 Apr 2023 21:45:59 +0000 (14:45 -0700)]
[PATCH][lldb] Fix dereference of null pointer.

The function DWARFASTParserClang::ParsePointerToMemberType attempts to make
two pointers and then immediately tries to dereference them, without
verifying that the pointesr were successfully created. Sometimes the pointer
creation fails, and the dereference then causes a segfault. This add a check
that the pointers are non-null before attempting to dereference them.

15 months agoReapply (3) "[Assignment Tracking] Enable by default"
OCHyams [Tue, 11 Apr 2023 19:41:52 +0000 (20:41 +0100)]
Reapply (3) "[Assignment Tracking] Enable by default"

Re-land D146987.

This reverts commit 4f1954ed67c12aca3fd3e67151185c64dc941768 which
reverts D146987.

15 months ago[mlgo] Fix the help message for interactive mode default advice
Mircea Trofin [Tue, 11 Apr 2023 19:52:06 +0000 (12:52 -0700)]
[mlgo] Fix the help message for interactive mode default advice

This avoids the use-after-free introduced by D147794 and fixed
in 437dfa5b0365.

15 months ago[SLP][NFC]Introduce ShuffleCostEstimator and adjustExtracts member function.
Alexey Bataev [Fri, 7 Apr 2023 13:14:36 +0000 (06:14 -0700)]
[SLP][NFC]Introduce ShuffleCostEstimator and adjustExtracts member function.

Added ShuffleCostEstimator class and the first adjustExtracts member,
which is just a copy of previous AdjustExtractCost lambda.

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

15 months ago[clang-tidy] support nested inline namespace in c++20 for modernize-concat-nested...
Congcong Cai [Tue, 11 Apr 2023 18:45:49 +0000 (20:45 +0200)]
[clang-tidy] support nested inline namespace in c++20 for modernize-concat-nested-namespaces

Fixed https://github.com/llvm/llvm-project/issues/56022
c++20 support namespace like `namespace a::inline b {}`.
If an inline namespace is not the first, it can be concatened.

Reviewed By: PiotrZSL

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

15 months ago[clang] Add test for CWG1837
Vlad Serebrennikov [Tue, 11 Apr 2023 19:14:29 +0000 (22:14 +0300)]
[clang] Add test for CWG1837

[[https://wg21.link/p1787 | P1787]]: CWG1837 is resolved by restricting `this` to referring to the innermost enclosing class.
Wording: see changes to [expr.prim.this] and [expr.prim.lambda].

Reviewed By: #clang-language-wg, erichkeane

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

15 months ago[clang] Add test for CWG2007
Vlad Serebrennikov [Tue, 11 Apr 2023 19:12:57 +0000 (22:12 +0300)]
[clang] Add test for CWG2007

[[https://wg21.link/p1787 | P1787]]: CWG2007 is resolved by skipping unqualified lookup for operators that must be member functions.
Wording: For the operators =, [], or ->, the set of non-member candidates is empty; otherwise, it includes the result of the unqualified lookup for operator@... ([over.match.oper]/3)

Reviewed By: #clang-language-wg, shafik

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

15 months ago[clang] Add test for CWG2370
Vlad Serebrennikov [Tue, 11 Apr 2023 19:03:13 +0000 (22:03 +0300)]
[clang] Add test for CWG2370

[[https://wg21.link/p1787 | P1787]]: CWG2370 is resolved by performing a search in (only) the immediate scope of any friend, per the [[ http://wiki.edg.com/bin/view/Wg21sandiego2018/CoreWorkingGroup#Core_issue_2370_friend_declarati | CWG opinion from San Diego ]].
Wording: In a friend declaration declarator whose declarator-id is a qualified-id whose lookup context is a class or namespace S, lookup for an unqualified name that appears after the declarator-id performs a search in the scope associated with S. If that lookup finds nothing, it undergoes unqualified name lookup. ([basic.lookup.unqual]/6).

Clarification for P1787 description: when applied to the test in this patch, "immediate scope" refers to `N`, and "(only)" refers to the fact that `type` is not searched in parent scope of `N`. See example after the wording if additional clarification is needed. The most relevant line there is `friend void A::f(F);  // OK`.

Reviewed By: #clang-language-wg, shafik

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

15 months ago[RISCV] Add segment load/store to getTgtMemIntrinsic.
Craig Topper [Tue, 11 Apr 2023 18:30:15 +0000 (11:30 -0700)]
[RISCV] Add segment load/store to getTgtMemIntrinsic.

15 months ago[hwasan] Don't require untagged pointer in __hwasan_tag_memory
Vitaly Buka [Wed, 5 Apr 2023 23:46:42 +0000 (16:46 -0700)]
[hwasan] Don't require untagged pointer in __hwasan_tag_memory

Use likely have tagged pointer. I see no value making user to untag it.

Reviewed By: fmayer

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