Commit Graph

411273 Commits

Author SHA1 Message Date
Haojian Wu 192f8d9700 [clangd] Don't rename on symbols from system headers.
Fixes https://github.com/clangd/clangd/issues/963.

Differential Revision: https://reviews.llvm.org/D116643
2022-01-17 15:08:53 +01:00
Florian Hahn aa7f0e6a55
[DSE] Remove commented-out InvisibleToCallerBeforeRet. (NFC)
This code was is a leftover from earlier changes and should be removed.
2022-01-17 13:59:13 +00:00
Sanjay Patel 7037d110fa [InstCombine] propagate IR flags from binop through select
The tests with constant folding that produces poison
could potentially remove the select entirely:
https://alive2.llvm.org/ce/z/e-WUqF
...but this patch just removes the FMF-only limitation on
propagation.
2022-01-17 08:42:48 -05:00
Sanjay Patel 69daa2fa61 [InstCombine] add tests for binop with flags and select op; NFC 2022-01-17 08:42:48 -05:00
Sanjay Patel 9e8a0ea331 [InstCombine] auto-generate complete test check lines; NFC 2022-01-17 08:42:48 -05:00
Florian Hahn 4a6f475446
[LV] Make test more robust by adding users of inductions.
The modified tests didn't have actual users of all inductions, making it
trivial to eliminate them. Add users to make sure the inductions are
actually used in the vectorized version.
2022-01-17 13:28:59 +00:00
Florian Hahn 500fe60957
[VPlan] Drop unnecessary uses of getVPSingleValue (NFC). 2022-01-17 13:27:33 +00:00
David Sherwood 197f3c0deb [CodeGen][AArch64] Ensure isSExtCheaperThanZExt returns true for negative constants
When we know the value we're extending is a negative constant then it
makes sense to use SIGN_EXTEND because this may improve code quality in
some cases, particularly when doing a constant splat of an unpacked vector
type. For example, for SVE when splatting the value -1 into all elements
of a vector of type <vscale x 2 x i32> the element type will get promoted
from i32 -> i64. In this case we want the splat value to sign-extend from
(i32 -1) -> (i64 -1), whereas currently it zero-extends from
(i32 -1) -> (i64 0xFFFFFFFF). Sign-extending the constant means we can use
a single mov immediate instruction.

New tests added here:

  CodeGen/AArch64/sve-vector-splat.ll

I believe we see some code quality improvements in these existing
tests too:

  CodeGen/AArch64/reduce-and.ll
  CodeGen/AArch64/unfold-masked-merge-vector-variablemask.ll

The apparent regressions in CodeGen/AArch64/fast-isel-cmp-vec.ll only
occur because the test disables codegen prepare and branch folding.

Differential Revision: https://reviews.llvm.org/D114357
2022-01-17 11:08:57 +00:00
David Green 5f2edada68 [AArch64] Add tests for sinking mask And to smaller loads. NFC 2022-01-17 11:04:14 +00:00
Fraser Cormack af219e567f [RISCV] Add tests for scalable-vector vwsub patterns
This patch adds tests for patterns introduced in D117188.

Reviewed By: jacquesguan

Differential Revision: https://reviews.llvm.org/D117392
2022-01-17 10:53:39 +00:00
Nathan James 8b88ff0803
[clangd] Add option to use dirty file contents when building preambles.
Adds a option `use-dirty-preambles` to enable using unsaved in editor contents when building pre-ambles.
This enables a more seamless user experience when switching between header and implementation files and forgetting to save inbetween.
It's also in line with the LSP spec that states open files in the editor should be used instead of on the contents on disk - https://microsoft.github.io/language-server-protocol/overviews/lsp/overview/
For now the option is defaulted to off and hidden, Though I have a feeling it should be moved into the `.clangd` config and possibly defaulted to true.

Addresses https://github.com/clangd/clangd/issues/488

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D95046
2022-01-17 10:55:35 +00:00
Lorenzo Chelini ca2ac2bb14 [MLIR][Linalg] Handle Attribute in InitTensorOp
In some cases, the result of an initTensorOp may have an attribute.
However, the Attribute was not passed to `inferResultType`, failing the
verifier. Therefore, propagate the Attribute to `inferResultType`.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D117192
2022-01-17 11:43:19 +01:00
Haojian Wu ab3f100bec Reland (2) "[AST] Add RParen loc for decltype AutoTypeloc.""
The patch was reverted because it caused a crash during PCH build -- we
missed to update the RParenLoc in TreeTransform<Derived>::TransformAutoType.

