Commit Graph

87458 Commits

Author SHA1 Message Date
Faris Rehman 7809fa2040 [flang][driver] Add support for `-D`, `-U`
Add support for options -D and -U in the new Flang driver.

Summary of changes:
  - Create PreprocessorOptions, to be used by the driver then translated
    into Fortran::parser::Options
  - Create CompilerInvocation::setFortranOpts to pass preprocessor
    options into the parser options
  - Add a dedicated method, Flang::AddPreprocessingOptions, to extract
    preprocessing options from the driver arguments into the preprocessor
    command arguments

Macros specified like -DName will default to definition 1.

When defining macros, the new driver will drop anything after an
end-of-line character. This is consistent with gfortran and clang, but
different to what currently f18 does. However, flang (which is a bash
wrapper for f18), also drops everything after an end-of-line character.
So gfortran-like behaviour felt like the natural choice. Test is added
to demonstrate this behaviour.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D93401
2021-01-06 16:17:13 +00:00
Erich Keane 3fa6cedb6b Fix MaterializeTemporaryExpr's type when its an incomplete array.
Like the VarDecl that gets its type updated based on an init-list, this
patch corrects the MaterializeTemporaryExpr's type to make sure it isn't
creating an incomplete type, which leads to a handful of CodeGen crashes
(see PR 47636).

Based on @rsmith 's comments on D88236

Differential Revision: https://reviews.llvm.org/D88298
2021-01-06 07:17:12 -08:00
Yvan Roux 0c41b1c9f9 [Driver][MachineOutliner] Support outlining option with LTO
This patch propagates the -moutline flag when LTO is enabled and avoids
passing it explicitly to the linker plugin.

Differential Revision: https://reviews.llvm.org/D93385
2021-01-06 16:01:38 +01:00
Sven van Haastregt 29d375f5ff [OpenCL][NFC] Improve OpenCL test file naming
Change "negative" into "invalid" and put "invalid" at the beginning of
the file name, following the bulk of the invalid tests in the
SemaOpenCL directory.

Use the "invalid-" prefix only for tests that contain only invalid
constructs.

Drop the "valid" suffix for CodeGen tests, as inputs in this directory
are supposed to be valid anyway.
2021-01-06 14:16:44 +00:00
Jan Svoboda ce8c59e6af Reapply multiple "[clang][cli]" patches
This reverts 7ad666798f and 1876a2914f that reverted:

741978d727 [clang][cli] Port CodeGen option flags to new option parsing system
383778e217 [clang][cli] Port LangOpts option flags to new option parsing system
aec2991d08 [clang][cli] Port LangOpts simple string based options to new option parsing system
95d3cc67ca [clang][cli] Port CodeGenOpts simple string flags to new option parsing system
27b7d64688 [clang][cli] Streamline MarshallingInfoFlag description
70410a2649 [clang][cli] Let denormalizer decide how to render the option based on the option class
63a24816f5 [clang][cli] Implement `getAllArgValues` marshalling

Commit 741978d727 accidentally changed the `Group` attribute of `g[no_]column_info` options from `g_flags_Group` to `g_Group`, which changed the debug info options passed to cc1 by the driver.

Similar change was also present in 383778e217, which accidentally added `Group<f_Group>` to `f[no_]const_strings` and `f[no_]signed_wchar`.

This patch corrects all three accidental changes by replacing `Bool{G,F}Option` with `BoolCC1Option`.
2021-01-06 13:27:19 +01:00
Pushpinder Singh 4909cb1a0f [OpenMP][AMDGPU] Use AMDGPU_KERNEL calling convention for entry function
AMDGPU backend requires entry functions/kernels to have AMDGPU_KERNEL
calling convention for proper linking.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D94060
2021-01-06 02:03:30 -05:00
Yang Fan a032a4e799
[-Wcalled-once-parameter][NFC] Fix operator precedence warning 2021-01-06 12:16:30 +08:00
Yang Fan 74f93bc373
[Sema] Fix deleted function problem in implicitly movable test
In implicitly movable test, a two-stage overload resolution is performed.
If the first overload resolution selects a deleted function, Clang directly
performs the second overload resolution, without checking whether the
deleted function matches the additional criteria.

This patch fixes the above problem.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D92936
2021-01-06 10:05:40 +08:00
Richard Smith b12e473531 Allow dependent alias template specializations in the preferred_name
attribute.

This was intended to work, but didn't match the checks because these
types are modeled as TemplateSpecializationTypes not TypedefTypes.
2021-01-05 15:33:51 -08:00
Stephen Kelly 16c6e9c58e [ASTMatchers] Fix child traversal over range-for loops
Differential Revision: https://reviews.llvm.org/D94031
2021-01-05 21:29:37 +00:00
Alan Phipps 2168942117 [Coverage] Fix Profile test failures from commit rG9f2967bcfe2f
Fix test failures with Branch Coverage tests from commit rG9f2967bcfe2f
that failed build on builder clang-x64-windows-msvc while building llvm:
    http://lab.llvm.org:8011/#/builders/123/builds/2162
2021-01-05 14:53:07 -06:00
Atmn Patel f88a797521 [LoopDeletion] Allows deletion of possibly infinite side-effect free loops
From C11 and C++11 onwards, a forward-progress requirement has been
introduced for both languages. In the case of C, loops with non-constant
conditionals that do not have any observable side-effects (as defined by
6.8.5p6) can be assumed by the implementation to terminate, and in the
case of C++, this assumption extends to all functions. The clang
frontend will emit the `mustprogress` function attribute for C++
functions (D86233, D85393, D86841) and emit the loop metadata
`llvm.loop.mustprogress` for every loop in C11 or later that has a
non-constant conditional.

This patch modifies LoopDeletion so that only loops with
the `llvm.loop.mustprogress` metadata or loops contained in functions
that are required to make progress (`mustprogress` or `willreturn`) are
checked for observable side-effects. If these loops do not have an
observable side-effect, then we delete them.

Loops without observable side-effects that do not satisfy the above
conditions will not be deleted.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D86844
2021-01-05 09:56:16 -05:00
Alan Phipps 16f3401eae [Coverage] Fix test failures from commit rG9f2967bcfe2f
Fix test failures with Branch Coverage tests from commit rG9f2967bcfe2f
that failed build on builder clang-x64-windows-msvc while building llvm:
    http://lab.llvm.org:8011/#builders/123/builds/2155
2021-01-05 13:35:52 -06:00
Thomas Lively 497026c902 [WebAssembly] Prototype prefetch instructions
As proposed in https://github.com/WebAssembly/simd/pull/352 and using the
opcodes used in the V8 prototype:
https://chromium-review.googlesource.com/c/v8/v8/+/2543167. These instructions
are only usable via intrinsics and clang builtins to make them opt-in while they
are being benchmarked.

Differential Revision: https://reviews.llvm.org/D93883
2021-01-05 11:32:03 -08:00
Jan Svoboda f111cf992d [clang][cli] Specify correct integer width for -fbuild-session-timestamp
This fixes an issue where large integer values were rejected as invalid.

Reviewed By: arphaman

Differential Revision: https://reviews.llvm.org/D94101
2021-01-05 20:10:07 +01:00
Yitzhak Mandelbaum 675a2973ee [libTooling] Add support for smart pointers to relevant Transformer `Stencil`s.
Stencils `maybeDeref` and `maybeAddressOf` are designed to handle nodes that may
be pointers. Currently, they only handle native pointers. This patch extends the
support to recognize smart pointers and handle them as well.

Differential Revision: https://reviews.llvm.org/D93637
2021-01-05 17:57:41 +00:00
Stephen Kelly f22c0f40b5 [ASTMatchers] Omit methods from explicit template instantations
Differential Revision: https://reviews.llvm.org/D94032
2021-01-05 17:42:33 +00:00
Simon Pilgrim 55488bd3cd CGExpr - EmitMatrixSubscriptExpr - fix getAs<> null-dereference static analyzer warning. NFCI.
getAs<> can return null if the cast is invalid, which can lead to null pointer deferences. Use castAs<> instead which will assert that the cast is valid.
2021-01-05 17:08:11 +00:00
Florian Hahn 51d5991f04
[Clang] Add AArch64 VCMLA LANE variants.
This patch adds the LANE variants for VCMLA on AArch64 as defined in
"Arm Neon Intrinsics Reference for ACLE Q3 2020" [1]

This patch also updates `dup_typed` to accept constant type strings directly.

Based on a patch by Tim Northover.

[1] https://developer.arm.com/documentation/ihi0073/latest

Reviewed By: SjoerdMeijer

Differential Revision: https://reviews.llvm.org/D93014
2021-01-05 16:14:00 +00:00
Alan Phipps 9f2967bcfe [Coverage] Add support for Branch Coverage in LLVM Source-Based Code Coverage
This is an enhancement to LLVM Source-Based Code Coverage in clang to track how
many times individual branch-generating conditions are taken (evaluate to TRUE)
and not taken (evaluate to FALSE).  Individual conditions may comprise larger
boolean expressions using boolean logical operators.  This functionality is
very similar to what is supported by GCOV except that it is very closely
anchored to the ASTs.

Differential Revision: https://reviews.llvm.org/D84467
2021-01-05 09:51:51 -06:00
Valeriy Savchenko fec1a442e3 [-Wcalled-once-parameter] Introduce 'called_once' attribute
This commit introduces a new attribute `called_once`.
It can be applied to function-like parameters to signify that
this parameter should be called exactly once.  This concept
is particularly widespread in asynchronous programs.

Additionally, this commit introduce a new group of dataflow
analysis-based warnings to check this property.  It identifies
and reports the following situations:
  * parameter is called twice
  * parameter is never called
  * parameter is not called on one of the paths

Current implementation can also automatically infer `called_once`
attribute for completion handler paramaters that should follow the
same principle by convention.  This behavior is OFF by default and
can be turned on by using `-Wcompletion-handler`.

Differential Revision: https://reviews.llvm.org/D92039

rdar://72812043
2021-01-05 18:26:44 +03:00
Stephen Kelly 7e4f53f748 [ASTMatchers] Fix traversal matchers with explicit and defaulted methods
Differential Revision: https://reviews.llvm.org/D94030
2021-01-05 15:22:21 +00:00
Joe Ellis 3d5b18a3fd [clang][AArch64][SVE] Avoid going through memory for coerced VLST arguments
VLST arguments are coerced to VLATs at the function boundary for
consistency with the VLAT ABI. They are then bitcast back to VLSTs in
the function prolog. Previously, this conversion is done through memory.
With the introduction of the llvm.vector.{insert,extract} intrinsic, we
can avoid going through memory here.

Depends on D92761

Differential Revision: https://reviews.llvm.org/D92762
2021-01-05 15:18:21 +00:00
Stephen Kelly c3a21e5de3 [ASTMatchers] Ensure that we can match inside lambdas
Because we don't know in ASTMatchFinder whether we're matching in AsIs
or IgnoreUnlessSpelledInSource mode, we need to traverse the lambda
twice, but store whether we're matching in nodes spelled in source or
not.

Differential Revision: https://reviews.llvm.org/D93688
2021-01-05 14:39:46 +00:00
Anastasia Stulova 6f770292a0 [OpenCL] Restrict pointer to member functions.
Pointers to member functions are a special case
of function pointers and therefore have to be
disallowed.

Tags: #clang

Differential Revision: https://reviews.llvm.org/D93958
2021-01-05 13:32:18 +00:00
Kazushi (Jam) Marukawa 489000d851 [VE] Change clang to support SjLj Lowering
We supports SjLj exception handling in the backend, so changing
clang to allow lowering using SjLj exceptions.  Update a regression
test also.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D94076
2021-01-05 22:19:02 +09:00
Sven van Haastregt 0e4d2361b8 [OpenCL] Warn about side effects for unevaluated vec_step arg
The argument to the `vec_step` builtin is not evaluated.  Hoist the
diagnostic for this in `Sema::CheckUnaryExprOrTypeTraitOperand` such
that it comes before `Sema::CheckVecStepTraitOperandType`.

A minor side-effect of this change is that it also produces the
warning for `co_await` and `co_yield` as `sizeof` arguments now, which
seems to be reasonable given that the warning is emitted for `typeid`
already.

Differential Revision: https://reviews.llvm.org/D91348
2021-01-05 11:51:10 +00:00
Vassil Vassilev 02eb8e20b5 Inform the consumer on invalid template instantiations.
Some clients which want to track state need the information whether a template
was instantiated and made invalid.

