495344 Commits

Author SHA1 Message Date
David Blaikie
9ac0315898 Add comment to assert from a843f26 2024-03-12 18:28:30 +00:00
Noah Goldstein
5ca325e49c [InstCombine] Detect (x ^ -x) as a ~Mask
Proof: https://alive2.llvm.org/ce/z/TAFmPw

This is a lemma for clearing up some of the regressions that #84688
causes.

Closes #84868
2024-03-12 13:26:18 -05:00
Noah Goldstein
377da51546 [InstCombine] Add test for detecting (x ^ -x) as a ~Mask; NFC 2024-03-12 13:26:18 -05:00
David Blaikie
a843f26a77
[NFC] SLVectorizer comparator refactoring that preserves behavior (#84966)
Spinning off from #79321 / 35f4592 - looked like the comparator could be
simplified & made more clear/less risk of leaving hidden bugs.
2024-03-12 11:25:12 -07:00
amilendra
42ecccfe34
[libcxx] Fix incorrect type in the has-1024-bit-atomics feature test (#84904) 2024-03-12 14:17:13 -04:00
Adrian Prantl
536e0ebaaa Remove XFAIL from tests passing on green dragon 2024-03-12 11:06:23 -07:00
Fangrui Song
f1ca2a0967
[ELF] Add --compress-section to compress matched non-SHF_ALLOC sections
--compress-sections <section-glib>=[none|zlib|zstd] is similar to
--compress-debug-sections but applies to broader sections without the
SHF_ALLOC flag. lld will report an error if a SHF_ALLOC section is
matched. An interesting use case is to compress `.strtab`/`.symtab`,
which consume a significant portion of the file size (15.1% for a
release build of Clang).

An older revision is available at https://reviews.llvm.org/D154641 .
This patch focuses on non-allocated sections for safety. Moving
`maybeCompress` as D154641 does not handle STT_SECTION symbols for
`-r --compress-debug-sections=zlib` (see `relocatable-section-symbol.s`
from #66804).

Since different output sections may use different compression
algorithms, we need CompressedData::type to generalize
config->compressDebugSections.

GNU ld feature request: https://sourceware.org/bugzilla/show_bug.cgi?id=27452

Link: https://discourse.llvm.org/t/rfc-compress-arbitrary-sections-with-ld-lld-compress-sections/71674

Pull Request: https://github.com/llvm/llvm-project/pull/84855
2024-03-12 10:56:14 -07:00
Simon Pilgrim
c1af6ab505 [X86] getFauxShuffleMask - recognise CONCAT(SUB0, SUB1) style patterns
Handles the INSERT_SUBVECTOR(INSERT_SUBVECTOR(UNDEF,SUB0,0),SUB1,N) pattern

Currently limited to v8i64/v8f64 cases as only AVX512 has decent cross lane 2-input shuffles, the plan is to relax this as I deal with some regressions
2024-03-12 17:40:19 +00:00
Jun Wang
c4e517f59c
[AMDGPU] Adding the amdgpu_num_work_groups function attribute (#79035)
A new function attribute named amdgpu_num_work_groups is added. This
attribute, which consists of three integers, allows programmers to let
the compiler know the number of workgroups to be launched in each of the
three dimensions and do optimizations based on that information.

---------

Co-authored-by: Jun Wang <jun.wang7@amd.com>
2024-03-12 10:30:39 -07:00
Hiroshi Yamauchi
93503aafcd
Fix MSVC build issues (#84362)
MSVC fails when there is ambiguity (multiple options) around implicit
type conversion operators.

Make ConstString's conversion operator to string_view explicit to avoid
ambiguity with one to StringRef and remove an unused local variable that
MSVC also fails on.
2024-03-12 10:26:44 -07:00
Diego A. Estrada Rivera
7bee91fadf
[analyzer][NFC] Turn NodeBuilderContext into a class (#84638)
From issue #73088. I changed `NodeBuilderContext` into a class.
Additionally, there were some other mentions of the former being a
struct which I also changed into a class. This is my first time working
with an issue so I will be open to hearing any advice or changes that
need to be done.
2024-03-12 18:21:31 +01:00
Simon Pilgrim
683a9ac803 [X86] combineVectorPack - use APInt::truncSSat for PACKSS constant folding. NFC.
Unfortunately PACKUS can't use APInt::truncUSat
2024-03-12 17:10:27 +00:00
Mark de Wever
e09761944c
[libc++] Improves UB handling in ios_base destructor. (#76525)
Destroying an ios_base object before it is properly initialized is
undefined behavior. Unlike typical C++ classes the initialization is not
done in the constructor, but in a dedicated init function. Due to
virtual inheritance of the basic_ios object in ostream and friends this
undefined behaviour can be triggered when inheriting from classes that
can throw in their constructor and inheriting from ostream.

Use the __loc_ member of ios_base as sentinel to detect whether the
object has or has not been initialized.

Addresses https://github.com/llvm/llvm-project/issues/57964
2024-03-12 18:04:14 +01:00
Matt Arsenault
bd72ebd8d1
AMDGPU: Add some more mfma hazard recognizer tests (#84727) 2024-03-12 22:05:47 +05:30
XChy
c8cc7903b3
[SelectionDAG] Replace some basic patterns in visitADDLike with SDPatternMatch (#84759)
Resolves #84745.

Based on SDPatternMatch introduced by #78654, this patch replaces some
of basic patterns in `visitADDLike` with corresponding patterns in
SDPatternMatch.

This patch only replaces original folds, instead of introducing new ones.
2024-03-13 00:33:50 +08:00
Balazs Benics
fe8cf2fc90
[clang][ASTMatchers] Fix forEachArgumentWithParam* for deducing "this" operator calls (#84887)
This is a follow-up commit of #84446.
In this patch, I demonstrate that `forEachArgumentWithParam` and
`forEachArgumentWithParamType` did not correctly handle the presence of
the explicit object parameter for operator calls.

Prior to this patch, the matcher would skip the first (and only)
argument of the operator call if the explicit object param was used.

Note that I had to move the definition of
`isExplicitObjectMemberFunction`, to be declared before the matcher I
fix to be visible.

I also had to do some gymnastics for passing the language standard
version command-line flags to the invocation as
`matchAndVerifyResultTrue` wasn't really considered for non-c++11 code.
See the that it always prepends `-std=gnu++11` to the command-line
arguments. I workarounded it by accepting extra args, which get
appended, thus possibly overriding the hardcoded arguments.

I'm not sure if this qualifies for backporting to clang-18 (probably not
because its not a crash, but a semantic problem), but I figure it might
be useful for some vendors (like us).
But we are also happy to cherry-pick this fix to downstream. Let me know
if you want this to be backported or not.

CPP-5074
2024-03-12 17:31:22 +01:00
Mark de Wever
af21659c8c
[libc++][CI] Installs tzdata package in Docker. (#84643)
This allows testing the time zone information in the CI. This is needed
to let https://github.com/llvm/llvm-project/pull/82108 pass the CI.
2024-03-12 17:28:15 +01:00
Mark de Wever
65eea3e5dc
[libc++][TZDB] Fixes parsing interleaved rules. (#84808)
Typically the rules in the database are contiguous, but that is not a
requirement. This fixes the case when they are not.

---------

Co-authored-by: Louis Dionne <ldionne.2@gmail.com>
2024-03-12 17:26:39 +01:00
Jake Egan
fa1d13590c [AIX][tests] Disable failing tests on AIX
These new tests are failing on the AIX bot because the -I option isn't supported.

Disable these tests for now until they can be fixed.
2024-03-12 12:11:18 -04:00
Jason Molenda
87dc068280
[lldb] [debugserver] Handle interrupted reads correctly (#84872)
The first half of this patch is a long-standing annoyance, if I attach
to debugserver with lldb while it is waiting for an lldb connection, the
syscall is interrupted and it doesn't retry, debugserver exits
immediately.

The second half is a request from another tool that is communicating
with debugserver, that we retry reads on our sockets in the same way. I
haven't dug in to the details of how they're communicating that this is
necessary, but the best I've been able to find reading the POSIX API
docs, this is fine.

rdar://117113298
2024-03-12 09:03:28 -07:00
Nick Desaulniers
0ebf511ad0
[libc] move non <bit> functions to math_extras (#84818)
As per TODOs added in

48b0bc8370.
2024-03-12 08:44:06 -07:00
Joseph Huber
261e5648e7
[libc] Add utility functions for warp-level scan and reduction (#84866)
Summary:
The GPU uses a SIMT execution model. That means that each value actually
belongs to a group of 32 or 64 other lanes executing next to it. These
platforms offer some intrinsic fuctions to actually take elements from
neighboring lanes. With these we can do parallel scans or reductions.
These functions do not have an immediate user, but will be used in the
allocator interface that is in-progress and are generally good to have.
This patch is a precommit for these new utilitly functions.
2024-03-12 10:40:49 -05:00
Joseph Huber
c167a25887
[libc] Fix lane-id utility function not using built-in (#84902)
Summary:
Previously we got the lane-id from taking the global thread ID and
taking off the bottom 5 bits. This works but is inefficient compared to
the NVPTX intrinsic simply dedicated to get this value.
2024-03-12 10:40:35 -05:00
Nick Desaulniers
392436383a
[libc] fix typo in stdbit.h macro spec files (#84780) 2024-03-12 08:39:50 -07:00
Joseph Huber
9f69d3cf88
[Libomptarget] Use NVPTX lane id intrinsic in DeviceRTL (#84928)
Summary:
We are currently taking the lower 5 bites of the thread ID as the warp
ID. This doesn't work in non-1D grids and is also slower than just using
the dedicated hardware register.
2024-03-12 10:39:40 -05:00
Nick Desaulniers
f0c0ddae45
[libc] implement the final macros for stdbit.h support (#84798)
Relevant sections of n3096:
- 7.18.1p1
- 7.18.2
2024-03-12 08:39:17 -07:00
Nick Desaulniers
bae47d48b6
[libc] fix another build failure from using limits.h (#84827)
My GCC build is failing with issues similar why we added our own. Looks
like
we missed one spot. See also:

commit 72ce62941579 ("[libc] Add C23 limits.h header. (#78887)")
2024-03-12 08:38:34 -07:00
Nemanja Ivanovic
08dd645c15
[RISC-V] Bad immediate value for Zcmp instructions with E extension (#84925)
When we are using the Zcmp extension together with the E extension in
32-bit mode and we need to spill both callee-saved registers as well as
needing a couple of 32-bit stack slots, we emit a meaningless stack
adjustment with cm.push/cm.popret. Furthermore this leads to the stack
slot for the ra being clobbered so control returns to a random location.

This is just a pre-commit test so that the PR for the fix shows the
difference in code generation.
2024-03-12 16:26:49 +01:00
Nikita Popov
beba307c5b [LSR] Clear SCEVExpander before deleting phi nodes
Fixes https://github.com/llvm/llvm-project/issues/84709.
2024-03-12 16:24:10 +01:00
Bjorn Pettersson
4d0f79e346 Pre commit test cases SRL/SRA support in canCreateUndefOrPoison. NFC
Add test cases to show that we can't push freeze through SRA/SRL with
'exact' flag when there are multiple uses.
2024-03-12 16:03:18 +01:00
Bjorn Pettersson
3238b92142 [LoopSimplifyCFG] Drop no longer needed DependenceAnalysis.h include 2024-03-12 16:03:18 +01:00
Ben Langmuir
083da46ff0
[clang][deps] Fix dependency scanning with -working-directory (#84525)
Stop overriding -working-directory to CWD during argument parsing, which
should no longer necessary after we set the VFS working directory, and
set FSOpts correctly after parsing arguments so that working-directory
behaves correctly.
2024-03-12 08:02:54 -07:00
NagyDonat
f32b04d4ea
Revert "[analyzer] Accept C library functions from the std namespace" (#84926)
Reverts llvm/llvm-project#84469 because it causes buildbot failures.
I'll examine them and re-submit the change.
2024-03-12 16:01:04 +01:00
Fanbo Meng
0fe271c353
[SystemZ][z/OS] Add missing include header to AutoConvert.cpp to fix build (#84909)
ba13fa2a5d57581bff1a7e9322234af30f4882f6
added usages of `errnoAsErrorCode()` to AutoConvert.cpp, need to include
Error.h header to fix build failure.
2024-03-12 10:56:51 -04:00
Stephen Tozer
15f3f446c5
[RemoveDIs][NFC] Rename common interface functions for DPValues->DbgRecords (#84793)
As part of the effort to rename the DbgRecord classes, this patch
renames the widely-used functions that operate on DbgRecords but refer
to DbgValues or DPValues in their names to refer to DbgRecords instead;
all such functions are defined in one of `BasicBlock.h`,
`Instruction.h`, and `DebugProgramInstruction.h`.

This patch explicitly does not change the names of any comments or
variables, except for where they use the exact name of one of the
renamed functions. The reason for this is reviewability; this patch can
be trivially examined to determine that the only changes are direct
string substitutions and any results from clang-format responding to the
changed line lengths. Future patches will cover renaming variables and
comments, and then renaming the classes themselves.
2024-03-12 14:53:13 +00:00
Nico Weber
0aefd702f6 [gn] port bde7a6b791872b 2024-03-12 10:48:59 -04:00
bvlgah
2cae13d605
[DominanceFrontierBase] Fix doc of compare()'s return value. (#81352)
This is a trivial fix ( I guess it has not been noticed because of no
use). Currently, the doc says the function returns `true` if two
instances of `DominanceFrontierBase` matches, otherwise `false` is
returned. I have checked the implementation


9308d6688c/llvm/include/llvm/Analysis/DominanceFrontierImpl.h (L71-L94)

which examines whether two dominance frontier mappings are equal, and
the actual value it returns contradicts the description in the doc.
2024-03-12 14:46:18 +00:00
Florian Hahn
a3ad5faa32
[LAA] Fix typo IndidrectUnsafe -> IndirectUnsafe.
Fix type in textual analysis output.
2024-03-12 14:44:04 +00:00
harishch4
a4aac22683
[Flang][OpenMp] Fix to threadprivate not working with host-association. (#74966)
This patch considers host-associated variables to generate threadprivate
Ops.

Fixes: #60763 #84561
2024-03-12 20:04:35 +05:30
Kupa-Martin
f8fab2126f
[Clang][Sema] Fix type of enumerators in incomplete enumerations (#84068)
Enumerators dont have the type of their enumeration before the closing
brace. In these cases Expr::getEnumCoercedType() incorrectly returned
the enumeration type.

Introduced in PR #81418
Fixes #84712
2024-03-12 10:21:34 -04:00
Danial Klimkin
afd4758703
Revert "[NVPTX] Add support for atomic add for f16 type" (#84918)
Reverts llvm/llvm-project#84295 due to breakages.
2024-03-12 15:01:18 +01:00
Jonas Paulsson
9f7ed36f92
Don't do casting of atomic FP loads/stores in FE. (#83446)
The casting of FP atomic loads and stores were always done by the
front-end, even though the AtomicExpandPass will do it if the target
requests it (which is the default).

This patch removes this casting in the front-end entirely.
2024-03-12 09:53:11 -04:00
Stefan Gränitz
ffd31c5e92 Fix build after #84460: link LLVMTestingSupport explicitly in clang unittest
This is supposed to fix the DYLIB-enabled build, i.e. https://lab.llvm.org/buildbot/#/builders/196
2024-03-12 14:47:23 +01:00
Florian Hahn
d96d917f38
[Matrix] Add tests showing mis-compile with lifetime.end and fusion.
Add a set of tests showing miscompiles due to multiply fusion
introducing loads to dead objects after lifetime.end.
2024-03-12 13:33:55 +00:00
Jie Fu
f03aaa3c0c [clang] Silence -Wlogical-op-parentheses in Clang.cpp (NFC)
llvm-project/clang/lib/Driver/ToolChains/Clang.cpp:2721:49:
error: '&&' within '||' [-Werror,-Wlogical-op-parentheses]
        !Option.empty() && !NegateFortranOption && !NegateLimitedOption)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
llvm-project/clang/lib/Driver/ToolChains/Clang.cpp:2721:49:
note: place parentheses around the '&&' expression to silence this warning
        !Option.empty() && !NegateFortranOption && !NegateLimitedOption)
                                                ^
        (                                                              )
1 error generated.
2024-03-12 21:24:37 +08:00
Danial Klimkin
ee137e234c
Update BUILD.bazel for 80ab8234ac309418637488b97e0a62d8377b2ecf (#84908) 2024-03-12 14:21:04 +01:00
Stefan Gränitz
bde7a6b791
[clang-repl] Expose CreateExecutor() and ResetExecutor() in extended Interpreter interface (#84460)
IncrementalExecutor is an implementation detail of the Interpreter. In
order to test extended features properly, we must be able to setup and
tear down the executor manually.
2024-03-12 13:55:38 +01:00
Krzysztof Parzyszek
871086bf7f
[flang] Avoid passing null pointers to nonnull parameters (#84785)
Certain functions in glibc have "nonnull" attributes on pointer
parameters (even in cases where passing a null pointer should be handled
correctly). There are a few cases of such calls in flang: memcmp and
memcpy with the length parameter set to 0.

Avoid passing a null pointer to these functions, since the conflict with
the nonnull attribute could cause an undefined behavior.

This was detected by the undefined behavior sanitizer.
2024-03-12 07:53:57 -05:00
Sven van Haastregt
c7f1a987a6 [OpenCL] Elaborate about BIenqueue_kernel expansion; NFC 2024-03-12 12:53:22 +00:00
Krzysztof Parzyszek
629afd4dea
[flang][Lower] Fix use-after-free with TypeRange (#84369)
TypeRange is an iterator range, it does not own storage spanned by the
iterators. When using TypeRange, make sure that the actual contents
don't "expire" while the range is in use.

This was detected by address sanitizer.
2024-03-12 07:52:48 -05:00