Commit Graph

345165 Commits

Author SHA1 Message Date
Simon Pilgrim 814c65dedc ExecutionDomainFix - fix static analyzer out of range shift warnings.
Repeat the assertion that we already have in hasDomain for addDomain and setSingleDomain.
2020-03-12 18:52:56 +00:00
Florian Hahn c52f839e72 Revert "[SCCP] Use ValueLatticeElement instead of LatticeVal (NFCI)"
This commit is likely causing clang-with-lto-ubuntu to fail
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/16052

Also causes PR45185.

This reverts commit f1ac5d2263.
2020-03-12 18:49:11 +00:00
Paula Toth eb41cc6198 [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.
Summary: This adds a new module to enforce standards specific to the llvm-libc project. This change also adds the first check which restricts user from including system libc headers accidentally which can lead to subtle bugs that would be a challenge to detect.

Reviewers: alexfh, hokein, aaron.ballman

Reviewed By: aaron.ballman

Subscribers: juliehockett, arphaman, jfb, abrachet, sivachandra, Eugene.Zelenko, njames93, mgorny, xazax.hun, MaskRay, cfe-commits

Tags: #clang-tools-extra, #libc-project, #clang

Differential Revision: https://reviews.llvm.org/D75332
2020-03-12 11:46:05 -07:00
Stanislav Mekhanoshin 360aff0493 [AMDGPU] Simplify nested SI_END_CF
This is to replace the optimization from the SIOptimizeExecMaskingPreRA.
We have less opportunities in the control flow lowering because many
VGPR copies are still in place and will be removed later, but we know
for sure an instruction is SI_END_CF and not just an arbitrary S_OR_B64
with EXEC.

The subsequent change needs to convert s_and_saveexec into s_and and
address new TODO lines in tests, then code block guarded by the
-amdgpu-remove-redundant-endcf option in the pre-RA exec mask optimizer
will be removed.

Differential Revision: https://reviews.llvm.org/D76033
2020-03-12 11:25:07 -07:00
Sterling Augustine c53c2058ff Cache uwnind frame headers as they are found.
Summary:
This improves unwind performance quite substantially, and follows
a somewhat similar approach used in libgcc_s as described in the
thread here:

https://gcc.gnu.org/ml/gcc/2005-02/msg00625.html

On certain extremely exception heavy internal tests, the time
drops from about 80 minutes to about five minutes.

Subscribers: libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D75954
2020-03-12 10:53:33 -07:00
David Blaikie 30804d0a3f CFGDiff: Simplify and generalize over all graph types
Use GraphTraits in the implementation of the GraphDiff's own GraphTraits
so GraphDiff can be used across all graph types that provide
GraphTraits.

Also use partial template specializations to make the traits a bit more
compact.

Reviewers: asbirlea

Differential Revision: https://reviews.llvm.org/D76034
2020-03-12 10:45:45 -07:00
Richard Sandiford f8700db7f1 [Sema][SVE] Don't allow static or thread-local variables to have sizeless type
clang accepts a TU containing just:

  __SVInt8_t x;

However, sizeless types are not allowed to have static or thread-local
storage duration and trying to code-generate the TU triggers an LLVM
fatal error:

  Globals cannot contain scalable vectors
  <vscale x 16 x i8>* @x
  fatal error: error in backend: Broken module found, compilation aborted!

This patch adds an associated clang diagnostic.

Differential Revision: https://reviews.llvm.org/D75736
2020-03-12 17:39:29 +00:00
Jacques Pienaar 36e018b941 [mlir] Add derived attribute op interface
Interface provides uniform access to the the derived attribute query method.
2020-03-12 10:32:24 -07:00
Jonas Devlieghere bc9b6b33a0 [lldb/Utility] Add YAML traits for ConstString and FileSpec.
Add YAML traits for the ConstString and FileSpec classes so they can be
serialized as part of ProcessInfo. The latter needs to be serializable
for the reproducers.

Differential revision: https://reviews.llvm.org/D76002
2020-03-12 10:28:21 -07:00
Richard Sandiford adb290d974 [Sema][SVE] Reject atomic sizeless types
It would be difficult to guarantee atomicity for sizeless types,
so the SVE ACLE makes atomic sizeless types invalid.  As it happens,
we already rejected them before the patch, but for the wrong reason:

  error: _Atomic cannot be applied to type 'svint8_t' (aka '__SVInt8_t')
  which is not trivially copyable

The SVE types should be treated as trivially copyable; a later
patch fixes that.

Differential Revision: https://reviews.llvm.org/D75734
2020-03-12 17:20:23 +00:00
Richard Sandiford 627b5c1206 [Sema][SVE] Reject aligned/_Alignas for sizeless types
A previous patch rejected alignof for sizeless types.  This patch
extends that to cover the "aligned" attribute and _Alignas.  Since
sizeless types are not meant to be used for long-term data, cannot
be used in aggregates, and cannot have static storage duration,
there shouldn't be any need to fiddle with their alignment.

Like with alignof, this is a conservative position that can be
relaxed in future if it turns out to be too restrictive.

Differential Revision: https://reviews.llvm.org/D75573
2020-03-12 17:12:40 +00:00
Richard Sandiford 39969c7d3a [Sema][SVE] Reject sizeof and alignof for sizeless types
clang current accepts:

  void foo1(__SVInt8_t *x, __SVInt8_t *y) { *x = *y; }
  void foo2(__SVInt8_t *x, __SVInt8_t *y) {
    memcpy(y, x, sizeof(__SVInt8_t));
  }

The first function is valid ACLE code and generates correct LLVM IR.
However, the second function is invalid ACLE code and generates a
zero-length memcpy.  The point of this patch is to reject the use
of sizeof in the second case instead.

There's no similar wrong-code bug for alignof.  However, the SVE ACLE
conservatively treats alignof in the same way as sizeof, just as the
C++ standard does for incomplete types.  The idea is that layout of
sizeless types is an implementation property and isn't defined at
the language level.

Implementation-wise, the patch adds a new CompleteTypeKind enum
that controls whether RequireCompleteType & friends accept sizeless
built-in types.  For now the default is to maintain the status quo
and accept sizeless types.  However, the end of the series will flip
the default and remove the Default enum value.

The patch also adds new ...CompleteSized... wrappers that callers can
use if they explicitly want to reject sizeless types.  The callers then
use diagnostics that have an extra 0/1 parameter to indicats whether
the type is sizeless or not.

The idea is to have three cases:

1. calls that explicitly reject sizeless types, with a tweaked diagnostic
   for the sizeless case

2. calls that explicitly allow sizeless types

3. normal/old-style calls that don't make an explicit choice either way

Once the default is flipped, the 3. calls will conservatively reject
sizeless types, using the same diagnostic as for other incomplete types.

Differential Revision: https://reviews.llvm.org/D75572
2020-03-12 17:06:53 +00:00
Artem Belevich eb2ba2ea95 [CUDA] Warn about unsupported CUDA SDK version only if it's used.
This fixes an issue with clang issuing a warning about unknown CUDA SDK if it's
detected during non-CUDA compilation.

Differential Revision: https://reviews.llvm.org/D76030
2020-03-12 10:04:10 -07:00
Richard Sandiford f09c7d642a [Sema][SVE] Add tests for valid and invalid type usage
This patch adds C and C++ tests for various uses of SVE types.
The tests cover valid uses that are already (correctly) accepted and
invalid uses that are already (correctly) rejected.  Later patches
will expand the tests as they fix other cases.[*]

Some of the tests for invalid uses aren't obviously related to
scalable vectors.  Part of the reason for having them is to make
sure that the quality of the error message doesn't regress once/if
the types are treated as incomplete types.

[*] These later patches all fix invalid uses that are being incorrectly
    accepted.  I don't know of any cases in which valid uses are being
    incorrectly rejected.  In other words, this series is all about
    diagnosing invalid code rather than enabling something new.

Differential Revision: https://reviews.llvm.org/D75571
2020-03-12 16:56:13 +00:00
Simon Pilgrim 7bfc3bf39b Replace getAs/dyn_cast with castAs/cast to fix null dereference static analyzer warnings.
Both these casts are immediately deferenced and the cast will assert for us that they are of the correct type.
2020-03-12 16:50:50 +00:00
LLVM GN Syncbot b93dd67797 [gn build] Port fa8080376e 2020-03-12 16:33:39 +00:00
Richard Sandiford fa8080376e [AST][SVE] Add new Type queries for sizeless types
One of the defining features of the SVE ACLE types is that they
are "sizeless"; see the SVE ACLE spec:

    https://developer.arm.com/docs/100987/0000/arm-c-language-extensions-for-sve

or the email message:

    http://lists.llvm.org/pipermail/cfe-dev/2019-June/062523.html

for a fuller definition of what that means.

This patch adds two associated type queries:

- isSizelessBuiltinType asks specifically about types that are built
  into clang.  It is effectively an enum range check.

- isSizelessType instead tests for any type that has the "sizeless" type
  property.  At the moment it only returns true for the built-in types,
  but it seems better not to hard-code that assumption throughout
  the codebase.  (E.g. we could in principle support some form of
  user-defined sizeless types in future.  Even if that seems unlikely
  and never actually happens, the possibility at least exists.)

Differential Revision: https://reviews.llvm.org/D75570
2020-03-12 16:30:50 +00:00
Reid Kleckner 7420f96924 [TableGen] Move generated *Attr class methods out of line
After this change, clang spends ~200ms parsing Attrs.inc instead of
~560ms. A large part of the cost was from the StringSwitch
instantiations, but this is a good way to avoid similar problems in the
future.

Reviewed By: aaron.ballman, rjmccall

Differential Revision: https://reviews.llvm.org/D76040
2020-03-12 09:07:57 -07:00
LLVM GN Syncbot e79397f5e2 [gn build] Port 2c9cf9f4dd 2020-03-12 16:01:56 +00:00
Jonathan Roelofs 2c9cf9f4dd [clang-tidy] New check: bugprone-suspicious-include
Detects and fixes suspicious code like: `#include "foo.cpp"`.

Inspired by: https://twitter.com/lefticus/status/1228458240364687360?s=20

https://reviews.llvm.org/D74669
2020-03-12 09:59:28 -06:00
Zarko Todorovski d688312660 [PowerPC][AIX] Implement formal arguments passed in stack memory.
This patch is the callee side counterpart for https://reviews.llvm.org/D73209.
It removes the fatal error when we pass more formal arguments than available
registers.

Differential Revision: https://reviews.llvm.org/D74225
2020-03-12 11:48:00 -04:00
Simon Pilgrim 69993350ae ObjCMethodDecl::findPropertyDecl - fix static analyzer null dereference warnings. NFCI.
All paths dereference the ClassDecl pointer, so use a cast<> instead of dyn_cast<>, assert that its not null and remove the remaining null tests.
2020-03-12 15:36:49 +00:00
Hideto Ueno d9bf79f4e9 [Attributor][FIX] Add a missing dependence track in noalias deduction 2020-03-12 15:27:35 +00:00
Marcello Maggioni ba5500f27a [RAGreedy] Fix minor typo in comment. NFC 2020-03-12 08:15:04 -07:00
Raphael Isemann 352f16db87 [lldb] Let OptionValueRegex::Clear set to value to the default and not an empty regex
Since D75537 the test suite clears all settings before a test. This caused
two tests to fail:
    lldb-api :: functionalities/inline-stepping/TestInlineStepping.py
    lldb-api :: lang/cpp/std-function-step-into-callable/TestStdFunctionStepIntoCallable.py
The reason for that is that OptionValueRegex::Clear was setting the regex
to empty instead of the default value that was passed initially. This caused
that the target.process.thread.step-avoid-regexp setting which is used in the
tests was set to "" instead of "^std::".

This patch is just a quick fix that sets the regex back to the original value
to make the tests pass.

In total these 3 setting values have changed with D75537 and also need to be
fixed (even though they don't seem to break any tests).
  target.process.thread.step-avoid-regexp (regex) -> from '^std::' to empty string
  platform.module-cache-directory (file) -> from "~/.lldb/module_cache" to empty string
  script-lang (enum) -> from 'default' to 'python'
2020-03-12 16:12:14 +01:00
Fangrui Song eb4b5a36a6 [ELF] Move --print-map(-M)/--cref before checkSections() and openFile()
-M output can be useful when diagnosing an "error: output file too large" problem (emitted in openFile()).

I just ran into such a situation where I had to debug an erronerous
Linux kernel linker script. It tried to create a file larger than
INT64_MAX bytes.

This patch could have helped https://bugs.llvm.org/show_bug.cgi?id=44715 as well.

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D75966
2020-03-12 08:00:18 -07:00
Simon Pilgrim 7c2b3c9dda Replace getAs with castAs to fix null dereference static analyzer warnings.
Use castAs as we know the cast should succeed (and castAs will assert if it doesn't) and we're dereferencing it directly in the getThisType/getThisObjectType calls.
2020-03-12 14:56:51 +00:00
Simon Pilgrim dbde39e485 Fix static analyzer null dereference warning. NFCI. 2020-03-12 14:56:51 +00:00
Simon Pilgrim 5f9fcfb29e Replace getAs with castAs to fix null dereference static analyzer warnings.
Use castAs as we know the cast should succeed (and castAs will assert if it doesn't) and we're dereferencing it directly in the canAssignObjCInterfaces call.
2020-03-12 14:56:50 +00:00
Xiangling Liao 3e53bf5781 [PowerPC32] Fix the `setcc` inconsistent result type problem
Summary:
On 32-bit PPC target[AIX and BE], when we convert an `i64` to `f32`, a `setcc` operand expansion is needed. The expansion will set the result type of expanded `setcc` operation based on if the subtarget use CRBits or not. If the subtarget does use the CRBits, like AIX and BE, then it will set the result type to `i1`, leading to an inconsistency with original `setcc` result type[i32].
And the reason why it crashed underneath is because we don't set result type of setcc consistent in those two places.

This patch fixes this problem by setting original setcc opnode result type also with `getSetCCResultType`  interface.

Reviewers: sfertile, cebowleratibm, hubert.reinterpretcast, Xiangling_L

Reviewed By: sfertile

Subscribers: wuzish, nemanjai, hiraditya, kbarton, jsji, shchenz, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75702
2020-03-12 10:50:37 -04:00
Simon Moll c8e1081da6 [VE][nfc] Use RRIm for RRINDm, remove the latter
Summary:
De-duplicate isel instruction classes by using RRIm for RRINDm. The latter
becomes obsolete.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D76063
2020-03-12 15:38:07 +01:00
Sean Fertile 8b39341fb0 [PowerPC][AIX] Fix printing of program counter for AIX assembly.
Program counter on AIX is the dollar-sign.

Differential Revision:https://reviews.llvm.org/D75627
2020-03-12 10:37:18 -04:00
Raphael Isemann e3fc6b3c34 [lldb][NFC] Fix unsigned/signed comparison warning in SymbolFileDWARFTest.cpp
offset_t is unsigned, so if the RHS is signed we get a warning from clang:
    warning: comparison of integers of different signs: 'const unsigned long long' and 'const int'
2020-03-12 15:30:11 +01:00
Nicolas Vasilache 8093e31e4e [mlir][CRunnerUtils] Enable compilation with C++11 toolchain on microcontroller platforms.
Summary:
The C runner utils API was still not vanilla enough for certain use
cases on embedded ARM SDKs, this enables such cases.

Adding people more widely for historical Windows related build issues.

Differential Revision: https://reviews.llvm.org/D76031
2020-03-12 10:18:56 -04:00
Andrzej Warzynski 46b9f14d71 [AArch64][SVE] Add intrinsics for non-temporal scatters/gathers
Summary:
This patch adds the following intrinsics for non-temporal gather loads
and scatter stores:
  * aarch64_sve_ldnt1_gather_index
  * aarch64_sve_stnt1_scatter_index
These intrinsics implement the "scalar + vector of indices" addressing
mode.

As opposed to regular and first-faulting gathers/scatters, there's no
instruction that would take indices and then scale them. Instead, the
indices for non-temporal gathers/scatters are scaled before the
intrinsics are lowered to `ldnt1` instructions.

The new ISD nodes, GLDNT1_INDEX and SSTNT1_INDEX, are only used as
placeholders so that we can easily identify the cases implemented in
this patch in performGatherLoadCombine and performScatterStoreCombined.
Once encountered, they are replaced with:
  * GLDNT1_INDEX -> SPLAT_VECTOR + SHL + GLDNT1
  * SSTNT1_INDEX -> SPLAT_VECTOR + SHL + SSTNT1

The patterns for lowering ISD::SHL for scalable vectors (required by
this patch) were missing, so these are added too.

Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D75601
2020-03-12 13:55:56 +00:00
Sanjay Patel a66dc755db [InstSimplify] simplify FP ops harder with FMF (part 2)
This is part of the IR sibling for:
D75576

Related transform committed with:
rG8ec71585719d
2020-03-12 09:53:20 -04:00
Sergej Jaskiewicz 43252c1b17 [libcxxabi] Set LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX to ON if LIBCXX_ENABLE_SHARED is not defined
Differential Revision: https://reviews.llvm.org/D71894
2020-03-12 16:45:21 +03:00
Sven van Haastregt 592cec7087 [OpenCL] Add missing get_image_array_size builtins 2020-03-12 13:43:51 +00:00
Tatyana Krasnukha df90a15b1a [lldb] Clear all settings during a test's setUp
Global properties are shared between debugger instances and
if a test doesn't clear changes in settings it made,
this leads to side effects in other tests.

Differential Revision: https://reviews.llvm.org/D75537
2020-03-12 16:30:26 +03:00
Sanjay Patel 8ec7158571 [InstSimplify] simplify FP ops harder with FMF
This is part of the IR sibling for:
D75576

(I'm splitting part of the transform as a separate commit
to reduce risk. I don't know of any bugs that might be
exposed by this improved folding, but it's hard to see
those in advance...)
2020-03-12 09:13:28 -04:00
Simon Pilgrim 1e686d2689 [X86] Add FeatureFast7ByteNOP flag
Lets us remove another SLM proc family flag usage.

This is NFC, but we should probably check whether atom/glm/knl? should be using this flag as well...
2020-03-12 13:06:43 +00:00
Sam McCall 966cad0c65 [clangd] Add README pointing to docs, bugtracker etc. NFC 2020-03-12 14:00:08 +01:00
Simon Pilgrim fa8ce7c0fa [AMDGPU] Add some funnel shift intrinsic test coverage 2020-03-12 12:53:57 +00:00
Sanjay Patel dea2b93a7b [InstSimplify] reduce code for FP undef/nan folding; NFC 2020-03-12 08:46:15 -04:00
Nico Weber e51d4df4b2 Use `grep -F` instead of deprecated fgrep.
(In addition to the deprecation bit, this is useful on Windows
where people might have grep but not fgrep.)
2020-03-12 08:34:38 -04:00
Sanjay Patel d748e759d5 [InstSimplify] add tests for FP poison; NFC
Adapted from codegen tests seen in D75576.
2020-03-12 08:32:04 -04:00
Luke Drummond 0fa3320931 [lldb] reject `.debug_arange` sections with nonzero segment size
If a producer emits a nonzero segment size, `lldb` will silently read
incorrect values and crash, or do something worse later as the tuple
size is expected to be 2, rather than 3.

Neither LLVM, nor GCC produce segmented aranges, but this dangerous case
should still be checked and handled.

Reviewed by: clayborg, labath
Differential Revision: https://reviews.llvm.org/D75925
Subscribers: lldb-commits
Tags: #lldb
2020-03-12 12:22:50 +00:00
Florian Hahn f1ac5d2263 [SCCP] Use ValueLatticeElement instead of LatticeVal (NFCI)
This patch switches SCCP to use ValueLatticeElement for lattice values,
instead of the local LatticeVal, as first step to enable integer range support.

This patch does not make use of constant ranges for additional operations
and the only difference for now is that integer constants are represented by
single element ranges. To preserve the existing behavior, the following helpers
are used

* isConstant(LV): returns true when LV is either a constant or a constant range with a single element. This should return true in the same cases where LV.isConstant() returned true previously.
* getConstant(LV): returns a constant if LV is either a constant or a constant range with a single element. This should return a constant in the same cases as LV.getConstant() previously.
* getConstantInt(LV): same as getConstant, but additionally casted to ConstantInt.

Reviewers: davide, efriedma, mssimpso

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D60582
2020-03-12 12:03:06 +00:00
LLVM GN Syncbot f31f22ef0f [gn build] Port d5edcb9064 2020-03-12 11:58:14 +00:00
Dylan McKay 2cf4b4de0c [AVR] Fix reads of uninitialized variables from constructor of AVRSubtarget
The initialization order was not correct. These bugs were discovered by
valgrind. They appear to work fine in practice but this patch should
unblock switching the AVR backend on by default as now a standard AVR
llc invocation runs without memory errors.

The AVRISelLowering constructor would run before the subtarget boolean
fields were initialized to false. Now, the initialization order is
correct.
2020-03-13 00:57:19 +13:00