This relands 55d96ac and 37ec65e with a test and fix.
2022-01-17 11:33:11 +01:00
Alex Zinenko 2325f36301 Revert "[mlir] fix crash in PybindAdaptors.h"
This reverts commit 970cb57ef7.

Broke the buildbot.
2022-01-17 10:56:01 +01:00
Nikita Popov 873a7ee7e4 [MachineInstr] Don't include debug uses in bundle header (PR52817)
Following the recommendation in
https://github.com/llvm/llvm-project/issues/52817#issuecomment-1007635426,
this excludes debug instructions when finalizing the bundle. As uses
in debug instructions don't have effects, they will no longer be
included in the BUNDLE header.

Fixes https://github.com/llvm/llvm-project/issues/52817.

Differential Revision: https://reviews.llvm.org/D116945
2022-01-17 10:43:21 +01:00
Haojian Wu 884832407e [clangd] Avoid a code completion crash
This is a workaround (adding a newline to the eof) in clangd to avoid the code
completion crash, see https://github.com/clangd/clangd/issues/332.

In principle, this is a clang bug, we should fix it in clang, but it is not
trivial.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D117456
2022-01-17 10:35:55 +01:00
Ralf Grosse-Kunstleve a6598575f4 [LLDB] Fix Python GIL-not-held issues
The GIL must be held when calling any Python C API functions. In multithreaded applications that use callbacks this requirement can easily be violated by accident. A general tool to ensure GIL health is not available, but patching Python Py_INCREF to add an assert provides a basic health check:

```
+int PyGILState_Check(void); /* Include/internal/pystate.h */
+
 #define Py_INCREF(op) (                         \
+    assert(PyGILState_Check()),                 \
     _Py_INC_REFTOTAL  _Py_REF_DEBUG_COMMA       \
     ((PyObject *)(op))->ob_refcnt++)

 #define Py_DECREF(op)                                   \
     do {                                                \
+        assert(PyGILState_Check());                     \
         PyObject *_py_decref_tmp = (PyObject *)(op);    \
         if (_Py_DEC_REFTOTAL  _Py_REF_DEBUG_COMMA       \
         --(_py_decref_tmp)->ob_refcnt != 0)             \
```

Adding this assertion causes around 50 test failures in LLDB. Adjusting the scope of things guarded by `py_lock` fixes them.

More background: https://docs.python.org/3/glossary.html#term-global-interpreter-lock

Patch by Ralf Grosse-Kunstleve

Differential Revision: https://reviews.llvm.org/D114722
2022-01-17 10:32:19 +01:00
Nikita Popov af12a3f4a9 [ValueTracking] Remove ComputeMultiple() function
This function is no longer used since
499f1ca79f.
2022-01-17 10:28:31 +01:00
Alex Zinenko 970cb57ef7 [mlir] fix crash in PybindAdaptors.h
The constructor function was being defined without indicating its "__init__"
name, which made it interpret it as a regular fuction rather than a
constructor. When overload resolution failed, Pybind would attempt to print the
arguments actually passed to the function, including "self", which is not
initialized since the constructor couldn't be called. This would result in
"__repr__" being called with "self" referencing an uninitialized MLIR C API
object, which in turn would cause undefined behavior when attempting to print
in C++.

Fix this by specifying the correct name.

This in turn uncovers the fact the the mechanism used by PybindAdaptors.h to
bind constructors directly as "__init__" functions taking "self" is deprecated
by Pybind. The modern method requires using "py::init", which seems to rely on
the C++ equivalent of the bound class to be available, which is not the case in
PybindAdaptors.h. A deeper inspection shows that the deprecation concerns
old-style pybind11 constructors that had to allocate the object using
placement new with "self" as memory. The PybindAdaptors.h only provides
extension classes and never allocates (the object construction is delegated to
the base class), so it does not use the deprecated functionality. Use the
implementation detail tag class to convince pybind11 that we are using the
modern constructor binding method and suppress the warning.

On top of that, the definition of the function was incorrectly indicated as the
method on the "None" object instead of being the method of its parent class.
This would result in a second problem when Pybind would attempt to print
warnings pointing to the parent class since the "None" does not have a
"__name__" field or its C API equivalent.

Fix this by specifying the correct parent class by looking it up by name in the
parent module.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D117325
2022-01-17 10:28:01 +01:00
Lian Wang 85def34f5e [RISCV] Add scheduler for bfp instruction in Zbf extension
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117290
2022-01-17 09:17:18 +00:00
Nikita Popov 12bee2c054 [GlobalOpt] Drop an incorrect check
This was a last-minute addition to D117249, and of course I ended
up inverting the condition in a way that caused an uninitialized
memory read.

