462929 Commits

Author SHA1 Message Date
Peter Klausler
71d5a94985
[flang] Don't fold SIZE()/SHAPE() into expression referencing optional dummy arguments
When computing the shape of an expression at compilation time as part of
folding an intrinsic function like SIZE(), don't create an expression that
increases a dependence on the presence of an optional dummy argument.

Differential Revision: https://reviews.llvm.org/D151737
2023-05-31 08:57:18 -07:00
Nikita Popov
660e453012 [KnownBits] Also test 1-bit values in exhaustive tests (NFC)
Similar to what we do with ConstantRanges, also test 1-bit values
in exhaustive tests, as these often expose special conditions.
This would have exposed the assertion failure fixed in D151788
earlier.
2023-05-31 17:50:01 +02:00
Kazu Hirata
6eef8d9b2b [RISCV] Fix an unused variable warning
llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp:3793:7:
 error: unused variable 'XLenVT' [-Werror,-Wunused-variable]
2023-05-31 08:45:29 -07:00
Simon Pilgrim
d6a36619ce [X86] X86FixupVectorConstantsPass - use VBROADCASTSS/VBROADCASTSD for integer vector loads on AVX1-only targets
Matches behaviour in lowerBuildVectorAsBroadcast
2023-05-31 16:39:09 +01:00
Mark de Wever
f29f1c7e23 [libc++]{CI] Bumps clang-tidy version used.
The CI can no longer run with clang-tidy 16 increment it to version 17.
Whether permanently moving to the latest development version is being
discussed on Discourse.

Depends on D149455

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D151628
2023-05-31 17:25:42 +02:00
Mark de Wever
cf64668b8c [libc++][test] Prefers the newer clang-tidy version.
Module require Clang 17, since Clang 16 requires the magic # __FILE__
line. Therefore, if available, use clang-tidy 17 too. This change should
be reverted after LLVM 17 is released.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D149455
2023-05-31 17:24:37 +02:00
Mark de Wever
5d4281d549 [libc++] Gives ignore external linkage.
A slightly different fix is in D144994.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D151490
2023-05-31 17:22:52 +02:00
Mark de Wever
ac7d60f73a [libc++] Fixes use-after move diagnostic.
The diagnostic is issued by clang-tidy 17.

This just suppressed the diagnostic. The move operations are non-standard extensions and the class itself is deprecated.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D151223
2023-05-31 17:21:38 +02:00
Dave Lee
7578672c96 [lldb] Override GetVariable in ValueObjectSynthetic (NFC)
Make `GetVariable` a passthrough function the the underlying value object in `ValueObjectSynthetic`.

Differential Revision: https://reviews.llvm.org/D151384
2023-05-31 08:19:36 -07:00
Nikita Popov
42e98c6ae8 [APInt] Support zero-width extract in extractBitsAsZExtValue()
D111241 added support for extractBits() with zero width. Extend this
to extractBitsAsZExtValue() as well for consistency (in which case
it will always return zero).

Differential Revision: https://reviews.llvm.org/D151788
2023-05-31 17:13:48 +02:00
Nico Weber
3825910c73 [gn] port 4369de7af466 2023-05-31 11:12:32 -04:00
Dave Lee
cb463c34dd [lldb] Take StringRef name in GetChildMemberWithName (NFC)
`GetChildMemberWithName` does not need a `ConstString`. This change makes the function
take a `StringRef` instead, which alleviates the need for callers to construct a
`ConstString`. I don't expect this change to improve performance, only ergonomics.

This is in support of Alex's effort to replace `ConstString` where appropriate.

There are related `ValueObject` functions that can also be changed, if this is accepted.

Differential Revision: https://reviews.llvm.org/D151615
2023-05-31 08:08:40 -07:00
Paul Scoropan
e0df106818 [Flang] Move several definitions to IntrinsicCall header for code cleanliness and reusability
In the future we intend to add support for many PowerPC-specific intrinsics that ideally will exist in a separate new PPCIntrinsicCall file. But first we need to move definitions to the IntrinsicCall header file to increase code cleanliness and readability and to make code reusable for when we add PPCIntrinsicCall.

Reviewed By: vzakhari

Differential Revision: https://reviews.llvm.org/D151715
2023-05-31 15:03:53 +00:00
Florian Hahn
572cfa3fde
[LV] Use SCEV for uniformity analysis across VF
This patch uses SCEV to check if a value is uniform across a given VF.

The basic idea is to construct SCEVs where the AddRecs of the loop are
adjusted to reflect the version in the vectorized loop (Step multiplied
by VF). We construct a SCEV for the value of the vector lane 0
(offset 0) compare it to the expressions for lanes 1 to the last vector
lane (VF - 1). If they are equal, consider the expression uniform.

