Commit Graph

92680 Commits

Author SHA1 Message Date
Qiu Chaofan c091792cd3 [NFC] Fix SSE3 intrinsics test for PowerPC
Previous test in ppc-pmmintrin.c did not check IR of intrinsic function
definition. Add them and simplify.

These tests shouldn't be auto-generated, because we don't want to check
wrapper functions.
2022-02-09 17:00:34 +08:00
Muhammad Omair Javaid cd817231ec [clang-cl] Bump default -fms-compatibility-version to 19.14
clang-cl MSVC required version is 19.20 now. Update the default
-fms-compatibility-version to 19.14.

Differential Revision: https://reviews.llvm.org/D114639
2022-02-09 13:54:25 +05:00
Andrzej Warzynski 69c3309d45 [flang][driver] Add support for `-emit-mlir`
This patch adds support for generating MLIR files in Flang's frontend
driver (i.e. `flang-new -fc1`). `-emit-fir` is added as an alias for
`-emit-mlir`. We may want to decide to split the two in the future.

A new parent class for code-gen frontend actions is introduced:
`CodeGenAction`. We will be using this class to encapsulate logic shared
between all code-generation actions, but not required otherwise. For
now, it will:
 * run prescanning, parsing and semantic checks,
 * lower the input to MLIR.
`EmitObjAction` is updated to inherit from this class. This means that
the behaviour of `flang-new -fc1 -emit-obj` is also updated (previously,
it would just exit immediately). This change required
`flang/test/Driver/syntax-only.f90` to be updated.

For `-emit-fir`, a specialisation of `CodeGenAction` is introduced:
`EmitMLIRAction`. The key logic for this class is implemented in
`EmitMLIRAction::ExecuteAction`.

Differential Revision: https://reviews.llvm.org/D118985
2022-02-09 08:35:48 +00:00
Haojian Wu fe932a88e9 [pseudo] Add first and follow set computation in Grammar.
These will be used when building parsing table for LR parsers.

Separate from https://reviews.llvm.org/D118196.

Differential Revision: https://reviews.llvm.org/D118990
2022-02-09 09:16:27 +01:00
Saiyedul Islam 4db88a54b6
[OpenMP][Clang] Move partial support of reverse offload to a future version
OpenMP Spec 5.2 requires unimplemented requires clauses to produce
compile time error termination. Moving current partial support of
reverse_offload to a distant future version 9.9 so that existing
code can be tested and maintained until a complete implementation
is available.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D119256
2022-02-09 07:11:41 +00:00
Fangrui Song a163cdf6b5 [docs] Re-generate ClangCommandLineReference.rst 2022-02-08 20:54:52 -08:00
Yaxun (Sam) Liu 1d97cb1f6e [HIP] Emit amdgpu_code_object_version module flag
code object version determines ABI, therefore should not be mixed.

This patch emits amdgpu_code_object_version module flag in LLVM IR
based on code object version (default 4).

The amdgpu_code_object_version value is code object version times 100.

LLVM IR with different amdgpu_code_object_version module flag cannot
be linked.

The -cc1 option -mcode-object-version=none is for ROCm device library use
only, which supports multiple ABI.

Reviewed by: Artem Belevich

Differential Revision: https://reviews.llvm.org/D119026
2022-02-08 21:58:40 -05:00
Zakk Chen cfe7f69036 [RISCV][NFC] Refactor RISCVISAInfo.
1. Remove computeDefaultABIFromArch and add computeDefaultABI in
RISCVISAInfo.
2. Add parseFeatureBits which may used in D118333.

Differential Revision: https://reviews.llvm.org/D119250
2022-02-08 18:37:43 -08:00
Jon Roelofs 8440ec66f4 [docs] Document -ffinite-math-only, -fhonor-{infinities,infinites,nans} 2022-02-08 18:10:17 -08:00
Bill Wendling deaf22bc0e [X86] Implement -fzero-call-used-regs option
The "-fzero-call-used-regs" option tells the compiler to zero out
certain registers before the function returns. It's also available as a
function attribute: zero_call_used_regs.

The two upper categories are:

  - "used": Zero out used registers.
  - "all": Zero out all registers, whether used or not.

The individual options are:

  - "skip": Don't zero out any registers. This is the default.
  - "used": Zero out all used registers.
  - "used-arg": Zero out used registers that are used for arguments.
  - "used-gpr": Zero out used registers that are GPRs.
  - "used-gpr-arg": Zero out used GPRs that are used as arguments.
  - "all": Zero out all registers.
  - "all-arg": Zero out all registers used for arguments.
  - "all-gpr": Zero out all GPRs.
  - "all-gpr-arg": Zero out all GPRs used for arguments.