Differential revision: https://reviews.llvm.org/D92248
2021-01-05 09:43:38 +00:00
Simon Pilgrim 6725860d21 Sema::BuildCallExpr - use cast<> instead of dyn_cast<> for dereferenced pointer. NFCI.
We're immediately dereferencing the casted pointer, so use cast<> which will assert instead of dyn_cast<> which can return null.

Fixes static analyzer warning.
2021-01-05 09:34:00 +00:00
Petr Hosek f67d3dbdb9 [clang] - Also look for devtoolset-10
devtoolset-10 has just been released so look for it as well.

Patch By: stephan.dollberg

Differential Revision: https://reviews.llvm.org/D92792
2021-01-04 14:24:46 -08:00
Thorsten Schütt 2fd11e0b1e Revert "[NFC, Refactor] Modernize StorageClass from Specifiers.h to a scoped enum (II)"
This reverts commit efc82c4ad2.
2021-01-04 23:17:45 +01:00
Thorsten Schütt efc82c4ad2 [NFC, Refactor] Modernize StorageClass from Specifiers.h to a scoped enum (II)
Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D93765
2021-01-04 22:58:26 +01:00
Hongtao Yu 4034f9273e Switching Clang UniqueInternalLinkageNamesPass scheduling to using the LLVM one with newpm.
As a follow-up to D93656, I'm switching the Clang UniqueInternalLinkageNamesPass scheduling to using the LLVM one with newpm.

Test Plan:

Reviewed By: aeubanks, tmsriram

Differential Revision: https://reviews.llvm.org/D94019
2021-01-04 12:04:46 -08:00
Jon Chesterfield 76bfbb74d3 [libomptarget][amdgpu] Call into deviceRTL instead of ockl
[libomptarget][amdgpu] Call into deviceRTL instead of ockl

Amdgpu codegen presently emits a call into ockl. The same functionality
is already present in the deviceRTL. Adds an amdgpu specific entry point
to avoid the dependency. This lets simple openmp code (specifically, that
which doesn't use libm) run without rocm device libraries installed.

Reviewed By: ronlieb

Differential Revision: https://reviews.llvm.org/D93356
2021-01-04 16:48:47 +00:00
Simon Pilgrim 9f8c0d15c7 DeclCXX - Fix getAs<> null-dereference static analyzer warnings. NFCI.
getAs<> can return null if the cast is invalid, which can lead to null pointer deferences. Use castAs<> instead which will assert that the cast is valid.
2021-01-04 15:12:55 +00:00
Yang Fan e43b3d1f5e
Revert "[Sema] Fix deleted function problem in implicitly movable test"
This reverts commit 89b0972a
2021-01-04 17:21:19 +08:00
Brandon Bergren 4c77a0f1ce [PowerPC] NFC: Apply minor clang-format fix 2021-01-02 12:21:28 -06:00
Brandon Bergren 2288319733 [PowerPC] Enable OpenMP for powerpcle target. [5/5]
Enable OpenMP for powerpcle to match the rest of powerpc*.

Update tests.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92445
2021-01-02 12:18:07 -06:00
Brandon Bergren 6cee9d0cf8 [PowerPC] Support powerpcle target in Clang [3/5]
Add powerpcle support to clang.

For FreeBSD, assume a freestanding environment for now, as we only need it in the first place to build loader, which runs in the OpenFirmware environment instead of the FreeBSD environment.

For Linux, recognize glibc and musl environments to match current usage in Void Linux PPC.

Adjust driver to match current binutils behavior regarding machine naming.

Adjust and expand tests.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93919
2021-01-02 12:17:58 -06:00
Fangrui Song ec9f2c3be0 test/OpenMP/parallel_codegen.cpp: Allow multiple result attributes
On many targets the matched line is `define dso_local i32 @main` while
on ppc64 it is `define dso_local signext i32 @main`.
2021-01-01 10:46:34 -08:00
Yang Fan 89b0972aa2 [Sema] Fix deleted function problem in implicitly movable test
In implicitly movable test, a two-stage overload resolution is performed.
If the first overload resolution selects a deleted function, Clang directly
performs the second overload resolution, without checking whether the
deleted function matches the additional criteria.

This patch fixes the above problem.

Reviewed By: Quuxplusone

Differential Revision: https://reviews.llvm.org/D92936
2021-01-01 15:47:49 +08:00
Fangrui Song d1fd72343c Refactor how -fno-semantic-interposition sets dso_local on default visibility external linkage definitions
The idea is that the CC1 default for ELF should set dso_local on default
visibility external linkage definitions in the default -mrelocation-model pic
mode (-fpic/-fPIC) to match COFF/Mach-O and make output IR similar.

The refactoring is made available by 2820a2ca3a.

Currently only x86 supports local aliases. We move the decision to the driver.
There are three CC1 states:

* -fsemantic-interposition: make some linkages interposable and make default visibility external linkage definitions dso_preemptable.
* (default): selected if the target supports .Lfoo$local: make default visibility external linkage definitions dso_local
* -fhalf-no-semantic-interposition: if neither option is set or the target does not support .Lfoo$local: like -fno-semantic-interposition but local aliases are not used. So references can be interposed if not optimized out.

Add -fhalf-no-semantic-interposition to a few tests using the half-based semantic interposition behavior.
2020-12-31 13:59:45 -08:00
Fangrui Song 219d00e0d9 [test] Make ELF tests immune to dso_local/dso_preemptable/(none) differences
ELF -cc1 -mrelocation-model pic will default to no semantic interposition plus
setting dso_local on default visibility external linkage definitions, so that
COFF, Mach-O and ELF output will be similar.

This patch makes tests immune to the differences.
2020-12-31 13:59:44 -08:00
Atmn 1a65b8c739 [Clang][Misc] Change run line in fragile test
This test has %clang in the run line when it should have %clang_cc1.
This should prevent future release test failures.

Differential Revision: https://reviews.llvm.org/D93952
2020-12-31 13:48:21 -05:00
Bogdan Graur 8bee4d4e8f Revert "[LoopDeletion] Allows deletion of possibly infinite side-effect free loops"
Test clang/test/Misc/loop-opt-setup.c fails when executed in Release.

This reverts commit 6f1503d598.

Reviewed By: SureYeaah

Differential Revision: https://reviews.llvm.org/D93956
2020-12-31 11:47:49 +00:00
Fangrui Song fd739804e0 [test] Add {{.*}} to make ELF tests immune to dso_local/dso_preemptable/(none) differences
For a default visibility external linkage definition, dso_local is set for ELF
-fno-pic/-fpie and COFF and Mach-O. Since default clang -cc1 for ELF is similar
to -fpic ("PIC Level" is not set), this nuance causes unneeded binary format differences.

To make emitted IR similar, ELF -cc1 -fpic will default to -fno-semantic-interposition,
which sets dso_local for default visibility external linkage definitions.

To make this flip smooth and enable future (dso_local as definition default),
this patch replaces (function) `define ` with `define{{.*}} `,
(variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} `.
2020-12-31 00:27:11 -08:00
Fangrui Song f2cc2669a0 [test] Fix -triple and delete UNSUPPORTED: system-windows 2020-12-31 00:13:34 -08:00
Luo, Yuanke 08665b1805 Support tilezero intrinsic and c interface for AMX.
Differential Revision: https://reviews.llvm.org/D92837
2020-12-31 13:24:57 +08:00
Fangrui Song 809a1e0ffd [CodeGenModule] Set dso_local for Mach-O GlobalValue
* static relocation model: always
* other relocation models: if isStrongDefinitionForLinker

This will make LLVM IR emitted for COFF/Mach-O and executable ELF similar.
2020-12-30 20:52:01 -08:00
Fangrui Song 6b3351792c [test] Add {{.*}} to make tests immune to dso_local/dso_preemptable/(none) differences
For a definition (of most linkage types), dso_local is set for ELF -fno-pic/-fpie
and COFF, but not for Mach-O.  This nuance causes unneeded binary format differences.

This patch replaces (function) `define ` with `define{{.*}} `,
(variable/constant/alias) `= ` with `={{.*}} `, or inserts appropriate `{{.*}} `
if there is an explicit linkage.

* Clang will set dso_local for Mach-O, which is currently implied by TargetMachine.cpp. This will make COFF/Mach-O and executable ELF similar.
* Eventually I hope we can make dso_local the textual LLVM IR default (write explicit "dso_preemptable" when applicable) and -fpic ELF will be similar to everything else. This patch helps move toward that goal.
2020-12-30 20:52:01 -08:00
Atmn Patel 6f1503d598 [LoopDeletion] Allows deletion of possibly infinite side-effect free loops
From C11 and C++11 onwards, a forward-progress requirement has been
introduced for both languages. In the case of C, loops with non-constant
conditionals that do not have any observable side-effects (as defined by
6.8.5p6) can be assumed by the implementation to terminate, and in the
case of C++, this assumption extends to all functions. The clang
frontend will emit the `mustprogress` function attribute for C++
functions (D86233, D85393, D86841) and emit the loop metadata
`llvm.loop.mustprogress` for every loop in C11 or later that has a
non-constant conditional.

This patch modifies LoopDeletion so that only loops with
the `llvm.loop.mustprogress` metadata or loops contained in functions
that are required to make progress (`mustprogress` or `willreturn`) are
checked for observable side-effects. If these loops do not have an
observable side-effect, then we delete them.

Loops without observable side-effects that do not satisfy the above
conditions will not be deleted.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D86844
2020-12-30 21:43:01 -05:00
Juneyoung Lee 420d046d6b clang-format, address warnings 2020-12-30 23:05:07 +09:00
Juneyoung Lee 9b29610228 Use unary CreateShuffleVector if possible
As mentioned in D93793, there are quite a few places where unary `IRBuilder::CreateShuffleVector(X, Mask)` can be used
instead of `IRBuilder::CreateShuffleVector(X, Undef, Mask)`.
Let's update them.

Actually, it would have been more natural if the patches were made in this order:
(1) let them use unary CreateShuffleVector first
(2) update IRBuilder::CreateShuffleVector to use poison as a placeholder value (D93793)

The order is swapped, but in terms of correctness it is still fine.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D93923
2020-12-30 22:36:08 +09:00
Fangrui Song 2820a2ca3a Move -fno-semantic-interposition dso_local logic from TargetMachine to Clang CodeGenModule
This simplifies TargetMachine::shouldAssumeDSOLocal and and gives frontend the
decision to use dso_local. For LLVM synthesized functions/globals, they may lose
inferred dso_local but such optimizations are probably not very useful.

Note: the hasComdat() condition in canBenefitFromLocalAlias (D77429) may be dead now.
(llvm/CodeGen/X86/semantic-interposition-comdat.ll)
(Investigate whether we need test coverage when Fuchsia C++ ABI is clearer)
2020-12-29 23:37:55 -08:00
Luo, Yuanke 981a0bd858 [X86] Add x86_amx type for intel AMX.
The x86_amx is used for AMX intrisics. <256 x i32> is bitcast to x86_amx when
it is used by AMX intrinsics, and x86_amx is bitcast to <256 x i32> when it
is used by load/store instruction. So amx intrinsics only operate on type x86_amx.
It can help to separate amx intrinsics from llvm IR instructions (+-*/).
Thank Craig for the idea. This patch depend on https://reviews.llvm.org/D87981.

Differential Revision: https://reviews.llvm.org/D91927
2020-12-30 13:52:13 +08:00
Juneyoung Lee 278aa65cc4 [IR] Let IRBuilder's CreateVectorSplat/CreateShuffleVector use poison as placeholder
This patch updates IRBuilder to create insertelement/shufflevector using poison as a placeholder.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93793
2020-12-30 04:21:04 +09:00
Mark Murray 5abfeccf10 [ARM][AArch64] Add Cortex-A78C Support for Clang and LLVM
This patch upstreams support for the Armv8-a Cortex-A78C
processor for AArch64 and ARM.

In detail:

Adding cortex-a78c as cpu option for aarch64 and arm targets in clang
Adding Cortex-A78C CPU name and ProcessorModel in llvm
Details of the CPU can be found here:
https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a78c
2020-12-29 10:18:59 +00:00
Arthur Eubanks c5d100fdf2 [test] Fix conditional-temporaries.cpp
Broken by https://reviews.llvm.org/D93880.
(but now the test is much better :) )
2020-12-28 20:17:31 -08:00
James Y Knight 4ddf140c00 Fix PR35902: incorrect alignment used for ubsan check.
UBSan was using the complete-object align rather than nv alignment
when checking the "this" pointer of a method.

Furthermore, CGF.CXXABIThisAlignment was also being set incorrectly,
due to an incorrectly negated test. The latter doesn't appear to have
had any impact, due to it not really being used anywhere.

Differential Revision: https://reviews.llvm.org/D93072
2020-12-28 18:11:17 -05:00
Thomas Lively 5e09e9979b [WebAssembly] Prototype extending pairwise add instructions
As proposed in https://github.com/WebAssembly/simd/pull/380. This commit makes
the new instructions available only via clang builtins and LLVM intrinsics to
make their use opt-in while they are still being evaluated for inclusion in the
SIMD proposal.

Depends on D93771.

Differential Revision: https://reviews.llvm.org/D93775
2020-12-28 14:11:14 -08:00
Akira Hatanaka 34405b41d6 [CodeGen][ObjC] Destroy callee-destroyed arguments in the caller
function when the receiver is nil

Callee-destroyed arguments to a method have to be destroyed in the
caller function when the receiver is nil as the method doesn't get
executed. This fixes PR48207.

rdar://71808391

Differential Revision: https://reviews.llvm.org/D93273
2020-12-28 11:52:27 -08:00
Juneyoung Lee 9d70dbdc2b [InstCombine] use poison as placeholder for undemanded elems
Currently undef is used as a don’t-care vector when constructing a vector using a series of insertelement.
However, this is problematic because undef isn’t undefined enough.
Especially, a sequence of insertelement can be optimized to shufflevector, but using undef as its placeholder makes shufflevector a poison-blocking instruction because undef cannot be optimized to poison.
This makes a few straightforward optimizations incorrect, such as:

```
;  https://bugs.llvm.org/show_bug.cgi?id=44185

define <4 x float> @insert_not_undef_shuffle_translate_commute(float %x, <4 x float> %y, <4 x float> %q) {
  %xv = insertelement <4 x float> %q, float %x, i32 2
  %r = shufflevector <4 x float> %y, <4 x float> %xv, <4 x i32> { 0, 6, 2, undef }
  ret <4 x float> %r ; %r[3] is undef
}
=>
define <4 x float> @insert_not_undef_shuffle_translate_commute(float %x, <4 x float> %y, <4 x float> %q) {
  %r = insertelement <4 x float> %y, float %x, i32 1
  ret <4 x float> %r ; %r[3] = %y[3], incorrect if %y[3] = poison
}

Transformation doesn't verify!
ERROR: Target is more poisonous than source
```

I’d like to suggest
1. Using poison as insertelement’s placeholder value (IRBuilder::CreateVectorSplat should be patched too)
2. Updating shufflevector’s semantics to return poison element if mask is undef

Note that poison is currently lowered into UNDEF in SelDag, so codegen part is okay.
m_Undef() matches PoisonValue as well, so existing optimizations will still fire.

The only concern is hidden miscompilations that will go incorrect when poison constant is given.
A conservative way is copying all tests having `insertelement undef` & replacing it with `insertelement poison` & run Alive2 on it, but it will create many tests and people won’t like it. :(

Instead, I’ll simply locally maintain the tests and run Alive2.
If there is any bug found, I’ll report it.

Relevant links: https://bugs.llvm.org/show_bug.cgi?id=43958 , http://lists.llvm.org/pipermail/llvm-dev/2019-November/137242.html

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93586
2020-12-28 08:58:15 +09:00
mydeveloperday c7dcc4c725 [clang-format] PR48569 clang-format fails to align case label with `switch` with Whitesmith Indentation
https://bugs.llvm.org/show_bug.cgi?id=48569

This is a tentative fix which addresses a PR raise regarding Case indentation when working with Whitesmiths Indentation

I could not find online any reference sources as to what the case indentation for Whitesmith's should be (or be allowed to be)

But according to the documentation, we don't obey the rules for Whitesmith's

```
In particular, the documentation states that this option is to "indent case labels one level from the switch statement. When false, use the same indentation level as for the switch statement."
```

The behaviour we add here is actually as the TODO in the tests used to state in {D67627}, but when {D82016} was added and I brought these tests out from being TODO I realized I changed the indentation.

Reviewed By: curdeius, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D93806
2020-12-26 15:19:03 +00:00
Alexandre Ganea 69132d12de [Clang] Reverse test to save on indentation. NFC. 2020-12-23 19:24:53 -05:00
Duncan P. N. Exon Smith 3ee43adfb2 Basic: Add native support for stdin to SourceManager and FileManager
Add support for stdin to SourceManager and FileManager. Adds
FileManager::getSTDIN, which adds a FileEntryRef for `<stdin>` and reads
the MemoryBuffer, which is stored as `FileEntry::Content`.

Eventually the other buffers in `ContentCache` will sink to here as well
-- we probably usually want to load/save a MemoryBuffer eagerly -- but
it's happening early for stdin to get rid of
CompilerInstance::InitializeSourceManager's final call to
`SourceManager::overrideFileContents`.

clang/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp
relies on building a module from stdin; supporting that requires setting
ContentCache::BufferOverridden.

Differential Revision: https://reviews.llvm.org/D93148
2020-12-23 15:18:50 -08:00
Duncan P. N. Exon Smith 245218bb35 Basic: Support named pipes natively in SourceManager and FileManager
Handle named pipes natively in SourceManager and FileManager, removing a
call to `SourceManager::overrideFileContents` in
`CompilerInstance::InitializeSourceManager` (removing a blocker for
sinking the content cache to FileManager (which will incidently sink
this new named pipe logic with it)).

SourceManager usually checks if the file entry's size matches the
eventually loaded buffer, but that's now skipped for named pipes since
the `stat` won't reflect the full size.  Since we can't trust
`ContentsEntry->getSize()`, we also need shift the check for files that
are too large until after the buffer is loaded... and load the buffer
immediately in `createFileID` so that no client gets a bad value from
`ContentCache::getSize`. `FileManager::getBufferForFile` also needs to
treat these files as volatile when loading the buffer.

Native support in SourceManager / FileManager means that named pipes can
also be `#include`d, and clang/test/Misc/dev-fd-fs.c was expanded to
check for that.

This is a new version of 3b18a594c7, which
was reverted in b346322019 since it was
missing the `SourceManager` changes.

Differential Revision: https://reviews.llvm.org/D92531
2020-12-23 14:57:41 -08:00
Björn Schäpers 47877c9079 [clang-format] Add SpaceBeforeCaseColon option
With which you can add a space before the colon of a case or default
statement.

Differential Revision: https://reviews.llvm.org/D93240
2020-12-23 22:07:14 +01:00
Björn Schäpers 374f1d81fe [clang-format] Fix handling of TextProto comments
Differential Revision: https://reviews.llvm.org/D93163
2020-12-23 22:07:13 +01:00
Nathan James c7e825b910
[format][NFC] Use unsigned char as the base of all enums in FormatStyle
This removes alot of unnecessary padding, trimming the size of the struct from 728->608 on 64 bit platforms.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D93758
2020-12-23 20:27:44 +00:00
Sriraman Tallam 34e70d722d Append ".__part." to every basic block section symbol.
Every basic block section symbol created by -fbasic-block-sections will contain
".__part." to know that this symbol corresponds to a basic block fragment of
the function.

This patch solves two problems:

a) Like D89617, we want function symbols with suffixes to be properly qualified
   so that external tools like profile aggregators know exactly what this
   symbol corresponds to.
