Commit Graph

83757 Commits

Author SHA1 Message Date
Thomas Lively 8e3e56f2a3 [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic
Summary:

Although using `__builtin_shufflevector` and the `shufflevector`
instruction works fine, they are not opaque to the optimizer. As a
result, DAGCombine can potentially reduce the number of shuffles and
change the shuffle masks. This is unexpected behavior for users of the
WebAssembly SIMD intrinsics who have crafted their shuffles to
optimize the code generated by engines. This patch solves the problem
by adding a new shuffle intrinsic that is opaque to the optimizers in
line with the decision of the WebAssembly SIMD contributors at
https://github.com/WebAssembly/simd/issues/196#issuecomment-622494748. In
the future we may implement custom DAG combines to properly optimize
shuffles and replace this solution.

Reviewers: aheejin, dschuff

Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D66983
2020-05-11 10:01:55 -07:00
Kamlesh Kumar 9aee35bcc9 [Clang] Fix the incorrect return type of atomic_is_lock_free
Fixing the return type of atomic_is_lock_free as per
https://en.cppreference.com/w/c/atomic/atomic_is_lock_free

Differential Revision: https://reviews.llvm.org/D79504
2020-05-11 10:48:35 -04:00
Artem Dergachev ec2d93c7d7 [analyzer] SATestBuild.py: Allow comments in run_static_analyzer.cmd.
Because those can get really weird sometimes.
2020-05-11 17:26:37 +03:00
Sander de Smalen 4cad97595f [SveEmitter] Add builtins for svmovlb and svmovlt
These builtins are expanded in CGBuiltin to use intrinsics
for (signed/unsigned) shift left long top/bottom.

Reviewers: efriedma, SjoerdMeijer

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D79579
2020-05-11 09:41:58 +01:00
Haojian Wu 507d1eb1ce Add a missing test file for recovery expressions.
The test was missed in 8222107aa9.
2020-05-11 09:23:32 +02:00
Haojian Wu d82538b3f6 Fix -Wunused compiler warning. 2020-05-11 09:20:48 +02:00
Haojian Wu 8222107aa9 [AST] Preserve the type in RecoveryExprs for broken function calls.
RecoveryExprs are modeled as dependent type to prevent bogus diagnostics
and crashes in clang.

This patch allows to preseve the type for broken calls when the
RecoveryEprs have a known type, e.g. a broken non-overloaded call, a
overloaded call when the all candidates have the same return type, so
that more features (code completion still work on "take2args(x).^") still
work.

However, adding the type is risky, which may result in more clang code being
affected leading to new crashes and hurt diagnostic, and it requires large
effort to minimize the affect (update all sites in clang to handle errorDepend
case), so we add a new flag (off by default) to allow us to develop/test
them incrementally.

This patch also has some trivial fixes to suppress diagnostics (to prevent regressions).

Tested:

all existing tests are passed (when both "-frecovery-ast", "-frecovery-ast-type" flags are flipped on);

Reviewed By: sammccall

Subscribers: rsmith, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79160
2020-05-11 08:46:18 +02:00
Fangrui Song 25544ce2df [gcov] Default coverage version to '407*' and delete CC1 option -coverage-cfg-checksum
Defaulting to -Xclang -coverage-version='407*' makes .gcno/.gcda
compatible with gcov [4.7,8)

In addition, delete clang::CodeGenOptionsBase::CoverageExtraChecksum and GCOVOptions::UseCfgChecksum.
We can infer the information from the version.

With this change, .gcda files produced by `clang --coverage a.o` linked executable can be read by gcov 4.7~7.
We don't need other -Xclang -coverage* options.
There may be a mismatching version warning, though.

(Note, GCC r173147 "split checksum into cfg checksum and line checksum"
 made gcov 4.7 incompatible with previous versions.)
2020-05-10 16:14:07 -07:00
Richard Smith 8fc12b8698 Enforce the C++11 anonymous enum bitfields check even for
Objective-C++11 and under MS extensions.

This matches the MSVC behavior, and means that Objective-C behaves as a
set of extensions to the base language, rather than replacing the base
language rule with a different one.
2020-05-10 14:03:50 -07:00
Richard Smith 2d3f5a62de Fix typo in enum-base disambiguation. 2020-05-10 13:39:49 -07:00
Richard Smith d6425e2c14 Properly implement 'enum class' parsing.
The 'class' or 'struct' keyword is only permitted as part of either an
enum definition or a standalone opaque-enum-declaration, not as part of
an elaborated type specifier. We previously failed to diagnose this, and
generally didn't properly implement the restrictions on elaborated type
specifiers for enumeration types.

In passing, also fixed incorrect parsing for enum-bases, which we
previously parsed as a type-name, but are actually a type-specifier-seq.
This matters for cases like 'enum E : int *p;', which is valid as a
Microsoft extension.

Plus some minor parse diagnostic improvements.

Bumped the recently-added ExtWarn for 'enum E : int x;' to be
DefaultError; this is not an intentional extension, so producing an
error by default seems appropriate, but the warning flag to disable it
may still be useful for code written against old Clang. The same
treatment is given here to the diagnostic for 'enum class E x;', which
we similarly have incorrectly accepted for many years. These diagnostics
continue to be suppressed under -fms-extensions and when compiling
Objective-C code. We will need to decide separately whether Objective-C
should follow the C++ rules or the (older) MSVC rules.
2020-05-10 13:21:04 -07:00
Fangrui Song 13a633b438 [gcov] Delete CC1 option -coverage-no-function-names-in-data
rL144865 incorrectly wrote function names for GCOV_TAG_FUNCTION
(this might be part of the reasons the header says
"We emit files in a corrupt version of GCOV's "gcda" file format").

rL176173 and rL177475 realized the problem and introduced -coverage-no-function-names-in-data
to work around the issue. (However, the description is wrong.
libgcov never writes function names, even before GCC 4.2).

In reality, the linker command line has to look like:

clang --coverage -Xclang -coverage-version='407*' -Xclang -coverage-cfg-checksum -Xclang -coverage-no-function-names-in-data

Failing to pass -coverage-no-function-names-in-data can make gcov 4.7~7
either produce wrong results (for one gcov-4.9 program, I see "No executable lines")
or segfault (gcov-7).
(gcov-8 uses an incompatible format.)

This patch deletes -coverage-no-function-names-in-data and the related
function names support from libclang_rt.profile
2020-05-10 12:37:44 -07:00
Sanjay Patel d02b3aba37 [CodeGen] fix test to be (mostly) independent of LLVM optimizer; NFC
This test would break with the proposed change to IR canonicalization
in D79171.

The test tried to do the right thing by only using -mem2reg with opt,
but it was using -O3 before that step, so the opt part was meaningless.
2020-05-10 11:25:37 -04:00
Sanjay Patel bcc5ed7b24 [CodeGen] fix test to be (mostly) independent of LLVM optimizer; NFC
This test would break with the proposed change to IR canonicalization
in D79171. The raw unoptimized IR from clang is massive, so I've
replaced -instcombine with -mem2reg to make it more manageable,
but still be unlikely to break with unrelated changed to optimization.
2020-05-10 11:19:43 -04:00
Jinsong Ji a72b9dfd45 [sanitizer] Enable whitelist/blacklist in new PM
https://reviews.llvm.org/D63616 added `-fsanitize-coverage-whitelist`
and `-fsanitize-coverage-blacklist` for clang.

However, it was done only for legacy pass manager.
This patch enable it for new pass manager as well.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D79653
2020-05-10 02:34:29 +00:00
Petr Hosek 5b02be0b97 [Clang] Pass -z max-page-size to linker for Fuchsia
Currently all Fuchsia ABIs use a 4k page size, departing from
the recommended page sizes in the respective psABI documents.

Differential Revision: https://reviews.llvm.org/D79667
2020-05-09 13:44:20 -07:00
Petr Hosek c8fbcb1e78 [Clang] Pass --pack-dyn-relocs=relr to lld for Fuchsia
The compact format is fully supported on Fuchsia and is the
preferred default.

Patch By: mcgrathr

Differential Revision: https://reviews.llvm.org/D79665
2020-05-09 13:42:19 -07:00
Matt Arsenault a881dc1103 Fix typo 2020-05-09 16:00:17 -04:00
Simon Pilgrim 0b9783350b LTO.h - reduce includes to forward declarations. NFC.
Add missing ToolOutputFile.h dependency to BackendUtil.cpp
2020-05-09 15:10:51 +01:00
mydeveloperday 31fd12aa09 [clang-format] [PR34574] Handle [[nodiscard]] attribute in class declaration
Summary:
https://bugs.llvm.org/show_bug.cgi?id=34574
https://bugs.llvm.org/show_bug.cgi?id=38401

```
template <typename T>
class [[nodiscard]] result
{
  public:
    result(T&&)
    {
    }
};
```

formats incorrectly to

```
template <typename T>
class [[nodiscard]] result{public : result(T &&){}};
```

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79354
2020-05-09 11:27:23 +01:00
Fangrui Song 6bf0ad78dc [Driver] Don't pass -u__llvm_profile_runtime for clang -fprofile-arcs a.o
clang --coverage a.o       # InstrProfilingRuntime.cpp.o not linked in
clang --fprofile-arcs a.o  # InstrProfilingRuntime.cpp.o unexpectedly linked in

Fix --fprofile-arcs.
2020-05-08 23:36:29 -07:00
Richard Smith c90e198107 Fix parsing of enum-base to follow C++11 rules.
Previously we implemented non-standard disambiguation rules to
distinguish an enum-base from a bit-field but otherwise treated a :
after an elaborated-enum-specifier as introducing an enum-base. That
misparses various examples (anywhere an elaborated-type-specifier can
appear followed by a colon, such as within a ternary operator or
_Generic).

We now implement the C++11 rules, with the old cases accepted as
extensions where that seemed reasonable. These amount to:
 * an enum-base must always be accompanied by an enum definition (except
   in a standalone declaration of the form 'enum E : T;')
 * in a member-declaration, 'enum E :' always introduces an enum-base,
   never a bit-field
 * in a type-specifier (or similar context), 'enum E :' is not
   permitted; the colon means whatever else it would mean in that
   context.

Fixed underlying types for enums are also permitted in Objective-C and
under MS extensions, plus as a language extension in all other modes.
The behavior in ObjC and MS extensions modes is unchanged (but the
bit-field disambiguation is a bit better); remaining language modes
follow the C++11 rules.

Fixes PR45726, PR39979, PR19810, PR44941, and most of PR24297, plus C++
core issues 1514 and 1966.
2020-05-08 19:32:00 -07:00
Matt Arsenault 03cb328d6f clang: Cleanup usage of CreateMemCpy
It handles the the pointee type casts in preparation for opaque
pointers.
2020-05-08 20:57:56 -04:00
Fangrui Song 9a11174287 [Driver] Add -fno-test-coverage 2020-05-08 17:01:53 -07:00
Fangrui Song 0d4a33ba61 [Driver] Don't warn -Wunused-command-line-argument for --coverage -ftest-coverage -fprofile-arcs 2020-05-08 16:31:15 -07:00
Fangrui Song e1815eb2e1 [Driver] Reorganize --coverage -ftest-coverage -fprofile-arcs related tests
And fix a comment about __llvm_profile_runtime
2020-05-08 16:06:33 -07:00
Thomas Lively ebb69b8baf [clang][WebAssembly] Only expose wait and notify builtins with atomics
Summary:
Since the underlying wait and notify instructions are only available
when the atomics feature is enabled, it only makes sense to expose
their builtin functions when atomics are enabled.

Reviewers: aheejin, sunfish

Subscribers: dschuff, sbc100, jgravelle-google, jfb, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79534
2020-05-08 13:54:29 -07:00
Hubert Tong b116ded57d [AIX] Avoid structor alias; die before bad alias codegen
Summary:
`AsmPrinter::emitGlobalIndirectSymbol` is dependent on
`MCStreamer::emitAssignment` to produce `.set` directives for alias
symbols; however, the `.set` pseudo-op on AIX is documented as not
usable with external relocatable terms or expressions, which limits its
applicability in generating alias symbols.

Disable generating aliases on AIX until a different implementation
strategy is available.

Reviewers: cebowleratibm, jasonliu, sfertile, daltenty, DiggerLin

Reviewed By: jasonliu

Differential Revision: https://reviews.llvm.org/D79044
2020-05-08 16:51:34 -04:00
Nico Weber 51d938bc94 Fix bugs when an included file name is typo corrected.
D52774 fixed a bug with typo correction of includes, but didn't add
a test.

D65907 then broke recovery of typo correction of includes again,
because it extracted the code that writes to Filename to a separate
function that took the parameter not by reference.

Fix that, and also don't repeat the slash normalization computation
and fix both lookup and regular file name after recovery.

Differential Revision: https://reviews.llvm.org/D79595
2020-05-08 13:33:39 -04:00
Nico Weber e9b4113902 Add a flag that controls if clang-tidy and clang-include-fixer are built into libclang.
Based on the discussion on D55415, also make the flag default to false.
Having libclang depend on clang-tools-extra means check-clang builds all
of clang-tools-extra, which besides being a layering violation takes
quite some time, since clang-tools-extra has many files that are slow
to compile.

Longer term, we likely will want to remove this flag completely. If
people need this functionality, maybe there could be a
libclang-tools-extra that's libclang + clang-tidy and
clang-includes-fixer linked in.

Differential Revision: https://reviews.llvm.org/D79599
2020-05-08 11:41:45 -04:00
Weverything 4ae537c222 Fix false positive with -Wnon-c-typedef-for-linkage
Implicit methods for structs can confuse the warning, so exclude checking
the Decl's that are implicit. Implicit Decl's for lambdas still need to
be checked, so skipping all implicit Decl's won't work.

Differential Revision: https://reviews.llvm.org/D79548
2020-05-07 19:20:08 -07:00
Sriraman Tallam e8147ad822 Uniuqe Names for Internal Linkage Symbols.
This is a standalone patch and this would help Propeller do a better job of code
layout as it can accurately attribute the profiles to the right internal linkage
function.

This also helps SampledFDO/AutoFDO correctly associate sampled profiles to the
right internal function. Currently, if there is more than one internal symbol
foo, their profiles are aggregated by SampledFDO.

This patch adds a new clang option, -funique-internal-funcnames, to generate
unique names for functions with internal linkage. This patch appends the md5
hash of the module name to the function symbol as a best effort to generate a
unique name for symbols with internal linkage.

Differential Revision: https://reviews.llvm.org/D73307
2020-05-07 18:18:37 -07:00
mydeveloperday 5a4ddbd69d [clang-format] [PR45639] clang-format splits up the brackets of C++17 attribute [[ ]] when used with the first parameter
Summary:
https://bugs.llvm.org/show_bug.cgi?id=45639

clang-format incorrectly splits the `[[` in a long argument list

```
void SomeLongClassName::ALongMethodNameInThatClass([[maybe_unused]] const shared_ptr<ALongTypeName>& argumentNameForThat
LongType) {

}
```

becomes

```
void SomeLongClassName::ALongMethodNameInThatClass([
    [maybe_unused]] const shared_ptr<ALongTypeName> &argumentNameForThatLongType) {

}
```

leaving one `[` on the previous line

For a function with just 1 very long argument, clang-format chooses to split between the `[[`,

This revision prevents the slip between the two `[` and the second `[`

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79401
2020-05-07 22:00:04 +01:00
Erich Keane f9eaa6934e Ensure aux-target specific builtins get validated.
I discovered that when using an aux-target builtin, it was recognized as
a builtin but never checked. This patch checks for an aux-target builtin
and instead validates it against the correct target.

It does this by extracting the checking code for Target-specific
builtins into its own function, then calls with either targetInfo or
AuxTargetInfo.
2020-05-07 13:22:10 -07:00
Evgenii Stepanov b4aa71e1bd Allow -fsanitize-minimal-runtime with memtag sanitizer.
Summary:
MemTag does not have any runtime at the moment, it's strictly code
instrumentation.

Reviewers: pcc

Subscribers: cryptoad, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79522
2020-05-07 13:07:46 -07:00
Nico Weber d03838343f Make -Wnonportable-include-path ignore drive case on Windows.
See PR45812 for motivation.

No explicit test since I couldn't figure out how to get the
current disk drive in lower case into a form in lit where I could
mkdir it and cd to it. But the change does have test coverage in
that I can remove the case normalization in lit, and tests failed
on several bots (and for me locally if in a pwd with a lower-case
drive) without that normalization prior to this change.

Differential Revision: https://reviews.llvm.org/D79531
2020-05-07 15:54:09 -04:00
Erich Keane ed86058b53 Add static assert to ID Table to make sure aux targets work right.
I discovered that the limit on possible builtins managed by this
ObjCOrBuiltin variable is too low when combining large targets, since
aux-targets are appended to the targets list. A runtime assert exists
for this, however this patch creates a static-assert as well.

The logic for said static-assert is to make sure we have the room for
the aux-target and target to both be the largest list, which makes sure
we have room for all possible combinations.

I also incremented the number of bits by 1, since I discovered this
currently broken.  The current bit-count was 36, so this doesn't
increase any size.
2020-05-07 12:49:46 -07:00
mydeveloperday 5b8ffb4142 [clang-format] [PR45791] BeforeLambdaBody is confused by comment inside lambda
Summary:
https://bugs.llvm.org/show_bug.cgi?id=45791

Lambda with line comment is incorrectly formatted

```
auto k = []() // comment
{ return; };
````

```
auto k = []() // comment { return; };
```

Reviewed By: Wawha

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79320
2020-05-07 19:53:56 +01:00
mydeveloperday 3125aa9959 [clang-format] ensure dump_format_style.py works with Python3 correctly
Summary:
Python2 has been removed from cygwin, this means anyone running the dump_format_style.py in a cygwin shell could pick up python3 instead

In Python3 all strings are unicode as the file is opened in binary mode we need to encode the contents string or we'll face the following error

```
Traceback (most recent call last):
  File "./dump_format_style.py", line 228, in <module>
    output.write(contents)
TypeError: a bytes-like object is required, not 'str'
```

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79326
2020-05-07 19:52:12 +01:00
mydeveloperday 305a4abfd3 [clang-format] [PR45126] Help text is missing all available formats
Summary:
https://bugs.llvm.org/show_bug.cgi?id=45126

GNU and Microsoft styles are built in supported styles but are not displayed in the help text

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang, #clang-format

Differential Revision: https://reviews.llvm.org/D79372
2020-05-07 19:50:21 +01:00
Nico Weber e42fee75b8 Add a test for "clang --version". 2020-05-07 12:15:01 -04:00
Arthur Eubanks 48451ee6a7 [MSan] Pass MSan command line options under new pass manager
Summary:
Properly forward TrackOrigins and Recover user options to the MSan pass under the new pass manager.
This makes the number of check-msan failures when ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER is TRUE go from 52 to 2.

Based on https://reviews.llvm.org/D77249.

Reviewers: nemanjai, vitalybuka, leonardchan

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79445
2020-05-07 08:21:35 -07:00
Sander de Smalen 96a581d0f0 [SveEmitter] Add builtins for SVE2 svtbx (extended table lookup)
This patch adds builtins for:
- svtbx
2020-05-07 16:15:57 +01:00
Sander de Smalen e46043bba7 [SveEmitter] Add builtins for SVE2 Optional extensions (AES, SHA3, SM4, BITPERM)
This patch adds various builtins under their corresponding feature macros:

Defined under __ARM_FEATURE_SVE2_AES:
- svaesd
- svaese
- svaesimc
- svaesmc
- svpmullb_pair
- svpmullt_pair

Defined under __ARM_FEATURE_SVE2_SHA3:
- svrax1

Defined under __ARM_FEATURE_SVE2_SM4:
- svsm4e
- svsm4ekey

Defined under __ARM_FEATURE_SVE2_BITPERM:
- svbdep
- svbext
- svbgrp
2020-05-07 16:15:57 +01:00
Sander de Smalen f22cdc3cc3 [SveEmitter] Add builtins for SVE2 Character match instructions
This patch adds builtins for:
- svmatch
- svnmatch
2020-05-07 16:15:57 +01:00
Sander de Smalen ae652241bd [SveEmitter] Add builtins for SVE2 Vector histogram count instructions
This patch adds builtins for:
- svhistcnt
- svhistseg
2020-05-07 16:15:57 +01:00
Sander de Smalen fa0371f4fd [SveEmitter] Add builtins for SVE2 Floating-point integer binary logarithm instructions
This patch adds builtins for:
- svlogb
2020-05-07 16:15:57 +01:00
Sander de Smalen 086722c18e [SveEmitter] Add builtins for SVE2 Floating-point widening multiply-accumulate
This patch adds builtins for:
- svmlalb, svmlalb_lane
- svmlalt, svmlalt_lane
- svmlslb, svmlslb_lane
- svmlslt, svmlslt_lane
2020-05-07 16:15:57 +01:00
Sander de Smalen e76256e7c1 [SveEmitter] Add builtins for SVE2 Complex integer dot product
This patch adds builtins for:
- svcdot, svcdot_lane
2020-05-07 16:09:31 +01:00
Sander de Smalen 867bfae93f [SveEmitter] Add builtins for SVE2 Widening complex integer arithmetic
This patch adds builtins for:
- svaddlbt
- svqdmlalbt
- svqdmlslbt
- svsublbt
- svsubltb
2020-05-07 16:09:31 +01:00