I've dropped it entirely, as I don't think we actually care whether
the size is zero or not here. The previous code wasn't checking
this either.
2022-01-17 10:10:56 +01:00
Nikita Popov 499f1ca79f [GlobalOpt] Use generic type when converting malloc to global
The malloc to global transform currently determines the type of the
global by looking at bitcasts of the malloc. This is limited (the
transform fails if there are multiple different types) and
incompatible with opaque pointers.

My initial approach was to construct an appropriate struct type
based on usage in loads/stores. What this patch does instead is
to always create an [i8 x AllocSize] global, without trying to
guess types at all.

This does mean that other transforms that require a certain global
type may break. I fixed two of these in D117034 and D117223, which
I believe should be sufficient to avoid regressions. In particular,
the global SRA change should end up splitting the global into
naturally-typed sub-globals, at which point all other optimizations
should work.

Differential Revision: https://reviews.llvm.org/D117092
2022-01-17 09:55:33 +01:00
Sam McCall 16949762dc [docs] Clarify & update JSONCompilationDatabase docs
- prefer `arguments` over `command`, and add example
- clarify that there's no shell-unescaping of `arguments`

Fixes https://github.com/llvm/llvm-project/issues/53143

Differential Revision: https://reviews.llvm.org/D117428
2022-01-17 09:51:55 +01:00
Fangrui Song f855074ed1 [ELF] GnuHashTableSection: replace stable_sort with 2-key sort. NFC
strTabOffset stabilizes llvm::sort. My x86-64 executable is 5+KiB smaller.
2022-01-17 00:34:42 -08:00
Nikita Popov 4796b4ae7b [GlobalOpt] Make global SRA offset based
Currently global SRA uses the GEP structure to determine how to
split the global. This patch instead analyses the loads and stores
that are performed on the global, and collects which types are used
at which offset, and then splits the global according to those.

This is both more general, and works fine with opaque pointers.
This is also closer to how ordinary SROA is performed.

Differential Revision: https://reviews.llvm.org/D117223
2022-01-17 09:28:36 +01:00
Haojian Wu 64c108c9e4 [clangd] Better handling `\n` in the synthesized diagnostic message.
The newline-eof fix was rendered as "insert '...'", this patch
special-case it.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D117294
2022-01-17 09:27:58 +01:00
Nikita Popov 00b77d917c [DSE] Remove alloc function check in canSkipDef()
canSkipDef() currently skips inaccessiblememonly calls, but not
if they are allocation functions. This check was added in D103009,
but actually seems to be a leftover from a previous implementation
in D101440. canSkipDef() is not used on the storeIsNoop() path,
where the relevant transform ended up being implemented.

Differential Revision: https://reviews.llvm.org/D117005
2022-01-17 09:23:51 +01:00
Carl Ritson 4b22ffe0b9 CycleInfo: Fix trivial typo. NFC. 2022-01-17 17:06:45 +09:00
Fangrui Song 54fe70bfba [ELF] RelocationScanner::scanOne: replace rel.r_offset with offset. NFC 2022-01-17 00:05:27 -08:00
Cameron Mulhern 966f24e5a6 [clang-format] Add a BlockIndent option to AlignAfterOpenBracket
This style is similar to AlwaysBreak, but places closing brackets on new lines.

For example, if you have a multiline parameter list, clang-format currently only supports breaking per-parameter, but places the closing bracket on the line of the last parameter.

Function(
    param1,
    param2,
    param3);

A style supported by other code styling tools (e.g. rustfmt) is to allow the closing brackets to be placed on their own line, aiding the user in being able to quickly infer the bounds of the block of code.

Function(
    param1,
    param2,
    param3
);

For prior work on a similar feature, see: https://reviews.llvm.org/D33029.

Note: This currently only supports block indentation for closing parentheses.

Differential Revision: https://reviews.llvm.org/D109557
2022-01-17 09:03:23 +01:00
Fangrui Song 4c36567179 [ELF] Relocations: remove some cast<Undefined>. NFC 2022-01-17 00:02:47 -08:00
Fangrui Song b8d4eb84d7 [ELF] De-template getAlternativeSpelling. NFC 2022-01-16 23:56:25 -08:00
Kito Cheng cc35161dc7 [RISCV] Add initial support for getRegUsageForType and getNumberOfRegisters
Those two TTI hooks are used during vectorization for calculating
register pressure, the default implementation isn't consider for LMUL,
and that's also definitly wrong value for register number (all register class
are 8 registers).