b) The current basic block naming just adds a ".N" to the symbol name where N is
   some integer. This collides with how clang creates __cxx_global_var_init.N.
   clang creates these symbol names to call constructor functions and basic
   block symbol naming should not use the same style.

Fixed all the test cases and added an extra test for __cxx_global_var_init
breakage.

Differential Revision: https://reviews.llvm.org/D93082
2020-12-23 11:35:44 -08:00
Nico Weber 4c37453a04 clang: Build and run FrontendTests with CLANG_ENABLE_STATIC_ANALYZER=OFF too
They seem to pass fine with the analyzer off, and with this I would've
noticed my last check-clang break locally.
2020-12-23 14:27:09 -05:00
Nico Weber 1876a2914f Revert more changes that landed on top of 741978d727
This should've been in 7ad666798f but wasn't.

Squashes these twoc commits:
Revert "[clang][cli] Let denormalizer decide how to render the option based on the option class"
This reverts commit 70410a2649.

Revert "[clang][cli] Implement `getAllArgValues` marshalling"
This reverts commit 63a24816f5.
2020-12-23 14:20:21 -05:00
Alan Phipps bbd758a791 Revert "This is a test commit"
This reverts commit b920adf3b4.
2020-12-23 13:04:37 -06:00
Alan Phipps b920adf3b4 This is a test commit 2020-12-23 12:57:27 -06:00
Nico Weber 7ad666798f Revert 741978d727 and things that landed on top of it.
741978d727 made clang produce output that's 2x as large at least in
sanitizer builds. https://reviews.llvm.org/D83892#2470185 has a
standalone repro.

This reverts the following commits:

Revert "[clang][cli] Port CodeGenOpts simple string flags to new option parsing system"
This reverts commit 95d3cc67ca.

Revert "[clang][cli] Port LangOpts simple string based options to new option parsing system"
This reverts commit aec2991d08.

Revert "[clang][cli] Streamline MarshallingInfoFlag description"
This reverts commit 27b7d64688.

Revert "[clang][cli] Port LangOpts option flags to new option parsing system"
This reverts commit 383778e217.

Revert "[clang][cli] Port CodeGen option flags to new option parsing system"
This reverts commit 741978d727.
2020-12-23 12:52:11 -05:00
mydeveloperday 031743cb5b [clang-format] PR48539 ReflowComments breaks Qt translation comments
https://bugs.llvm.org/show_bug.cgi?id=48539

Add support for Qt Translator Comments to reflow

When reflown and a part of the comments are added on a new line, it should repeat these extra characters as part of the comment token.

Reviewed By: curdeius, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D93490
2020-12-23 14:45:14 +00:00
mydeveloperday 5426b2f9ed [clang-format] PR48535 clang-format Incorrectly Removes Space After C Style Cast When Type Is Not a Pointer
https://bugs.llvm.org/show_bug.cgi?id=48535

using `SpaceAfterCStyleCast: true`

```
size_t idx = (size_t) a;
size_t idx = (size_t) (a - 1);
```

is formatted as:

```
size_t idx = (size_t) a;
size_t idx = (size_t)(a - 1);
```

This revision aims to improve that by improving the function which tries to identify a CastRParen

Reviewed By: curdeius

Differential Revision: https://reviews.llvm.org/D93626
2020-12-23 14:45:14 +00:00
Nathan James eb9483b210
[format] Add overload to parseConfiguration that accept llvm::MemoryBufferRef
This overload should be used for better diagnostics when parsing configurations.
Now a failure to parse will list the filename (or <command-line>) instead of just `YAML`.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D93633
2020-12-23 12:08:29 +00:00
Adrian Kuegel 25a02c3d1a Revert "PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of"
This reverts commit d3bf0bb189.
This causes compilation in certain cases to fail.
Reproducer TBD.
2020-12-23 12:31:52 +01:00
Arthur O'Dwyer 22cf54a7fb Replace `T(x)` with `reinterpret_cast<T>(x)` everywhere it means reinterpret_cast. NFC.
Differential Revision: https://reviews.llvm.org/D76572
2020-12-22 19:54:29 -05:00
Arthur Eubanks 34e72a1461 Revert "DR2064: decltype(E) is only a dependent type if E is type-dependent, not"
This reverts commit 638867afd4.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See bug for repro.
2020-12-22 10:18:08 -08:00
Arthur Eubanks af0dbaaa38 Revert "Following up on PR48517, fix handling of template arguments that refer"
This reverts commit 8c1f2d15b8.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See bug for repro.
2020-12-22 10:18:08 -08:00
Arthur Eubanks 2080232333 Revert "[c++20] P1907R1: Support for generalized non-type template arguments of scalar type."
This reverts commit 9e08e51a20.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See bug for repro.
2020-12-22 10:18:08 -08:00
Arthur Eubanks ab7a60eb41 Revert "Fix MSVC "not all control paths return a value" warnings. NFCI."
This reverts commit 7e84aa1b81.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See bug for repro.
2020-12-22 10:18:07 -08:00
Arthur Eubanks 85d4a4bcc7 Revert "Fix memory leak complicated non-type template arguments."
This reverts commit ed13d8c667.