While re-writing expressions, we also need to catch expressions we
cannot determine uniformity (e.g. SCEVUnknown).

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D148841
2023-05-31 16:01:00 +01:00
Marco Elver
4369de7af4 [compiler-rt] Avoid memintrinsic calls inserted by the compiler
D135716 introduced -ftrivial-auto-var-init=pattern where supported.
Unfortunately this introduces unwanted memset() for large stack arrays,
as shown by the new tests added for asan and msan (tsan already had this
test).

In general, the problem of compiler-inserted memintrinsic calls
(memset/memcpy/memmove) is not new to compiler-rt, and has been a
problem before.

To avoid introducing unwanted memintrinsic calls, we redefine
memintrinsics as __sanitizer_internal_mem* at the assembly level for
most source files automatically (where sanitizer_common_internal_defs.h
is included).

In few cases, redefining a symbol in this way causes issues for
interceptors, namely the memintrinsic interceptor themselves. For such
source files we have to selectively disable the redefinition.

Other alternatives have been considered, but simply do not work well in
the context of compiler-rt:

	1. Linker --wrap:  this does not work because --wrap only
	   applies to the final link, and would not apply when building
	   sanitizer static libraries.

	2. Changing references to memset() via objcopy:  this may work,
	   but due to the complexities of the build system, introducing
	   such a post-processing step for the right object files (in
	   particular object files defining memset cannot be touched)
	   seems infeasible.

The chosen solution works well (as shown by the tests). Other libraries
have chosen the same solution where nothing else works (see e.g. glibc's
"symbol-hacks.h").

v2:
- Fix ubsan_minimal build where compiler decides to insert
  memset/memcpy: ubsan_minimal has work without RTSanitizerCommonLibc,
  therefore do not redefine the builtins.
- Fix definition of internal_mem* functions with compilers that want the
  aliased function to already be defined before.
- Fix definition of __sanitizer_internal_mem* functions with compilers
  more pedantic about attribute placement around extern "C".

Reviewed By: vitalybuka, dvyukov

Differential Revision: https://reviews.llvm.org/D151152
2023-05-31 16:58:53 +02:00
Michael Liao
26d7b7bb8f [TableGen] Add !getdagarg and !getdagname
- This patch proposes to add `!getdagarg` and `!getdagname` bang
  operators as the inverse operation of `!dag`. They allow us to examine
  arguments of a given dag.

Reviewed By: simon_tatham

Differential Revision: https://reviews.llvm.org/D151602
2023-05-31 10:54:43 -04:00
Philip Reames
e69318138e [RISCV] Use v(f)slide1down for shuffle+insert idiom
This is a follow up to D151468 which added the vslide1down case as a sub-case of vslide1down matching. This generalizes that code into generic mask matching - specifically to point out the sub-vector insert restriction in the original patch. Since the matching logic is basically the same, go ahead and support vslide1up at the same time.

Differential Revision: https://reviews.llvm.org/D151742
2023-05-31 07:53:51 -07:00
Nikita Popov
5442264744 [InstCombine] Name instructions in test (NFC) 2023-05-31 16:39:54 +02:00
Kazu Hirata
f9b523ebc3 [Analysis] Remove unused class LegacyAARGetter
The last use was removed by:

  commit fa6ea7a419f37befbed04368bcb8af4c718facbb
  Author: Arthur Eubanks <aeubanks@google.com>
  Date:   Mon Mar 20 11:18:35 2023 -0700

Once we remove it, createLegacyPMAAResults and createLegacyPMAAResults
become unused, so this patch removes them as well.

Differential Revision: https://reviews.llvm.org/D151787
2023-05-31 07:30:14 -07:00
Fangrui Song
8634b43a03 [ELF][RISCV] --wrap=foo: Correctly update st_value(foo)
With --wrap=foo, we may have `d->file != file` for a defined symbol `foo`.
For the object file defining `foo`, its symbol table may not contain
`foo` after `redirectSymbols` changed the `foo` entry to `__wrap_foo` (see D50569).

Therefore, skipping `foo` with the condition `if (!d || d->file != file)` may
cause `__wrap_foo` not to be updated. See `ab.o w.o --wrap=foo` in the new test
(originally reported by D150220).

We could adjust the condition to `if (!d)`, but that would leave many `anchors`
entries if a symbol is referenced by many files. Switch to iterating over
`symtab` instead.

Note: D149735 (actually not NFC) allowed duplicate `anchors` entries and fixed
`a.o bw.o --wrap=foo`.

Reviewed By: jobnoorman