This is used to help mitigate Return-Oriented Programming exploits.

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D110869
2022-02-08 17:42:54 -08:00
Richard Smith dc8f4e118d [cxx_status] Add a couple of Feb 2022 library papers that need compiler support. 2022-02-08 17:25:52 -08:00
tyb0807 9b81d2fae8 Revert "[AArch64] ACLE feature macro for Armv8.8-A MOPS"
This reverts commit d379ec9908.
2022-02-09 00:10:09 +00:00
Ahmed Bougacha ca9f0ec1a3 [clang] Document objc_unsafeClaimAutoreleasedReturnValue.
This has been added a few years ago but wasn't listed here.
2022-02-08 14:30:39 -08:00
Ahmed Bougacha 6ba68a5fc3 [clang][Driver] Use a VersionTuple for darwin linker version checks.
This unifies a couple spots that did it manually by checking the
flag directly.

It does mean that we're now dropping the 5th component, but that's
not used in any of these checks, and to my knowledge it's never been
used in ld64.
2022-02-08 14:30:39 -08:00
Arthur Eubanks f16cc5df22 [test] Remove -fno-experimental-new-pass-manager -O1 from sanitize-address-field-padding.cpp
-O1 doesn't seem necessary here.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D118936
2022-02-08 13:22:43 -08:00
Arthur Eubanks f05a63f9a0 [clang] Properly cache member pointer LLVM types
When not going through the main Clang->LLVM type cache, we'd
accidentally create multiple different opaque types for a member pointer
type.

This allows us to remove the -verify-type-cache flag now that
check-clang passes with it on. We can do the verification in expensive
builds. Previously microsoft-abi-member-pointers.cpp was failing with
-verify-type-cache.

I suspect that there may be more issues when we have multiple member
pointer types and we clear the cache, but we can leave that for later.

Followup to D118744.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D119215
2022-02-08 13:22:24 -08:00
tyb0807 d379ec9908 [AArch64] ACLE feature macro for Armv8.8-A MOPS
This introduces the new __ARM_FEATURE_MOPS ACLE feature test macro,
which signals the availability of the new Armv8.8-A/Armv9.3-A
instructions for standardising memcpy, memset and memmove operations.

This patch supersedes the one from https://reviews.llvm.org/D116160.

Differential Revision: https://reviews.llvm.org/D118199
2022-02-08 21:07:49 +00:00
Sylvestre Ledru f2c2e924e7 Fix a typo (occured => occurred)
Reported:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1005195
2022-02-08 21:35:26 +01:00
Martin Storsjö 079b6d02d1 [clang] [MinGW] Recognize -lcrtdll as a library replacing -lmsvcrt
Differential Revision: https://reviews.llvm.org/D119234
2022-02-08 21:57:07 +02:00
James Y Knight 9545976ff1 Revert "[Clang] Propagate guaranteed alignment for malloc and others"
The above change assumed that malloc (and friends) would always
allocate memory to getNewAlign(), even for allocations which have a
smaller size. This is not actually required by spec (a 1-byte
allocation may validly have 1-byte alignment).

Some real-world malloc implementations do not provide this guarantee,
and thus this optimization is breaking programs.

Fixes #53540

This reverts commit c2297544c0.

Differential Revision: https://reviews.llvm.org/D118804
2022-02-08 14:34:44 -05:00
Amilendra Kodithuwakku 424e850f1e [clang][ARM] Re-word PACBTI warning.
The original warning added in D115501 when pacbti is used with an
incompatible architecture was not exactly correct because it was
not really ignored and can affect codegen.

Therefore reword to say that the pacbti option is incompatible with
the given architecture.

Reviewed By: chill

Differential Revision: https://reviews.llvm.org/D119166
2022-02-08 19:13:02 +00:00
Leonard Chan 4ac58b6102 [clang][Fuchsia] Ensure static sanitizer libs are only linked in after the -nostdlib check
Differential Revision: https://reviews.llvm.org/D119201
2022-02-08 10:53:22 -08:00
Steffen Larsen ead1690d31 Allow parameter pack expansions and initializer lists in annotate attribute
These changes make the Clang parser recognize expression parameter pack
expansion and initializer lists in attribute arguments. Because
expression parameter pack expansion requires additional handling while
creating and instantiating templates, the support for them must be
explicitly supported through the AcceptsExprPack flag.