This is part of 5 commits being reverted due to https://crbug.com/1161059. See bug for repro.
2020-12-22 10:18:07 -08:00
Jan Svoboda bef9eb84b2 [clang] NFC: Refactor custom class into a lambda in CompilerInvocation
Change `makeFlagToValueNormalizer` so that one specialization converts all integral/enum arguments into `uint64_t` and forwards them to the more generic version.

This makes it easy to replace the custom `FlagToValueNormalizer` struct with a lambda, which is the common approach in other (de)normalizers.

Finally, drop custom `is_int_convertbile` in favor of `llvm::is_integral_or_enum`.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93628
2020-12-22 14:45:29 +01:00
Jan Svoboda 63a24816f5 [clang][cli] Implement `getAllArgValues` marshalling
This infrastructure can be used ~30 more command line options.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93631
2020-12-22 14:11:16 +01:00
mydeveloperday c4fc8a21d1 [clang-format] NFC keep the code clang-formatted 2020-12-22 12:46:14 +00:00
Stephen Kelly 3b879fc973 [ASTMatchers] Traverse-ignore range-for implementation details
Differential Revision: https://reviews.llvm.org/D93596
2020-12-22 12:09:32 +00:00
Nico Weber 00065d5cbd Revert "-fstack-clash-protection: Return an actual error when used on unsupported OS"
This reverts commit 4d59c8fdb9.
Breaks tens of thousands of tests, and had pending review comments, see
comments on https://reviews.llvm.org/D92245 (and e.g.
http://lab.llvm.org:8011/#/builders/109/builds/5236 for failures).
2020-12-22 06:51:19 -05:00
Sylvestre Ledru 4d59c8fdb9 -fstack-clash-protection: Return an actual error when used on unsupported OS
$ clang-12: error: -fstack-clash-protection is not supported on Windows or Mac OS X

Differential Revision: https://reviews.llvm.org/D92245
2020-12-22 12:06:08 +01:00
Tom Stellard dbb01536f6 scan-view: Remove Reporter.py and associated AppleScript files
I'm not exactly sure what this is, but it appears to be a tool for reporting
internal issues at Apple.  These files haven't been meaningfully updated in
12 years, and it doesn't seem like there is any reason to keep them in tree.

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D93565
2020-12-21 19:24:35 -08:00
Fangrui Song 6bbb04a732 [Driver] Default Generic_GCC ppc/ppc64/ppc64le to -fasynchronous-unwind-tables
GCC made the switch on 2018-04-10 ("rs6000: Enable -fasynchronous-unwind-tables by default").
In Clang, FreeBSD/NetBSD powerpc have already defaulted to -fasynchronous-unwind-tables.

This patch defaults Generic_GCC powerpc (which affects Linux) to use -fasynchronous-unwind-tables.

Reviewed By: #powerpc, nemanjai

Differential Revision: https://reviews.llvm.org/D92054
2020-12-21 15:32:35 -08:00
Scott Linder ffba47df76 Revert "[AMDGPU][HIP] Switch default DWARF version to 5"
This reverts commit c4d10e7e9b.

Differential Revision: https://reviews.llvm.org/D93648
2020-12-21 21:43:51 +00:00
Michael Liao bb8d20d9f3 [cuda][hip] Fix typoes in header wrappers. 2020-12-21 13:02:47 -05:00
David Spickett 9a93f95fce [clang] Fix expected errors in plugin attribute example
b2ba6867ea was landed
with updated error messages in the example file
but not in the test file.
2020-12-21 16:47:23 +00:00
Yafei Liu b2ba6867ea Refactoring the attribute plugin example to fit the new API
Make the example compile and the test case pass.
2020-12-21 08:24:09 -05:00
Jan Svoboda 5a85526728 [clang] Use enum for LangOptions::SYCLVersion instead of unsigned
`LangOptions::SYCLVersion` can only have two values. This patch introduces an enum that allows us to reduce the member size from 32 bits to 1 bit.

Consequently, this also makes marshalling of this option fit into our model for enums: D84674.

Reviewed By: bader

Differential Revision: https://reviews.llvm.org/D93540
2020-12-21 11:32:47 +01:00
Jan Svoboda 70410a2649 [clang][cli] Let denormalizer decide how to render the option based on the option class
Before this patch, you needed to use `AutoNormalizeEnumJoined` whenever you wanted to **de**normalize joined enum.
Besides the naming confusion, this means the fact the option is joined is specified in two places: in the normalization multiclass and in the `Joined<["-"], ...>` multiclass.
This patch makes this work automatically, taking into account the `OptionClass` of options.

Also, the enum denormalizer now just looks up the spelling of the present enum case in a table and forwards it to the string denormalizer.

I also added more tests that exercise this.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84189
2020-12-21 11:32:47 +01:00
Jan Svoboda 27b7d64688 [clang][cli] Streamline MarshallingInfoFlag description
This replaces the existing `MarshallingInfoFlag<...>, IsNegative` with simpler `MarshallingInfoNegativeFlag`.

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84675
2020-12-21 11:32:46 +01:00
Arthur Eubanks db1616c768 [test] Fix new-pass-manager-opt-bisect.c
Requires x86 target to be registered.
2020-12-20 17:13:42 -08:00
Samuel Eubanks 47dbee6790 Make NPM OptBisectInstrumentation use global singleton OptBisect
Currently there is an issue where the legacy pass manager uses a different OptBisect counter than the new pass manager.
This fix makes the npm OptBisectInstrumentation use the global OptBisect.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D92897
2020-12-20 13:47:56 -08:00
Simon Pilgrim 7e84aa1b81 Fix MSVC "not all control paths return a value" warnings. NFCI.
Add missing llvm_unreachable()'s after each all-enums switch statement.
2020-12-20 11:32:40 +00:00
Kristof Beyls 9c895aea11 [ARM] Add clang command line support for -mharden-sls=
The command line syntax is identical to the -mharden-sls= command line
syntax for AArch64 targets.

Differential Revision: https://reviews.llvm.org/D93221
2020-12-19 12:49:26 +00:00
Richard Smith f5cef870d1 [www] Remove '$Date$' marker from cxx_dr_status.
This doesn't actually work (any more?), and instead renders as a literal
$Date$ on the website.
2020-12-18 14:14:52 -08:00
Richard Smith ed13d8c667 Fix memory leak complicated non-type template arguments. 2020-12-18 13:42:24 -08:00
Richard Smith 72d8f79f0c [c++2b] Add tests for feature test macros. 2020-12-18 13:42:23 -08:00
Richard Smith 939ba0b501 Add tests for the absence of feature test macros for features we don't
support yet.
2020-12-18 13:42:23 -08:00
Richard Smith b4c63ef6dd [c++20] Mark class type NTTPs as done and start defining the feature test macro. 2020-12-18 13:42:23 -08:00
Roman Lebedev 897c985e1e
[InstCombine] Canonicalize SPF to abs intrinsic
This patch enables canonicalization of SPF_ABS and SPF_ABS
to the abs intrinsic.

This is a recommit, the original try was
05d4c4ebc2,
but it was reverted due to an apparent miscompile,
which since then has just been fixed by the previous commit.

Differential Revision: https://reviews.llvm.org/D87188
2020-12-18 21:18:14 +03:00
Björn Schäpers 5e5ef53597 [clang-format][NFC] Expand BreakBeforeBraces examples
Differential Revision: https://reviews.llvm.org/D93170
2020-12-18 19:08:03 +01:00
Kevin P. Neal 7fef551cb1 Revert "Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute.""
Similar to D69312, and documented in D69839, the IRBuilder needs to add
the strictfp attribute to invoke instructions when constrained floating
point is enabled.

This is try 2, with the test corrected.

Differential Revision: https://reviews.llvm.org/D93134
2020-12-18 12:42:06 -05:00
Aaron Ballman 2d2498ec6c No longer reject tag declarations in the clause-1 of a for loop.
We currently reject this valid C construct by claiming it declares a
non-local variable: for (struct { int i; } s={0}; s.i != 0; s.i--) ;

We expected all declaration in the clause-1 declaration statement to be
a local VarDecl, but there can be other declarations involved such as a
tag declaration. This fixes PR35757.
2020-12-18 07:56:17 -05:00
Andrzej Warzynski 7d246cb19d [flang][driver] Add support for `-fsyntax-only`
The behaviour triggered with this flag is consistent with `-fparse-only`
in `flang` (i.e. the throwaway driver). This new spelling is consistent
with Clang and gfortran, and was proposed and agreed on for the new
driver in [1].

This patch also adds some minimal logic to communicate whether the
semantic checks have failed or not. When semantic checks fail, a
frontend driver error is generated. The return code from the frontend
driver is then determined by checking the driver diagnostics - the
presence of driver errors means that the compilation has failed. This
logic is consistent with `clang -cc1`.

[1] http://lists.llvm.org/pipermail/flang-dev/2020-November/000588.html

Differential Revision: https://reviews.llvm.org/D92854
2020-12-18 09:35:02 +00:00
Jan Svoboda 95d3cc67ca [clang][cli] Port CodeGenOpts simple string flags to new option parsing system
Depends on D84668

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84669
2020-12-18 10:28:48 +01:00
Richard Smith 569676c057 Make Expr::HasSideEffect more precise for instantiation-dependent
expressions.