So in this patch we tried to:

1. Calculate right register usage for vector type and scalar type.
2. Return right number of register for general purpose register and
   vector register.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D116890
2022-01-17 15:27:54 +08:00
Qiu Chaofan d771cf2775 [PowerPC] Allow -mfloat128 option for VSX targets
Targets with VSX feature but without native float128 instructions can
also use that type with supplementary libcalls. We don't enable it by
default now because Glibc assumes long double and float128 can be
implicitly converted in between, which is not available under default
'ibmlongdouble' semantics in clang.

This commit partly relands cbd93ce.
2022-01-17 15:12:33 +08:00
Fangrui Song 9c4292a59d [ELF] Remove unneeded SyntheticSection memset(*, 0, *)
After the D33630 fallout was properly fixed by a4c5db30be.

Tested by D37462/D44986 tests, the new --no-rosegment test in build-id.s, and a few --rosegment/--no-rosegment programs.
2022-01-16 22:51:57 -08:00
Fangrui Song a4c5db30be [ELF] Remove redundant fillTrap and memset(*, 0, *). NFC
The new tests in build-id.s would catch problems if we made a mistake here.
2022-01-16 22:37:31 -08:00
Fangrui Song d46054d75d [ELF][test] Add --build-id tests for -z separate-loadable-segments and --no-rosegment 2022-01-16 22:36:22 -08:00
Fangrui Song aad90763d9 [ELF] RelocationSection<ELFT>::writeTo: use unstable partition 2022-01-16 21:44:19 -08:00
esmeyi 61106ca752 Reland https://reviews.llvm.org/D113825 after fixing the test expectations. 2022-01-17 00:28:25 -05:00
Fangrui Song 769057a5d0 [ELF] Change some DenseMap<StringRef, *> to DenseMap<CachedHashStringRef, *>. NFC 2022-01-16 21:19:01 -08:00
Fangrui Song e205445434 [ELF] StringTableSection: Use DenseMap<CachedHashStringRef> to avoid redundant hash computation
5~6% speedup when linking clang and chrome.
2022-01-16 21:02:05 -08:00
Fangrui Song 427d3b93ee [Driver][FreeBSD] -r: imply -nostdlib like GCC
Similar to D116843 for Gnu.cpp

Reviewed By: dim

Differential Revision: https://reviews.llvm.org/D117388
2022-01-16 19:44:48 -08:00
John Ericson 09949c48cb [compiler-rt][cmake] Use `GNUInstallDirs` to support custom installation dirs
I am breaking apart D99484 so the cause of build failures is easier to
understand.

Differential Revision: https://reviews.llvm.org/D117420
2022-01-17 03:13:56 +00:00
eopXD 5a457782a2 [RISCV] Add patterns for vector widening integer multiply-add instructions
Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117404
2022-01-16 18:37:13 -08:00
Dominik Grewe 5f782d25a7 Preserve argument locations when cloning a region.
Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D117403
2022-01-16 21:17:23 +00:00
Nikita Popov 0d7fbb0737 [AttrBuilder] Remove unused removeAttributes() overload
The idiomatic way would be to call remove() with an AttributeMask
constructed from an AttributeSet.
2022-01-16 21:32:54 +01:00
Nikita Popov 7cbbef5bbc [AttrBuilder] Remove unused hasAttributes() overload
This is unused, and doesn't make a lot of sense as an API. The
usual pattern would be to combine the AttrBuilder(AttributeSet)
constructor with the overlaps() method.
2022-01-16 21:00:18 +01:00
Bjorn Pettersson 9f237c9e7d [DAGCombine] Refactor DAGCombiner::ReduceLoadWidth. NFCI
Update code comments in DAGCombiner::ReduceLoadWidth and refactor
the handling of SRL a bit. The refactoring is done with the intent
of adding support for folding away SRA by using SEXTLOAD in a
follow-up patch.

The function is also renamed as DAGCombiner::reduceLoadWidth.

Differential Revision: https://reviews.llvm.org/D117104
2022-01-16 20:24:52 +01:00
Stanislav Gatev 37e6496c80 [clang][dataflow] Add transfer functions for bind temporary and static cast
This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.

Differential Revision: https://reviews.llvm.org/D117339
2022-01-16 17:41:02 +00:00
Arjun P 79be1fe0d5 [MLIR] Simplex::getRationalSample: return an optional, empty if Simplex is empty 2022-01-16 22:02:27 +05:30