Handling expression pack expansions may require a delay to when the
arguments of an attribute are correctly populated. To this end,
attributes that are set to accept these - through setting the
AcceptsExprPack flag - will automatically have an additional variadic
expression argument member named DelayedArgs. This member is not
exposed the same way other arguments are but is set through the new
CreateWithDelayedArgs creator function generated for applicable
attributes.

To illustrate how to implement support for expression pack expansion
support, clang::annotate is made to support pack expansions. This is
done by making handleAnnotationAttr delay setting the actual attribute
arguments until after template instantiation if it was unable to
populate the arguments due to dependencies in the parsed expressions.
2022-02-08 13:38:07 -05:00
Corentin Jabot c151225096 [C++2b] Implement multidimentional subscript operator
Implement P2128R6 in C++23 mode.

Unlike GCC's implementation, this doesn't try to recover when a user
meant to use a comma expression.

Because the syntax changes meaning in C++23, the patch is *NOT*
implemented as an extension. Instead, declaring an array with not
exactly 1 parameter is an error in older languages modes. There is an
off-by-default extension warning in C++23 mode.

Unlike the standard, we supports default arguments;

Ie, we assume, based on conversations in WG21, that the proposed
resolution to CWG2507 will be accepted.

We allow arrays OpenMP sections and C++23 multidimensional array to
coexist:

[a , b] multi dimensional array
[a : b] open mp section
[a, b: c] // error

The rest of the patch is relatively straight forward: we take care to
support an arbitrary number of arguments everywhere.
2022-02-08 12:10:47 -05:00
Krzysztof Parzyszek 2ecda9ec9c [Hexagon] Alter meaning of versionless -mhvx
The documentation for the official (downstream) Qualcomm Hexagon Clang
states that -mhvx sets the HVX version to be the same as the CPU version.
The current implementation upstream would use the most recent versioned
-mhvx= flag first (if present), then the CPU version. Change the upstream
behavior to match the documented behavior of the downstream compiler.
2022-02-08 09:06:15 -08:00
Dawid Jurczak 5d8d3a11c4 [NFC] Increase initial size of FoldingSets used in ASTContext and CodeGenTypes
Among many FoldingSet users most notable seem to be ASTContext and CodeGenTypes.
The reasons that we spend not-so-tiny amount of time in FoldingSet calls from there, are following:

  1. Default FoldingSet capacity for 2^6 items very often is not enough.
     For PointerTypes/ElaboratedTypes/ParenTypes it's not unlikely to observe growing it to 256 or 512 items.
     FunctionProtoTypes can easily exceed 1k items capacity growing up to 4k or even 8k size.

  2. FoldingSetBase::GrowBucketCount cost itself is not very bad (pure reallocations are rather cheap thanks to BumpPtrAllocator).
     What matters is high collision rate when lot of items end up in same bucket slowing down FoldingSetBase::FindNodeOrInsertPos and trashing CPU cache
     (as items with same hash are organized in intrusive linked list which need to be traversed).

This change address both issues by increasing initial size of FoldingSets used in ASTContext and CodeGenTypes.

Extracted from: https://reviews.llvm.org/D118385

Differential Revision: https://reviews.llvm.org/D118608
2022-02-08 17:54:04 +01:00
Balazs Benics 620d99b7ed Revert "[analyzer] Prevent misuses of -analyze-function"
This reverts commit 841817b1ed.

Ah, it still fails on build bots for some reason.
Pinning the target triple was not enough.
2022-02-08 17:42:46 +01:00
Balazs Benics 841817b1ed [analyzer] Prevent misuses of -analyze-function
Sometimes when I pass the mentioned option I forget about passing the
parameter list for c++ sources.
It would be also useful newcomers to learn about this.

This patch introduces some logic checking common misuses involving
`-analyze-function`.

Reviewed-By: martong

Differential Revision: https://reviews.llvm.org/D118690
2022-02-08 17:27:57 +01:00
Roman Lebedev eaac0e87fb
[NFC][clang] Autogenerate checklines in CodeGenCXX/nrvo.cpp
It checks IR after optimizations, which is inherently fragile,
and the results are now different after the recent patch.
2022-02-08 18:27:54 +03:00
Nikita Popov 18834dca2d [OpenCL] Mark kernel arguments as ABI aligned
Following the discussion on D118229, this marks all pointer-typed
kernel arguments as having ABI alignment, per section 6.3.5 of
the OpenCL spec:

> For arguments to a __kernel function declared to be a pointer to
> a data type, the OpenCL compiler can assume that the pointee is
> always appropriately aligned as required by the data type.