Fixes a regression in the clang-tidy test suite from making DeclRefExprs
referring to dependent declarations be instantiation-dependent.
2020-12-18 01:08:42 -08:00
Richard Smith 9e08e51a20 [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. 2020-12-18 01:08:41 -08:00
Jan Svoboda 333d41e9eb [clang][cli] Port FrontendOpts simple string based options to new option parsing system
Depends on D84189

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84190
2020-12-18 10:00:03 +01:00
Jan Svoboda d1b3f82e51 [clang][cli] Port PreprocessorOpts simple string based options to new option parsing system
Depends on D84671

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84672
2020-12-18 09:52:20 +01:00
Jan Svoboda aec2991d08 [clang][cli] Port LangOpts simple string based options to new option parsing system
Depends on D84670

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84671
2020-12-18 09:44:02 +01:00
Jan Svoboda ff4b76d74f [clang][cli] Port TargetOpts simple string based options to new option parsing system
Depends on D84190

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84668
2020-12-18 09:40:56 +01:00
Jan Svoboda f4511aec2b [clang][cli] Port HeaderSearch simple string options to new option parsing system
Depends on D84669

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84670
2020-12-18 09:30:32 +01:00
Jan Svoboda caeb56503e [clang][cli] Convert Analyzer option string based options to new option parsing system
Depends on D84185

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84186
2020-12-18 08:56:06 +01:00
Richard Smith 8c1f2d15b8 Following up on PR48517, fix handling of template arguments that refer
to dependent declarations.

Treat an id-expression that names a local variable in a templated
function as being instantiation-dependent.

This addresses a language defect whereby a reference to a dependent
declaration can be formed without any construct being value-dependent.
Fixing that through value-dependence turns out to be problematic, so
instead this patch takes the approach (proposed on the core reflector)
of allowing the use of pointers or references to (but not values of)
dependent declarations inside value-dependent expressions, and instead
treating template arguments as dependent if they evaluate to a constant
involving such dependent declarations.

This ends up affecting a bunch of OpenMP tests, due to OpenMP
imprecisely handling instantiation-dependent constructs, bailing out
early instead of processing dependent constructs to the extent possible
when handling the template.
2020-12-17 23:54:37 -08:00
Richard Smith 4b388859f5 Ensure that we transform types into the current instantiation even if
they're only instantiation-dependent.
2020-12-17 23:23:05 -08:00
Richard Smith 71886c56f3 Where possible, don't try to ask whether a template argument is
dependent until it's been converted to match its parameter.

The type of a non-type template parameter can in general affect whether
the template argument is dependent.

Note that this is not always possible. For template arguments that name
static local variables in templates, the type of the template parameter
affects whether the argument is dependent, so the query is imprecise
until we know the parameter type. For example, in:

template<typename T> void f() {
  static const int n = 5;
  typename T::template X<n> x;
}

... we don't know whether 'n' is dependent until we know whether the
corresponding template parameter is of type 'int' or 'const int&'.
2020-12-17 23:23:05 -08:00
Richard Smith 638867afd4 DR2064: decltype(E) is only a dependent type if E is type-dependent, not
if E is merely instantiation-dependent.
2020-12-17 23:23:05 -08:00
Richard Smith d3bf0bb189 PR24076, PR33655, C++ CWG 1558: Consider the instantiation-dependence of
the nested-name-specifier when determining whether a qualified type is
instantiation-dependent.
2020-12-17 21:31:23 -08:00
Rong Xu 3733463dbb [IR][PGO] Add hot func attribute and use hot/cold attribute in func section
Clang FE currently has hot/cold function attribute. But we only have
cold function attribute in LLVM IR.

This patch adds support of hot function attribute to LLVM IR.  This
attribute will be used in setting function section prefix/suffix.
Currently .hot and .unlikely suffix only are added in PGO (Sample PGO)
compilation (through isFunctionHotInCallGraph and
isFunctionColdInCallGraph).

This patch changes the behavior. The new behavior is:
(1) If the user annotates a function as hot or isFunctionHotInCallGraph
    is true, this function will be marked as hot. Otherwise,
(2) If the user annotates a function as cold or
    isFunctionColdInCallGraph is true, this function will be marked as
    cold.

The changes are:
(1) user annotated function attribute will used in setting function
    section prefix/suffix.
(2) hot attribute overwrites profile count based hotness.
(3) profile count based hotness overwrite user annotated cold attribute.

The intention for these changes is to provide the user a way to mark
certain function as hot in cases where training input is hard to cover
all the hot functions.

Differential Revision: https://reviews.llvm.org/D92493
2020-12-17 18:41:12 -08:00
Tom Stellard 3203143f13 CodeGen: Improve generated IR for __builtin_mul_overflow(uint, uint, int)
Add a special case for handling __builtin_mul_overflow with unsigned
inputs and a signed output to avoid emitting the __muloti4 library
call on x86_64.  __muloti4 is not implemented in libgcc, so avoiding
this call fixes compilation of some programs that call
__builtin_mul_overflow with these arguments.

For example, this fixes the build of cpio with clang, which includes code from
gnulib that calls __builtin_mul_overflow with these argument types.

Reviewed By: vsk

Differential Revision: https://reviews.llvm.org/D84405
2020-12-17 14:30:31 -08:00
Joachim Meyer c755e41c33 Fix -Wno-error= parsing in clang-format.
As noted in https://reviews.llvm.org/D86137#2460135 parsing of
the clang-format parameter -Wno-error=unknown fails.
This currently is done by having `-Wno-error=unknown` as an option.
In this patch this is changed to make `-Wno-error=` parse an enum into a bit set.
This way the parsing is fixed and also we can possibly add new options easily.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D93459
2020-12-17 22:23:42 +01:00
Nico Weber 49c248bd62 clang-cl: Remove /Zd flag
cl.exe doesn't understand Zd (in either MSVC 2017 or 2019), so neiter
should we. It used to do the same as `-gline-tables-only` which is
exposed as clang-cl flag as well, so if you want this behavior, use
`gline-tables-only`. That makes it clear that it's a clang-cl-only flag
that won't work with cl.exe.

Motivated by the discussion in D92958.

Differential Revision: https://reviews.llvm.org/D93458
2020-12-17 15:39:40 -05:00
Johannes Doerfert 994bb6eb7d [OpenMP][NFC] Provide a new remark and documentation
If a GPU function is externally reachable we give up trying to find the
(unique) kernel it is called from. This can hinder optimizations. Emit a
remark and explain mitigation strategies.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D93439
2020-12-17 14:38:26 -06:00
Nick Desaulniers e75fec2b23 [AttrDocs] document always_inline
GNU documentaion for always_inline:
https://gcc.gnu.org/onlinedocs/gcc/Inline.html

GNU documentation for function attributes:
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html

Microsoft documentation for __force_inline:
https://docs.microsoft.com/en-us/cpp/cpp/inline-functions-cpp

Reviewed By: ojeda

Differential Revision: https://reviews.llvm.org/D68410
2020-12-17 12:34:23 -08:00
Valentin Clement f4c8b80318 [openmp] Remove clause from OMPKinds.def and use OMP.td info
Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D92955
2020-12-17 14:08:12 -05:00
Baptiste Saleil c2892978e9 [PowerPC] Rename the vector pair intrinsics and builtins to replace the _mma_ prefix by _vsx_
On PPC, the vector pair instructions are independent from MMA.
This patch renames the vector pair LLVM intrinsics and Clang builtins to replace the _mma_ prefix by _vsx_ in their names.
We also move the vector pair type/intrinsic/builtin tests to their own files.

Differential Revision: https://reviews.llvm.org/D91974
2020-12-17 13:19:27 -05:00
Tomas Matheson f500662924 Detect section type conflicts between functions and variables
If two variables are declared with __attribute__((section(name))) and
the implicit section types (e.g. read only vs writeable) conflict, an
error is raised. Extend this mechanism so that an error is raised if the
section type implied by a function's __attribute__((section)) conflicts
with that of another variable.
2020-12-17 11:43:47 -05:00
Jon Chesterfield daf39e3f2d [amdgpu] Default to code object v3
[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye, yaxunl

Differential Revision: https://reviews.llvm.org/D93258
2020-12-17 16:09:33 +00:00
Zequan Wu fb0f728805 [Clang] Make nomerge attribute a function attribute as well as a statement attribute.
Differential Revision: https://reviews.llvm.org/D92800
2020-12-17 07:45:38 -08:00
Florian Hahn 01089c876b
[InstCombine] Preserve !annotation on newly created instructions.
If the source instruction has !annotation metadata, all instructions
created during combining should also have it. Tell the builder to
add it.

The !annotation system was discussed on llvm-dev as part of
'RFC: Combining Annotation Metadata and Remarks'
(http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html)

This patch is based on an earlier patch by Francis Visoiu Mistrih.

Reviewed By: thegameg, lebedev.ri

Differential Revision: https://reviews.llvm.org/D91444
2020-12-17 15:20:23 +00:00
serge-sans-paille 5e31e226b5 Remove Python2 fallback and only advertise Python3 in the doc
Differential Revision: https://www.youtube.com/watch?v=RsL0cipURA0
2020-12-17 15:40:16 +01:00
Lucas Prates c5046ebdf6 [ARM] Adding v8.7-A command-line support for the ARM target
This extends the command-line support for the 'armv8.7-a' architecture
name to the ARM target.

Based on a patch written by Momchil Velikov.

Reviewed By: ostannard

Differential Revision: https://reviews.llvm.org/D93231
2020-12-17 13:48:54 +00:00
Lucas Prates c4d851b079 [ARM][AAarch64] Initial command-line support for v8.7-A
This introduces command-line support for the 'armv8.7-a' architecture name
(and an alias without the '-', as usual), and for the 'ls64' extension name.

Based on patches written by Simon Tatham.

Reviewed By: ostannard

Differential Revision: https://reviews.llvm.org/D91776
2020-12-17 13:47:28 +00:00
dfukalov 9ed8e0caab [NFC] Reduce include files dependency and AA header cleanup (part 2).
Continuing work started in https://reviews.llvm.org/D92489:

Removed a bunch of includes from "AliasAnalysis.h" and "LoopPassManager.h".

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D92852
2020-12-17 14:04:48 +03:00
Barry Revzin 92310454bf Make LLVM build in C++20 mode
Part of the <=> changes in C++20 make certain patterns of writing equality
operators ambiguous with themselves (sorry!).
This patch goes through and adjusts all the comparison operators such that
they should work in both C++17 and C++20 modes. It also makes two other small
C++20-specific changes (adding a constructor to a type that cases to be an
aggregate, and adding casts from u8 literals which no longer have type
const char*).

There were four categories of errors that this review fixes.
Here are canonical examples of them, ordered from most to least common:

// 1) Missing const
namespace missing_const {
    struct A {
    #ifndef FIXED
        bool operator==(A const&);
    #else
        bool operator==(A const&) const;
    #endif
    };

    bool a = A{} == A{}; // error
}

// 2) Type mismatch on CRTP
namespace crtp_mismatch {
    template <typename Derived>
    struct Base {
    #ifndef FIXED
        bool operator==(Derived const&) const;
    #else
        // in one case changed to taking Base const&
        friend bool operator==(Derived const&, Derived const&);
    #endif
    };

    struct D : Base<D> { };

    bool b = D{} == D{}; // error
}

// 3) iterator/const_iterator with only mixed comparison
namespace iter_const_iter {
    template <bool Const>
    struct iterator {
        using const_iterator = iterator<true>;

        iterator();

        template <bool B, std::enable_if_t<(Const && !B), int> = 0>
        iterator(iterator<B> const&);

    #ifndef FIXED
        bool operator==(const_iterator const&) const;
    #else
        friend bool operator==(iterator const&, iterator const&);
    #endif
    };

    bool c = iterator<false>{} == iterator<false>{} // error
          || iterator<false>{} == iterator<true>{}
          || iterator<true>{} == iterator<false>{}
          || iterator<true>{} == iterator<true>{};
}

// 4) Same-type comparison but only have mixed-type operator
namespace ambiguous_choice {
    enum Color { Red };

    struct C {
        C();
        C(Color);
        operator Color() const;
        bool operator==(Color) const;
        friend bool operator==(C, C);
    };

    bool c = C{} == C{}; // error
    bool d = C{} == Red;
}

Differential revision: https://reviews.llvm.org/D78938
2020-12-17 10:44:10 +00:00
mydeveloperday db41c0b357 [clang-format] PR35514 brace-init member initializers in function-try-blocks are not formatted correctly
https://bugs.llvm.org/show_bug.cgi?id=35514

Initializer lists with a try-block are incorrectly formatted.

e.g.

```
Foo(int abc, int def) try : _abc(abc), _def{def}, _ghi{1} {
  callA();
  callB();
} catch (std::exception&) {
}
```

is formatted as:

```
Foo(int abc, int def) try : _abc(abc), _def { def }
, _ghi{1} {
  callA();
  callB();
}
catch (std::exception&) {
}
```

This revision adds support in the parseTryCatch for braced initializers in the initializer list

Reviewed By: curdeius, HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D93296
2020-12-17 09:39:37 +00:00
Andrzej Warzynski 7f19712a6a [clang][nfc] Update comment to match the opening `{` 2020-12-17 09:04:41 +00:00
Fangrui Song c70f36865e Use basic_string::find(char) instead of basic_string::find(const char *s, size_type pos=0)
Many (StringRef) cannot be detected by clang-tidy performance-faster-string-find.
2020-12-16 23:28:32 -08:00
Johannes Doerfert 2e6e4e6aee [OpenMP] Add initial support for `omp [begin/end] assumes`
The `assumes` directive is an OpenMP 5.1 feature that allows the user to
provide assumptions to the optimizer. Assumptions can refer to
directives (`absent` and `contains` clauses), expressions (`holds`
clause), or generic properties (`no_openmp_routines`, `ext_ABCD`, ...).

The `assumes` spelling is used for assumptions in the global scope while
`assume` is used for executable contexts with an associated structured
block.

This patch only implements the global spellings. While clauses with
arguments are "accepted" by the parser, they will simply be ignored for
now. The implementation lowers the assumptions directly to the
`AssumptionAttr`.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D91980
2020-12-16 20:02:49 -06:00
Tom Roeder 1844ab770c [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.
This allows ASTs to be merged when they contain GenericSelectionExpr
nodes (this is _Generic from C11). This is needed, for example, for
CTU analysis of C code that makes use of _Generic, like the Linux
kernel.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter. Additionally, this change adds support for structural
equivalence of _Generic in the AST.

Reviewed By: martong, aaron.ballman

Differential Revision: https://reviews.llvm.org/D92600
2020-12-16 15:39:50 -08:00
Tom Roeder f31e9bcd73 Test commit: add valid punctuation to a comment. NFC. 2020-12-16 15:33:19 -08:00
Thomas Preud'homme 150fe05db4 [Test] Fix undef var in catch-undef-behavior.c
Commit 9e52c43090 removed the directive
defining LINE_1600 but left a string substitution to that variable in a
CHECK-NOT directive. This will make that CHECK-NOT directive always fail
to match, no matter the string.

This commit follows the pattern done in
9e52c43090 of simplifying the CHECK-NOT to
only look for the function name and the opening parenthesis, thereby not
requiring the LINE_1600 variable.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D93350
2020-12-16 22:39:41 +00:00
Reid Kleckner b7905e81fc Fix split-debug.c test on Windows 2020-12-16 13:48:57 -08:00
Shivanshu Goyal e53b9f733a Print source location in the error message when parens are missing around sizeof typename and the expression is inside macro expansion
Given the following code:

```
void Foo(int);

void Baz()
{
	Bar(sizeof int);
}
```

The error message which is printed today is this:
```
error: expected parentheses around type name in sizeof expression
```

There is no source location printed whatsoever, so fixing a compile break like this becomes extremely hard in a large codebase.

My change improves the error message. But it doesn't output a FixItHint because I wasn't able to figure out how to get the locations for left and right parens. So any tips would be appreciated.

```
<source>:7:6: error: expected parentheses around type name in sizeof expression
        Bar(sizeof int);
            ^
```

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D91129
2020-12-16 12:03:31 -08:00
Richard Smith 735ab86b81 PR47474: Add test for Clang's current behavior.
Our current behavior rejects the example, following the current language
rules, but it's likely the rules will be revised to allow this example.
2020-12-16 12:01:00 -08:00
Yaxun (Sam) Liu b9fb063e63 [clang-offload-bundler] Add option -allow-missing-bundles
There are out-of-tree tools using clang-offload-bundler to extract
bundles from bundled files. When a bundle is not in the bundled
file, clang-offload-bundler is expected to emit an error message
and return non-zero value. However currently clang-offload-bundler
silently generates empty file for the missing bundles.

Since OpenMP/HIP toolchains expect the current behavior, an option
-allow-missing-bundles is added to let clang-offload-bundler
create empty file when a bundle is missing when unbundling.
The unbundling job action is updated to use this option by
default.

clang-offload-bundler itself will emit error when a bundle
is missing when unbundling by default.

Changes are also made to check duplicate targets in -targets
option and emit error.

Differential Revision: https://reviews.llvm.org/D93068
2020-12-16 14:52:39 -05:00
Emma Blink 7685d818ef Mark implicit coroutine variables as being implicit
This prevents the clang-tidy readability-identifier-naming check from
triggering on implicit __coro_gro and __promise variables in coroutines.
2020-12-16 14:42:07 -05:00
Bardia Mahjour 6eff12788e [DDG] Data Dependence Graph - DOT printer - recommit
This is being recommitted to try and address the MSVC complaint.

This patch implements a DDG printer pass that generates a graph in
the DOT description language, providing a more visually appealing
representation of the DDG. Similar to the CFG DOT printer, this
functionality is provided under an option called -dot-ddg and can
be generated in a less verbose mode under -dot-ddg-only option.

Reviewed By: Meinersbur

Differential Revision: https://reviews.llvm.org/D90159
2020-12-16 12:37:36 -05:00
Jon Chesterfield c0619d3b21 [NFC] Use regex for code object version in hip tests
[NFC] Use regex for code object version in hip tests

Extracted from D93258. Makes tests robust to changes in default
code object version.

Reviewed By: t-tye

Differential Revision: https://reviews.llvm.org/D93398
2020-12-16 17:00:19 +00:00
Erik Pilkington 92d6e8001e NFC: balance a quote in AttrDocs.td
This was confusing my editor.
2020-12-16 10:01:24 -05:00
Erik Pilkington 95b2dab199 [Sema] Fix a miscompile by retaining array qualifiers when folding VLAs to constant arrays
rdar://72243125

Differential revision: https://reviews.llvm.org/D93247
2020-12-16 10:01:24 -05:00
Joe Ellis dad07baf12 [clang][AArch64][SVE] Avoid going through memory for VLAT <-> VLST casts
This change makes use of the llvm.vector.extract intrinsic to avoid
going through memory when performing bitcasts between vector-length
agnostic types and vector-length specific types.

Depends on D91362

Reviewed By: c-rhodes

Differential Revision: https://reviews.llvm.org/D92761
2020-12-16 12:24:32 +00:00
Jan Svoboda 0da240c2d0 [clang][cli] Port DependencyOutput string based options to new option parsing system
Depends on D84186

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D84187
2020-12-16 10:28:37 +01:00
Qiu Chaofan f141d1afc5 [NFC] Pre-commit test for long-double builtins
This test reflects clang behavior on long-double type math library
builtins under default or explicit 128-bit long-double options.
2020-12-16 17:19:54 +08:00
Jan Svoboda 383778e217 [clang][cli] Port LangOpts option flags to new option parsing system
Depends on D83892 & D83694 & D93104.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D83979
2020-12-16 10:16:27 +01:00
Jan Svoboda 741978d727 [clang][cli] Port CodeGen option flags to new option parsing system
Depends on D83697.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D83892
2020-12-16 10:00:33 +01:00
Jan Svoboda f2661bed18 [clang][cli] Prevent double denormalization
If both flags created through BoolOption are CC1Option and the keypath has a non-default or non-implied value, the denormalizer gets called twice. If the denormalizer has the ability to generate both flags, we can end up generating the same flag twice.

Reviewed By: dexonsmith, Bigcheese

Differential Revision: https://reviews.llvm.org/D93094
2020-12-16 09:44:54 +01:00
Jan Svoboda 95114f21f5 [clang][cli] Do not marshall only CC1Option flags in BoolOption
We cannot be sure whether a flag is CC1Option inside the definition of `BoolOption`. Take the example below:

```
let Flags = [CC1Option] in {
  defm xxx : BoolOption<...>;
}
```

where TableGen applies `Flags = [CC1Option]` to the `xxx` and `no_xxx` records **after** they have been is fully declared by `BoolOption`.

For the refactored `-f[no-]debug-pass-manager` flags (see the diff), this means `BoolOption` never adds any marshalling info, as it doesn't see either of the flags as `CC1Option`.

For that reason, we should defensively append the marshalling information to both flags inside `BoolOption`. Now the check for `CC1Option` needs to happen later, in the parsing macro, when all TableGen logic has been resolved.

However, for some flags defined through `BoolOption`, we can run into issues:

```
// Options.td
def fenable_xxx : /* ... */;

// Both flags are CC1Option, the first is implied.
defm xxx : BoolOption<"xxx,
  "Opts.Xxx", DefaultsToFalse,
  ChangedBy<PosFlag, [CC1Option], "", [fenable_xxx]>,
  ResetBy<NegFlag, [CC1Option]>>;
```

When parsing `clang -cc1 -fenable-xxx`:
* we run parsing for `PosFlag`:
  * set `Opts.Xxx` to default `false`,
  * discover `PosFlag` is implied by `-fenable-xxx`: set `Opts.Xxx` to `true`,
  * don't see `-fxxx` on command line: do nothing,
* we run parsing for `NegFlag`:
  * set `Opts.Xxx` to default `false`,
  * discover `NegFlag` cannot be implied: do nothing,
  * don't see `-fno-xxx` on command line: do nothing.

Now we ended up with `Opts.Xxx` set to `false` instead of `true`. For this reason, we need to ensure to append the same `ImpliedByAnyOf` instance to both flags.

This means both parsing runs now behave identically (they set the same default value, run the same "implied by" check, and call `makeBooleanOptionNormalizer` that already has information on both flags, so it returns the same value in both calls).

The solution works well, but what might be confusing is this: you have defined a flag **A** that is not `CC1Option`, but can be implied by another flag **B** that is `CC1Option`:
* if **A** is defined manually, it will never get implied, as the code never runs
```
def no_signed_zeros : Flag<["-"], "fno-signed-zeros">, Group<f_Group>, Flags<[]>,
  MarshallingInfoFlag<"LangOpts->NoSignedZero">, ImpliedByAnyOf<[menable_unsafe_fp_math]>;
```
* if **A** is defined by `BoolOption`, it could get implied, as the code is run by its `CC1Option` counterpart:
```
defm signed_zeros : BoolOption<"signed-zeros",
  "LangOpts->NoSignedZero", DefaultsToFalse,
  ChangedBy<NegFlag, [], "Allow optimizations that ignore the sign of floating point zeros",
            [cl_no_signed_zeros, menable_unsafe_fp_math]>,
  ResetBy<PosFlag, [CC1Option]>, "f">, Group<f_Group>;
```

This is a surprising inconsistency.

One solution might be to somehow propagate the final `Flags` of the implied flag in `ImpliedByAnyOf` and check whether it has `CC1Option` in the parsing macro. However, I think it doesn't make sense to spend time thinking about a corner case that won't come up in real code.

An observation: it is unfortunate that the marshalling information is a part of the flag definition. If we represented it in a separate structure, we could avoid the "double parsing" problem by having a single source of truth. This would require a lot of additional work though.

Note: the original patch missed the `CC1Option` check in the parsing macro, making my reasoning here incomplete. Moreover, it contained a change to denormalization that wasn't necessarily related to these changes, so I've extracted that to a follow-up patch: D93094.

Reviewed By: dexonsmith, Bigcheese

Differential Revision: https://reviews.llvm.org/D93008
2020-12-16 09:29:40 +01:00
Yaxun (Sam) Liu 4f14b80803 [HIP] unbundle bundled preprocessor output
There is a use case that users want to emit preprocessor
output as file and compile the preprocessor output later
with -x hip-cpp-output.

Clang emits bundled preprocessor output when users
compile with -E for combined host/device compilations.
Clang should be able to compile the bundled preprocessor
output with -x hip-cpp-output. Basically clang should
unbundle the bundled preprocessor output and launch
device and host compilation actions.

Currently there is a bug in clang driver causing bundled
preprocessor output not unbundled.

This patch fixes that.

Differential Revision: https://reviews.llvm.org/D92720
2020-12-15 22:14:18 -05:00
Nathan James c415e709e9
[ASTMatchers][NFC] Strip prefixes eagerly in dynamic matcher arg traits. 2020-12-16 01:56:30 +00:00
Johannes Doerfert 1efd7a73ac Revert "[OpenMP] Add initial support for `omp [begin/end] assumes`"
There is a build error with gcc-5 [0], investigating now.

[0] https://reviews.llvm.org/D91980#2456526

This reverts commit a5a14cbe7f.
2020-12-15 18:03:10 -06:00
Stephen Kelly 702f822ca5 [ASTMatcher] Avoid isImplicit call on object which could be nullptr
A callExpr whose argument is dependent has a null getCalleeDecl().

Differential Revision: https://reviews.llvm.org/D93324
2020-12-15 23:27:38 +00:00
Johannes Doerfert bc7126b2bc [FIX] Add the comma missing in D91979 2020-12-15 17:24:53 -06:00
Richard Smith 7e7f38f853 DR1413 and part of P1815R2: Minor improvements to Clang's determination
of type- and value-dependency.

A static data member initialized to a constant inside a class template
is no longer considered value-dependent, per DR1413. A const but not
constexpr variable of literal type (other than integer or enumeration)
is no longer considered value-dependent, per P1815R2.
2020-12-15 14:53:26 -08:00
Richard Smith 6b760a50f5 DR2100: &expr is value-dependent if expr constant-evaluates to a
dependent declaration.
2020-12-15 14:53:26 -08:00
Johannes Doerfert a5a14cbe7f [OpenMP] Add initial support for `omp [begin/end] assumes`
The `assumes` directive is an OpenMP 5.1 feature that allows the user to
provide assumptions to the optimizer. Assumptions can refer to
directives (`absent` and `contains` clauses), expressions (`holds`
clause), or generic properties (`no_openmp_routines`, `ext_ABCD`, ...).

The `assumes` spelling is used for assumptions in the global scope while
`assume` is used for executable contexts with an associated structured
block.

This patch only implements the global spellings. While clauses with
arguments are "accepted" by the parser, they will simply be ignored for
now. The implementation lowers the assumptions directly to the
`AssumptionAttr`.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D91980
2020-12-15 16:51:34 -06:00
Johannes Doerfert b9c77542e2 [Clang][Attr] Introduce the `assume` function attribute
The `assume` attribute is a way to provide additional, arbitrary
information to the optimizer. For now, assumptions are restricted to
strings which will be accumulated for a function and emitted as comma
separated string function attribute. The key of the LLVM-IR function
attribute is `llvm.assume`. Similar to `llvm.assume` and
`__builtin_assume`, the `assume` attribute provides a user defined
assumption to the compiler.

A follow up patch will introduce an LLVM-core API to query the
assumptions attached to a function. We also expect to add more options,
e.g., expression arguments, to the `assume` attribute later on.

The `omp [begin] asssumes` pragma will leverage this attribute and
expose the functionality in the absence of OpenMP.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D91979
2020-12-15 16:51:34 -06:00
Richard Smith c4736b91f8 Don't memcpy from an empty ArrayRef; the base pointer could be null, and
the C rules say memcpy can't accept a null pointer.

This should fix a test failure with the ubsan buildbots.
2020-12-15 14:37:52 -08:00
Duncan P. N. Exon Smith 0eb4378290 Frontend: Fix confusing comment at call to clearOutputFiles, NFC
Fix the comment in front of `compileModuleImpl`'s call to
`CompilerInstance::clearOutputFiles`. The purpose of this call is to
delete any stray temporary files after the module generation thread
crashes.

The comment is from f545f67de3, and
was associated with manually deleting a generated module map. Then
13afbf42d8 added this `clearOutputFiles`
call between the comment and the code it referenced. Finally,
1f76c4e810 started sending the generated
module map directly to the SourceManager instead of putting it on disk,
deleting the call that the comment referenced.

No functionality change.
2020-12-15 14:21:37 -08:00
Fangrui Song 59decf8e9c [clang] Migrate deprecated DebugInfo::get to DILocation::get 2020-12-15 13:59:31 -08:00
Baptiste Saleil 57d83c3a90 [PowerPC] Enable paired vector type and intrinsics when MMA is disabled
This patch enables the Clang type __vector_pair and its associated LLVM
intrinsics even when MMA is disabled. With this patch, the type is now controlled
by the PPC paired-vector-memops option. The builtins and intrinsics will be
renamed to drop the mma prefix in another patch.

Differential Revision: https://reviews.llvm.org/D91819
2020-12-15 15:14:11 -06:00
Craig Topper c103f9ef5a [RISCV] Use default member initializers for the feature flags in RISCVTargetInfo. NFC
This avoids having to repeat all the flags in the constructor's
initializer list in the same order. This style is already used by
several other targets.
2020-12-15 12:37:47 -08:00
Richard Smith 76edf98b27 Set decl on DeclRefExpr directly during deserialization rather than
relying on a setter that might have additional side-effects. NFC.
2020-12-15 12:00:57 -08:00
Richard Smith 6c365cd31e Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types.
For the Itanium ABI, this implements the mangling rule suggested in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47, namely mangling
such template arguments as being cast to the parameter type in the case
where the template name is overloadable. This can cause a mangling
change for rare cases, where

 * the template argument declaration is converted from its declared type
   to the type of the template parameter, and
 * the template parameter either has a deduced type or is a parameter of
   a function template.

However, such changes are necessary to avoid mangling collisions. The
ABI changes can be reversed with -fclang-abi-compat=11 or earlier.

Re-commit with a fix for a couple of regressions.

Differential Revision: https://reviews.llvm.org/D91488
2020-12-15 12:00:57 -08:00
Aaron Ballman ef40d5233b Adding a test case that I accidentally dropped from 27ea7d0a6e 2020-12-15 14:56:44 -05:00
cchen 82f2c61ca0 [OPENMP51] Add present modifier in defaultmap clause
Support present modifier in defaultmap by adding an extra dimension
for `ImplicitMap`. Therefore, we now create OMPMapClause in `ActOnOpenMPExecutableDirective`
based on both `maptype` and `maptype-modifier`.

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D92427
2020-12-15 13:50:12 -06:00
Kevin P. Neal 2ec5973fdd Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute."
The test is busted on some hosts that aren't the one I'm using.

This reverts commit 67a1ffd88a.
2020-12-15 12:58:47 -05:00
Kevin P. Neal 67a1ffd88a [FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute.
Similar to D69312, and documented in D69839, the IRBuilder needs to add
the strictfp attribute to invoke instructions when constrained floating
point is enabled.

Differential Revision: https://reviews.llvm.org/D93134
2020-12-15 12:38:10 -05:00
Joe Ellis 5a2a8369e8 [AArch64][NEON] Remove undocumented vceqz{,q}_p16, vml{a,s}q_n_f64 intrinsics
Prior to this patch, Clang supported the following C/C++ intrinsics:

    vceqz_p16
    vceqzq_p16
    vmlaq_n_f64
    vmlsq_n_f64

... exposed through arm_neon.h. However, these intrinsics are not part
of the ACLE, allowing developers to write code that is not compatible
with other toolchains.

This patch removes these intrinsics.

There is a bug report capturing this issue here:

    https://bugs.llvm.org/show_bug.cgi?id=47471

Reviewed By: bsmith

Differential Revision: https://reviews.llvm.org/D93206
2020-12-15 17:19:16 +00:00
Nathan James 8acb5f2723
[clang][driver][NFC] Use StringRef instead of std::string 2020-12-15 16:19:12 +00:00
Mircea Trofin e2dc306b1a [utils] Fix UpdateTestChecks case where 2 runs differ for last label
Two RUN lines produce outputs that, each, have some common parts and
some different parts. The common parts are checked under label A. The
differing parts are associated to a function and checked under labels B
and C, respectivelly.
When build_function_body_dictionary is called for the first RUN line, it
will attribute the function body to labels A and C. When the second RUN
is passed to build_function_body_dictionary, it sees that the function
body under A is different from what it has. If in this second RUN line,
A were at the end of the prefixes list, A's body is still kept
associated with the first run's function.

When we output the function body (i.e. add_checks), we stop after
emitting for the first prefix matching that function. So we end up with
the wrong function body (first RUN's A-association).

There is no reason to special-case the last label in the prefixes list,
and the fix is to always clear a label association if we find a RUN line
where the body is different.

Differential Revision: https://reviews.llvm.org/D93078
2020-12-15 07:16:54 -08:00
Chuanqi Xu 8b48d24373 [clang-format] Recognize c++ coroutine keywords as unary operator to avoid misleading pointer alignment
Summary: The clang-format may go wrong when handle c++ coroutine keywords and pointer.
The default value for PointerAlignment is PAS_Right. So the following format is good:
```
co_return *a;
```
But within some code style, the value for PointerAlignment is PAS_Left, the behavior goes wrong:
```
co_return* a;
```

test-plan: check-clang

reviewers: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D91245
2020-12-15 20:50:46 +08:00
Jan Svoboda 56c5548d7f [clang][cli] Squash multiple cc1 -fxxx-exceptions flags into single -exception-model=xxx option
This patch enables marshalling of the exception model options while enforcing their mutual exclusivity. The clang driver interface remains the same, this only affects the cc1 command line.

Depends on D93215.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93216
2020-12-15 10:15:58 +01:00
Jan Svoboda 573255b47e [clang][cli] Squash exception model in LangOptions into one member
This squashes multiple members in LangOptions into one. This is leveraged in a follow-up patch that implements marshalling of related command-line options.

Depends on D93214.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93215
2020-12-15 10:15:58 +01:00
Jan Svoboda f24e58df7d [clang][cli] Create accessors for exception models in LangOptions
This abstracts away the members that are being replaced in a follow-up patch.

Depends on D83979.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D93214
2020-12-15 10:15:58 +01:00
Nico Weber 7799ef7121 Revert "Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef"
This reverts commit a40db5502b.
and follow-up d636b881bb

Somewhat speculative, likely broke check-clang on Windows:
https://reviews.llvm.org/D92975#2453482
2020-12-14 22:05:08 -05:00
Nico Weber c9ede6f336 Revert "[amdgpu] Default to code object v3"
This reverts commit 4b2e7d0215.
Breaks check-clang, see https://reviews.llvm.org/D93258#2453600
2020-12-14 22:01:26 -05:00
Rong Xu c36f31c4db [PGO] remove unintentional code in early commit
Remove unintentional code in
commit 54e03d [PGO] Verify BFI counts after loading profile data.
2020-12-14 18:41:49 -08:00
Alexander Kornienko 9c49b0bba0 Remove the ast_type_traits namespace.
This is the final cleanup after https://reviews.llvm.org/D74499

Reviewed By: steveire

Differential Revision: https://reviews.llvm.org/D93244
2020-12-15 02:16:12 +01:00
Jon Chesterfield 4b2e7d0215 [amdgpu] Default to code object v3
[amdgpu] Default to code object v3
v4 is not yet readily available, and doesn't appear
to be implemented in the back end

Reviewed By: t-tye

Differential Revision: https://reviews.llvm.org/D93258
2020-12-15 01:11:09 +00:00
Reid Kleckner d2ed9d6b7e Revert "ADT: Migrate users of AlignedCharArrayUnion to std::aligned_union_t, NFC"
We determined that the MSVC implementation of std::aligned* isn't suited
to our needs. It doesn't support 16 byte alignment or higher, and it
doesn't really guarantee 8 byte alignment. See
https://github.com/microsoft/STL/issues/1533

Also reverts "ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC"

Also reverts "ADT: Remove AlignedCharArrayUnion, NFC" to bring back
AlignedCharArrayUnion.

This reverts commit 4d8bf870a8.

This reverts commit d10f9863a5.

This reverts commit 4b5dc150b9.
2020-12-14 17:04:06 -08:00
Rong Xu 54e03d03a7 [PGO] Verify BFI counts after loading profile data
This patch adds the functionality to compare BFI counts with real
profile
counts right after reading the profile. It will print remarks under
-Rpass-analysis=pgo, or the internal option -pass-remarks-analysis=pgo.

Differential Revision: https://reviews.llvm.org/D91813
2020-12-14 15:56:10 -08:00
Gulfem Savrun Yeniceri 7c0e3a77bc [clang][IR] Add support for leaf attribute
This patch adds support for leaf attribute as an optimization hint
in Clang/LLVM.

Differential Revision: https://reviews.llvm.org/D90275
2020-12-14 14:48:17 -08:00
Duncan P. N. Exon Smith b61f288a58 Add comment to closing brace of anonymous namespace, NFC 2020-12-14 14:38:12 -08:00
Duncan P. N. Exon Smith 90d056ceb9 AST: Silence an instance of -Wsign-compare, NFC
Looks this this was added by 68f53960e1.
2020-12-14 14:36:59 -08:00
Duncan P. N. Exon Smith a40db5502b Lex: Migrate HeaderSearch::LoadedModuleMaps to FileEntryRef
Migrate `HeaderSearch::LoadedModuleMaps` and a number of APIs over to
`FileEntryRef`. This should have no functionality change. Note that two
`FileEntryRef`s hash the same if they point at the same `FileEntry`.

Differential Revision: https://reviews.llvm.org/D92975
2020-12-14 14:35:11 -08:00
Bardia Mahjour a29ecca781 Revert "[DDG] Data Dependence Graph - DOT printer"
This reverts commit fd4a10732c, to
investigate the failure on windows: http://lab.llvm.org:8011/#/builders/127/builds/3274
2020-12-14 16:54:20 -05:00
Philip Reames 3b3eb7f07f Speculative fix for build bot failures
(The clang build fails for me locally, so this is based on built bot output and a guess as to root cause.)

f5fe849 made the execution of LAA conditional, so I'm guessing that's the root cause.
2020-12-14 13:44:40 -08:00
Bardia Mahjour fd4a10732c [DDG] Data Dependence Graph - DOT printer
This patch implements a DDG printer pass that generates a graph in
the DOT description language, providing a more visually appealing
representation of the DDG. Similar to the CFG DOT printer, this
functionality is provided under an option called -dot-ddg and can
be generated in a less verbose mode under -dot-ddg-only option.

Differential Revision: https://reviews.llvm.org/D90159
2020-12-14 16:41:14 -05:00
Matt Arsenault ef4da3c2ba clang: Add byval on x86_intrcc parameter 0
This will allow removing the special case treatment of the parameter
and avoid depending on the pointer's element type.
2020-12-14 16:34:37 -05:00
Hafiz Abid Qadeer 670686ad8e Add initial support for multilibs in Baremetal toolchain.
This patch add support of riscv multilibs in the Baremetal toolchain. It is
a bit different to what is done in GNU.cpp as we are not iterating a
GNU sysroot to find the multilibs. This is intended for an llvm only
toolchain. We are not checking for the presence of any runtime bits to
enable a specific multilib.

I have structured the patch so that other targets for which
there is no multilibs support yet in Baremetal.cpp (e.g. arm-none-eabi)
will not be affected. Patch also allows some multilibs reuse.

Long term, I would like to go in the direction of data-driven specification of
multilib directories and flags.

Reviewed By: jroelofs

Differential Revision: https://reviews.llvm.org/D93138
2020-12-14 20:49:45 +00:00
Artem Belevich 0936655bac [CUDA] Do not diagnose host/device variable access in dependent types.
`isCUDADeviceBuiltinSurfaceType()`/`isCUDADeviceBuiltinTextureType()` do not
work on dependent types as they rely on specific type attributes.

Differential Revision: https://reviews.llvm.org/D92893
2020-12-14 11:53:18 -08:00
Sylvain Audi 5f53d28fa6 Revert "[clang-scan-deps] Support clang-cl"
Reverting, as it breaks build on mac.

This reverts commit 640ad76911.
2020-12-14 13:32:38 -05:00
Gabor Marton 68f53960e1 [ASTImporter] Fix import of a typedef that has an attribute
The import of a typedefs with an attribute uses clang::Decl::setAttrs().
But that needs the ASTContext which we can get only from the
TranslationUnitDecl. But we can get the TUDecl only thourgh the
DeclContext, which is not set by the time of the setAttrs call.

Fix: import the attributes only after the DC is surely imported.
Btw, having the attribute import initiated from GetImportedOrCreateDecl was
fundamentally flawed. Now that is implicitly fixed.

Differential Revision: https://reviews.llvm.org/D92962
2020-12-14 18:27:05 +01:00
Sylvain Audi 640ad76911 [clang-scan-deps] Support clang-cl
clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

Differential Revision: https://reviews.llvm.org/D92191
2020-12-14 12:06:05 -05:00
Raphael Isemann 22ccdb7870 Revert "Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types."
This reverts commit 05cdf4acf4. It breaks stage-2
compilation of LLVM, see https://reviews.llvm.org/D91488#2451534
2020-12-14 14:03:38 +01:00
Jan Svoboda 16aa00b622 [clang][cli] Port FileSystem options to new option parsing system
Depends on D84187

Reviewed By: dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84188
2020-12-14 10:17:23 +01:00
Jan Svoboda e2fc85c69b [clang][cli] Better defaults for MarshallingInfoString
Depends on D84018

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D84185
2020-12-14 09:59:56 +01:00
Jan Svoboda 4b6f29413c [clang][cli] Port Preprocessor and PreprocessorOutput option flags to new option parsing system
Depends on D83979

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D84018
2020-12-14 09:19:57 +01:00
Haojian Wu 6326b09885 [AST][RecoveryExpr] Preserve type for broken overrload member call expr.
Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D80109
2020-12-14 08:50:41 +01:00
Richard Smith 05cdf4acf4 Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types.
For the Itanium ABI, this implements the mangling rule suggested in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47, namely mangling
such template arguments as being cast to the parameter type in the case
where the template name is overloadable. This can cause a mangling
change for rare cases, where

 * the template argument declaration is converted from its declared type
   to the type of the template parameter, and
 * the template parameter either has a deduced type or is a parameter of
   a function template.

However, such changes are necessary to avoid mangling collisions. The
ABI changes can be reversed with -fclang-abi-compat=11 or earlier.

Re-commit with a fix for the regression introduced last time: don't
expect parameters and arguments to line up inside an <unresolved-name>
mangling.

Differential Revision: https://reviews.llvm.org/D91488
2020-12-13 22:43:24 -08:00
Richard Smith abbd57e558 Factor out and centralize repeated 'getExpandedPackSize'. 2020-12-13 22:43:23 -08:00
Tony 5ad202ce89 [NFC][AMDGPU] Reformat AMD GPU targets in cuda.cpp
Differential Revision: https://reviews.llvm.org/D93181
2020-12-13 23:02:59 +00:00
Simon Pilgrim 4855a1004d [X86] Convert fadd/fmul _mm_reduce_* intrinsics to emit llvm.reduction intrinsics (PR47506)
Followup to D87604, having confirmed on PR47506 that we can use the llvm codegen expansion for fadd/fmul as well.

Differential Revision: https://reviews.llvm.org/D92940
2020-12-13 15:37:35 +00:00
Björn Schäpers 36306403d4 [clang-format] Remove double trim
Lines[i] is already trimmed 3 lines before

Differential Revision: https://reviews.llvm.org/D91996
2020-12-13 14:16:54 +01:00
Kazushi (Jam) Marukawa 05d1729232 [VE] Optimize toolchain regression test
Optimize toolchain regression test for VE by removing not a useful test
(-fuse-init-array test) and merge several tests to one test which checks
default behavior of driver.  Also add sysroot to reduce conflicts.

These are suggested in https://reviews.llvm.org/D92996.
Thank you so much.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93084
2020-12-13 20:26:05 +09:00
Alexey Bader a500a43587 [CodeGen][AMDGPU] Fix ICE for static initializer IR generation
Differential Revision: https://reviews.llvm.org/D92782
2020-12-12 23:26:54 +03:00
Nico Weber 956034c6c8 [mac/arm] XFAIL two more tests on arm64-apple
Part of PR46644
2020-12-12 15:20:50 -05:00
Nico Weber a5c65de295 mac/arm: XFAIL the last 3 failing tests
We should fix them, but let's XFAIL them for now so that we can start
running check-clang on bots and lock in the passing tests.

Part of 46644.
2020-12-12 15:09:17 -05:00
Tony 7beee561e2 [AMDGPU] Add missing targets to target-invalid-cpu-note.c
Differential Revision: https://reviews.llvm.org/D93018
2020-12-12 18:19:03 +00:00
Tony 92ab6ed667 [AMDGPU] Add missing targets to amdgpu-features.cl
Differential Revision: https://reviews.llvm.org/D93017
2020-12-12 18:19:02 +00:00
Melanie Blower 320af6b138 Create SPIRABIInfo to enable SPIR_FUNC calling convention.
Background: Call to library arithmetic functions for div is emitted by the
compiler and it set wrong “C” calling convention for calls to these functions,
whereas library functions are declared with `spir_function` calling convention.
InstCombine optimization replaces such calls with “unreachable” instruction.
It looks like clang lacks SPIRABIInfo class which should specify default
calling conventions for “system” function calls. SPIR supports only
SPIR_FUNC and SPIR_KERNEL calling convention.

Reviewers: Erich Keane, Anastasia

Differential Revision: https://reviews.llvm.org/D92721
2020-12-12 05:48:20 -08:00
Jan Svoboda adf3c27742 [clang][cli] Revert accidental access-control flag rename
This commit <https://reviews.llvm.org/rGe5158b52730d323bb8cd2cba6dc6c89b90cba452> introduced an accidental change, which renames `-faccess-control` and `-fno-access-control` to `-fno-access-control` and `-fno-no-access-control`.

Reviewed By: dexonsmith, MaskRay

Differential Revision: https://reviews.llvm.org/D93104
2020-12-12 11:26:53 +01:00
Jan Svoboda 6baa9769ed [clang][cli] Add flexible TableGen multiclass for boolean options
This introduces more flexible multiclass for declaring two flags controlling the same boolean keypath.

Compared to existing Opt{In,Out}FFlag multiclasses, the new syntax makes it easier to read option declarations and reason about the keypath.

This also makes specifying common properties of both flags possible.

I'm open to suggestions on the class names. Not 100% sure the benefits are worth the added complexity.

Depends on D92774.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92775
2020-12-12 10:53:28 +01:00
Jan Svoboda 10f40576f7 [clang][cli] Don't always emit -f[no-]legacy-pass-manager
We don't need to always generate `-f[no-]experimental-new-pass-manager`.

This patch does not change the behavior of any other command line flag. (For example `-triple` is still being always generated.)

Reviewed By: dexonsmith, Bigcheese

Differential Revision: https://reviews.llvm.org/D92857
2020-12-12 10:11:23 +01:00
Jan Svoboda 6f26a6de48 Reland "[clang][cli] CompilerInvocationTest: add tests for boolean options"
Add more tests of the command line marshalling infrastructure.

The new tests now make a "round-trip": from arguments, to CompilerInvocation instance to arguments again in a single test case.

The TODOs are resolved in a follow-up patch.

Depends on D92830.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D92774
2020-12-12 09:46:20 +01:00
Duncan P. N. Exon Smith e095959e0c Fixup for 8c86197de3 to avoid making it platform-dependent 2020-12-11 17:34:00 -08:00
Duncan P. N. Exon Smith 8c86197de3 clang-import-test: Clean up error output for files that cannot be found
Pass on the filesystem error string `FileManager::getFileRef` in
`clang-import-test`'s `ParseSource` function. Also include "error:" and
a newline in the output. As a side effect, migrate to the `FileEntryRef`
overload of `SourceManager::createFileID`.

No real functionality change here, just slightly better output on error.

Differential Revision: https://reviews.llvm.org/D92971
2020-12-11 17:07:58 -08:00
Duncan P. N. Exon Smith a600432199 Frontend: Migrate to FileEntryRef in TextDiagnosticTest, NFC
Migrate over to the `FileEntryRef` overloads of
`SourceManager::createFileID` and `overrideFileContents` (using
`getVirtualFileRef`) in `TextDiagnostic`'s `ShowLine` test.

No functionality change.

Differential Revision: https://reviews.llvm.org/D92968
2020-12-11 17:06:28 -08:00
Nikita Popov 8d4b139e9d Revert "Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types."
This reverts commit 7b3470baf8.

Causes a crash while building tramp3d-v4 from test-suite.
2020-12-12 00:04:10 +01:00
Richard Smith 7b3470baf8 Consider reference, pointer, and pointer-to-member TemplateArguments to be different if they have different types.
For the Itanium ABI, this implements the mangling rule suggested in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47, namely mangling
such template arguments as being cast to the parameter type in the case
where the template name is overloadable. This can cause a mangling
change for rare cases, where

 * the template argument declaration is converted from its declared type
   to the type of the template parameter, and
 * the template parameter either has a deduced type or is a parameter of
   a function template.

However, such changes are necessary to avoid mangling collisions. The
ABI changes can be reversed with -fclang-abi-compat=11 or earlier.

Differential Revision: https://reviews.llvm.org/D91488
2020-12-11 13:26:33 -08:00
Marco Elver c28b18af19 [KernelAddressSanitizer] Fix globals exclusion for indirect aliases
GlobalAlias::getAliasee() may not always point directly to a
GlobalVariable. In such cases, try to find the canonical GlobalVariable
that the alias refers to.

Link: https://github.com/ClangBuiltLinux/linux/issues/1208

Reviewed By: dvyukov, nickdesaulniers

Differential Revision: https://reviews.llvm.org/D92846
2020-12-11 12:20:40 +01:00
Haojian Wu 556e4eba44 [AST][RecoveryAST] Preserve type for member call expr if argments are not matched.
Differential Revision: https://reviews.llvm.org/D92298
2020-12-11 10:38:03 +01:00
Haojian Wu 5663bf201f Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis."
The patch introduced a cycle dependency:

clangAnalysis -> clangFrontend -> clangSema -> clangAnalysis

This reverts commit 00ffea77ad.
This reverts commit ea6641085d.
2020-12-11 10:16:13 +01:00
Artem Dergachev 8c5ca7c6e6 [analyzer] OSObjectCStyleCast: Improve warning message.
Suggest OSRequiredCast as a closer alternative to C-style cast.
Explain how to decide.
2020-12-10 19:46:33 -08:00
Duncan P. N. Exon Smith 494aacd72c Tooling: Migrate some tests to FileEntryRef, NFC
Migrate to the `FileEntryRef` overload of `SourceManager::createFileID`
(using `FileManager::getOptionalFileRef`) in RefactoringTest.cpp and
RewriterTestContext.h.

No functionality change.

Differential Revision: https://reviews.llvm.org/D92967
2020-12-10 18:05:03 -08:00
Richard Smith a3fe12dc58 Ensure that we don't leave behind "InstantiatingSpecialization" entries
after destroying an InstantiatingTemplate object.

This previously caused us to (silently!) bail out of class template
instantiation, thinking we'd produced an error, in some corner cases.
2020-12-10 17:01:44 -08:00
Alexander Kornienko 027899dab6 Remove references to the ast_type_traits namespace
Follow up to cd62511496 /
https://reviews.llvm.org/D74499

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D92994
2020-12-11 00:58:46 +01:00
Kazushi (Jam) Marukawa cd5855ac3b [VE] Remove -faddrsig and -fnoaddrsig tests
Remove explicitly declared -faddrsig and -fnoaddrsig option tests
since those are already tested in addrsig.c.  We test only the implicit
behavior of VE driver.

This is suggested in https://reviews.llvm.org/D92386.  Thanks.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D92996
2020-12-11 08:25:38 +09:00
Duncan P. N. Exon Smith 0978c83e6f Basic: Initialize FileEntry's fields inline, almost NFC
Initialize most of FileEntry's fields inline (all the ones that can be).
The only functionality change is to avoid leaving some fields
uninitialized.
2020-12-10 13:57:21 -08:00