Differential Revision: https://reviews.llvm.org/D151768
2023-05-31 07:19:44 -07:00
Tom Eccles
408f4196ba [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

The old differential revision for this patch was
https://reviews.llvm.org/D150853

Re-applying here fixing the issue which led to the patch being reverted. The
issue was from erasing uses of the allocation operation while still iterating
over those uses (leading to a use-after-free). I have added a regression
test which catches this bug for -fsanitize=address builds, but it is
hard to reliably cause a crash from the use-after-free in normal builds.

Differential Revision: https://reviews.llvm.org/D151728
2023-05-31 14:06:57 +00:00
Paul Robinson
543705641a [Headers][doc] Fix typo in avx2intrin.h doc 2023-05-31 06:43:38 -07:00
Jan Sjodin
f6a631d406 [MLIR] Remove dependency on omp dialect in LLVM dialect.
This fixes a buildbot failure where the dependency on the omp dialect
in the LLVM dialect caused error. Instead of accessing the interface
defined in the omp dialect we directly access the attributes
instead. To make this work the IsDeviceAttr is removed and replaced
with a BoolAttr instead.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D151745
2023-05-31 08:40:22 -05:00
Paul Robinson
e5399f1d7c [Headers][doc] Add shuffle-like intrinsic descriptions to avx2intrin.h
Differential Revision: https://reviews.llvm.org/D151749
2023-05-31 06:33:18 -07:00
Dmitry Makogon
0a3dc73e70 [Test] Move LoopStrengthReduce/pr62563.ll to X86 specific test folder (NFC)
The test case is X86 specific. Should unblock buildbots after 253e3e2.
2023-05-31 20:24:30 +07:00
Florian Hahn
6bcbb3af05
[ConstraintElim] Move logic to remove stack entry to helper (NFC).
Preparation for follow-up patch that uses the logic in a separate place.
2023-05-31 14:22:45 +01:00
Nikita Popov
97f0e7b06e [AA] Fix comparison of AliasResults (PR63019)
Comparison between two AliasResults implicitly decayed to comparison
of AliasResult::Kind. As a result, MergeAliasResults() ended up
considering two PartialAlias results with different offsets as
equivalent.

Fix this by adding an operator== implementation. To stay
compatible with extensive use of comparisons between AliasResult
and AliasResult::Kind, add an overload for that as well, which
will ignore the offset. In the future, it would probably be a
good idea to remove these implicit decays to AliasResult::Kind
and add dedicated methods to check for specific AliasResult kinds.

Fixes https://github.com/llvm/llvm-project/issues/63019.
2023-05-31 15:03:41 +02:00
Nikita Popov
4d64ffa941 [GVN] Add test for PR63019 (NFC) 2023-05-31 14:55:25 +02:00
Arnaud Bienner
ce97312d10 Implement BufferOverlap check for sprint/snprintf
Differential Revision: https://reviews.llvm.org/D150430
2023-05-31 14:43:16 +02:00
LLVM GN Syncbot
0b42ee46b0 [gn build] Port 26bda9e95a9d 2023-05-31 12:30:10 +00:00
Thorsten Schütt
dd2fea9c23 [GlobalIsel][X86] Legalize G_CTLZ and G_CTPOP for 32-bit
Note that 32-bit support is very limited

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D151459
2023-05-31 14:24:52 +02:00
Nico Weber
344e91a6f0 [gn] port 301eb6b68f3 (AttrTokenKinds.inc) 2023-05-31 08:21:36 -04:00
rikhuijzer
64bd5bbb9b [mlir] Avoid tensor canonicalizer crash on negative dimensions
Fixes #59703.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D151611
2023-05-31 14:14:30 +02:00
Guillaume Chatelet
c76a3e795e [libc][NFC] Fixing various typos 2023-05-31 12:11:09 +00:00
Simon Pilgrim
7030c01c92 [X86] Replace X32 test check prefix with X86
We try to only use X32 for gnux32 triple test cases
2023-05-31 13:01:51 +01:00
Simon Pilgrim
6432658825 [X86] Replace X32 test check prefixes with X86
We try to only use X32 for gnux32 triple test cases
2023-05-31 13:01:50 +01:00
Benjamin Chetioui
981766a3d6 [mlir][bazel] Disable Transform/test-repro-dump.mlir test in bazel build. 2023-05-31 11:50:48 +00:00
Dmitry Makogon
253e3e2619 [Test] Add test showing miscompilation in LoopStrengthReduce on min/max expressions (NFC)
This is a test case from https://github.com/llvm/llvm-project/issues/62563.
2023-05-31 18:46:23 +07:00
Simon Pilgrim
f1a42300aa [X86] printConstant - fix asm comment issue when broadcasting from a wider constant pool entry
In cases where a broadcast op is loading from a constant entry wider than the broadcast element, we were incorrectly printing the entire entry and not just the lower bits referenced by the broadcast.
2023-05-31 12:28:17 +01:00
Simon Pilgrim
65dce67f16 [X86] getTargetConstantBitsFromNode - ensure we truncate broadcasts from wider constants.
We might be broadcasting the lower portion of a wider constant pool entry, ensure we truncate the full width of the constant back to the broadcast width.

(This also exposes an issue with how asm comments print these constants - I'll address that in a followup).

Fixes #63030
2023-05-31 12:08:02 +01:00
Simon Pilgrim
b85f42a4a6 [X86] Replace X32 test check prefixes with X86
We try to only use X32 for gnux32 triple test cases
2023-05-31 12:08:02 +01:00
Timm Bäder
2e676fad26 Revert "[clang][Interp] Optionally cast comparison result to non-bool"
This reverts commit 81522a012accfcc6bbf4dfa21a793aea6e4e532a.

Looks like we're not ready for this yet:
https://lab.llvm.org/buildbot/#/builders/139/builds/41797
2023-05-31 13:07:40 +02:00
Timm Bäder
81522a012a [clang][Interp] Optionally cast comparison result to non-bool
Our comparison opcodes always produce a Boolean value and push it on the
stack. However, the result of such a comparison in C is int, so the
later code expects an integer value on the stack.

Work around this problem by casting the boolean value to int in those
cases. This is not ideal for C however. The comparison is usually
wrapped in a IntegerToBool cast anyway.

Differential Revision: https://reviews.llvm.org/D149645
2023-05-31 13:01:01 +02:00
Haojian Wu
b2f4e75b66 [bazel] Port for 301eb6b68f30074ee3a90e2dfbd11dfd87076323 2023-05-31 12:49:21 +02:00
Timm Bäder
722fc7e7ff [clang][Interp] Add missing static_assert messages 2023-05-31 12:28:22 +02:00
Dhruv Chawla
3b3912e9b8 Reapply [SelectionDAG] Handle NSW for ADD/SUB in computeKnownBits()
This exposed a miscompile due to incorrect flag preservation in
integer type legalization, which has been fixed in D151472.

-----

This patch is a continuation of D150110. It separates the cases for
ADD and SUB into their own cases so that computeForAddSub can be
directly called and the NSW flag passed. This allows better
optimization when the NSW flag is enabled, and allows fixing up the
TODO that was there previously in SimplifyDemandedBits.

Differential Revision: https://reviews.llvm.org/D150769
2023-05-31 12:25:41 +02:00
Marco Elver
26bda9e95a Revert "[compiler-rt] Avoid memintrinsic calls inserted by the compiler"
This reverts commit e614d5667f6c6fc6c645587cb9aee1a058285454.

Build bot failures:

| FAILED: lib/clang/17/lib/linux/libclang_rt.ubsan_minimal-i386.so
| : && /usr/bin/clang++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete   -m32 -nodefaultlibs -Wl,-z,text -nostdlib++ -shared -Wl,-soname,libclang_rt.ubsan_minimal-i386.so -o lib/clang/17/lib/linux/libclang_rt.ubsan_minimal-i386.so projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o  -lgcc_s  -lc && :
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_type_mismatch_minimal':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:120: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_type_mismatch_minimal_abort':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:120: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_alignment_assumption_minimal':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:121: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_alignment_assumption_minimal_abort':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:121: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o: in function `__ubsan_handle_add_overflow_minimal':
| /b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:122: undefined reference to `__sanitizer_internal_memcpy'
| /usr/bin/ld: projects/compiler-rt/lib/ubsan_minimal/CMakeFiles/RTUbsan_minimal.i386.dir/ubsan_minimal_handlers.cpp.o:/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp:122: more undefined references to `__sanitizer_internal_memcpy' follow

Link: https://lab.llvm.org/buildbot#builders/74/builds/19569
2023-05-31 12:20:19 +02:00
OCHyams
f40e8f14d6 [Assignment Tracking] Ignore stores to a negative offset from an alloca
Fixes crash reported in llvm.org/PR62838.

Reviewed By: jryans

Differential Revision: https://reviews.llvm.org/D151326
2023-05-31 11:17:20 +01:00
Timm Bäder
da836b36bc [clang][Interp] Track frame depth
Save the depth of each InterpFrame and bail out if we're too deep.

Differential Revision: https://reviews.llvm.org/D148614
2023-05-31 12:08:03 +02:00
Nico Weber
a2e3b6f8c5 [gn] Port e614d5667f6c 2023-05-31 06:07:38 -04:00