Differential Revision: https://reviews.llvm.org/D118894
2022-02-08 16:12:51 +01:00
Simon Pilgrim 09857a4bd1 [X86] Remove __builtin_ia32_padd/psub saturated intrinsics and use generic __builtin_elementwise_add/sub_sat
D117898 added the generic __builtin_elementwise_add_sat and __builtin_elementwise_sub_sat with the same integer behaviour as the SSE/AVX instructions

This patch removes the __builtin_ia32_padd/psub saturated intrinsics and just uses the generics - the existing tests see no changes:

__m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
  // CHECK-LABEL: test_mm256_adds_epi8
  // CHECK: call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
  return _mm256_adds_epi8(a, b);
}
2022-02-08 15:00:10 +00:00
Simon Pilgrim a59faf272e Revert rG6c174ab2ad0676b295f11f6c3913eff9289fa6b9 "[X86] Remove __builtin_ia32_padd/psub saturated intrinsics and use generic __builtin_elementwise_add/sub_sat"
Missed some legacy builtin tests that need cleaning up first
2022-02-08 14:45:28 +00:00
Simon Pilgrim 6c174ab2ad [X86] Remove __builtin_ia32_padd/psub saturated intrinsics and use generic __builtin_elementwise_add/sub_sat
D117898 added the generic __builtin_elementwise_add_sat and __builtin_elementwise_sub_sat with the same integer behaviour as the SSE/AVX instructions

This patch removes the __builtin_ia32_padd/psub saturated intrinsics and just uses the generics - the existing tests see no changes:

__m256i test_mm256_adds_epi8(__m256i a, __m256i b) {
  // CHECK-LABEL: test_mm256_adds_epi8
  // CHECK: call <32 x i8> @llvm.sadd.sat.v32i8(<32 x i8> %{{.*}}, <32 x i8> %{{.*}})
  return _mm256_adds_epi8(a, b);
}
2022-02-08 14:21:20 +00:00
Corentin Jabot 3c17f3955c Add core papers adopted at the february plenary.
2 papers are added to the status page, one targeting
C++23, the other added to the batch of C++20 concept papers.
2022-02-08 09:13:04 -05:00
Sven van Haastregt 9b8a93e3b6 [OpenCL] opencl-c.h: remove arg names from arm_dot; NFC
This simplifies completeness comparisons against OpenCLBuiltins.td.
2022-02-08 13:42:24 +00:00
David Pagan 0a7cc078ac Enable inoutset dependency-type in depend clause.
Done in manner similar to mutexinoutset
(see https://reviews.llvm.org/D57576)

Runtime support already exists in LLVM OpenMP runtime (see
https://reviews.llvm.org/D97085).

The value used to identify an inoutset dependency type in the LLVM
OpenMP runtime is 8.

Some tests updated due to change in dependency type error messages that
now include new dependency type. Also updated
test/OpenMP/task_codegen.cpp to verify we emit the right code.
2022-02-08 08:35:36 -05:00
Simon Pilgrim 508b3f437d Attempt to fix sphinx 'Malformed table' warning. 2022-02-08 11:48:37 +00:00
Simon Pilgrim c00db97159 [Clang] Add elementwise saturated add/sub builtins
This patch implements `__builtin_elementwise_add_sat` and `__builtin_elementwise_sub_sat` builtins.

These map to the add/sub saturated math intrinsics described here:
https://llvm.org/docs/LangRef.html#saturation-arithmetic-intrinsics

With this in place we should then be able to replace the x86 SSE adds/subs intrinsics with these generic variants - it looks like other targets should be able to use these as well (arm/aarch64/webassembly all have similar examples in cgbuiltin).

Differential Revision: https://reviews.llvm.org/D117898
2022-02-08 11:22:01 +00:00
Clement Courbet 90d2291fbb [NFC] Fix comment.
The extra space causes the table to render incorrectly in doxygen.
2022-02-08 09:42:44 +01:00
Marek Kurdej 06e42590a5 [clang-format] Comment unused parameters. NFC. 2022-02-08 09:33:55 +01:00
Marek Kurdej 7d6397348e [clang-format] Fix typo. NFC. 2022-02-08 09:33:54 +01:00
Chuanqi Xu 3504937dfb [C++20] [Modules] Don't create multiple global module fragment
Since the serialization code would recognize modules by names and the
name of all global module fragment is <global>, so that the
serialization code would complain for the same module.

This patch fixes this by using a unique global module fragment in Sema.
Before this patch, the compiler would fail on an assertion complaining
the duplicated modules.

Reviewed By: urnathan, rsmith

Differential Revision: https://reviews.llvm.org/D115610
2022-02-08 11:52:09 +08:00
Chuanqi Xu e39ba04617 [C++20] [Coroutines] Warning for always_inline coroutine
See the discussion in https://reviews.llvm.org/D100282. The coroutine
marked always inline might not be inlined properly in current compiler
support. Since the coroutine would be splitted into pieces. And the call
to resume() and destroy() functions might be indirect call. Also the
ramp function wouldn't get inlined under O0 due to pipeline ordering
problems. It might be different to what users expects to. Emit a warning
to tell it.

This is what GCC does too: https://godbolt.org/z/7eajb1Gf8

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D115867
2022-02-08 11:43:42 +08:00
Arthur Eubanks 45084eab5e [clang] Fix some clang->llvm type cache invalidation issues
Take the following as an example

  struct z {
    z (*p)();
  };

  z f();

When we attempt to get the LLVM type of f, we recurse into z. z itself
has a function pointer with the same type as f. Given the recursion,
Clang simply treats z::p as a pointer to an empty struct `{}*`. The
LLVM type of f is as expected. So we have two different potential
LLVM types for a given Clang type. If we store one of those into the
cache, when we access the cache with a different context (e.g. we
are/aren't recursing on z) we may get an incorrect result. There is some
attempt to clear the cache in these cases, but it doesn't seem to handle
all cases.

This change makes it so we only use the cache when we are not in any
sort of function context, i.e. `noRecordsBeingLaidOut() &&
FunctionsBeingProcessed.empty()`, which are the cases where we may
decide to choose a different LLVM type for a given Clang type. LLVM
types for builtin types are never recursive so they're always ok.

This allows us to clear the type cache less often (as seen with the
removal of one of the calls to `TypeCache.clear()`). We
still need to clear it when we use a placeholder type then replace it
later with the final type and other dependent types need to be
recalculated.

I've added a check that the cached type matches what we compute. It
triggered in this test case without the fix. It's currently not
check-clang clean so it's not on by default for something like expensive
checks builds.

This change uncovered another issue where the LLVM types for an argument
and its local temporary don't match. For example in type-cache-3, when
expanding z::dc's argument into a temporary alloca, we ConvertType() the
type of z::p which is `void ({}*)*`, which doesn't match the alloca GEP
type of `{}*`.

No noticeable compile time changes:
https://llvm-compile-time-tracker.com/compare.php?from=3918dd6b8acf8c5886b9921138312d1c638b2937&to=50bdec9836ed40e38ece0657f3058e730adffc4c&stat=instructions

Fixes #53465.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D118744
2022-02-07 18:59:09 -08:00
Alex Lorenz b58bf76f97 [clang][driver] update the darwin driver to point to correct macho_embedded path
Compiler-rt started emitting the macho_embedded libraries in
`<resource_dir>/lib/darwin/macho_embedded` after
https://reviews.llvm.org/D105765 / 1e03c37b97,
so update the clang's driver to reflect that.

Differential Revision: https://reviews.llvm.org/D115403
2022-02-07 16:50:58 -08:00
Elizabeth Andrews ed5b42b741 Fix address space for function pointers with qualifier
This patch fixes a bug introduced in commit 4eaf5846d0. Commit
4eaf5846d0 sets address space of function type as program
address space unconditionally. This breaks types which have
address space qualifiers. E.g. __ptr32.

This patch fixes the bug by using address space qualifiers if
present.

Differential Revision: https://reviews.llvm.org/D119045
2022-02-07 12:53:24 -08:00
Aaron Ballman 7deaeb2a05 Use functions with prototypes when appropriate; NFC
A significant number of our tests in C accidentally use functions
without prototypes. This patch converts the function signatures to have
a prototype for the situations where the test is not specific to K&R C
declarations. e.g.,

  void func();

becomes

  void func(void);

This is the fourth batch of tests being updated (there are a significant
number of other tests left to be updated).
2022-02-07 15:29:36 -05:00
Joseph Huber 5c9ee35138 [Clang][Docs] Fix some typos in offloading design documentation 2022-02-07 15:24:17 -05:00
Joseph Huber 7ee8bd60f2 [OpenMP] Use executable path when searching for lld
Summary:
This patch changes the ClangLinkerWrapper to use the executable path
when searching for the lld binary. Previously we relied on the program
name. Also not finding 'llvm-strip' is not considered an error anymore
because it is an optional optimization.
2022-02-07 15:09:51 -05:00
Arthur Eubanks 2724c153f9 [clang] Cache OpenCL types
If we call CGOpenCLRuntime::convertOpenCLSpecificType() multiple times
we should get the same type back.

Reviewed By: svenvh

Differential Revision: https://reviews.llvm.org/D119011
2022-02-07 09:23:04 -08:00