Keith Smiley [Wed, 10 Nov 2021 05:28:56 +0000 (21:28 -0800)]
[lld-macho] Fix trailing slash in oso_prefix
Previously if you passed `-oso_prefix path/to/foo/` with a trailing
slash at the end, using `real_path` would remove that slash, but that
slash is necessary to make sure OSO prefix paths end up as valid
relative paths instead of starting with `/`.
Differential Revision: https://reviews.llvm.org/D113541
Duncan P. N. Exon Smith [Thu, 4 Nov 2021 00:52:34 +0000 (17:52 -0700)]
ADT: Fix const-correctness of iterator adaptors
This fixes const-correctness of iterator adaptors, dropping non-`const`
overloads for `operator*()`.
Iterators, like the pointers that they generalize, have two types of
`const`.
The `const` qualifier on members indicates whether the iterator itself
can be changed. This is analagous to `int *const`.
The `const` qualifier on return values of `operator*()`, `operator[]()`,
and `operator->()` controls whether the the pointed-to value can be
changed. This is analogous to `const int *`.
Since `operator*()` does not (in principle) change the iterator, then
there should only be one definition, which is `const`-qualified. E.g.,
iterators wrapping `int*` should look like:
```
int *operator*() const; // always const-qualified, no overloads
```
ba7a6b314fd14bb2c9ff5d3f4fe2b6525514cada changed `iterator_adaptor_base`
away from this to work around bugs in other iterator adaptors. That was
already reverted. This patch adds back its test, which combined
llvm::enumerate() and llvm::make_filter_range(), adds a test for
iterator_adaptor_base itself, and cleans up the `const`-ness of the
other iterator adaptors.
This also updates the documented requirements for
`iterator_facade_base`:
```
/// OLD:
/// - const T &operator*() const;
/// - T &operator*();
/// New:
/// - T &operator*() const;
```
In a future commit we might also clean up `iterator_facade`'s overloads
of `operator->()` and `operator[]()`. These already (correctly) return
non-`const` proxies regardless of the iterator's `const` qualifier.
Differential Revision: https://reviews.llvm.org/D113158
Philip Reames [Fri, 12 Nov 2021 19:15:57 +0000 (11:15 -0800)]
(re-)Autogen one last unroll-and-jam test
This case was complicated because someone had added new non-autogened test to an autogened file. In particular, those new tests used two variables (%J and %j) which differeded only in capitalization. The auto-updater doesn't distinguish case, so this meant auto-gened versions of the new tests failed with non-obvious errors.
There are two key lessons here:
1) Please don't use two values which differ only in case. This is problematic for automatic tooling, but is also hard to understand for a human.
2) Please DO NOT add new tests to an autogened test without running autogen again. If autogen doesn't pass on your new test, put them in a separate file.
Peter Klausler [Wed, 10 Nov 2021 22:02:30 +0000 (14:02 -0800)]
[flang] Fix rounding edge case in F output editing
When an Fw.d output edit descriptor has a "d" value exactly
equal to the number of zeroes after the decimal point for a value
(e.g., 0.07 with F5.1), the Fw.d output editing code needs to
do the rounding itself to either 0.0 or 0.1 after performing
a conversion without rounding (to avoid 0.04999 rounding up twice).
Differential Revision: https://reviews.llvm.org/D113698
Alfsonso Gregory [Fri, 12 Nov 2021 18:53:50 +0000 (13:53 -0500)]
[libc++][NFC] Resolve Python 2 FIXME
We don't use Python 2 anymore, so let us do the recommended fix instead
of using the workaround made for Python 2.
Differential Revision: https://reviews.llvm.org/D107715
Peter Klausler [Wed, 10 Nov 2021 19:55:46 +0000 (11:55 -0800)]
[flang] Respect NO_STOP_MESSAGE=1 in runtime
When an environment variable NO_STOP_MESSAGE=1 is set,
assume that STOP statements with a successful code
have QUIET=.TRUE.
Differential Revision: https://reviews.llvm.org/D113701
Lang Hames [Fri, 12 Nov 2021 18:28:38 +0000 (10:28 -0800)]
[ORC-RT][llvm-jitlink] Fix a buggy check in ORC-RT MachO TLV deregistration.
The check was failing because it was matching against the end of the range, not
the start.
This bug wasn't causing the ORC-RT MachO TLV regression test to fail because
we were only logging deallocation errors (including TLV deregistration errors)
and not actually returning a failure code. This commit updates llvm-jitlink to
report the errors properly.
Lang Hames [Fri, 12 Nov 2021 16:46:03 +0000 (08:46 -0800)]
[JITLink] Fix think-o in handwritten CWrapperFunctionResult -> Error converter.
We need to skip the length field when generating error strings.
No test case: This hand-hacked deserializer should be removed in the near future
once JITLink can use generic ORC APIs (including SPS and WrapperFunction).
Philip Reames [Fri, 12 Nov 2021 18:30:27 +0000 (10:30 -0800)]
Autogen a bunch of unrolling tests for ease of update
Peter Klausler [Wed, 10 Nov 2021 23:49:05 +0000 (15:49 -0800)]
[flang] Fix ORDER= argument to RESHAPE
The ORDER= argument to the transformational intrinsic function RESHAPE
was being misinterpreted in an inverted way that could be detected only
with 3-d or higher rank array. Fix in both folding and the runtime, and
extend tests.
Differential Revision: https://reviews.llvm.org/D113699
Florian Hahn [Fri, 12 Nov 2021 18:16:03 +0000 (18:16 +0000)]
[SCEV] Update SCEVLoopGuardRewriter to take SCEV -> SCEV map (NFC).
Split off refactoring from D113577 to reduce the diff. NFC as the new
interface will only be used in D113577.
Nawrin Sultana [Mon, 25 Oct 2021 19:01:56 +0000 (14:01 -0500)]
[OpenMP] Set default blocktime to 0 for hybrid cpu
Differential Revision:https://reviews.llvm.org/D113012
Quinn Pham [Thu, 11 Nov 2021 20:14:11 +0000 (14:14 -0600)]
[lldb][NFC] Inclusive language: rename m_master in ASTImporterDelegate
[NFC] As part of using inclusive language within the llvm project, this patch
replaces `m_master` in `ASTImporterDelegate` with `m_main`.
Reviewed By: teemperor, clayborg
Differential Revision: https://reviews.llvm.org/D113720
Simon Pilgrim [Fri, 12 Nov 2021 17:57:20 +0000 (17:57 +0000)]
[AMDGPU] Regenerate udiv.ll tests
Philip Reames [Fri, 12 Nov 2021 17:48:20 +0000 (09:48 -0800)]
Refresh an autogen test to reduce spurious diffs
Fangrui Song [Fri, 12 Nov 2021 17:47:31 +0000 (09:47 -0800)]
[ELF] Make --no-relax disable R_X86_64_GOTPCRELX and R_X86_64_REX_GOTPCRELX GOT optimization
This brings back the original version of D81359.
I have found several use cases now.
* Unlike GNU ld, LLD's relocation processing is one pass. If we decide to
optimize(relax) R_X86_64_{,REX_}GOTPCRELX, we will suppress GOT generation and
cannot undo the decision later. Optimizing R_X86_64_REX_GOTPCRELX can usually
make it easy to hit `relocation R_X86_64_REX_GOTPCRELX out of range` because
the distance to GOT is usually shorter. Without --no-relax, the user has to
recompile with `-Wa,-mrelax-relocations=no`.
* The option would help during my investigationg of the root cause of https://git.kernel.org/linus/
09e43968db40c33a73e9ddbfd937f46d5c334924
* There is need for relaxation for AArch64 & RISC-V. Implementing this for
x86-64 improves consistency with little target-specific cost (two-line
X86_64.cpp change).
Reviewed By: alexander-shaposhnikov
Differential Revision: https://reviews.llvm.org/D113615
Sam McCall [Fri, 12 Nov 2021 17:42:54 +0000 (18:42 +0100)]
[clangd] Mark completions as plain-text when there's no snippet part
This helps nvim support the "repeat" action
Fixes https://github.com/clangd/clangd/issues/922
Philip Reames [Fri, 12 Nov 2021 17:37:50 +0000 (09:37 -0800)]
[tests] Add coverage for cases we can prune exits when runtlme unrolling
Nikita Popov [Fri, 12 Nov 2021 17:17:27 +0000 (18:17 +0100)]
[ConstantRangeTest] Add helper to enumerate APInts (NFC)
While ForeachNumInConstantRange(ConstantRange::getFull(Bits))
works, it's somewhat roundabout, and I keep looking for this
function.
Quinn Pham [Wed, 10 Nov 2021 14:50:14 +0000 (08:50 -0600)]
[lldb][NFC] Inclusive language: replace master/slave names for ptys
[NFC] This patch replaces master and slave with primary and secondary
respectively when referring to pseudoterminals/file descriptors.
Reviewed By: clayborg, teemperor
Differential Revision: https://reviews.llvm.org/D113687
Dmitry Vyukov [Fri, 12 Nov 2021 16:43:26 +0000 (17:43 +0100)]
Revert "tsan: new runtime (v3)"
Summary:
This reverts commit
ac95b8d9548cb3c07e60236d3e9e1fd05f79579b.
There is a number of bot failures:
http://45.33.8.238/mac/38755/step_4.txt
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/38135/consoleFull#-
148886289949ba4694-19c4-4d7e-bec5-
911270d8a58c
Reviewers: vitalybuka, melver
Subscribers:
Simon Pilgrim [Fri, 12 Nov 2021 16:47:43 +0000 (16:47 +0000)]
[X86] convertShiftLeftToScale - improve vXi8 constant handling
Add support for v32i8/v64i8 converting shift-by-constant to multiply-by-constant. This helps us avoid the generic vXi8 shift lowering, and a lot of VPBLENDVB ops which can be particularly slow.
We also needed to reorder a few shift lowering patterns to prevent regressions, particularly for XOP+AVX2 (Excavator) targets (which can split to fast v16i8 shifts) and AVX512-BWI targets (which prefers to extend to fast v32i16 shifts).
Zarko Todorovski [Fri, 12 Nov 2021 15:47:03 +0000 (15:47 +0000)]
[NFC][llvm] Remove uses of blacklist in llvm/test/Instrumentation
Small patch that changes blacklisted_global to blocked_global and a change in comments.
Reviewed By: pgousseau
Differential Revision: https://reviews.llvm.org/D113692
Brian Cain [Wed, 10 Nov 2021 17:26:10 +0000 (09:26 -0800)]
[libcxx] Change the type of __size to correspond
__size was declared as unsigned which was compatible with
Joel E. Denny [Fri, 12 Nov 2021 14:55:32 +0000 (09:55 -0500)]
[OpenMP] Fix main thread barrier for Pascal and amdgpu
Fixes what's left of https://bugs.llvm.org/show_bug.cgi?id=51781.
Reviewed By: jdoerfert, JonChesterfield, tianshilei1992
Differential Revision: https://reviews.llvm.org/D113602
Florian Hahn [Fri, 12 Nov 2021 16:09:19 +0000 (16:09 +0000)]
[LV] Precommit test case from PR52485.
Jay Foad [Thu, 11 Nov 2021 14:45:56 +0000 (14:45 +0000)]
[AMDGPU] Simplify 64-bit division/remainder expansion
The old expansion open-coded a 64-bit addition in a strange way, by
adding the high parts *without* carry-in from the low part, and then
adding the carry back in later on. Fixing this saves a couple of
instructions and makes the code much easier to understand.
Differential Revision: https://reviews.llvm.org/D113679
Zarko Todorovski [Fri, 12 Nov 2021 14:30:06 +0000 (14:30 +0000)]
[clang] Inclusive language: change instances of blacklist/whitelist to allowlist/ignorelist
Change the error message to use ignorelist, and changed some variable and function
names in related code and test.
Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D113189
Kazu Hirata [Fri, 12 Nov 2021 15:33:29 +0000 (07:33 -0800)]
[CodeGen] Use SDNode::uses (NFC)
Roman Lebedev [Fri, 12 Nov 2021 14:06:22 +0000 (17:06 +0300)]
[NFC][SROA] Add more tests for non-capturing pointer-escaping calls
Nicolas Vasilache [Fri, 12 Nov 2021 14:58:03 +0000 (14:58 +0000)]
[mlir] NFC - Address post-commit comments
Address comments from https://reviews.llvm.org/D113745
which landed as
aa3731806723a2a12914aecda2af6e40e1903702
Justas Janickas [Mon, 20 Sep 2021 13:18:32 +0000 (14:18 +0100)]
[OpenCL] Constructor address space test adjusted for C++ for OpenCL 2021
Reuses C++ for OpenCL constructor address space test so that it
supports optional generic address spaces in version 2021.
Differential Revision: https://reviews.llvm.org/D110184
Alexey Bataev [Fri, 12 Nov 2021 14:28:03 +0000 (06:28 -0800)]
[Feature][NFC]Improve test checks to avoid possible false postitive test
failures, NFC.
Kerry McLaughlin [Fri, 12 Nov 2021 11:12:20 +0000 (11:12 +0000)]
[AArch64][SVE] Remove i1 type from isElementTypeLegalForScalableVector
`collectElementTypesForWidening` collects the types of load, store and
reduction Phis in a loop. These types are later checked using
`isElementTypeLegalForScalableVector` to prevent vectorisation of
loops with instruction types that are unsupported.
This patch removes i1 from the list of types supported for scalable
vectors. This fixes an assert ("Cannot yet scalarize uniform stores") in
`setCostBasedWideningDecision` when we have a loop containing a uniform
i1 store and a scalable VF, which we cannot create a scatter for.
Reviewed By: david-arm
Differential Revision: https://reviews.llvm.org/D113680
Alexey Bataev [Thu, 29 Jul 2021 18:22:19 +0000 (11:22 -0700)]
[SLP]Improve vectorization of split loads.
Need to fix ther cost estimation for split loads, since we look at the
subregs already, no need to permute them, need just to estimate
subregister insert, if it is smaller than the real register. Also, using
split loads, it might be profitable already to vectorize smaller trees
with gathering of the loads.
Differential Revision: https://reviews.llvm.org/D107188
Simon Pilgrim [Fri, 12 Nov 2021 14:02:43 +0000 (14:02 +0000)]
[X86] combineX86ShufflesConstants - constant fold from target shuffles unless optsize = true
Currently we only constant fold target shuffles if any of the sources has one use, or it would remove a variable shuffle mask - the aim being to avoid constant pool bloat.
This patch proposes we should constant fold by default and only limit this if optsize is enabled - I've added a basic test for this in vector-mul.ll (the pmuludq case is by far the most common), I can add other specific test cases if people need them.
This should permit further constant folding, break some instruction dependencies and help reduce shuffle port pressure.
Differential Revision: https://reviews.llvm.org/D113748
Kadir Cetinkaya [Fri, 12 Nov 2021 13:50:13 +0000 (14:50 +0100)]
[clangd] Fix use-after-free in test
Dmitry Vyukov [Tue, 27 Apr 2021 11:55:41 +0000 (13:55 +0200)]
tsan: new runtime (v3)
This change switches tsan to the new runtime which features:
- 2x smaller shadow memory (2x of app memory)
- faster fully vectorized race detection
- small fixed-size vector clocks (512b)
- fast vectorized vector clock operations
- unlimited number of alive threads/goroutimes
Depends on D112602.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D112603
Raphael Isemann [Fri, 12 Nov 2021 12:54:19 +0000 (13:54 +0100)]
[lldb] Fix that the embedded Python REPL crashes if it receives SIGINT
When LLDB receives a SIGINT while running the embedded Python REPL it currently
just crashes in `ScriptInterpreterPythonImpl::Interrupt` with an error such as
the one below:
```
Fatal Python error: PyThreadState_Get: the function must be called with the GIL
held, but the GIL is released (the current Python thread state is NULL)
```
The faulty code that causes this error is this part of `ScriptInterpreterPythonImpl::Interrupt`:
```
PyThreadState *state = PyThreadState_GET();
if (!state)
state = GetThreadState();
if (state) {
long tid = state->thread_id;
PyThreadState_Swap(state);
int num_threads = PyThreadState_SetAsyncExc(tid, PyExc_KeyboardInterrupt);
```
The obvious fix I tried is to just acquire the GIL before this code is running
which fixes the crash but the `KeyboardInterrupt` we want to raise immediately
is actually just queued and would only be raised once the next line of input has
been parsed (which e.g. won't interrupt Python code that is currently waiting on
a timer or IO from what I can see). Also none of the functions we call here is
marked as safe to be called from a signal handler from what I can see, so we
might still end up crashing here with some bad timing.
Python 3.2 introduced `PyErr_SetInterrupt` to solve this and the function takes
care of all the details and avoids doing anything that isn't safe to do inside a
signal handler. The only thing we need to do is to manually setup our own fake
SIGINT handler that behaves the same way as the standalone Python REPL signal
handler (which raises a KeyboardInterrupt).
From what I understand the old code used to work with Python 2 so I kept the old
code around until we officially drop support for Python 2.
There is a small gap here with Python 3.0->3.1 where we might still be crashing,
but those versions have reached their EOL more than a decade ago so I think we
don't need to bother about them.
Reviewed By: JDevlieghere
Differential Revision: https://reviews.llvm.org/D104886
Sanjay Patel [Fri, 12 Nov 2021 13:12:59 +0000 (08:12 -0500)]
[x86] fold vector (X > -1) & Y to shift+andn
and (pcmpgt X, -1), Y --> pandn (vsrai X, BitWidth-1), Y
This avoids the -1 constant vector in favor of an arithmetic shift
instruction if it exists (the ISA is still not complete after all
these years...).
We catch this pattern late in combining by matching PCMPGT, so it
should not interfere with more general folds.
Differential Revision: https://reviews.llvm.org/D113603
Jan Svoboda [Fri, 12 Nov 2021 13:15:24 +0000 (14:15 +0100)]
[clang] NFC: Format a loop in CompilerInstance
This code will be moved to a separate function in a future patch. Reformatting now to prevent a bunch of clang-format complains on Phabricator.
Nicolas Vasilache [Fri, 12 Nov 2021 13:13:47 +0000 (13:13 +0000)]
[mlir][Vector] Add support for 1D depthwise conv vectorization
At this time the 2 flavors of conv are a little too different to allow significant code sharing and other will likely come up.
so we go the easy route first by duplicating and adapting.
Reviewed By: gysit
Differential Revision: https://reviews.llvm.org/D113758
Dmitry Vyukov [Fri, 12 Nov 2021 13:07:23 +0000 (14:07 +0100)]
tsan: ignore some errors in the clone_setns test
Some bots failed with:
unshare failed: 1
https://lab.llvm.org/buildbot/#/builders/70/builds/14101
Look only for the target EINVAL error.
Differential Revision: https://reviews.llvm.org/D113759
Phoebe Wang [Fri, 12 Nov 2021 13:05:51 +0000 (21:05 +0800)]
Add nounwind for tests. NFC
Kadir Cetinkaya [Wed, 10 Nov 2021 11:10:33 +0000 (12:10 +0100)]
[clangd] Mark macros from preamble for code completion
If the main file is a header, mark the marcos defined in its preamble
section as code-completion ready.
Fixes https://github.com/clangd/clangd/issues/921.
Differential Revision: https://reviews.llvm.org/D113555
Adrian Kuegel [Fri, 12 Nov 2021 12:15:51 +0000 (13:15 +0100)]
Revert "[clang] retain type sugar in auto / template argument deduction"
This reverts commit
9b6036deedf28e10d797fc4ca734d57680d18053.
Breaks two libc++ tests.
Adrian Kuegel [Fri, 12 Nov 2021 12:12:02 +0000 (13:12 +0100)]
Revert "[lldb] fix test expectation broken by clang fix at D110216"
This reverts commit
55085952175ed3b029097a0594acc4e34a5df218.
The patch it depends on is reverted.
Florian Hahn [Fri, 12 Nov 2021 12:20:00 +0000 (12:20 +0000)]
[SCEV] Use APIntOps::umin to select best max BC count (NFC).
Suggested in D102267, but I missed this in the committed version.
Florian Hahn [Fri, 12 Nov 2021 12:19:35 +0000 (12:19 +0000)]
[SCEV] Add test case where applying zext info pessimizes BTC.
Add an additional test case for D113578.
Dmitry Vyukov [Thu, 11 Nov 2021 19:37:05 +0000 (20:37 +0100)]
tsan: don't start background thread after clone
Start the background thread only after fork, but not after clone.
For fork we did this always and it's known to work (or user code has adopted).
But if we do this for the new clone interceptor some code (sandbox2) fails.
So model we used to do for years and don't start the background thread after clone.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D113744
Nicolas Vasilache [Fri, 12 Nov 2021 09:44:14 +0000 (09:44 +0000)]
[mlir][Linalg] Rewrite DownscaleSizeOneWindowed2DConvolution to use rank-reducing insert/extract slices.
This rewriting enables better bufferization and canonicalizations.
Differential Revision: https://reviews.llvm.org/D113745
Dmitry Vyukov [Fri, 12 Nov 2021 09:06:20 +0000 (10:06 +0100)]
tsan: fix XMM register corruption in hacky call
The compiler does not recognize HACKY_CALL as a call
(we intentionally hide it from the compiler so that it can
compile non-leaf functions as leaf functions).
To compensate for that hacky call thunk saves and restores
all caller-saved registers. However, it saves only
general-purposes registers and does not save XMM registers.
This is a latent bug that was masked up until a recent "NFC" commit
d736002e90 ("tsan: move memory access functions to a separate file"),
which allowed more inlining and exposed the 10-year bug.
Save and restore caller-saved XMM registers (all) as well.
Currently the bug manifests as e.g. frexp interceptor messes the
return value and the added test fails with:
i=8177 y=0.000000 exp=4
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D113742
Tomasz Miąsko [Sat, 16 Oct 2021 12:10:31 +0000 (14:10 +0200)]
[llvm-nm] Demangle Rust symbols
Add support for demangling Rust v0 symbols to llvm-nm by reusing
nonMicrosoftDemangle which supports both Itanium and Rust mangling.
Reviewed By: dblaikie, jhenderson
Differential Revision: https://reviews.llvm.org/D111937
Jan Svoboda [Fri, 12 Nov 2021 11:11:15 +0000 (12:11 +0100)]
[clang] NFC: Use range-based for loop
Jan Svoboda [Fri, 12 Nov 2021 11:05:02 +0000 (12:05 +0100)]
[clang] NFC: Remove benign condition
Salman Javed [Fri, 12 Nov 2021 10:24:19 +0000 (23:24 +1300)]
[clang-tidy] Re-apply 0076957 with fix for failing ASan tests
Re-apply "Fix lint warning in ClangTidyDiagnosticConsumer.cpp (NFC)"
with fixes for the failing ASan tests.
This reverts commit
74add1b6d6d377ab2cdce26699cf798110817e42.
Gabor Marton [Fri, 5 Nov 2021 10:53:29 +0000 (11:53 +0100)]
[analyzer][solver] Remove reference to RangedConstraintManager
We no longer need a reference to RangedConstraintManager, we call top
level `State->assume` functions.
Differential Revision: https://reviews.llvm.org/D113261
Gabor Marton [Mon, 26 Jul 2021 20:55:44 +0000 (22:55 +0200)]
[analyzer][solver] Iterate to a fixpoint during symbol simplification with constants
D103314 introduced symbol simplification when a new constant constraint is
added. Currently, we simplify existing equivalence classes by iterating over
all existing members of them and trying to simplify each member symbol with
simplifySVal.
At the end of such a simplification round we may end up introducing a
new constant constraint. Example:
```
if (a + b + c != d)
return;
if (c + b != 0)
return;
// Simplification starts here.
if (b != 0)
return;
```
The `c == 0` constraint is the result of the first simplification iteration.
However, we could do another round of simplification to reach the conclusion
that `a == d`. Generally, we could do as many new iterations until we reach a
fixpoint.
We can reach to a fixpoint by recursively calling `State->assume` on the
newly simplified symbol. By calling `State->assume` we re-ignite the
whole assume machinery (along e.g with adjustment handling).
Why should we do this? By reaching a fixpoint in simplification we are capable
of discovering infeasible states at the moment of the introduction of the
**first** constant constraint.
Let's modify the previous example just a bit, and consider what happens without
the fixpoint iteration.
```
if (a + b + c != d)
return;
if (c + b != 0)
return;
// Adding a new constraint.
if (a == d)
return;
// This brings in a contradiction.
if (b != 0)
return;
clang_analyzer_warnIfReached(); // This produces a warning.
// The path is already infeasible...
if (c == 0) // ...but we realize that only when we evaluate `c == 0`.
return;
```
What happens currently, without the fixpoint iteration? As the inline comments
suggest, without the fixpoint iteration we are doomed to realize that we are on
an infeasible path only after we are already walking on that. With fixpoint
iteration we can detect that before stepping on that. With fixpoint iteration,
the `clang_analyzer_warnIfReached` does not warn in the above example b/c
during the evaluation of `b == 0` we realize the contradiction. The engine and
the checkers do rely on that either `assume(Cond)` or `assume(!Cond)` should be
feasible. This is in fact assured by the so called expensive checks
(LLVM_ENABLE_EXPENSIVE_CHECKS). The StdLibraryFuncionsChecker is notably one of
the checkers that has a very similar assertion.
Before this patch, we simply added the simplified symbol to the equivalence
class. In this patch, after we have added the simplified symbol, we remove the
old (more complex) symbol from the members of the equivalence class
(`ClassMembers`). Removing the old symbol is beneficial because during the next
iteration of the simplification we don't have to consider again the old symbol.
Contrary to how we handle `ClassMembers`, we don't remove the old Sym->Class
relation from the `ClassMap`. This is important for two reasons: The
constraints of the old symbol can still be found via it's equivalence class
that it used to be the member of (1). We can spare one removal and thus one
additional tree in the forest of `ClassMap` (2).
Performance and complexity: Let us assume that in a State we have N non-trivial
equivalence classes and that all constraints and disequality info is related to
non-trivial classes. In the worst case, we can simplify only one symbol of one
class in each iteration. The number of symbols in one class cannot grow b/c we
replace the old symbol with the simplified one. Also, the number of the
equivalence classes can decrease only, b/c the algorithm does a merge operation
optionally. We need N iterations in this case to reach the fixpoint. Thus, the
steps needed to be done in the worst case is proportional to `N*N`. Empirical
results (attached) show that there is some hardly noticeable run-time and peak
memory discrepancy compared to the baseline. In my opinion, these differences
could be the result of measurement error.
This worst case scenario can be extended to that cases when we have trivial
classes in the constraints and in the disequality map are transforming to such
a State where there are only non-trivial classes, b/c the algorithm does merge
operations. A merge operation on two trivial classes results in one non-trivial
class.
Differential Revision: https://reviews.llvm.org/D106823
Neubauer, Sebastian [Thu, 11 Nov 2021 14:58:42 +0000 (15:58 +0100)]
[AMDGPU][NFC] Fix typos
Differential Revision: https://reviews.llvm.org/D113672
Florian Hahn [Fri, 12 Nov 2021 10:30:03 +0000 (10:30 +0000)]
[SCEV] Add tests where guards limit both %n and (zext %n).
Suggested in D113577.
Kiran Chandramohan [Fri, 12 Nov 2021 10:10:18 +0000 (10:10 +0000)]
[Flang] Add type conversion for FIR integer kind
Convert fir.int<kind> to their llvm equivalent type
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: clementval, awarzynski
Differential Revision: https://reviews.llvm.org/D113660
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Adrian Kuegel [Fri, 12 Nov 2021 10:05:58 +0000 (11:05 +0100)]
Revert "Implement target_clones multiversioning"
This reverts commit
9deab60ae710f8c4cc810cd680edfb64c803f42d.
There is a possibly unintended semantic change.
Salman Javed [Fri, 12 Nov 2021 09:59:33 +0000 (22:59 +1300)]
Re-land commit 735e433 after fixing buildbot issue
This reverts commit d73e27d.
Kiran Chandramohan [Fri, 12 Nov 2021 09:35:03 +0000 (09:35 +0000)]
[Flang] Add type conversion for FIR heap type
Convert fir.heap type to its llvm equivalent type (llvm.ptr)
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D113670
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Salman Javed [Fri, 12 Nov 2021 09:42:18 +0000 (22:42 +1300)]
Revert "Make minor fixes to docs based on post-commit review of commit 5de69e1"
Sphinx buildbot failing.
This reverts commit
735e4332e2a63e5f0a04f91472fa2403c7d37fe3.
Florian Hahn [Fri, 12 Nov 2021 09:40:03 +0000 (09:40 +0000)]
[DSE] Add test case with multiple inbounds stores, followed by OOB.
This patch extends the existing out-of-bounds store tests with a case
with a bigger object and multiple inbounds stores, followed by an OOB
store. The OOB store is not used to remove the inbounds stores in this
case at the moment.
Salman Javed [Fri, 12 Nov 2021 09:36:21 +0000 (22:36 +1300)]
Make minor fixes to docs based on post-commit review of commit 5de69e1
- Jaro–Winkler and Sørensen–Dice should use en-dashes not regular
dashes. In reStructuredText this is typed as `--`.
- Letters at the beginning of a sentence should be capitalized.
Jean Perier [Fri, 12 Nov 2021 08:34:02 +0000 (09:34 +0100)]
[flang] fix unused variable warning from D113659
Jean Perier [Fri, 12 Nov 2021 08:25:22 +0000 (09:25 +0100)]
[flang] Fix vector cshift runtime with non zero lower bounds
The source index should not be compared to zero after applying the
shift with the modulo, it must be compared to the lower bound.
Otherwise, the extent is not added in case it should and the computed
source index may be less than the lower bound, causing invalid results.
Differential Revision: https://reviews.llvm.org/D113659
Vitaly Buka [Fri, 12 Nov 2021 07:32:58 +0000 (23:32 -0800)]
[NFC][lsan] Simplify root_regions initialization
Simon Moll [Fri, 12 Nov 2021 07:23:07 +0000 (08:23 +0100)]
[VE] Disable incompatible compiler-rt tests
Some compiler-rt tests are inherently incompatible with VE because..
* No consistent denormal support on VE. We skip denormal fp inputs in builtin tests.
* `madvise` unsupported on VE.
* Instruction alignment requirements.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D113093
Mehdi Amini [Fri, 12 Nov 2021 07:20:33 +0000 (07:20 +0000)]
Add a cppType string in AttrDef to make it possible to use them as parameters in other attributes
Differential Revision: https://reviews.llvm.org/D113737
Simon Moll [Fri, 12 Nov 2021 07:19:36 +0000 (08:19 +0100)]
[VE][NFCi] Remove unused tablegen parameters
TableGen has started warning about unused template parameters in the isel patterns. Remove those.
Reviewed By: kaz7
Differential Revision: https://reviews.llvm.org/D113675
Markus Lavin [Thu, 11 Nov 2021 14:27:15 +0000 (15:27 +0100)]
Fix minor deficiency in machine-sink.
Register uses that are MRI->isConstantPhysReg() should not inhibit
sinking transformation.
Reviewed By: StephenTozer
Differential Revision: https://reviews.llvm.org/D111531
Stella Laurenzo [Fri, 12 Nov 2021 05:18:16 +0000 (21:18 -0800)]
[mlir] Add MLIR-C dylib.
Per discussion on discord and various feature requests across bindings (Haskell and Rust bindings authors have asked me directly), we should be building a link-ready MLIR-C dylib which exports the C API and can be used without linking to anything else.
This patch:
* Adds a new MLIR-C aggregate shared library (libMLIR-C.so), which is similar in name and function to libLLVM-C.so.
* It is guarded by the new CMake option MLIR_BUILD_MLIR_C_DYLIB, which has a similar purpose/name to the LLVM_BUILD_LLVM_C_DYLIB option.
* On all platforms, this will work with both static, BUILD_SHARED_LIBS, and libMLIR builds, if supported:
* In static builds: libMLIR-C.so will export the CAPI symbols and statically link all dependencies into itself.
* In BUILD_SHARED_LIBS: libMLIR-C.so will export the CAPI symbols and have dynamic dependencies on implementation shared libraries.
* In libMLIR.so mode: same as static. libMLIR.so was not finished for actual linking use within the project. An eventual relayering so that libMLIR-C.so depends on libMLIR.so is possible but requires first re-engineering the latter to use the aggregate facility.
* On Linux, exported symbols are filtered to only the CAPI. On others (MacOS, Windows), all symbols are exported. A CMake status is printed unless if global visibility is hidden indicating that this has not yet been implemented. The library should still work, but it will be larger and more likely to conflict until fixed. Someone should look at lifting the corresponding support from libLLVM-C.so and adapting. Or, for special uses, just build with `-DCMAKE_CXX_VISIBILITY_PRESET=hidden -DCMAKE_C_VISIBILITY_PRESET=hidden`.
* Includes fixes to execution engine symbol export macros to enable default visibility. Without this, the advice to use hidden visibility would have resulted in test failures and unusable execution engine support libraries.
Differential Revision: https://reviews.llvm.org/D113731
Kazu Hirata [Fri, 12 Nov 2021 06:28:55 +0000 (22:28 -0800)]
[CodeGen, Target] Use MachineRegisterInfo::use_operands (NFC)
David Blaikie [Fri, 12 Nov 2021 05:47:30 +0000 (21:47 -0800)]
DebugInfo/Printing: Improve name of policy for including types for template arguments
Feedback from Richard Smith that the policy should be named closer to
the context its used in.
Serge Pavlov [Wed, 3 Nov 2021 12:34:52 +0000 (19:34 +0700)]
[X86] Preserve FPSW when popping x87 stack
When compiler converts x87 operations to stack model, it may insert
instructions that pop top stack element. To do it the compiler inserts
instruction FSTP right after the instruction that calculates value on
the stack. It can break the code that uses FPSW set by the last
instruction. For example, an instruction FXAM is usually followed by
FNSTSW, but FSTP is inserted after FXAM. As FSTP leaves condition code
in FPSW undefined, the compiler produces incorrect code.
With this change FSTP in inserted after the FPSW consumer if the last
instruction sets FPSW.
Differential Revision: https://reviews.llvm.org/D113335
Kazu Hirata [Fri, 12 Nov 2021 04:29:48 +0000 (20:29 -0800)]
Revert "[lld-macho] Fix symbol relocs handling for compact unwind's functionAddress"
This reverts commit
e941fe506114569410ec8c77e600cddd5a77559d.
The commit in question causes:
lld/MachO/InputFiles.cpp:916:13: error: use of undeclared identifier
'it'
Jez Ng [Fri, 12 Nov 2021 03:53:35 +0000 (22:53 -0500)]
[lld-macho] Fix symbol relocs handling for compact unwind's functionAddress
Clang seems to emit all functionAddress relocs as section relocs, but
`ld -r` can turn those relocs into symbol ones. It turns out that we
weren't handling that case correctly when the symbol was a weak def
whose definition did not prevail.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D113702
Petr Hosek [Fri, 12 Nov 2021 03:24:49 +0000 (19:24 -0800)]
[Fuchsia][CMake] Don't set libcxxabi and libunwind variables on Windows
We don't build libcxxabi and libunwind for Windows so don't set the
corresponding variables to avoid configuration errors.
Differential Revision: https://reviews.llvm.org/D113729
Mogball [Fri, 12 Nov 2021 03:12:36 +0000 (03:12 +0000)]
[mlir][ods] Fix DenseSet ambiguous reference
Luís Ferreira [Thu, 11 Nov 2021 21:39:50 +0000 (13:39 -0800)]
[DebugInfo] run clang-format on some unformatted files
This trivial patch runs clang-format on some unformatted files before
doing logic changes and prevent hard to review diffs.
Differential Revision: https://reviews.llvm.org/D113572
Arthur Eubanks [Fri, 12 Nov 2021 02:53:34 +0000 (18:53 -0800)]
[llvm-reduce] Fix build after D113537
Forgot to amend D113537 with these changes before committing.
Arthur Eubanks [Fri, 12 Nov 2021 02:45:59 +0000 (18:45 -0800)]
[llvm-reduce] Count chunks by running a preliminary reduction
Having a separate counting method runs the risk of a mismatch between
the actual reduction method and the counting method.
Instead, create an Oracle that always returns true for shouldKeep(), run
the reduction, and count how many times shouldKeep() was called. The
module should not be modified if shouldKeep() always returns true.
Reviewed By: Meinersbur
Differential Revision: https://reviews.llvm.org/D113537
Arthur Eubanks [Wed, 10 Nov 2021 01:47:43 +0000 (17:47 -0800)]
[llvm-reduce] Skip replacing metadata and callee operands
Metadata operands tend to require special conditions, especially on dbg
intrinsics. We also don't have a zero value for metadata.
Replacing callee operands is a little weird, since calling undef/null
doesn't make sense. It also causes tons of invalid reductions when
reducing calls to intrinsics since only arguments to intrinsics can be
of the metadata type.
Reviewed By: Meinersbur
Differential Revision: https://reviews.llvm.org/D113532
Arthur Eubanks [Wed, 10 Nov 2021 20:51:51 +0000 (12:51 -0800)]
[gn build] Fix Android compiler-rt targets
If a sysroot was specified, it would take precedence over the Android
NDK sysroot since it would appear after in the command line.
Also only build runtimes for enabled target arches. Many places have
copied this around so create and use supported_android_toolchains.
Reviewed By: pcc
Differential Revision: https://reviews.llvm.org/D113606
Mehdi Amini [Fri, 12 Nov 2021 02:30:53 +0000 (02:30 +0000)]
Revert "[mlir] Allow out-of-tree python building from installed MLIR."
This reverts commit
c7be8b75399c727ec9e1ddc3f81510f284c65155.
Build is broken (multiple buildbots)
LLVM GN Syncbot [Fri, 12 Nov 2021 02:22:04 +0000 (02:22 +0000)]
[gn build] Port
c15f930e9656
Michael Kruse [Fri, 12 Nov 2021 00:23:27 +0000 (18:23 -0600)]
[llvm-reduce] Introduce operands-skip pass.
Add a new "operands-skip" pass whose goal is to remove instructions in the middle of dependency chains. For instance:
```
%baseptr = alloca i32
%arrayidx = getelementptr i32, i32* %baseptr, i32 %idxprom
store i32 42, i32* %arrayidx
```
might be reducible to
```
%baseptr = alloca i32
%arrayidx = getelementptr ... ; now dead, together with the computation of %idxprom
store i32 42, i32* %baseptr
```
Other passes would either replace `%baseptr` with undef (operands, instructions) or move it to become a function argument (operands-to-args), both of which might fail the interestingness check.
In principle the implementation allows operand replacement with any value or instruction in the function that passes the filter constraints (same type, dominance, "more reduced"), but is limited in this patch to values that are directly or indirectly used to compute the current operand value, motivated by the example above. Additionally, function arguments are added to the candidate set which helps reducing the number of relevant arguments mitigating a concern of too many arguments mentioned in https://reviews.llvm.org/D110274#3025013.
Possible future extensions:
* Instead of requiring the same type, bitcast/trunc/zext could be automatically inserted for some more flexibility.
* If undef is added to the candidate set, "operands-skip"is able to produce any reduction that "operands" can do. Additional candidates might be zero and one, where the "reductive power" classification can prefer one over the other. If undefined behaviour should not be introduced, undef can be removed from the candidate set.
Recommit after resolving conflict with D112651 and reusing
shouldReduceOperand from D113532.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D111818
Stella Laurenzo [Fri, 12 Nov 2021 01:31:39 +0000 (17:31 -0800)]
[mlir] Allow out-of-tree python building from installed MLIR.
* Depends on D111504, which provides the boilerplate for building aggregate shared libraries from installed MLIR.
* Adds a full-fledged Python example dialect and tests to the Standalone example (need to do a bit of tweaking in the top level CMake and lit tests to adapt better to if not building with Python enabled).
* Rips out remnants of custom extension building in favor of `pybind11_add_module` which does the right thing.
* Makes python and extension sources installable (outputs to src/python/${name} in the install tree): Both Python and C++ extension sources get installed as downstreams need all of this in order to build a derived version of the API.
* Exports sources targets (with our properties that make everything work) by converting them to INTERFACE libraries (which have export support), as recommended for the forseeable future by CMake devs. Renames custom properties to start with lower-case letter, as also recommended/required (groan).
* Adds a ROOT_DIR argument to `declare_mlir_python_extension` since now all C++ sources for an extension must be under the same directory (to line up at install time).
* Need to validate against a downstream or two and adjust, prior to submitting.
Downstreams will need to adapt by:
* Remove absolute paths from any SOURCES for `declare_mlir_python_extension` (I believe all downstreams are just using `${CMAKE_CURRENT_SOURCE_DIR}` here, which can just be ommitted). May need to set `ROOT_DIR` if not relative to the current source directory.
* To allow further downstreams to install/build, will need to make sure that all C++ extension headers are also listed under SOURCES for `declare_mlir_python_extension`.
Reviewed By: stephenneuendorffer, mikeurbach
Differential Revision: https://reviews.llvm.org/D111513
Mogball [Fri, 12 Nov 2021 01:39:15 +0000 (01:39 +0000)]
[mlir][ods] Escape attribute summaries
Phoebe Wang [Fri, 12 Nov 2021 00:50:07 +0000 (08:50 +0800)]
[X86][FP16] Avoid to generate VZEXT_MOVL with i16
This fixes the crash due to lacking VZEXT_MOVL support with i16.
Reviewed By: LuoYuanke, RKSimon
Differential Revision: https://reviews.llvm.org/D113661
Michael Kruse [Fri, 12 Nov 2021 01:25:39 +0000 (19:25 -0600)]
Revert "[llvm-reduce] Introduce operands-skip pass."
This reverts commit
fa4210a9a0729eba04593b7df7b701e2b243de39.
It causes compile failures, presumably because conflicting with another
patch landed after I checked locally.
Matthias Springer [Fri, 12 Nov 2021 01:00:43 +0000 (10:00 +0900)]
[mlir][linalg][bufferize] Decouple ComprehensiveBufferize from Linalg
The remaining dialects will be decoupled from ComprehensiveBufferize in separate commits.
Differential Revision: https://reviews.llvm.org/D113459
Mogball [Thu, 11 Nov 2021 22:08:54 +0000 (22:08 +0000)]
[mlir][ods] Unique attribute, successor, region constraints
With `-Os` turned on, results in 2-5% binary size reduction
(depends on the original binary). Without it, the binary size
is essentially unchanged.
Depends on D113128
Differential Revision: https://reviews.llvm.org/D113331
Michael Kruse [Fri, 12 Nov 2021 00:23:27 +0000 (18:23 -0600)]
[llvm-reduce] Introduce operands-skip pass.
Add a new "operands-skip" pass whose goal is to remove instructions in the middle of dependency chains. For instance:
```
%baseptr = alloca i32
%arrayidx = getelementptr i32, i32* %baseptr, i32 %idxprom
store i32 42, i32* %arrayidx
```
might be reducible to
```
%baseptr = alloca i32
%arrayidx = getelementptr ... ; now dead, together with the computation of %idxprom
store i32 42, i32* %baseptr
```
Other passes would either replace `%baseptr` with undef (operands, instructions) or move it to become a function argument (operands-to-args), both of which might fail the interestingness check.
In principle the implementation allows operand replacement with any value or instruction in the function that passes the filter constraints (same type, dominance, "more reduced"), but is limited in this patch to values that are directly or indirectly used to compute the current operand value, motivated by the example above. Additionally, function arguments are added to the candidate set which helps reducing the number of relevant arguments mitigating a concern of too many arguments mentioned in https://reviews.llvm.org/D110274#3025013.
Possible future extensions:
* Instead of requiring the same type, bitcast/trunc/zext could be automatically inserted for some more flexibility.
* If undef is added to the candidate set, "operands-skip"is able to produce any reduction that "operands" can do. Additional candidates might be zero and one, where the "reductive power" classification can prefer one over the other. If undefined behaviour should not be introduced, undef can be removed from the candidate set.
Reviewed By: aeubanks
Differential Revision: https://reviews.llvm.org/D111818
Matthias Springer [Fri, 12 Nov 2021 00:50:35 +0000 (09:50 +0900)]
[mlir][linalg][bufferize] Add PostAnalysisStep
This helper struct allows users of ComprehensiveBufferize to inject "post analysis" steps that are implemented after the analysis but before the bufferization.
Differential Revision: https://reviews.llvm.org/D113458
Matheus Izvekov [Fri, 12 Nov 2021 00:27:27 +0000 (01:27 +0100)]
[lldb] fix test expectation broken by clang fix at D110216
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Differential Revision: https://reviews.llvm.org/D113722
Matheus Izvekov [Mon, 13 Sep 2021 13:35:45 +0000 (15:35 +0200)]
[clang] retain type sugar in auto / template argument deduction
This implements the following changes:
* AutoType retains sugared deduced-as-type.
* Template argument deduction machinery analyses the sugared type all the way
down. It would previously lose the sugar on first recursion.
* Undeduced AutoType will be properly canonicalized, including the constraint
template arguments.
* Remove the decltype node created from the decltype(auto) deduction.
As a result, we start seeing sugared types in a lot more test cases,
including some which showed very unfriendly `type-parameter-*-*` types.
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: rsmith
Differential Revision: https://reviews.llvm.org/D110216