Nikita Popov [Fri, 29 Apr 2022 13:08:17 +0000 (15:08 +0200)]
[InstCombine] Add test for unused atomic load from non-constant global (NFC)
Nikita Popov [Wed, 27 Apr 2022 15:19:52 +0000 (17:19 +0200)]
[SelectionDAGBuilder] Don't create MGATHER/MSCATTER with Scale != ElemSize
This is an alternative to
D124530. In getUniformBase() only create
scales that match the gather/scatter element size. If targets also
support other scales, then they can produce those scales in target
DAG combines. This is what X86 already does (as long as the
resulting scale would be 1, 2, 4 or 8).
This essentially restores the pre-opaque-pointer state of things.
Fixes https://github.com/llvm/llvm-project/issues/55021.
Differential Revision: https://reviews.llvm.org/
D124605
Jean Perier [Fri, 29 Apr 2022 12:52:27 +0000 (14:52 +0200)]
[flang] Handle common block with different sizes in same file
Semantics is not preventing a named common block to appear with
different size in a same file (named common block should always have
the same storage size (see Fortran 2018 8.10.2.5), but it is a common
extension to accept different sizes).
Lowering was not coping with this well, since it just use the first
common block appearance, starting with BLOCK DATAs to define common
blocks (this also was an issue with the blank common block, which can
legally appear with different size in different scoping units).
Semantics is also not preventing named common from being initialized
outside of a BLOCK DATA, and lowering was dealing badly with this,
since it only gave an initial value to common blocks Globals if the
first common block appearance, starting with BLOCK DATAs had an initial
value.
Semantics is also allowing blank common to be initialized, while
lowering was assuming this would never happen, and was never creating
an initial value for it.
Lastly, semantics was not complaining if a COMMON block was initialized
in several scoping unit in a same file, while lowering can only generate
one of these initial value.
To fix this, add a structure to keep track of COMMON block properties
(biggest size, and initial value if any) at the Program level. Once the
size of a common block appearance is know, the common block appearance
is checked against this information. It allows semantics to emit an error
in case of multiple initialization in different scopes of a same common
block, and to warn in case named common blocks appears with different
sizes. Lastly, this allows lowering to use the Program level info about
common blocks to emit the right GlobalOp for a Common Block, regardless
of the COMMON Block appearances order: It emits a GlobalOp with the
biggest size, whose lowest bytes are initialized with the initial value
if any is given in a scope where the common block appears.
Lowering is updated to go emit the common blocks before anything else so
that the related GlobalOps are available when lowering the scopes where
common block appear. It is also updated to not assume that blank common
are never initialized.
Differential Revision: https://reviews.llvm.org/
D124622
Nikita Popov [Thu, 21 Apr 2022 13:57:37 +0000 (15:57 +0200)]
[InstCombine] Remove memset of undef value
This removes memset with undef char. We already do this for stores
of undef value.
This comes with the caveat that this optimization is not, strictly
speaking, legal for undef values, because we might be overwriting
a poison value. However, our entire load/store model currently still
operates on undef values, so we need to support undef here as well
for internal consistency.
Once https://github.com/llvm/llvm-project/issues/52930 is resolved,
these and related folds can be limited to poison -- I've added
FIXMEs to that effect.
Differential Revision: https://reviews.llvm.org/
D124173
Ricky Zhou [Fri, 29 Apr 2022 12:42:00 +0000 (13:42 +0100)]
[LV] Rename CountRoundDown to VectorTripCount (NFC)
The name CountRoundDown is potentially misleading, as the number of
iterations can be rounded up when folding the tail.
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/
D119681
Nikita Popov [Fri, 29 Apr 2022 10:49:52 +0000 (12:49 +0200)]
[InstCombine] Fold logical and/or of range icmps with nowrap flags
This is an edge-case where we don't convert to bitwise and/or based
on implies poison reasoning, so explicitly try to perform the fold
in logical form. The transform itself is poison-safe, as both icmps
are based on the same value and any nowrap flags are discarded as
part of the fold (https://alive2.llvm.org/ce/z/aCwC8b for the used
example).
Matthias Springer [Fri, 29 Apr 2022 12:34:41 +0000 (21:34 +0900)]
[mlir][linalg][transform] Add TileOp to transform dialect
This commit adds a tiling op to the transform dialect as an external op.
Differential Revision: https://reviews.llvm.org/
D124661
Florian Hahn [Fri, 29 Apr 2022 12:34:54 +0000 (13:34 +0100)]
[VPlan] Simplify & adjust code as suggested in
D123005.
Improve code as suggested in
D123005. Applied separately, because the
comments where made a diff that has not been rebased to current main.
David Spickett [Fri, 29 Apr 2022 12:22:33 +0000 (12:22 +0000)]
[lldb] Allow EXE or exe in toolchain-msvc.test
I suspect that one of link or cl is found by shutil.which
and one isn't, hence the case difference. It doesn't really
matter for what the test is looking for.
NAKAMURA Takumi [Fri, 29 Apr 2022 11:15:07 +0000 (20:15 +0900)]
llvm/Support/Debug.h: Suppress warnings with -Asserts. [-Wunused-variable]
Re. setCurrentDebugTypes(X,N), the only user is llvm-ml.cpp (exc. DebugTests)
since
llvmorg-15-init-8355-g82ecf9a0b1b3.
FIXME: X and N are evaluated regardless of NDEBUG.
Could we avoid evaluating (but w/o warnings) with NDEBUG?
NAKAMURA Takumi [Fri, 29 Apr 2022 11:32:46 +0000 (20:32 +0900)]
AVRExpandPseudoInsts.cpp: Fix a warning. [-Wunused-but-set-variable]
It has been enabled since
llvmorg-15-init-5683-g2af845a6519c, aka
D122271.
Paul Walker [Tue, 5 Apr 2022 16:49:01 +0000 (17:49 +0100)]
[DAGCombiner][SVE] Ensure MGATHER/MSCATTER addressing mode combines preserve index scaling
refineUniformBase and selectGatherScatterAddrMode both attempt the
transformation:
base(0) + index(A+splat(B)) => base(B) + index(A)
However, this is only safe when index is not implicitly scaled.
Differential Revision: https://reviews.llvm.org/
D123222
David Spickett [Fri, 29 Apr 2022 11:21:59 +0000 (11:21 +0000)]
Reland "[lldb] Use shutil.which in Shell tests find_executable"
This reverts commit
d9247cc84825539d346c74eb1379c6cb948d3a71.
With the Windows tests updated to expect .EXE suffixes. This changed
because shutil.which uses PATHEXT which will contain, amongst others,
"EXE".
Also I noticed the "." in ".exe" was the wildcard dot not literal
dot so I've escaped those.
Nikita Popov [Fri, 29 Apr 2022 11:24:04 +0000 (13:24 +0200)]
[InstCombine] Add test for is_alpha check with logical or and nsw (NFC)
The combination of logical or and nsw prevents the fold from
happening.
Jay Foad [Fri, 29 Apr 2022 11:05:27 +0000 (12:05 +0100)]
[AMDGPU] Simplify the test case for
D124450
Simon Pilgrim [Fri, 29 Apr 2022 11:08:27 +0000 (12:08 +0100)]
[X86] SimplifyDemandedVectorEltsForTargetNode - fold (uniform) shift(0,x) -> 0
Sam McCall [Fri, 29 Apr 2022 11:08:28 +0000 (13:08 +0200)]
[include-cleaner] Add missing deps from unittests
David Spickett [Fri, 29 Apr 2022 11:02:59 +0000 (11:02 +0000)]
Revert "[lldb] Use shutil.which in Shell tests find_executable"
This reverts commit
713752610edd3d8766f56e2704bb7241434cd15b.
Some test output needs updating for Windows builders:
https://lab.llvm.org/buildbot/#/builders/83/builds/18356
Nikita Popov [Fri, 29 Apr 2022 10:45:42 +0000 (12:45 +0200)]
[InstCombine] Pass ICmpInsts to foldAndOrOfICmpsUsingRanges() (NFC)
Pass the whole instruction rather than unpacking it. This makes it
easier to reuse the function in another place, as the entire
logic is encapsulated.
Simon Pilgrim [Fri, 29 Apr 2022 10:32:22 +0000 (11:32 +0100)]
[X86] SimplifyDemandedVectorEltsForTargetNode - fold shift(0,x) -> 0
Nikita Popov [Fri, 29 Apr 2022 10:15:03 +0000 (12:15 +0200)]
[InstCombine] Remove foldAndOrOfEqualityCmpsWithConstants() fold
This fold handles a special subset of foldAndOrOfICmpsUsingRanges(),
use the more generic implementation instead.
The result can differ if a representation using a range comparison
is possible, in which case that is preferred over masking. There is
a canonicalization opportunity here.
Florian Hahn [Fri, 29 Apr 2022 10:09:19 +0000 (11:09 +0100)]
[OCaml] Remove add_loop_unswitch use in test.
Nikita Popov [Fri, 29 Apr 2022 09:31:12 +0000 (11:31 +0200)]
[InstCombine] Fold and of two ranges differing by mask
This is the de Morgan conjugated variant of the existing fold for
ors. Implement this by switching the range code to always work
on ors and perform invert operands at the start and end. This makes
reasoning easier and makes the extension more obviosuly correct.
David Spickett [Thu, 28 Apr 2022 10:24:49 +0000 (10:24 +0000)]
[lldb] Use shutil.which in Shell tests find_executable
In build.py we have our own find_executable that looks
a lot like the distutils one that I switched to shutil.which.
This find_executable isn't quite the same as shutil.which
so I've refactored it to call that in the correct way.
Note that the path passed to shutil.which is in the form that
PATH would be, meaning separators are allowed.
```
>>> shutil.which("gcc", path="/home/david.spickett:/bin")
'/bin/gcc'
```
We just need to make sure it doesn't ignore the existing PATH
and normalise the result if it does find the binary.
The .exe extension is automatically added to the binary name
if we are on Windows.
Depends on
D124601
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/
D124604
Florian Hahn [Fri, 29 Apr 2022 09:53:17 +0000 (10:53 +0100)]
Remove loop-unswitch from various bindings.
LoopUnswitch has been removed in
fb4113ef0c8b.
Also remove it from various bindings.
LLVM GN Syncbot [Fri, 29 Apr 2022 09:40:01 +0000 (09:40 +0000)]
[gn build] Port
fb4113ef0c8b
Nikita Popov [Fri, 29 Apr 2022 09:38:16 +0000 (11:38 +0200)]
[InstCombine] Add tests for and of two ranges differing by mask (NFC)
Florian Hahn [Fri, 29 Apr 2022 09:30:49 +0000 (10:30 +0100)]
[Passes] Remove legacy LoopUnswitch pass.
The legacy LoopUnswitch pass is only used in the legacy pass manager
pipeline, which is deprecated.
The NewPM replacement is SimpleLoopUnswitch and I think it is time to
remove the legacy LoopUnswitch code.
Fixes #31000.
Reviewed By: aeubanks, Meinersbur, asbirlea
Differential Revision: https://reviews.llvm.org/
D124376
Simon Pilgrim [Fri, 29 Apr 2022 09:30:11 +0000 (10:30 +0100)]
[X86] combineShuffle - reuse SDLoc. NFCI.
Simon Pilgrim [Fri, 29 Apr 2022 09:20:39 +0000 (10:20 +0100)]
[X86] Fold ANDNP(undef,x)/ANDNP(x,undef) -> 0
Matches the fold in DAGCombiner::visitANDLike.
Nikita Popov [Thu, 28 Apr 2022 15:14:18 +0000 (17:14 +0200)]
[InstCombine] Switch an or of icmps fold to use constant ranges
We can express this fold more naturally when working on the constant
range implementation. This change is not entirely NFC, because the
code now also handles cases that don't match the precise pattern
this previously looked for, e.g. we can omit an add on one of the
ranges.
Nikita Popov [Fri, 29 Apr 2022 09:13:50 +0000 (11:13 +0200)]
[InstCombine] Add additional test for icmp of two ranges (NFC)
Sam McCall [Wed, 13 Apr 2022 19:13:34 +0000 (21:13 +0200)]
[include-cleaner] Include-cleaner library structure, and simplistic AST walking.
Include-cleaner is a library that uses the clang AST and preprocessor to
determine which headers are used. It will be used in clang-tidy, in
clangd, in a standalone tool at least for testing, and in out-of-tree tools.
Roughly, it walks the AST, finds referenced decls, maps these to
used sourcelocations, then to FileEntrys, then matching these against #includes.
However there are many wrinkles: dealing with macros, standard library
symbols, umbrella headers, IWYU directives etc.
It is not built on the C++20 modules concept of usage, to allow:
- use with existing non-modules codebases
- a flexible API embeddable in clang-tidy, clangd, and other tools
- avoiding a chicken-and-egg problem where include cleanups are needed
before modules can be adopted
This library is based on existing functionality in clangd that provides
an unused-include warning. However it has design changes:
- it accommodates diagnosing missing includes too (this means tracking
where references come from, not just the set of targets)
- it more clearly separates the different mappings
(symbol => location => header => include) for better testing
- it handles special cases like standard library symbols and IWYU directives
more elegantly by adding unified Location and Header types instead of
side-tables
- it will support some customization of policy where necessary (e.g.
for style questions of what constitutes a use, or to allow
both missing-include and unused-include modes to be conservative)
This patch adds the basic directory structure under clang-tools-extra
and a skeleton version of the AST traversal, which will be the central
piece.
A more end-to-end prototype is in https://reviews.llvm.org/
D122677
RFC: https://discourse.llvm.org/t/rfc-lifting-include-cleaner-missing-unused-include-detection-out-of-clangd/61228
Differential Revision: https://reviews.llvm.org/
D124164
David Spickett [Thu, 28 Apr 2022 09:12:18 +0000 (09:12 +0000)]
[lldb] Use shutil.which instead of distutils find_executable
distutils is deprecated and shutil.which is the suggested
replacement for this function.
https://peps.python.org/pep-0632/#migration-advice
https://docs.python.org/3/library/shutil.html#shutil.which
It was added in Python3.3 but given that we're already using
shutil.which elsewhere I think this is ok/no worse than before.
We do have our own find_executable in lldb/test/Shell/helper/build.py
but I'd rather leave that as is for now. Also we have our own versions
of which() but again, a change for another time.
This work is part of #54337.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/
D124601
David Green [Fri, 29 Apr 2022 08:30:02 +0000 (09:30 +0100)]
[VecCombine] Fix sort comparator logic in foldShuffleFromReductions
I think this sort comparator was overly complex, and the windows
expensive check bot agreed, failing as it was not giving a strict weak
ordering. Change it to use the comparison of the mask values as unsigned
integers. This should sort the undef elements to the end whilst keeping
X<Y otherwise.
Nikita Popov [Fri, 29 Apr 2022 07:48:21 +0000 (09:48 +0200)]
[SimplifyCFG] Replace condition value when threading
Replace the condition value with the known constant value on the
threaded edge. This happens implicitly with phi threading because
we replace with the incoming value, but not for non-phi threading.
Daniel Kiss [Fri, 29 Apr 2022 07:40:55 +0000 (09:40 +0200)]
Disable test for Android/Bionic.
Test depends on pthread_cancel which is not supported on Android.
Nikita Popov [Wed, 20 Apr 2022 15:37:13 +0000 (17:37 +0200)]
[SimplifyCFG] Thread branches on same condition in more cases (PR54980)
SimplifyCFG implements basic jump threading, if a branch is
performed on a phi node with constant operands. However,
InstCombine canonicalizes such phis to the condition value of a
previous branch, if possible. SimplifyCFG does support this as
well, but only in the very limited case where the same condition
is used in a direct predecessor -- notably, this does not include
the common diamond pattern (i.e. two consecutive if/elses on the
same condition).
This patch extends the code to look back a limited number of
blocks to find a branch on the same value, rather than only
looking at the direct predecessor.
Fixes https://github.com/llvm/llvm-project/issues/54980.
Differential Revision: https://reviews.llvm.org/
D124159
Joao Moreira [Fri, 29 Apr 2022 06:32:48 +0000 (14:32 +0800)]
[X86] Fix CodeGen Module Flag for -mibt-seal
When assertions are enabled, clang will perform RoundTrip for CompilerInvocation argument generation. ibt-seal flags are currently missing in this argument generation, and because of that, the feature doesn't get enabled for these cases. Performing RoundTrip is the default for assert builds, rendering the feature broken in these scenarios.
This patch fixes this and adds a test to properly verify that modules are being generated with the flag when -mibt-seal is used.
Please, add any known relevant reviewer which I may have missed.
[1] - https://reviews.llvm.org/
D116070
Reviewed By: pengfei, gftg, aaron.ballman, nickdesaulniers
Differential Revision: https://reviews.llvm.org/
D118052
Serge Pavlov [Mon, 29 Nov 2021 07:26:02 +0000 (14:26 +0700)]
[SystemZ] Custom lowering of llvm.is_fpclass
Differential Revision: https://reviews.llvm.org/
D114695
Fangrui Song [Fri, 29 Apr 2022 05:29:39 +0000 (22:29 -0700)]
[ELF][test] Improve data-segment-relro.test
LiaoChunyu [Fri, 29 Apr 2022 05:18:26 +0000 (13:18 +0800)]
[RISCV] Add cost model for SK_Broadcast
Add cost model for broadcast shuffle in RISCVTTIImpl::getShuffleCost
with scalable vector. The cost model might not the best.
For scalable vector, BasicTTIImpl::getShuffleCost return invalid cost,
so this patch relies on the existing cost model in BasicTTIImpl.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/
D124101
jonasyhwang [Fri, 29 Apr 2022 04:58:53 +0000 (12:58 +0800)]
[Clang][CodeGen]Fix __builtin_dump_struct missing record type field name
Thanks for @rsmith to point this. I'm sorry for introducing this bug.
See @rsmith 's comment in https://reviews.llvm.org/
D122248
Eg:(By @rsmith ) https://godbolt.org/z/o7vcbWaEf
I have added a test case
struct:
```
struct U19A {
int a;
};
struct U19B {
struct U19A a;
};
struct U19B a = {
.a.a = 2022
};
```
Dump result:
```
struct U19B {
struct U19A a = {
int a = 2022
}
}
```
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/
D122920
Hsiangkai Wang [Fri, 22 Apr 2022 01:41:09 +0000 (01:41 +0000)]
[RISCV] Merge addi into load/store as there is a ADD between them
This patch adds peephole optimizations for the following patterns:
(load (add base, (addi src, off1)), off2)
-> (load (add base, src), off1+off2)
(store val, (add base, (addi src, off1)), off2)
-> (store val, (add base, src), off1+off2)
Differential Revision: https://reviews.llvm.org/
D124231
Serge Pavlov [Tue, 9 Nov 2021 11:20:59 +0000 (18:20 +0700)]
[PowerPC] Support of ppc_fp128 in lowering of llvm.is_fpclass
PowerPC supports `ppc_fp128`, which is not an IEEE floating point
type. The generic lowering of llvm.is_fpclass could not handle it
properly. This change extends the generic lowering code to
support `ppc_fp128`.
The change was tested on emulator using runtime tests from
https://reviews.llvm.org/
D112933 and the patch for clang
https://reviews.llvm.org/
D112932.
Differential Revision: https://reviews.llvm.org/
D113908
Vitaly Buka [Fri, 29 Apr 2022 02:14:52 +0000 (19:14 -0700)]
[asan] Enable detect_stack_use_after_return=1 by default on Linux
By default -fsanitize=address already compiles with this check, why not use it.
For compatibly it can be disabled with env ASAN_OPTIONS=detect_stack_use_after_return=0.
Reviewed By: eugenis, kda, #sanitizers, hans
Differential Revision: https://reviews.llvm.org/
D124057
Qiongsi Wu [Fri, 29 Apr 2022 04:02:59 +0000 (00:02 -0400)]
Reland: [clang] Adding Platform/Architecture Specific Resource Header Installation Targets
The goal of this patch is to improve distribution build's flexibility to include only applicable header files.
Currently, the clang-resource-headers target contains nearly all the files in clang/lib/Headers. Most of these files are platform specific (e.g. immintrin.h is x86 specific). A distribution build will have to either include all the headers for all the platforms, or not include any headers. For example, if a distribution build for powerpc includes the clang-resource-headers target, it will include all the x86 specific headers, even-though the x86 specific headers cannot be used.
This patch breaks up the clang-resource-headers list to a core list and platform specific lists. With the patch, a distribution build can now include the ppc-resource-headers to include the headers applicable to the powerpc platform.
Specifically, one can now have
cmake ... LLVM_DISTRIBUTION_COMPONENTS="clang;ppc-resource-headers" ... ../llvm
ninja install-distribution then installs the powerpc headers.
Similarly, one can do
cmake ... LLVM_DISTRIBUTION_COMPONENTS="clang;x86-resource-headers" ... ../llvm
to include headers applicable to the x86 platform in a distribution installation.
To implement this behaviour, the patch does two things
It breaks up the long files header file list to a core list and platform specific lists.
It adds numerous platform specific installation targets.
Differential Revision: https://reviews.llvm.org/
D123498
Douglas Gliner [Fri, 29 Apr 2022 03:41:47 +0000 (20:41 -0700)]
[CMake] Ensure correct extension for llvm-lit is used on Windows when LLVM_INSTALL_UTILS is enabled.
D77110 initially added support for setting LLVM_CONFIG_DEFAULT_EXTERNAL_LIT
to llvm-lit in the install directory if LLVM_INSTALL_UTILS is on.
D79144 ensured that, on Windows, llvm-lit.py is correctly set for
LLVM_CONFIG_DEFAULT_EXTERNAL_LIT within the context of the build area,
however, it did not account for the install area which is the latter set
directive for this same variable.
This patch ensures that LLVM_CONFIG_DEFAULT_EXTERNAL_LIT under the install
area uses llvm-lit.py under Windows since llvm-lit without the extension
is not created.
Differential Revision: https://reviews.llvm.org/
D124197
Ken Matsui [Thu, 28 Apr 2022 19:45:55 +0000 (15:45 -0400)]
[NFC] Prevent shadowing a variable declared in `if`
Prevents confusion over which `S` is referenced in the final `else`
branch if such use is added.
Reviewed By: hubert.reinterpretcast
Differential Revision: https://reviews.llvm.org/
D124556
Vitaly Buka [Tue, 19 Apr 2022 03:37:28 +0000 (20:37 -0700)]
[msan][libcxx] Enable -fsanitize-memory-param-retval
We are considering to make -fsanitize-memory-param-retval enabled by default so probably this patch is unnneded.
Reviewed By: #libc, EricWF
Differential Revision: https://reviews.llvm.org/
D123979
Duncan P. N. Exon Smith [Thu, 28 Apr 2022 06:43:35 +0000 (23:43 -0700)]
Frontend: Delete output streams before closing CompilerInstance outputs
Delete the output streams coming from
CompilerInstance::createOutputFile() and friends once writes are
finished. Concretely, replacing `OS->flush()` with `OS.reset()` in:
- `ExtractAPIAction::EndSourceFileAction()`
- `PrecompiledPreambleAction::setEmittedPreamblePCH()`
- `cc1_main()'s support for `-ftime-trace`
This fixes theoretical bugs related to proxy streams, which may have
cleanups to run in their destructor. For example, a proxy that
CompilerInstance sometimes uses is `buffer_ostream`, which wraps a
`raw_ostream` lacking pwrite support and adds it. `flush()` does not
promise that output is complete; `buffer_ostream` needs to wait until
the destructor to forward anything so that it can service later calls to
`pwrite()`. If the destructor isn't called then the proxied stream
hasn't received any content.
This also protects against some logic bugs, triggering a null
dereference on a later attempt to write to the stream.
No tests, since in practice these particular code paths never use
use `buffer_ostream`; you need to be writing a binary file to a
pipe (such as stdout) to hit it, but `-extract-api` writes a text file
and the other two use computed filenames that will never (in practice)
be a pipe. This is effectively NFC, for now.
But I have some other patches in the works that add guard rails,
crashing if the stream hasn't been destructed by the time the
CompilerInstance is told to keep the output file, since in most cases
this is a problem.
Differential Revision: https://reviews.llvm.org/
D124635
Artem Dergachev [Wed, 23 Mar 2022 04:45:24 +0000 (21:45 -0700)]
[analyzer] Add path note tags to standard library function summaries.
The patch is straightforward except the tiny fix in BugReporterVisitors.cpp
that suppresses a default note for "Assuming pointer value is null" when
a note tag from the checker is present. This is probably the right thing to do
but also definitely not a complete solution to the problem of different sources
of path notes being unaware of each other, which is a large and annoying issue
that we have to deal with. Note tags really help there because they're nicely
introspectable. The problem is demonstrated by the newly added getenv() test.
Differential Revision: https://reviews.llvm.org/
D122285
Yaxun (Sam) Liu [Wed, 30 Mar 2022 14:33:03 +0000 (10:33 -0400)]
[CUDA][HIP] Fix mangling number for local struct
MSVC and Itanium mangling use different mangling numbers
for function-scope structs, which causes inconsistent
mangled kernel names in device and host compilations.
This patch uses Itanium mangling number for structs
in for mangling device side names in CUDA/HIP host
compilation on Windows to fix this issue.
A state is added to ASTContext to indicate whether the
current name mangling is for device side names in host
compilation. Device and host mangling number
are encoded/decoded as upper and lower half of 32 bit
unsigned integer to fit into the original mangling number
field for AST. Diagnostic will be emitted if a manglining
number exceeds limit.
Reviewed by: Artem Belevich, Reid Kleckner
Differential Revision: https://reviews.llvm.org/
D122734
Fixes: SWDEV-328515
Roman Lebedev [Thu, 28 Apr 2022 20:17:57 +0000 (23:17 +0300)]
[NFC][SCEV] Refactor `createNodeForSelectViaUMinSeq()` out of `createNodeForSelectOrPHIViaUMinSeq()`
Roman Lebedev [Thu, 28 Apr 2022 19:35:37 +0000 (22:35 +0300)]
[NFC][SCEV] Tests with modellable pointer `select`s
Zequan Wu [Thu, 28 Apr 2022 23:17:12 +0000 (16:17 -0700)]
Revert "[DebugInfo][InstrRef] Describe value sizes when spilt to stack"
This reverts commit
a15b66e76d1ecff625a4bbb4a46ff83a43138f49.
This causes linker to crash at assertion: `Assertion failed: !Expr->isComplex(), file C:\b\s\w\ir\cache\builder\src\third_party\llvm\llvm\lib\CodeGen\LiveDebugValues\InstrRefBasedImpl.cpp, line 907`.
wlei [Sun, 24 Apr 2022 19:07:54 +0000 (12:07 -0700)]
[llvm-profgen] Decouple artificial branch from LBR parser and fix external address related issues
This patch is fixing two issues for both CS and non-CS.
1) For external-call-internal, the head samples of the the internal function should be recorded.
2) avoid ignoring LBR after meeting the interrupt branch for CS profile
LBR parser is shared between CS and non-CS, we found it's error-prone while dealing with artificial branch inside LBR parser. Since artificial branch is mainly used for CS profile unwinding, this patch tries to simplify LBR parser by decoupling artificial branch code from it, the concept of artificial branch is removed and split into two transitional branches(internal-to-external, external-to-internal). Then we leave all the processing of external branch to unwinder.
Specifically for unwinder, remembering that we introduce external frame in https://reviews.llvm.org/
D115550. We can just take external address as a regular address and reuse current unwind function(unwindCall, unwindReturn). For a normal case, the external frame will match an external LBR, and it will be filtered out by `unwindLinear` without losing any context.
The data also shows that the interrupt or standalone LBR pattern(unpaired case) does exist, we choose to handle it by clearing the call stack and keeping unwinding. Here we leverage checking in `unwindLinear`, because a standalone LBR, no matter its type, since it doesn’t have other part to pair, it will eventually cause a wrong linear range, like [external, internal], [internal, external]. Then set the state to invalid there.
Reviewed By: hoy, wenlei
Differential Revision: https://reviews.llvm.org/
D118177
Jonas Devlieghere [Thu, 28 Apr 2022 22:40:17 +0000 (15:40 -0700)]
[lldb] Remove ConnectionFileDescriptorTest.Connectv(4|6)
These tests are timing out on the bots.
Argyrios Kyrtzidis [Wed, 27 Apr 2022 21:31:54 +0000 (14:31 -0700)]
[Tooling/DependencyScanning] Make skipping excluded PP ranges during dependency scanning the default
This is to improve maintenance a bit and remove need to maintain the additional option and related code-paths.
Differential Revision: https://reviews.llvm.org/
D124558
Mircea Trofin [Thu, 28 Apr 2022 22:10:21 +0000 (15:10 -0700)]
[NFC] remove const from FunctionPropertiesAnalysis::run, keep on Result
The goal in
75881d8b023e was just modifying what `Result` is, didn't
need to also modify ::run.
Jonas Devlieghere [Thu, 28 Apr 2022 19:48:14 +0000 (12:48 -0700)]
[lldb] Fix crash when launching in terminal
This patch fixes a crash when using process launch -t to launch the
inferior from a TTY. The issue is that on Darwin, Host.mm is calling
ConnectionFileDescriptor::Connect without a socket_id_callback_type. The
overload passes nullptr as the function ref, which gets called
unconditionally as the socket_id_callback.
One potential way to fix this is to change all the lambdas to include a
null check, but instead I went with an empty lambda.
Differential revision: https://reviews.llvm.org/
D124535
CHIANG, YU-HSUN (Tommy Chiang, oToToT) [Fri, 22 Apr 2022 01:54:15 +0000 (09:54 +0800)]
[MC][AArch64] Enable '+v8a' when nothing specified for MCSubtargetInfo
Since
D110065, the 'R' profile support is added to LLVM. It turns the
`generic` cpu into the intersection of v8-a and v8-r. However, this
makes some backward compatibility problems. The original patch makes
the clang driver implicitly pass -march=armv8-a when only the triple
is specified. Since it only applies to clang, other tools like
llvm-objdump still faces the backward compatibility problem.
This patch applies the same idea to MC related tools by enabling '+v8a'
feature when nothing is specified (both CPU and FS are empty) for
MCSubtargetInfo creation.
This patch should fix PR53956.
Reviewed by: labrinea
Differential Revision: https://reviews.llvm.org/
D124319
Alexey Moksyakov [Thu, 28 Apr 2022 20:34:03 +0000 (23:34 +0300)]
[BOLT] Fix r_aarch64_prelxx test
The relocation value is calculated using the formula S + A - P,
the verification of the value is performed by inversely calculating the location address
Reviewed By: Amir
Differential Revision: https://reviews.llvm.org/
D124270
Benjamin Kramer [Thu, 28 Apr 2022 20:51:27 +0000 (22:51 +0200)]
[bazel] Port
92a836da0759
Yuanfang Chen [Thu, 28 Apr 2022 20:37:07 +0000 (13:37 -0700)]
[lit][unit] set the default result start and pid
In case of interrupting, there were None. Fixes PR55176.
David Penry [Thu, 28 Apr 2022 20:23:22 +0000 (13:23 -0700)]
Revert "[CodeGen][ARM] Enable Swing Module Scheduling for ARM"
This reverts commit
28d09bbbc3d09c912b54a4d5edb32cab7de32a6f
while I investigate a buildbot failure.
Simon Pilgrim [Thu, 28 Apr 2022 20:28:16 +0000 (21:28 +0100)]
[X86] Don't fold AND(SRL(X,Y),1) -> SETCC(BT(X,Y)) on BMI2 targets
With BMI2 we have SHRX which is a lot quicker than regular x86 shifts.
Fixes #55138
Craig Topper [Thu, 28 Apr 2022 19:47:58 +0000 (12:47 -0700)]
[RISCV] Add riscv32 RUN lines to bittest.ll. NFC
Add extra check-prefixes to merge common results.
David Penry [Tue, 29 Mar 2022 17:13:55 +0000 (10:13 -0700)]
[CodeGen][ARM] Enable Swing Module Scheduling for ARM
This patch permits Swing Modulo Scheduling for ARM targets
turns it on by default for the Cortex-M7. The t2Bcc
instruction is recognized as a loop-ending branch.
MachinePipeliner is extended by adding support for
"unpipelineable" instructions. These instructions are
those which contribute to the loop exit test; in the SMS
papers they are removed before creating the dependence graph
and then inserted into the final schedule of the kernel and
prologues. Support for these instructions was not previously
necessary because current targets supporting SMS have only
supported it for hardware loop branches, which have no
loop-exit-contributing instructions in the loop body.
The current structure of the MachinePipeliner makes it difficult
to remove/exclude these instructions from the dependence graph.
Therefore, this patch leaves them in the graph, but adds a
"normalization" method which moves them in the schedule to
stage 0, which causes them to appear properly in kernel and
prologues.
It was also necessary to be more careful about boundary nodes
when iterating across successors in the dependence graph because
the loop exit branch is now a non-artificial successor to
instructions in the graph. In additional, schedules with physical
use/def pairs in the same cycle should be treated as creating an
invalid schedule because the scheduling logic doesn't respect
physical register dependence once scheduled to the same cycle.
Reviewed By: dmgreen
Differential Revision: https://reviews.llvm.org/
D122672
River Riddle [Tue, 26 Apr 2022 20:29:45 +0000 (13:29 -0700)]
[mlir:PDLL] Fix the import of native constraints from ODS
We weren't properly returning the result of the constraint,
which leads to errors when actually trying to use the generated
C++.
Differential Revision: https://reviews.llvm.org/
D124586
River Riddle [Tue, 26 Apr 2022 20:27:03 +0000 (13:27 -0700)]
[mlir:PDLL] Fix error handling of eof within a string literal
We currently aren't handling this properly, and in the case
of a string block just crash. This commit adds proper error handling
and detection for eof.
Differential Revision: https://reviews.llvm.org/
D124585
River Riddle [Tue, 26 Apr 2022 20:05:23 +0000 (13:05 -0700)]
[mlir:LSP] Improve conversion between SourceMgr and LSP locations
SourceMgr generally uses 1-based locations, whereas the LSP is zero based.
This commit corrects this conversion and also enhances the conversion from SMLoc
to SMRange to support string tokens.
Differential Revision: https://reviews.llvm.org/
D124584
River Riddle [Tue, 26 Apr 2022 19:18:27 +0000 (12:18 -0700)]
[mlir:PDL] Rework errors for pdl.operations with non-inferrable results
We currently emit an error during verification if a pdl.operation with non-inferrable
results is used within a rewrite. This allows for catching some errors during compile
time, but is slightly broken. For one, the verification at the PDL level assumes that
all dialects have been loaded, which is true at run time, but may not be true when
the PDL is generated (such as via PDLL). This commit fixes this by not emitting the
error if the operation isn't registered, i.e. it uses the `mightHave` variant of trait/interface
methods.
Secondly, we currently don't verify when a pdl.operation has no explicit results, but the
operation being created is known to expect at least one. This commit adds a heuristic
error to detect these cases when possible and fail. We can't always capture when the user
made an error, but we can capture the most common case where the user expected an
operation to infer its result types (when it actually isn't possible).
Differential Revision: https://reviews.llvm.org/
D124583
River Riddle [Tue, 26 Apr 2022 18:21:18 +0000 (11:21 -0700)]
[mlir:PDL] Fix a syntax ambiguity in pdl.attribute
pdl.attribute currently has a syntax ambiguity that leads to the incorrect parsing
of pdl.attribute operations with locations that don't also have a constant value. For example:
```
pdl.attribute loc("foo")
```
The above IR is treated as being a pdl.attribute with a constant value containing the location,
`loc("foo")`, which is incorrect. This commit changes the syntax to use `= <constant-value>` to
clearly distinguish when the constant value is present, as opposed to just trying to parse an attribute.
Differential Revision: https://reviews.llvm.org/
D124582
River Riddle [Tue, 26 Apr 2022 18:12:45 +0000 (11:12 -0700)]
[mlir] Attach InferTypeOpInterface on SameOperandsAndResultType operations when possible
This allows for inferring the result types of operations in certain situations by using the type of
an operand. This commit allowed for automatically supporting type inference for many more
operations with no additional effort, e.g. nearly all Arithmetic operations now support
result type inferrence with no additional changes.
Differential Revision: https://reviews.llvm.org/
D124581
River Riddle [Tue, 26 Apr 2022 18:00:35 +0000 (11:00 -0700)]
[mlir:ODS] Support using attributes in AllTypesMatch to automatically add InferTypeOpInterface
This allows for using attribute types in result type inference for use with
InferTypeOpInterface. This was a TODO before, but it isn't much
additional work to properly support this. After this commit,
arith::ConstantOp can now have its InferTypeOpInterface implementation automatically
generated.
Differential Revision: https://reviews.llvm.org/
D124580
Peter Klausler [Wed, 27 Apr 2022 19:45:07 +0000 (12:45 -0700)]
[flang][runtime] Support B/O/Z editing of CHARACTER
This is a common extension, though semantics differ across
compilers. I've chosen to interpret the CHARACTER data
as if it were an arbitrary-precision integer value and
format or read it as such. This matches Intel's compilers
and nvfortran. (GNU Fortran can't handle lengths > 1 and XLF
seems to get the enddianness wrong.)
This patch generalizes the previous implementations of
B/O/Z input and output so that they'll work for arbitrary data
in memory, and then uses them for all B/O/Z input/output,
including (now) CHARACTER.
Differential Revision: https://reviews.llvm.org/
D124547
Mircea Trofin [Thu, 28 Apr 2022 18:18:28 +0000 (11:18 -0700)]
[NFC] const-ed the return type of FunctionPropertiesAnalysis
The result is a data bag, this makes sure it's signaled to a user that
the data can't be mutated when, for example, doing something like:
auto &R = FAM.getResult<FunctionPropertiesAnalysis>(F)
...
R.Uses++
Simon Pilgrim [Thu, 28 Apr 2022 19:12:38 +0000 (20:12 +0100)]
[X86] setcc.ll - add "NOTBM" check-prefix for expected common code
Florian Hahn [Thu, 28 Apr 2022 19:16:21 +0000 (20:16 +0100)]
Revert "[VPlan] Remove uneeded needsVectorIV check."
This reverts commit
43842b887e0a7b918bb2d6c9f672025b2c621f8a while I
investigate a buildbot failure.
It also reverts the follow-up commit
2883de05145fc5b4afb99b91f69ebb835af36af5.
Chris Lattner [Thu, 28 Apr 2022 18:37:17 +0000 (11:37 -0700)]
[OpAsmParser] Simplify logic for requiredOperandCount in parseOperandList.
I would ideally like to eliminate 'requiredOperandCount' as a bit of
verification that should be in the client side, but it is much more
widely used than I expected. Just tidy some pieces up around it given
we can't drop it immediately.
NFC.
Differential Revision: https://reviews.llvm.org/
D124629
Bill Wendling [Thu, 28 Apr 2022 19:00:47 +0000 (12:00 -0700)]
[randstruct] Randomize all elements of a record
A record may have more than just FieldDecls in it. If so, then we're
likely to drop them if we only randomize the FieldDecls.
We need to be careful about anonymous structs/unions. Their fields are
made available in the RecordDecl as IndirectFieldDecls, which are listed
after the anonymous struct/union. The ordering doesn't appear to be
super important, however we place them unrandomized at the end of the
RecordDecl just in case. There's also the possiblity of
StaticAssertDecls. We also want those at the end.
All other non-FieldDecls we place at the top, just in case we get
something like:
struct foo {
enum e { BORK };
enum e a;
};
Link: https://github.com/KSPP/linux/issues/185
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/
D123958
Dominic Chen [Thu, 21 Apr 2022 22:08:04 +0000 (15:08 -0700)]
[libc] Support 32-bit ARM platform tests
Set LONG_DOUBLE_IS_DOUBLE, add ifdefs for 128-bit integer types
Differential Revision: https://reviews.llvm.org/
D124204
David Tenty [Tue, 5 Apr 2022 21:27:00 +0000 (17:27 -0400)]
[LLVM] Add exported visibility style for XCOFF
For the AIX linker, under default options, global or weak symbols which
have no visibility bits set to zero (i.e. no visibility, similar to ELF
default) are only exported if specified on an export list provided to
the linker. So AIX has an additional visibility style called
"exported" which indicates to the linker that the symbol should
be explicitly globally exported.
This change maps "dllexport" in the LLVM IR to correspond to XCOFF
exported as we feel this best models the intended semantic (discussion
on the discourse RFC thread: https://discourse.llvm.org/t/rfc-adding-exported-visibility-style-to-the-ir-to-model-xcoff-exported-visibility/61853)
and allows us to enable writing this visibility for the AIX target
in the assembly path.
Reviewed By: DiggerLin
Differential Revision: https://reviews.llvm.org/
D123951
David Green [Thu, 28 Apr 2022 18:46:12 +0000 (19:46 +0100)]
[VectorCombine] Try to reduce shuffle cost for commutative reduction operands
Given a shuffle feeding a commutative reduction, the lane ordering of
the shuffle will not alter the result. This is also true if there are a
number of operations between the reduction and the shuffle, providing
they only operate lane-wise. This patch searches for cases like that in
Vector Combine, allowing us to check the cost of the shuffle vs an
in-order identity shuffle and replace the order if possible. This only
handles a single shuffle at the moment to keep things simple, and is
able to ignore splats that produce results where every result is the
same.
This is a more powerful version of a combine that already happens in
instrcombine, capable of optimizing more cases by looking through more
instructions and being able to cost the shuffle.
Differential Revision: https://reviews.llvm.org/
D123494
Jacques Pienaar [Thu, 28 Apr 2022 18:42:46 +0000 (11:42 -0700)]
[mlir] Add basic tree-sitter grammar file
tree-sitter grammar file that tries to closely matches LangRef (it could use
some tweaking and cleanup, but kept fairly basic). Also updated LangRef in
places where found some issues while doing the nearly direct transcription.
This only adds a grammar file, not all the other parts (npm etc) that
accompanies it. Those I'll propose for separate repo like we do for vscode
extension.
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/
D124352
Biplob Mishra [Thu, 28 Apr 2022 18:24:28 +0000 (19:24 +0100)]
InstCombine: Add no-one-use tests and create thwart complexity-based canonicalization for the or-and combine tests
Chris Lattner [Tue, 26 Apr 2022 19:03:03 +0000 (12:03 -0700)]
[AsmParser] Rework logic around "region argument parsing"
The asm parser had a notional distinction between parsing an
operand (like "%foo" or "%4#3") and parsing a region argument
(which isn't supposed to allow a result number like #3).
Unfortunately the implementation has two problems:
1) It didn't actually check for the result number and reject
it. parseRegionArgument and parseOperand were identical.
2) It had a lot of machinery built up around it that paralleled
operand parsing. This also was functionally identical, but
also had some subtle differences (e.g. the parseOptional
stuff had a different result type).
I thought about just removing all of this, but decided that the
missing error checking was important, so I reimplemented it with
a `allowResultNumber` flag on parseOperand. This keeps the
codepaths unified and adds the missing error checks.
Differential Revision: https://reviews.llvm.org/
D124470
Yitzhak Mandelbaum [Wed, 27 Apr 2022 17:21:59 +0000 (17:21 +0000)]
[clang][dataflow] Perform structural comparison of indirection values in `join`.
This patch changes `Environment::join`, in the case that two values at the same
location are not (pointer) equal, to structurally compare indirection values
(pointers and references) for equivalence (that is, equivalent pointees) before
resorting to merging.
This change makes join consistent with equivalence, which also performs
structural comparison. It also fixes a bug where the values are `ReferenceValue`
but the merge creates a non-reference value. This case arises when the
`ReferenceValue`s were created to represent an lvalue, so the "reference-ness"
is not reflected in the type. In this case, the pointees will always be
equivalent, because lvalues at the same code location point to the location of a
fixed declaration, whose location is itself stable across blocks.
We were unable to reproduce a unit test for this latter bug, but have verified
the fix in the context of a larger piece of code that triggers the bug.
Differential Revision: https://reviews.llvm.org/
D124540
Alexey Bataev [Mon, 7 Mar 2022 21:11:12 +0000 (13:11 -0800)]
[OPENMP]PR53344: Emit code for final update of the inscan reduction vars in worksharing loops.
Need to emit final update of the inscan reduction variables. For
worksharing loops, the reduction values are stored in the temp array,
need to copy the last element to the original var at the end of the
construct.
Differential Revision: https://reviews.llvm.org/
D121156
Paul Robinson [Thu, 28 Apr 2022 17:34:57 +0000 (10:34 -0700)]
[PS5] Default to omit leaf frame pointer
Alan Zhao [Thu, 28 Apr 2022 17:01:10 +0000 (13:01 -0400)]
[llvm-ml] Improve indirect call parsing
In MASM, if a QWORD symbol is passed to a jmp or call instruction in
64-bit mode or a DWORD or WORD symbol is passed in 32-bit mode, then
MSVC's assembler recognizes that as an indirect call. Additionally, if
the operand is qualified as a ptr, then that should also be an indirect
call.
Furthermore, in 64-bit mode, such operands are implicitly rip-relative
(in fact, MSVC's assembler ml64.exe does not allow explicitly specifying
rip as a base register.)
To keep this patch managable, this patch does not include:
* error messages for wrong operand types (e.g. passing a QWORD in 32-bit
mode)
* resolving indirect calls if the symbol is declared after it's first
use (llvm-ml currently only runs a single pass).
* imlementing the extern keyword (required to resolve
https://crbug.com/762167.)
This patch is likely missing a bunch of edge cases, so please do point
them out in the review.
Reviewed By: epastor, hans, MaskRay
Committed By: epastor (on behalf of ayzhao)
Differential Revision: https://reviews.llvm.org/
D124413
Simon Pilgrim [Thu, 28 Apr 2022 16:49:11 +0000 (17:49 +0100)]
[InstCombine][X86] simplifyDemandedVectorEltsIntrinsic - handle avx2 per-element vector shifts
Alexey Bataev [Wed, 14 Apr 2021 14:49:32 +0000 (07:49 -0700)]
[COST]Improve cost model for shuffles in SLP.
Introduced masks where they are not added and improved target dependent
cost models to avoid returning of the incorrect cost results after
adding masks.
Differential Revision: https://reviews.llvm.org/
D100486
Paul Robinson [Thu, 28 Apr 2022 16:58:47 +0000 (09:58 -0700)]
[PS5] Defaults for -fdeclspec, -ffunction/data-sections
Craig Topper [Thu, 28 Apr 2022 16:21:13 +0000 (09:21 -0700)]
[RISCV] Use default promotion for (i32 (shl 1, X)) on RV64 when Zbs is enabled.
This improves opportunities to use bset/bclr/binv. Unfortunately,
there are no W versions of these instrcutions so this isn't always
a clear win. If we use SLLW we get free sign extend and shift masking,
but need to put a 1 in a register and can't remove an or/xor. If
we use bset/bclr/binv we remove the immediate materializationg and
logic op, but might need a mask on the shift amount and sext.w.
Reviewed By: luismarques
Differential Revision: https://reviews.llvm.org/
D124096
Aaron Ballman [Thu, 28 Apr 2022 16:57:07 +0000 (12:57 -0400)]
Fix "not all control paths return a value" diagnostic; NFC
Pavel Samolysov [Thu, 28 Apr 2022 16:51:39 +0000 (09:51 -0700)]
[ArgPromotion] Move ArgPart and OffsetAndArgPart to anonymous namespace
The structure ArgPart and alias OffsetAndArgPart have been moved
into the anonymous namespace. NFC.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/
D124617
Pavel Samolysov [Thu, 28 Apr 2022 16:37:35 +0000 (09:37 -0700)]
[ArgPromotion] Change the condition to check the promotion limit
The condition should be 'ArgParts.size() > MaxElements', so that if we
have exactly 3 elements in the 'ArgParts' vector, the promotion should
be allowed because the 'MaxElement' threshold is not exceeded yet.
The default value for 'MaxElement' has been decreased to 2 in order
to avoid an actual change in argument promoting behavior. However,
this changes byval argument transformation behavior by allowing
adding not more than 2 arguments to the function instead of 3 allowed
before.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/
D124178
Bjorn Pettersson [Thu, 28 Apr 2022 16:31:05 +0000 (18:31 +0200)]
[SelectionDAG] Use correct boolean representation in FoldConstantArithmetic
The description of SETCC says
/// SetCC operator - This evaluates to a true value iff the condition is
/// true. If the result value type is not i1 then the high bits conform
/// to getBooleanContents.
Without this patch, we sign extended the i1 to the used larger type
regardless of getBooleanContents. This resulted in miscompiles, as
shown in the attached testcase that ended up returning -1 instead of
1 when using -mattr=+v.
Fixes https://github.com/llvm/llvm-project/issues/55168
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/
D124618