Valentin Clement [Mon, 29 Nov 2021 16:07:49 +0000 (17:07 +0100)]
[fir] Get rid of the global option in FIRBuilder
Replace the global option `nameLengthHashSize` with a constexpr
with the same name. The option was not used in fir-dev so switching
to a constexpr is fine.
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D114630
Roman Lebedev [Mon, 29 Nov 2021 15:37:07 +0000 (18:37 +0300)]
[X86][Costmodel] `getInterleavedMemoryOpCostAVX512()`: masked load can not be folded into a shuffle
The mask on the shuffle is for the output, not the input.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D114697
Mirko Brkusanin [Fri, 26 Nov 2021 16:01:35 +0000 (17:01 +0100)]
[AMDGPU][GlobalISel] Transform (fsub (fpext (fneg (fmul x, y))), z) -> (fneg (fma (fpext x), (fpext y), z))
Patch by: Mateja Marjanovic
Differential Revision: https://reviews.llvm.org/D98050
Mirko Brkusanin [Fri, 26 Nov 2021 16:01:35 +0000 (17:01 +0100)]
[AMDGPU][GlobalISel] Transform (fsub (fpext (fmul x, y)), z) -> (fma (fpext x), (fpext y), (fneg z))
Patch by: Mateja Marjanovic
Differential Revision: https://reviews.llvm.org/D98049
Mirko Brkusanin [Fri, 26 Nov 2021 16:01:34 +0000 (17:01 +0100)]
[AMDGPU][GlobalISel] Transform (fsub (fneg (fmul, x, y)), z) -> (fma (fneg x), y, (fneg z))
Patch by: Mateja Marjanovic
Differential Revision: https://reviews.llvm.org/D98048
Mirko Brkusanin [Fri, 26 Nov 2021 16:01:34 +0000 (17:01 +0100)]
[AMDGPU][GlobalISel] Transform (fsub (fmul x, y), z) -> (fma x, y, -z)
Patch by: Mateja Marjanovic
Differential Revision: https://reviews.llvm.org/D96614
Mirko Brkusanin [Fri, 26 Nov 2021 16:01:33 +0000 (17:01 +0100)]
[AMDGPU][GlobalISel] Transform (fadd (fma x, y, (fpext (fmul u, v))), z) -> (fma x, y, (fma (fpext u), (fpext v), z))
Patch by: Mateja Marjanovic
Differential Revision: https://reviews.llvm.org/D98047
Mirko Brkusanin [Fri, 26 Nov 2021 16:01:33 +0000 (17:01 +0100)]
[AMDGPU][GlobalISel] Transform (fadd (fma x, y, (fmul u, v)), z) -> (fma x, y, (fma u, v, z))
Patch by: Mateja Marjanovic
Differential Revision: https://reviews.llvm.org/D97938
Mirko Brkusanin [Fri, 26 Nov 2021 16:01:32 +0000 (17:01 +0100)]
[AMDGPU][GlobalISel] Transform (fadd (fpext (fmul x, y)), z) -> (fma (fpext x), (fpext y), z)
Patch by: Mateja Marjanovic
Differential Revision: https://reviews.llvm.org/D97937
Mirko Brkusanin [Fri, 26 Nov 2021 16:01:32 +0000 (17:01 +0100)]
[AMDGPU][GlobalISel] Transform (fadd (fmul x, y), z) -> (fma x, y, z)
Patch by: Mateja Marjanovic
Differential Revision: https://reviews.llvm.org/D93305
Jay Foad [Mon, 29 Nov 2021 15:04:26 +0000 (15:04 +0000)]
[AMDGPU] Fix list indentation in docs
Jay Foad [Mon, 29 Nov 2021 15:00:47 +0000 (15:00 +0000)]
[AMDGPU] Fix "must generated" typo in docs
Omer Aviram [Mon, 29 Nov 2021 14:55:52 +0000 (09:55 -0500)]
[X86] Add vector test coverage for or with no common bits tests
Ensure D113970 handles vector types patterns as well.
Differential Revision: https://reviews.llvm.org/D114575
Stephan Herhut [Mon, 29 Nov 2021 13:39:51 +0000 (14:39 +0100)]
[mlir][memref] Fix bug in verification of memref.collapse_shape
The verifier computed an illegal type with negative dimension size when collapsing partially static memrefs.
Differential Revision: https://reviews.llvm.org/D114702
Erich Keane [Mon, 29 Nov 2021 14:28:02 +0000 (06:28 -0800)]
Reapply 'Implement target_clones multiversioning'
See discussion in D51650, this change was a little aggressive in an
error while doing a 'while we were here', so this removes that error
condition, as it is apparently useful.
This reverts commit
bb4934601d731465e01e2e22c80ce2dbe687d73f.
mydeveloperday [Mon, 29 Nov 2021 14:22:28 +0000 (14:22 +0000)]
[clang-format] regressed default behavior for operator parentheses
{D110833} regressed behavior of spaces before parentheses for operators, this revision reverts that so that operators are handled as they were before.
I think in hindsight it was a mistake to try and consume operator behaviour in with the function behaviour, I think Operators can be considered a special style. Its seems the code is getting confused as to if this is a function declaration or definition.
I think latterly we can consider adding an operator parentheses specific custom option but this should have been explicitly called out as it can impact projects.
Reviewed By: HazardyKnusperkeks, curdeius
Differential Revision: https://reviews.llvm.org/D114696
David Sherwood [Thu, 25 Nov 2021 15:39:18 +0000 (15:39 +0000)]
[CodeGen][AArch64] Bail out in performConcatVectorsCombine for scalable vectors
I tried to exercise the existing combine patterns in performConcatVectorsCombine
for scalable vectors and at the moment it doesn't seem possible. Parts of
the code currently assume we're dealing with fixed-width vectors with calls
to getVectorNumElements(), therefore I've decided to simply bail out early
for scalable vectors.
Added a test here to show that we don't crash when attempting to combine
truncate + concat:
CodeGen/AArch64/concat_vector-truncate-combine.ll
Differential Revision: https://reviews.llvm.org/D114600
Erich Keane [Thu, 11 Nov 2021 20:55:45 +0000 (12:55 -0800)]
Don't consider 'LinkageSpec' when calculating DeclContext 'Encloses'
We don't properly handle lookup through using directives when there is
a linkage spec in the common chain. This is because `CppLookupName` and
`CppNamespaceLookup` end up skipping `LinkageSpec`'s (correctly, as they
are not lookup scopes), but the `UnqualUsingDirectiveSet` does not.
I discovered that when we are calculating the `CommonAncestor` for a
using-directive, we were coming up with the `LinkageSpec`, instead of
the `LinkageSpec`'s parent. Then, when we use
`UnqualUsingDirectiveSet::getNamespacesFor` a scope, we don't end up
finding any that were in the `LinkageSpec` (again, since `CppLookupName`
skips linkage specs), so those don't end up participating in the lookup.
The function `UnqualUsingDirectiveSet::addUsingDirective` calculates
this common ancestor via a loop through the the `DeclSpec::Encloses`
function.
Changing this Encloses function to believe that a `LinkageSpec`
`Encloses` nothing ends up fixing the problem without breaking any other tests,
so I opted to do that. A less aggressive patch could perhaps change only
the `addUsingDirective`, but my examination of all uses of `Encloses`
showed that it seems to be used exclusively in lookup, which makes me think
this is correct everywhere.
Differential Revision: https://reviews.llvm.org/D113709
Roman Lebedev [Mon, 29 Nov 2021 13:44:33 +0000 (16:44 +0300)]
[NFC][X86][LV][Costmodel] Add most basic test for masked interleaved load
Zhuo Zhang [Mon, 29 Nov 2021 13:00:02 +0000 (21:00 +0800)]
fix typos in comments
Bjorn Pettersson [Wed, 22 Sep 2021 20:52:41 +0000 (22:52 +0200)]
Use a deterministic order when updating the DominatorTree
This solves a problem with non-deterministic output from opt due
to not performing dominator tree updates in a deterministic order.
The problem that was analysed indicated that JumpThreading was using
the DomTreeUpdater via llvm::MergeBasicBlockIntoOnlyPred. When
preparing the list of updates to send to DomTreeUpdater::applyUpdates
we iterated over a SmallPtrSet, which didn't give a well-defined
order of updates to perform.
The added domtree-updates.ll test case is an example that would
result in non-deterministic printouts of the domtree. Semantically
those domtree:s are equivalent, but it show the fact that when we
use the domtree iterator the order in which nodes are visited depend
on the order in which dominator tree updates are performed.
Since some passes (at least EarlyCSE) are iterating over nodes in the
dominator tree in a similar fashion as the domtree printer, then the
order in which transforms are applied by such passes, transitively,
also depend on the order in which dominator tree updates are
performed. And taking EarlyCSE as an example the end result could be
different depending on in which order the transforms are applied.
Reviewed By: nikic, kuhar
Differential Revision: https://reviews.llvm.org/D110292
Bradley Smith [Wed, 24 Nov 2021 16:47:02 +0000 (16:47 +0000)]
[AArch64][SVE] Mark fixed-type FP extending/truncating loads/stores as custom
This allows the generic DAG combine to fold fp_extend/fp_trunc into
loads/stores which we can then lower into a integer extending
load/truncating store plus an FP_EXTEND/FP_ROUND.
The nuance here is that fixed-type FP_EXTEND/FP_ROUND require unpacked
types hence lowering them introduces an unpack/zip. By allowing these
nodes to be combined with loads/store we make it much easier to have
this unpack/zip combined into the load/store by our custom lowering.
Differential Revision: https://reviews.llvm.org/D114580
Roman Lebedev [Mon, 29 Nov 2021 11:41:48 +0000 (14:41 +0300)]
[X86][Costmodel] Now that `getReplicationShuffleCost()` is good, update `getInterleavedMemoryOpCostAVX512()`
... to actually ask about i1-elt-wide mask, since that is what will probably be used on AVX512.
This unblocks D111460.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D114316
Valentin Clement [Mon, 29 Nov 2021 09:58:22 +0000 (10:58 +0100)]
[fir] Add data flow optimization pass
Add pass to perform store/load forwarding and potentially removing dead
stores.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: kiranchandramohan, schweitz, mehdi_amini, awarzynski
Differential Revision: https://reviews.llvm.org/D111288
Balazs Benics [Mon, 29 Nov 2021 09:39:36 +0000 (10:39 +0100)]
[analyzer][NFC] Refactor AnalysisConsumer::getModeForDecl()
I just read this part of the code, and I found the nested ifs less
readable.
Reviewed By: martong
Differential Revision: https://reviews.llvm.org/D114441
Valentin Clement [Mon, 29 Nov 2021 09:21:30 +0000 (10:21 +0100)]
[fir] Add assignment runtime API builder
This patch adds the builder that generate assignment runtime API calls.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: rovka, awarzynski
Differential Revision: https://reviews.llvm.org/D114475
Co-authored-by: Jean Perier <jperier@nvidia.com>
Valentin Clement [Mon, 29 Nov 2021 09:08:19 +0000 (10:08 +0100)]
[fir] Add fir transformational intrinsic builder
This patch adds the builder to generate transformational
intrinsic runtime API calls.
This patch is part of the upstreaming effort from fir-dev branch.
Reviewed By: rovka
Differential Revision: https://reviews.llvm.org/D114470
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: mleair <leairmark@gmail.com>
Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
Florian Hahn [Mon, 29 Nov 2021 09:09:00 +0000 (09:09 +0000)]
[LV] Move code from widenInstruction to VPWidenRecipe. (NFC)
The code in widenInstruction has already been transitioned to
only rely on information provided by VPWidenRecipe directly.
Moving the code directly to VPWidenRecipe::execute completes
the transition for the recipe.
It provides the following advantages:
1. Less indirection, easier to see what's going on.
2. Removes accesses to fields of ILV.
2) in particular ensures that no dependencies on
fields in ILV for vector code generation are re-introduced.
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D114322
Valentin Clement [Mon, 29 Nov 2021 09:07:13 +0000 (10:07 +0100)]
[fir] Add base for runtime builder unittests
This patch adds the common base shared by builder runtime
unittests. It extracted from D114460 to make it easier to base other patches
on it.
Reviewed By: kiranchandramohan, rovka
Differential Revision: https://reviews.llvm.org/D114557
Balazs Benics [Mon, 29 Nov 2021 08:56:43 +0000 (09:56 +0100)]
[clang-tidy] Ignore narrowing conversions in case of bitfields
Bitfields are special. Due to integral promotion [conv.prom/5] bitfield
member access expressions are frequently wrapped by an implicit cast to
`int` if that type can represent all the values of the bitfield.
Consider these examples:
struct SmallBitfield { unsigned int id : 4; };
x.id & 1; (case-1)
x.id & 1u; (case-2)
x.id << 1u; (case-3)
(unsigned)x.id << 1; (case-4)
Due to the promotion rules, we would get a warning for case-1. It's
debatable how useful this is, but the user at least has a convenient way
of //fixing// it by adding the `u` unsigned-suffix to the literal as
demonstrated by case-2. However, this won't work for shift operators like
the one in case-3. In case of a normal binary operator, both operands
contribute to the result type. However, the type of the shift expression is
the promoted type of the left operand. One could still suppress this
superfluous warning by explicitly casting the bitfield member access as
case-4 demonstrates, but why? The compiler already knew that the value from
the member access should safely fit into an `int`, why do we have this
warning in the first place? So, hereby we suppress this specific scenario,
when a bitfield's value is implicitly cast to int (likely due to integral
promotion).
Note that the bitshift operation might invoke unspecified/undefined
behavior, but that's another topic, this checker is about detecting
conversion-related defects.
Example AST for `x.id << 1`:
BinaryOperator 'int' '<<'
|-ImplicitCastExpr 'int' <IntegralCast>
| `-ImplicitCastExpr 'unsigned int' <LValueToRValue>
| `-MemberExpr 'unsigned int' lvalue bitfield .id
| `-DeclRefExpr 'SmallBitfield' lvalue ParmVar 'x' 'SmallBitfield'
`-IntegerLiteral 'int' 1
Reviewed By: courbet
Differential Revision: https://reviews.llvm.org/D114105
Balazs Benics [Mon, 29 Nov 2021 08:56:43 +0000 (09:56 +0100)]
[clang-tidy] Fix crashing altera-struct-pack-align on invalid RecordDecls
Reviewed-By: martong
Differential Revision: https://reviews.llvm.org/D114256
Balazs Benics [Mon, 29 Nov 2021 08:56:43 +0000 (09:56 +0100)]
[libtooling][clang-tidy] Fix crashing on rendering invalid SourceRanges
Invalid SourceRanges can occur generally if the code does not compile,
thus we expect clang error diagnostics.
Unlike `clang`, `clang-tidy` did not swallow invalid source ranges, but
tried to highlight them, and blow various assertions.
The following two examples produce invalid source ranges, but this is
not a complete list:
void test(x); // error: unknown type name 'x'
struct Foo {
member; // error: C++ requires a type specifier for all declarations
};
Thanks @whisperity helping me fix this.
Reviewed-By: xazax.hun
Differential Revision: https://reviews.llvm.org/D114254
Balazs Benics [Mon, 29 Nov 2021 08:56:43 +0000 (09:56 +0100)]
Fix cppcoreguidelines-virtual-base-class-destructor in macros
The `cppcoreguidelines-virtual-base-class-destructor` checker crashed on
this example:
#define DECLARE(CLASS) \
class CLASS { \
protected: \
virtual ~CLASS(); \
}
DECLARE(Foo); // no-crash
The checker will hit the following assertion:
clang-tidy: llvm/include/llvm/ADT/Optional.h:196: T &llvm::optional_detail::OptionalStorage<clang::Token, true>::getValue() & [T = clang::Token]: Assertion `hasVal' failed."
It turns out, `Lexer::findNextToken()` returned `llvm::None` within the
`getVirtualKeywordRange()` function when the `VirtualEndLoc`
SourceLocation represents a macro expansion.
To prevent this from happening, I decided to propagate the `llvm::None`
further up and only create the removal of `virtual` if the
`getVirtualKeywordRange()` succeeds.
I considered an alternative fix for this issue:
I could have checked the `Destructor.getLocation().isMacroID()` before
doing any Fixit calculation inside the `check()` function.
In contrast to this approach my patch will preserve the diagnostics and
drop the fixits only if it would have crashed.
Reviewed By: whisperity
Differential Revision: https://reviews.llvm.org/D113558
David Sherwood [Tue, 23 Nov 2021 14:36:08 +0000 (14:36 +0000)]
[CodeGen][SVE] Use whilelo instruction when lowering @llvm.get.active.lane.mask
In most common cases the @llvm.get.active.lane.mask intrinsic maps directly
to the SVE whilelo instruction, which already takes overflow into account.
However, currently in SelectionDAGBuilder::visitIntrinsicCall we always lower
this immediately to a generic sequence of instructions that explicitly
take overflow into account. This makes it very difficult to then later
transform back into a single whilelo instruction. Therefore, this patch
introduces a new TLI function called shouldExpandGetActiveLaneMask that asks if
we should lower/expand this to a sequence of generic ISD nodes, or instead
just leave it as an intrinsic for the target to lower.
You can see the significant improvement in code quality for some of the
tests in this file:
CodeGen/AArch64/active_lane_mask.ll
Differential Revision: https://reviews.llvm.org/D114542
Jean Perier [Mon, 29 Nov 2021 07:27:16 +0000 (08:27 +0100)]
[flang] Return true in IsSymplyContiguous for allocatables
The current code was relying on the fact that allocatables are deferred
shape and that isAssumedShape() should therefore return true for them.
This is not true, because the current parsing/semantic analysis always
builds a semantics::ArraySpec for `x(:)` that returns true to both
isDeferredShape()/isAssumedShape(), whether x is allocatable/pointer or
not.
It proved tricky to change this behavior, so this is a simple fix for
IsSymplyContiguous where it currently matters, but we most likely want
to investigate more and fix the isDeferredShape()/isAssumedShape() in
a second time.
Differential Revision: https://reviews.llvm.org/D114599
Fangrui Song [Mon, 29 Nov 2021 05:47:55 +0000 (21:47 -0800)]
[ELF] Avoid std::stable_partition which may allocate memory. NFC
Fangrui Song [Mon, 29 Nov 2021 05:07:33 +0000 (21:07 -0800)]
[ELF] Speed up/simplify removeUnusedSyntheticSections. NFC
Make one change: when the OutputSection is nullptr (due to /DISCARD/ or garbage
collected BssSection (replaceCommonSymbols)), discard the SyntheticSection as well.
Endre Fülöp [Fri, 5 Nov 2021 09:42:44 +0000 (10:42 +0100)]
[analyzer][doc] Add user documenation for taint analysis
Checker alpha.security.taint.TaintPropagation now has user documentation for
taint analysis with an example showing external YAML configuration format.
The format of the taint configuration file is now documented under the user
documentation of Clang SA.
Differential Revision: https://reviews.llvm.org/D113251
Fangrui Song [Mon, 29 Nov 2021 03:50:33 +0000 (19:50 -0800)]
[ELF] Decrease InputSectionBase::entsize to uint32_t
While here, change the sh_addralign argument to uint32_t (InputSection ctor's
argument and the member are uint32_t); add constexpr.
Fangrui Song [Mon, 29 Nov 2021 03:08:27 +0000 (19:08 -0800)]
[ELF] Simplify some ctx->outSec with sec. NFC
Fangrui Song [Mon, 29 Nov 2021 03:05:15 +0000 (19:05 -0800)]
[ELF] Simplify/remove LinkerScript::switchTo. NFC
Jake Egan [Mon, 29 Nov 2021 02:55:13 +0000 (21:55 -0500)]
[AIX] Disable empty.ll test using unsupported split dwarf
This test uses split-dwarf feature, which is not currently supported on AIX. Set this test to `UNSUPPORTED` on AIX for now.
Reviewed By: shchenz
Differential Revision: https://reviews.llvm.org/D114567
Fangrui Song [Mon, 29 Nov 2021 02:44:23 +0000 (18:44 -0800)]
[ELF] Support --oformat= beside Separate --oformat
Both GNU ld's manpage and ours use --oformat= as the canonical form.
It's odd that we do not support it...
Fangrui Song [Mon, 29 Nov 2021 02:33:55 +0000 (18:33 -0800)]
[ELF][test] --oformat binary: Check that SIZEOF_HEADERS==0
Saleem Abdulrasool [Mon, 29 Nov 2021 02:21:57 +0000 (18:21 -0800)]
test: add a lit configuration for Windows subdirectory
This adds a local configuration to the Windows subdirectory to filter
out the tests on non-Windows platforms using the lit filtering.
Kazu Hirata [Mon, 29 Nov 2021 02:14:49 +0000 (18:14 -0800)]
[llvm] Use range-based for loops (NFC)
Stella Laurenzo [Sun, 28 Nov 2021 23:33:03 +0000 (15:33 -0800)]
[mlir][python] Normalize asm-printing IR behavior.
While working on an integration, I found a lot of inconsistencies on IR printing and verification. It turns out that we were:
* Only doing "soft fail" verification on IR printing of Operation, not of a Module.
* Failed verification was interacting badly with binary=True IR printing (causing a TypeError trying to pass an `str` to a `bytes` based handle).
* For systematic integrations, it is often desirable to control verification yourself so that you can explicitly handle errors.
This patch:
* Trues up the "soft fail" semantics by having `Module.__str__` delegate to `Operation.__str__` vs having a shortcut implementation.
* Fixes soft fail in the presence of binary=True (and adds an additional happy path test case to make sure the binary functionality works).
* Adds an `assume_verified` boolean flag to the `print`/`get_asm` methods which disables internal verification, presupposing that the caller has taken care of it.
It turns out that we had a number of tests which were generating illegal IR but it wasn't being caught because they were doing a print on the `Module` vs operation. All except two were trivially fixed:
* linalg/ops.py : Had two tests for direct constructing a Matmul incorrectly. Fixing them made them just like the next two tests so just deleted (no need to test the verifier only at this level).
* linalg/opdsl/emit_structured_generic.py : Hand coded conv and pooling tests appear to be using illegal shaped inputs/outputs, causing a verification failure. I just used the `assume_verified=` flag to restore the original behavior and left a TODO. Will get someone who owns that to fix it properly in a followup (would also be nice to break this file up into multiple test modules as it is hard to tell exactly what is failing).
Notes to downstreams:
* If, like some of our tests, you get verification failures after this patch, it is likely that your IR was always invalid and you will need to fix the root cause. To temporarily revert to prior (broken) behavior, replace calls like `print(module)` with `print(module.operation.get_asm(assume_verified=True))`.
Differential Revision: https://reviews.llvm.org/D114680
Fangrui Song [Mon, 29 Nov 2021 00:58:06 +0000 (16:58 -0800)]
[ELF] Simplify/remove LinkerScript::output and advance. NFC
Nathan Ridge [Mon, 29 Nov 2021 00:29:06 +0000 (19:29 -0500)]
Compilation Database: Point Bazel users to a solution
This doc lists ways of getting compilation databases out of some popular build systems for use with clangd and other tooling.
We built such a way for Bazel and just released it after a bunch of requests on GitHub. Thought I should propose that we add a link to help people find it and use clang tooling.
(This is my first revision submitted via LLVM Phabricator, so if I've messed something up, I'd really appreciate your help and patience. Asking for a review from Sam McCall, because I've had a great time working with him elsewhere on GitHub before and because I saw him in the Git history for this file.)
Reviewed By: sammccall
Differential Revision: https://reviews.llvm.org/D114213
Fangrui Song [Mon, 29 Nov 2021 00:17:10 +0000 (16:17 -0800)]
[ELF] Remove unneeded getOutputSectionVA. NFC
I attempted to remove it 1 or 2 year ago but kept it just to have a good
diagnostic in case the output section is nullptr (should be impossible).
It is long enough that we haven't seen such a case.
Fangrui Song [Mon, 29 Nov 2021 00:09:04 +0000 (16:09 -0800)]
[ELF] Inline InputSection::getOffset into callers and remove it. NFC
This is an unneeded abstraction which may cause confusion:
SectionBase::getOffset has the same name but hard codes -1 as the size of OutputSection.
Patrick Oppenlander [Sun, 28 Nov 2021 23:39:55 +0000 (15:39 -0800)]
[Driver] Support PowerPC SPE musl dynamic linker name ld-musl-powerpc-sf.so.1
Musl treats PowerPC SPE as a soft-float target (as the PowerPC SPE ABI
is soft-float compatible).
Reviewed By: jhibbits, MaskRay
Differential Revision: https://reviews.llvm.org/D105869
Fangrui Song [Sun, 28 Nov 2021 23:32:29 +0000 (15:32 -0800)]
[ELF] Replace one make_unique from r316378 with a stack object. NFC
Fangrui Song [Sun, 28 Nov 2021 22:56:29 +0000 (14:56 -0800)]
[ELF] Simplify OutputSection::sectionIndex assignment. NFC
And improve comments.
Fangrui Song [Sun, 28 Nov 2021 22:47:57 +0000 (14:47 -0800)]
[ELF] Fix out-of-bounds write in memset(&Out::first, ...)
Fix r285764: there is no guarantee that Out::first is placed before other
static data members of `struct Out`. After `bufferStart` was introduced, this
out-of-bounds write is destined in many compilers. It is likely benign, though.
And move `Out::elfHeader->size` assignment beside `Out::elfHeader->sectionIndex`
Fangrui Song [Sun, 28 Nov 2021 21:44:41 +0000 (13:44 -0800)]
[ELF] Simplify assignFileOffsets
There is a difference with non-SHF_ALLOC SHT_NOBITS when off%sh_addralign!=0
which doesn't happen/matter in practice.
Nicolas Vasilache [Sun, 28 Nov 2021 21:26:29 +0000 (21:26 +0000)]
[mlir] NFC - Move invalid.mlir tests to the proper dialects
Dimitry Andric [Sun, 28 Nov 2021 17:09:06 +0000 (18:09 +0100)]
[AArch64] Avoid crashing on invalid -Wa,-march= values
As reported in https://bugs.freebsd.org/260078, the gnutls Makefiles
pass -Wa,-march=all to compile a number of assembly files. Clang does
not support this -march value, but because of a mistake in handling
the arguments, an unitialized Arg pointer is dereferenced, which can
cause a segfault.
Work around this by adding a check if the local WaMArch variable is
initialized, and if so, using its value in the diagnostic message.
Reviewed By: tschuett
Differential Revision: https://reviews.llvm.org/D114677
Nikita Popov [Sun, 28 Nov 2021 20:53:25 +0000 (21:53 +0100)]
[DSE] Use MapVector for IOLs
I'm not sure whether this can cause any actual non-determinism,
but at least it makes the DSE debug log non-deterministic, which
makes it harder to debug other non-determinism issues.
Fangrui Song [Sun, 28 Nov 2021 20:47:49 +0000 (12:47 -0800)]
[ELF] -z separate-*: Use max-page-size instead of common-page-size for text/non-SHF_ALLOC transition and writeTrapInstr
For -z separate-code and -z separate-loadable-segments:
When RW is present, the RX to RW transition is aligned with max-page-size.
When RW is absent, the RX to non-SHF_ALLOC transition should use max-page-size as well.
Fangrui Song [Sun, 28 Nov 2021 19:43:59 +0000 (11:43 -0800)]
[ELF] Simplify assignFileOffsets. NFC
Florian Hahn [Sun, 28 Nov 2021 18:29:18 +0000 (18:29 +0000)]
[LV] Move code from widenGEP to VPWidenGEPRecipe (NFC).
The code in widenGEP has already been transitioned to only rely on
information provided by VPWidenGEPRecipe directly.
Moving the code directly to VPWidenGEPRecipe::execute completes
the transition for the recipe.
It provides the following advantages:
1. Less indirection, easier to see what's going on.
2. Removes accesses to fields of ILV.
2) in particular ensures that no dependencies on
fields in ILV for GEP code generation are re-introduced.
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D114321
Kazu Hirata [Sun, 28 Nov 2021 18:04:54 +0000 (10:04 -0800)]
[llvm] Use range-based for loops (NFC)
Nico Weber [Fri, 26 Nov 2021 21:16:18 +0000 (16:16 -0500)]
[clang] Fix -Wreturn-type false positive in @try statements
After
04f30795f16638, -Wreturn-type has an effect on functions that
contain @try/@catch statements. CheckFallThrough() was missing
a case for ObjCAtTryStmts, leading to a false positive.
(What about the other two places in CheckFallThrough() that handle
CXXTryStmt but not ObjCAtTryStmts?
- I think the last use of CXXTryStmt is dead in practice:
04c6851cd made it so
that calls never add edges to try bodies, and the CFG block for a try
statement is always an empty block containing just the try element itself as
terminator (the try body itself is part of the normal flow of the function
and not connected to the block for the try statement itself. The try statment
cfg block is only connected to the catch bodies, and only reachable from
throw expressions within the try body.)
- The first use of CXXTryStmt might be important. It looks similar to
the code that adds all cfg blocks for try statements as roots of
the reachability graph for the reachability warnings, but I can't
find a way to trigger it. So I'm omitting it for now. The CXXTryStmt
code path seems to only be hit by try statements that are function
bodies without a surrounding compound statements
(`f() try { ... } catch ...`), and those don't exist for ObjC
@try statements.
)
Fixes PR52473.
Differential Revfision: https://reviews.llvm.org/D114660
David Green [Sun, 28 Nov 2021 16:36:17 +0000 (16:36 +0000)]
[ARM] Add testing for various fptosi.sat patterns. NFC
Sanjay Patel [Sun, 28 Nov 2021 14:59:37 +0000 (09:59 -0500)]
[InstCombine] use decomposeBitTestICmp to make icmp (trunc X), C more consistent
This is a follow-on suggested in D112634.
Two folds that were added with that patch are subsumed in the call to
decomposeBitTestICmp, and two other folds are potentially inverted.
The deleted folds were very specialized by instcombine standards
because they were restricted to legal integer types based on the data
layout. This generalizes the canonical form independent of target/types.
This change has a reasonable chance of exposing regressions either in
IR or codegen, but I don't have any evidence for either of those yet.
A spot check of asm across several in-tree targets shows variations
that I expect are mostly neutral.
We have one improvement in an existing IR test that I noted with a
comment. Using mask ops might also make more code match with D114272.
Differential Revision: https://reviews.llvm.org/D114386
Sanjay Patel [Sun, 28 Nov 2021 14:21:39 +0000 (09:21 -0500)]
[InstCombine] reduce code duplication; NFC
Mark de Wever [Sun, 28 Nov 2021 14:24:45 +0000 (15:24 +0100)]
[libc++] Add myself to the credits.
Noticed while updating the credits for the to_chars patch.
Mark de Wever [Sun, 28 Nov 2021 12:17:04 +0000 (13:17 +0100)]
[libc++] Remove support for Clang 9 and older.
I encountered this while reviewing an unrelated patch. Will land after
the CI passes.
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D114673
Florian Hahn [Sun, 28 Nov 2021 12:00:55 +0000 (12:00 +0000)]
[SCEV] Turn validity check in getExistingSCEV into assert (NFC).
Now that we track users of SCEV expressions, we should be able to always
invalidate containing expressions.
With that, I think the case where a value gets removed but
SCEVs containing references to it should not be possible any longer.
Turn check into an assert.
This slightly reduces compile-time:
NewPM-O3: -0.27%
NewPM-ReleaseThinLTO: -0.21%
NewPM-ReleaseLTO-g: -0.26%
http://llvm-compile-time-tracker.com/compare.php?from=
c3dc6b081da6ba503e67d260033f81f61eb38ea3&to=
95a4a028b1f1dd0bc3d221435953b7d2c031b3d5&stat=instructions
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D114633
Mark de Wever [Sun, 26 Sep 2021 15:11:42 +0000 (17:11 +0200)]
[libc++][format] Adds formatting benchmarks.
These benchmarks will be used to test the performance inpact of the next
set of optimization patches.
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D110501
Vitaly Buka [Tue, 23 Nov 2021 23:41:25 +0000 (15:41 -0800)]
[sanitizer] Remove storeIds and use padding of StackDepotNode
Depends on D114489.
Reviewed By: morehouse, dvyukov
Differential Revision: https://reviews.llvm.org/D114490
Sander de Smalen [Sun, 21 Nov 2021 20:07:51 +0000 (20:07 +0000)]
[LV] Fix incorrectly marking a pointer indvar as 'scalar'.
collectLoopScalars should only add non-uniform nodes to the list if they
are used by a load/store instruction that is marked as CM_Scalarize.
Before this patch, the LV incorrectly marked pointer induction variables
as 'scalar' when they required to be widened by something else,
such as a compare instruction, and weren't used by a node marked as
'CM_Scalarize'. This case is covered by sve-widen-phi.ll.
This change also allows removing some code where the LV tried to
widen the PHI nodes with a stepvector, even though it was marked as
'scalarAfterVectorization'. Now that this code is more careful about
marking instructions that need widening as 'scalar', this code has
become redundant.
Differential Revision: https://reviews.llvm.org/D114373
Sander de Smalen [Mon, 22 Nov 2021 15:50:39 +0000 (15:50 +0000)]
NFC: Simplify sve-widen-phi.ll by unrolling once.
The unroll factor > 1 has little value for what is being tested.
Vitaly Buka [Tue, 23 Nov 2021 20:35:39 +0000 (12:35 -0800)]
[sanitizer] Switch StackStore from pointers to 32bit IDs
Depends on D114488.
Reviewed By: morehouse, dvyukov, kstoimenov
Differential Revision: https://reviews.llvm.org/D114489
Chia-hung Duan [Sat, 27 Nov 2021 22:36:42 +0000 (22:36 +0000)]
[mlir] Enable MLIRDialectUtilsTests
Also remove `TooFewDims` test which tried to create an invalid AffineMap.
The creation of an invalid AffineMap is rejected by `willBeValidAffineMap`,
as a result we can deprecate the test.
Reviewed By: bondhugula
Differential Revision: https://reviews.llvm.org/D114657
David Green [Sat, 27 Nov 2021 20:21:41 +0000 (20:21 +0000)]
[ARM] CSINC/CSINV patterns from CMOV
We sometimes end up generating CMOV with constant operands that can be
simplified to CSINC or CSINV under Arm-8.1m. This adds some simple
patterns for them.
Differential Revision: https://reviews.llvm.org/D114349
Kazu Hirata [Sat, 27 Nov 2021 19:16:18 +0000 (11:16 -0800)]
[Target] Use range-based for loops (NFC)
David Green [Sat, 27 Nov 2021 19:07:16 +0000 (19:07 +0000)]
[ARM] Fold away unnecessary CSET/CMPZ
Codegen from expanded vector operations can end up with unnecessary
CMPZ/CSINC, of the form:
CSXYZ A, B, C1 (CMPZ (CSINC 0, 0, C2, D), 0)
These can be converted to remove the CMPZ and CSINC, depending on the
condition.
if C1==NE -> CSXYZ A, B, C2, D
if C1==EQ -> CSXYZ A, B, NOT(C2), D
Differential Revision: https://reviews.llvm.org/D114013
Simon Pilgrim [Fri, 26 Nov 2021 22:30:22 +0000 (22:30 +0000)]
[PowerPC] Regenerate ppc64-P9-vabsd.ll tests
Kristina Bessonova [Sat, 27 Nov 2021 15:56:40 +0000 (17:56 +0200)]
[DwarfCompileUnit] Set parent DIE right after creating a local entity
No functional changes intended.
Before this patch DwarfCompileUnit::createScopeChildrenDIE() and
DwarfCompileUnit::createAndAddScopeChildrenDIE() used to emit child subtrees
and then when all the children get created, attach them to a parent scope DIE.
However, when a DIE doesn't have a parent, all the requests for its unit DIE
fail.
Currently, this is not a big issue since it isn't usually needed to know unit DIE
for a local (function-scoped) entity. But once we introduce lexical blocks as
a valid scope for global variables (static locals) and type DIEs, any requests
for a unit DIE need to be guarded against local scope due to the potential
absence of the DIE's parent.
To avoid the aforementioned issue, this patch refactors a few DwarfCompileUnit
methods to support the idea of attaching a DIE to its parent as close to the
creation of this DIE as possible.
Reviewed By: ellis
Differential Revision: https://reviews.llvm.org/D114350
Nikita Popov [Fri, 19 Nov 2021 17:57:15 +0000 (18:57 +0100)]
[SCEV] Simplify forgetSymbolicName() (NFCI)
With the recently introduced tracking as well as D113349, we can
greatly simplify forgetSymbolicName(). In fact, we can simply
replace it with forgetMemoizedResults().
What forgetSymbolicName() used to do is to walk the IR use-def
chain to find all SCEVs that mention the SymbolicName. However,
thanks to use tracking, we can now determine the relevant SCEVs
in a more direct way. D113349 is needed to also clear out the
actual IR to SCEV mapping in ValueExprMap.
Differential Revision: https://reviews.llvm.org/D114263
Nikita Popov [Sat, 27 Nov 2021 15:17:09 +0000 (16:17 +0100)]
[SCEV] Simplify invalidation after BE count calculation (NFCI)
After backedge taken counts have been calculated, we want to
invalidate all addrecs and dependent expressions in the loop,
because we might compute better results with the newly available
backedge taken counts. Previously this was done with a forgetLoop()
style use-def walk. With recent improvements to SCEV invalidation,
we can instead directly invalidate any SCEVs using addrecs in this
loop. This requires a great deal less subtlety to avoid invalidating
more than necessary, and in particular gets rid of the hack from
D113349. The change is similar to D114263 in spirit.
David Green [Sat, 27 Nov 2021 13:21:09 +0000 (13:21 +0000)]
[ARM] Extra testing for v2i1 types. NFC
This adds extra tests for various operations from making the v2i1 type
legal.
Florian Hahn [Sat, 27 Nov 2021 13:04:28 +0000 (13:04 +0000)]
[DSE] Optimize defining access of defs while walking upwards.
This patch extends the code that walks memory defs upwards to find
clobbering accesses to also try to optimize the clobbering defining
access.
We should be able to find set the optimized access of our starting def
(KillingDef), if the following holds:
1. It is the first call of getDomMemoryDef for KillingDef (so Current
== KillingDef->getDefiningAccess().
2. No potentially aliasing defs are skipped.
Then if a (partly) aliasing def is encountered, it can be used as
optimized access for KillingDef. No further optimizations can be
applied to KillingDef.
I'd appreciate a careful look, as the existing documentation is not too
clear on what is expected for optimized accesses.
The motivation for this patch is to use the optimized accesses to cover
more cases of redundant stores as follow-up to D111727.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D112313
Kristina Bessonova [Sat, 27 Nov 2021 12:02:34 +0000 (14:02 +0200)]
[NVPTX][AsmPrinter] Avoid removing globals before calling AsmPrinter::doFinalization()
Instead of removing globals from a module, we, it seems, can just override
AsmPrinter::emitGlobalVariable() to do nothing as NVPTXAsmPrinter already
emitted globals by this time and we don't want to do it twice.
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D113653
Nikita Popov [Sat, 30 Oct 2021 19:40:14 +0000 (21:40 +0200)]
Reland [SCEV] Fix and validate ValueExprMap/ExprValueMap consistency
Relative to the previous landing attempt, this introduces an additional
flag on forgetMemoizedResults() to not remove SCEVUnknown phis from
the value map. The invalidation after BECount calculation wants to
leave these alone and skips them in its own use-def walk, but we can
still end up invalidating them via forgetMemoizedResults() if there
is another IR value with the same SCEV. This is intended as a temporary
workaround only, and the need for this should go away once the
getBackedgeTakenInfo() invalidation is refactored in the spirit of
D114263.
-----
This adds validation for consistency of ValueExprMap and
ExprValueMap, and fixes identified issues:
* Addrec construction directly wrote to ValueExprMap in a few places,
without updating ExprValueMap. Add a helper to ensures they stay
consistent. The adjustment in forgetSymbolicName() explicitly
drops the old value from the map, so that we don't rely on it
being overwritten.
* forgetMemoizedResultsImpl() was dropping the SCEV from
ExprValueMap, but not dropping the corresponding entries from
ValueExprMap.
Differential Revision: https://reviews.llvm.org/D113349
Ard Biesheuvel [Sat, 27 Nov 2021 09:26:37 +0000 (10:26 +0100)]
[ARM] implement support for ALU/LDR PC-relative group relocations
Currently, LLD does not support the complete set of ARM group relocations.
Given that I intend to start using these in the Linux kernel [0], let's add
support for these.
This implements the group processing as documented in the ELF psABI. Notably,
this means support is dropped for very far symbol references that also carry a
small component, where the immediate is rotated in such a way that only part of
it wraps to the other end of the 32-bit word. To me, it seems unlikely that
this is something anyone could be relying on, but of course I could be wrong.
[0] https://lore.kernel.org/r/
20211122092816.2865873-8-ardb@kernel.org/
Reviewed By: peter.smith, MaskRay
Differential Revision: https://reviews.llvm.org/D114172
Bjorn Pettersson [Thu, 18 Nov 2021 15:55:39 +0000 (16:55 +0100)]
[test] Use -passes syntax in Feature/OperandBundles lit tests
Simply use the new PM syntax instead of the deprecated legacy PM
syntax when specifying the opt pipeline in some regression tests.
Differential Revision: https://reviews.llvm.org/D114518
Bjorn Pettersson [Thu, 18 Nov 2021 15:51:19 +0000 (16:51 +0100)]
[test] Use -passes in lit tests for the UpdateTestChecks tool
The UpdateTestChecks tool itself does not care about which pass
manager that is used in the opt invocation. So the lit tests that
are verifying the behavior of the UpdateTestChecks tool is updated
to use the new-PM syntax (-passes=) when specifying the pass pipeline
in the test cases that are used for verifying the UpdateTestChecks
tool.
Differential Revision: https://reviews.llvm.org/D114517
Bjorn Pettersson [Thu, 18 Nov 2021 09:14:04 +0000 (10:14 +0100)]
[test] Use -passes syntax when specifying pipeline in some more tests
The legacy PM is deprecated, so update a bunch of lit tests running
opt to use the new PM syntax when specifying the pipeline.
In this patch focus has been put on test cases for ConstantMerge,
ConstraintElimination, CorrelatedValuePropagation, GlobalDCE,
GlobalOpt, SCCP, TailCallElim and PredicateInfo.
Differential Revision: https://reviews.llvm.org/D114516
Hsiangkai Wang [Wed, 4 Aug 2021 08:10:05 +0000 (16:10 +0800)]
[RISCV] Emit DWARF location expression for RVV stack objects.
VLENB is the length of a vector register in bytes. We use
<vscale x 64 bits> to represent one vector register. The dwarf offset is
VLENB * scalable_offset / 8.
For the mask vector, it occupies one vector register.
Differential Revision: https://reviews.llvm.org/D107432
Kazu Hirata [Sat, 27 Nov 2021 05:21:17 +0000 (21:21 -0800)]
[Target] Use range-based for loops (NFC)
Stanislav Funiak [Sat, 27 Nov 2021 03:33:27 +0000 (09:03 +0530)]
Fixed broken build under GCC 5.4.
This diff fixes broken build caused by D108550. Under GCC 5, auto lambdas that capture this require `this->` for member calls.
Reviewed By: bondhugula
Differential Revision: https://reviews.llvm.org/D114659
Fangrui Song [Fri, 26 Nov 2021 23:00:10 +0000 (15:00 -0800)]
[ELF][test] Test that .o definition does not inherit .so STV_PROTECTED
Test %t2.so %t.o beside %t.o %t2.so
Konstantin Boyarinov [Fri, 26 Nov 2021 22:24:16 +0000 (01:24 +0300)]
[libcxx][NFC] Add tests for associative containers key_comp and value_comp
Add missing tests to improve associative containers code coverage:
- Tests for key_comp() and value_comp() observers
- Tests for std::map and std::multimap value_compare member class
Reviewed by: ldionne, rarutyun, #libc
Differential Revision: https://reviews.llvm.org/D113998
Fangrui Song [Fri, 26 Nov 2021 22:10:55 +0000 (14:10 -0800)]
[ELF] Simplify Symbol::extract. NFC
Vitaly Buka [Fri, 19 Nov 2021 03:39:45 +0000 (19:39 -0800)]
[sanitizer] Switch StackStore to 8 MiB blocks
Larger blocks are more convenient for compressions.
Blocks are allocated with MmapNoReserveOrDie to save some memory.
Also it's 15% faster on StackDepotBenchmarkSuite
Depends on D114464.
Reviewed By: morehouse
Differential Revision: https://reviews.llvm.org/D114488
Erik Desjardins [Fri, 26 Nov 2021 21:25:08 +0000 (16:25 -0500)]
[InstSimplify] Fold X {lshr,udiv} C <u X --> true for nonzero X, non-identity C
This eliminates the bounds check in Rust code like
pub fn mid(data: &[i32]) -> i32 {
if data.is_empty() { return 0; }
return data[data.len()/2];
}
(from https://blog.sigplan.org/2021/11/18/undefined-behavior-deserves-a-better-reputation/)
Alive proofs:
lshr https://alive2.llvm.org/ce/z/nyTu8D
udiv https://alive2.llvm.org/ce/z/CNUZH7
Differential Revision: https://reviews.llvm.org/D114279
Patrick Oppenlander [Fri, 26 Nov 2021 21:29:06 +0000 (13:29 -0800)]
[compiler-rt][CMake] Support powerpcspe build
Reviewed By: jhibbits, MaskRay
Differential Revision: https://reviews.llvm.org/D98836