Commit Graph

86826 Commits

Author SHA1 Message Date
Joe Ellis 1d7abcf99e [AArch64][SVE] Add tests for VLST -> VLAT lax conversions
These were previously missing from the SVE lax conversions tests
introduced in this commit:

    23a96b84a8
    (https://reviews.llvm.org/D91067)

Differential Revision: https://reviews.llvm.org/D91642
2020-11-17 18:03:42 +00:00
Stephen Kelly 6ef6beaa57 Comment out new test while I figure out what is wrong with it 2020-11-17 17:48:48 +00:00
Stephen Kelly 4cadb66b49 [AST] Update matchers to be traverse-aware
Don't match Stmt or Decl nodes not spelled in the source when using
TK_IgnoreUnlessSpelledInSource.  This prevents accidental modification
of source code at incorrect locations.

Differential Revision: https://reviews.llvm.org/D90984
2020-11-17 16:31:08 +00:00
Stephen Kelly 246b428fb3 [AST] Ignore implicit nodes in IgnoreUnlessSpelledInSource mode
Update the ASTNodeTraverser to dump only nodes spelled in source.  There
are only a few which need to be handled, but Decl nodes for which
isImplicit() is true are handled together.

Update the RAV instances used in ASTMatchFinder to ignore the nodes too.
As with handling of template instantiations, it is necessary to allow
the RAV to process the implicit nodes because they need to be visitable
before the first traverse() matcher is encountered.  An exception to
this is in the MatchChildASTVisitor, because we sometimes wish to make a
node matchable but make its children not-matchable.  This is the case
for defaulted CXXMethodDecls for example.

Extend TransformerTests to illustrate the kinds of problems that can
arise when performing source code rewriting due to matching implicit
nodes.

This change accounts for handling nodes not spelled in source when using
direct matching of nodes, and when using the has() and hasDescendant()
matchers.  Other matchers such as
cxxRecordDecl(hasMethod(cxxMethodDecl())) still succeed for
compiler-generated methods for example after this change.  Updating the
implementations of hasMethod() and other matchers is for a follow-up
patch.

Differential Revision: https://reviews.llvm.org/D90982
2020-11-17 16:30:07 +00:00
Stephen Kelly 34c0f3cbf1 Move ASTMatchFinder definition so it can be accessed from other functions 2020-11-17 16:29:00 +00:00
Stephen Kelly 36011bdfb6 Rename API to not be constrained to template instantiations
A follow-up commit will use this method to ignore implcit AST nodes.
2020-11-17 16:28:59 +00:00
Stephen Kelly 019723fc29 Invert accessor for checking traversal mode
For now, there is a traversal mode which ignores implicit casts and
parenthesis. Invert the check in order to not obviously break that.
2020-11-17 16:28:59 +00:00
Ben Shi bba96c9965 [clang][AVR] Improve avr-ld command line options
Reviewed By: dylanmckay

Differential Revision: https://reviews.llvm.org/D88410
2020-11-17 23:28:41 +08:00
Alexey Bataev 5292187a2d [OPENMP]Fix PR48076: mapping of data member pointer.
If the data member pointer is mapped, the compiler tries to optimize the
mapping of such data by discarding explicit mapping flags and trying to
emit combined data instead. In some cases, this optimization is not
quite correctly implemented and it leads to a program crash at the
runtime. Instead, if the data member is mapped, just emit it as is and
do not emit combined mapping flags for it.

Differential Revision: https://reviews.llvm.org/D91552
2020-11-17 07:18:32 -08:00
Florian Hahn 46846ac45b
[Matrix] Add inline assembly test case.
This patch adds a new test cases which uses a matrix value as memory
inline assembly argument. Currently the pointer element type does not
match the vector type.
2020-11-17 15:13:16 +00:00
Joe Ellis 23a96b84a8 [AArch64][SVE] Support implicit lax vector conversions for SVE types
Lax vector conversions was behaving incorrectly for implicit casts
between scalable and fixed-length vector types. For example, this:

    #include <arm_sve.h>

    #define N __ARM_FEATURE_SVE_BITS
    #define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))

    typedef svfloat32_t fixed_float32_t FIXED_ATTR;

    void allowed_depending() {
      fixed_float32_t fs32;
      svfloat64_t s64;

      fs32 = s64;
    }

... would fail because the vectors have differing lane sizes. This patch
implements the correct behaviour for
-flax-vector-conversions={none,all,integer}. Specifically:

- -flax-vector-conversions=none prevents all lax vector conversions
  between scalable and fixed-sized vectors.
- -flax-vector-conversions=integer allows lax vector conversions between
  scalable and fixed-size vectors whose element types are integers.
- -flax-vector-conversions=all allows all lax vector conversions between
  scalable and fixed-size vectors (including those with floating point
  element types).

The implicit conversions are implemented as bitcasts.

Reviewed By: fpetrogalli

Differential Revision: https://reviews.llvm.org/D91067
2020-11-17 14:50:17 +00:00
Erich Keane 6976fef05b Update 'note-candiate' functions to skip lambda-conversion-op-overloads
In the wake of https://reviews.llvm.org/D89559, we discovered that a
couple of tests (the ones modified below to have additional triple
versions) would fail on Win32, for 1 of two reasons.  We seem to not
have a win32 buildbot anymore, so the triple is to make sure this
doesn't get broken in the future.

First, two of the three 'note-candidate' functions weren't appropriately
skipping the remaining conversion functions.

Second, in 1 situation (note surrogate candidates) we actually print the
type of the conversion operator.  The two tests that ran into that
needed updating to make sure it printed the proper one in the win32
case.
2020-11-17 05:49:31 -08:00
Nathan James d44edfc109
[clang][NFC] Use SmallString instead of SmallVector<char
Simplifies code in some places and is more explicit about what is being used.
No additional includes were added here so no impact on compile time.
2020-11-17 13:02:58 +00:00
Simon Pilgrim 0627140cd5 [clang][driver] Fix definition/declaration argument name mismatches. NFCI.
AddCXXStdlibLibArgs args were using the names for the clang equivalent methods.

Silences cppcheck warnings.
2020-11-17 12:39:45 +00:00
Sven van Haastregt f0c690018a [OpenCL] Stop opencl-c-base.h leaking extension enabling
opencl-c.h disables all extensions at its end, but opencl-c-base.h
does not, and that causes any inclusion of only opencl-c-base.h to
leave some extensions (such as cl_khr_fp16) enabled.  This affects the
-fdeclare-opencl-builtins option for example.

This violates the OpenCL Extension Specification which specifies that
"The initial state of the compiler is as if the directive #pragma
OPENCL EXTENSION all : disable was issued".

Fix by disabling all extensions at the end of opencl-c-base.h and
enable extensions inside opencl.h which relied on opencl-c-base.h
enabling the cl_khr_fp16/64 extensions.

Differential Revision: https://reviews.llvm.org/D91429
2020-11-17 12:07:40 +00:00
Serge Pavlov 9faedb2d71 [Driver] Quote executable in reports generated by -fproc-stat-report
The option -fproc-stat-report=<file> makes driver to generate child
process resource comsumption report. In the report executable name was
not quoted and it made parsing the report more difficult. With this
change the executable name is surrounded by quotation marks.
2020-11-17 15:16:09 +07:00
Yaxun (Sam) Liu 3f4b5893ef [AMDGPU] Add option -munsafe-fp-atomics
Add an option -munsafe-fp-atomics for AMDGPU target.

When enabled, clang adds function attribute "amdgpu-unsafe-fp-atomics"
to any functions for amdgpu target. This allows amdgpu backend to use
unsafe fp atomic instructions in these functions.

Differential Revision: https://reviews.llvm.org/D91546
2020-11-16 21:52:12 -05:00
CJ Johnson 69cd776e1e [CodeGen] Apply 'nonnull' and 'dereferenceable(N)' to 'this' pointer
arguments.

* Adds 'nonnull' and 'dereferenceable(N)' to 'this' pointer arguments
* Gates 'nonnull' on -f(no-)delete-null-pointer-checks
* Introduces this-nonnull.cpp and microsoft-abi-this-nullable.cpp tests to
  explicitly test the behavior of this change
* Refactors hundreds of over-constrained clang tests to permit these
  attributes, where needed
* Updates Clang12 patch notes mentioning this change

Reviewed-by: rsmith, jdoerfert

Differential Revision: https://reviews.llvm.org/D17993
2020-11-16 17:39:17 -08:00
Artem Dergachev 499bce3aba Revert "Revert "[analyzer] NFC: Separate PathDiagnosticConsumer options from AnalyzerOptions.""
This reverts commit 10f1ca99b4.

(cherry picked from commit c599fc738a70e482976c6cc0ea31bef561641279)
2020-11-16 14:37:50 -08:00
Michael Liao f375885ab8 [InferAddrSpace] Teach to handle assumed address space.
- In certain cases, a generic pointer could be assumed as a pointer to
  the global memory space or other spaces. With a dedicated target hook
  to query that address space from a given value, infer-address-space
  pass could infer and propagate that to all its users.

Differential Revision: https://reviews.llvm.org/D91121
2020-11-16 17:06:33 -05:00
Thorsten 41b65f166b Convert ConstexprKind from Specifiers.h to a scoped enum; NFC 2020-11-16 14:10:19 -05:00
Yonghong Song 4369223ea7 BPF: make __builtin_btf_type_id() return 64bit int
Linux kernel recently added support for kernel modules
  https://lore.kernel.org/bpf/20201110011932.3201430-5-andrii@kernel.org/

In such cases, a type id in the kernel needs to be presented
as (btf id for modules, btf type id for this module).
Change __builtin_btf_type_id() to return 64bit value
so libbpf can do the above encoding.

Differential Revision: https://reviews.llvm.org/D91489
2020-11-16 07:08:41 -08:00
Xiangling Liao 9e407afd9b [AIX][driver] Include crti[_64].o and -bcdtors also for C language link invocations by default
In order to support attribute((constructor)) and attribute((destructor)),
which is used by various LLVM non-C++ runtime components, AIX will include
crti[_64].o and -bcdtors for C language link invocations by default.

Differential Revision: https://reviews.llvm.org/D91361
2020-11-16 10:07:57 -05:00
Florian Hahn 8dbe44cb29 Add pass to add !annotate metadata from @llvm.global.annotations.
This patch adds a new pass to add !annotation metadata for entries in
@llvm.global.anotations, which is generated  using
__attribute__((annotate("_name"))) on functions in Clang.

This has been discussed on llvm-dev as part of
    RFC: Combining Annotation Metadata and Remarks
    http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html

Reviewed By: thegameg

Differential Revision: https://reviews.llvm.org/D91195
2020-11-16 14:57:11 +00:00
Francesco Petrogalli 02bdbdc760 [clang][SveEmitter] Fix enum declarations. [NFCI]
Adapt the declarations of `svpattern` and `svprfop` to the most recent
one defined in section "5. Enum declarations" of the SVE ACLE
specifications [1].

The signature of the intrinsics using these enums have been changed
accordingly.

A test has been added to make sure that `svpattern` and `svprfop` are
not typedefs.

[1] https://developer.arm.com/documentation/100987/latest, version
00bet6

Reviewed By: joechrisellis

Differential Revision: https://reviews.llvm.org/D91333
2020-11-16 14:49:45 +00:00
Aaron Ballman f9e639efda Fix bots that are running with assertions enabled; NFC. 2020-11-16 09:23:10 -05:00
Aaron Ballman f7c881b89e Adding some explicit casts to appease build bots; NFC 2020-11-16 09:13:24 -05:00
Thorsten 7c6412e0cc Convert TypeSpecifierSign from Specifiers.h to a scoped enum; NFC 2020-11-16 09:08:08 -05:00
Thorsten a6ac2b32fb Convert TypeSpecifiersPipe from Specifiers.h to a scoped enum; NFC 2020-11-16 08:28:21 -05:00
Vassil Vassilev 54e655b3f8 Reland "Move the test compiler setup in a common place. NFCI"
Original commit message: "
Move the test compiler setup in a common place. NFCI

This patch reduces the copy paste in the unittest/CodeGen folder by moving the
common compiler setup phase in a header file.

Differential revision: https://reviews.llvm.org/D91061
"

This patch includes a fix for the memory leaks pointed out by @vitalybuka
2020-11-16 13:22:10 +00:00
Vitaly Buka 6c185acfff Revert "Move the test compiler setup in a common place. NFCI"
There is memory leaks

This reverts commit 23cc838099.
This reverts commit 888d06dfb8.
2020-11-16 04:21:28 -08:00
Florian Hahn ca2e7e5999 [IRGen] Add !annotation metadata for auto-init stores.
This patch updates Clang's IRGen to add !annotation nodes with an
"auto-init" annotation to all stores for auto-initialization.

As discussed in 'RFC: Combining Annotation Metadata and Remarks'
(http://lists.llvm.org/pipermail/llvm-dev/2020-November/146393.html)
this allows using optimization remarks to track down where auto-init
code was inserted (and not removed by optimizations).

There are a few cases in the tests where !annotation gets dropped by
optimizations. Those optimizations will be updated in subsequent
patches.

This patch is based on a patch by Francis Visoiu Mistrih.

Reviewed By: thegameg, paquette

Differential Revision: https://reviews.llvm.org/D91417
2020-11-16 10:37:02 +00:00
Jan Svoboda 2f3055c543 [clang][cli] Add support for options with two flags for controlling the same field.
This enables automatically parsing and generating CC1 arguments for options where two flags control the same field, e.g. -fexperimental-new-pass-manager and -fno-experimental new pass manager.

Reviewed By: Bigcheese, dexonsmith

Original patch by Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D83071
2020-11-16 10:21:54 +01:00
Richard Smith dc58cd1480 PR48169: Fix crash generating debug info for class non-type template
parameters.

It appears that LLVM isn't able to generate a DW_AT_const_value for a
constant of class type, but if it could, we'd match GCC's debug info in
this case, and in the interim we no longer crash.
2020-11-15 17:43:26 -08:00
faisalv e6aa06545b [NFC, Refactor] Modernize the TypeSpecifierWidth enum (Specifiers.h) to a scoped enum
Reviewed here: https://reviews.llvm.org/D91409 by Aaron.
Highlights of the review:
  - avoid an underlying type for enums
  - avoid enum bit fields (MSVC packing anomalies) and favor static_casts to unsigned bit-fields

Patch by Thorsten Schuett <schuett@gmail.com> w some minor fixes in SemaType.cpp where a couple asserts had to be repaired to deal with lack of implicit coversion to int.

Thanks Thorsten!
2020-11-15 11:13:57 -06:00
Aaron Puchert dea31f135c Consistent spelling in diagnostics: {l,r}value instead of {l,r}-value
As Richard Smith pointed out in the review of D90123, both the C and C++
standard call it lvalue and rvalue, so let's stick to the same spelling
in Clang.
2020-11-15 18:05:11 +01:00
Aaron Puchert 6f84779674 [Sema] Improve notes for value category mismatch in overloading
When an overloaded member function has a ref-qualifier, like:

class X {
    void f() &&;
    void f(int) &;
};

we would print strange notes when the ref-qualifier doesn't fit the value
category:

X x;
x.f();
X().f(0);

would both print a note "no known conversion from 'X' to 'X' for object
argument" on their relevant overload instead of pointing out the
mismatch in value category.

At first I thought the solution is easy: just use the FailureKind member
of the BadConversionSequence struct. But it turns out that we weren't
properly setting this for function arguments. So I went through
TryReferenceInit to make sure we're doing that right, and found a number
of notes in the existing tests that improved as well.

Fixes PR47791.

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D90123
2020-11-15 18:05:11 +01:00
Yaxun (Sam) Liu fb58142e00 Fix temporary file name on Windows
Bound arch may contain ':', which is invalid in Windows file names.

This patch fixes that.

Differential Revision: https://reviews.llvm.org/D91421
2020-11-15 08:11:05 -05:00
Simon Pilgrim 5e373b2e94 [Sema] Use isa<> instead of dyn_cast<> as pointer is never dereferenced. NFCI.
We are only checking for the class type. Fixes Wshadow warnings.
2020-11-15 12:58:36 +00:00
Vassil Vassilev 23cc838099 Add forgotten in 888d06d file. 2020-11-14 21:32:23 +00:00
Vassil Vassilev 888d06dfb8 Move the test compiler setup in a common place. NFCI
This patch reduces the copy paste in the unittest/CodeGen folder by moving the
common compiler setup phase in a header file.

Differential revision: https://reviews.llvm.org/D91061
2020-11-14 21:30:30 +00:00
Fangrui Song c35448ba80 [Driver][test] Fix cc1-spawnprocess.c 2020-11-14 09:53:34 -08:00
Nathan James 0a6e051a9b
[NFC] Small refactor to CompilationDatabase 2020-11-14 14:03:35 +00:00
mydeveloperday db6f7e0e9e [git-clang-format] Process CUDA header files
Clang supports compiling CUDA source files,
CUDA header files may contain CUDA specific code
that is why they have special extension, which
can be recognized by nvcc (CUDA compiler driver)
as CUDA source file.
Format them by default as well.

Reviewed By: MyDeveloperDay

Patch By: tomilov

Differential Revision: https://reviews.llvm.org/D90780
2020-11-14 12:39:16 +00:00
Roman Lebedev 6861d938e5
Revert "clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM"
See discussion in https://bugs.llvm.org/show_bug.cgi?id=45073 / https://reviews.llvm.org/D66324#2334485
the implementation is known-broken for certain inputs,
the bugreport was up for a significant amount of timer,
and there has been no activity to address it.
Therefore, just completely rip out all of misexpect handling.

I suspect, fixing it requires redesigning the internals of MD_misexpect.
Should anyone commit to fixing the implementation problem,
starting from clean slate may be better anyways.

This reverts commit 7bdad08429,
and some of it's follow-ups, that don't stand on their own.
2020-11-14 13:12:38 +03:00
Fangrui Song bc7df035ae Make -fintegrated-cc1 work with cc1as
Tested 0.018s faster on my machine.
2020-11-14 01:16:16 -08:00
Mehdi Amini 42e88bd6b1 Replace sequences of v.push_back(v[i]); v.erase(&v[i]); with std::rotate (NFC)
The code has a few sequence that looked like:

    Ops.push_back(Ops[0]);
    Ops.erase(Ops.begin());

And are equivalent to:

    std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());

The latter has the advantage of never reallocating the vector, which
would be a bug in the original code as push_back would read from the
memory it deallocated.
2020-11-14 00:55:33 +00:00
Arthur Eubanks 52f05fb2c2 [MemProf][NewPM] Make memprof passes required
Just like other sanitizers.
Fixes check-memprof under NPM.

Reviewed By: leonardchan

Differential Revision: https://reviews.llvm.org/D91389
2020-11-13 15:15:27 -08:00
Duncan P. N. Exon Smith cfde3edeae Frontend: Remove unused parameter from ASTUnit::LoadFromCompilerInvocationAction, NFC
Drop `IncludeBriefCommentsInCodeCompletion` since it is always `false`.

Differential Revision: https://reviews.llvm.org/D91295
2020-11-13 17:47:17 -05:00
Vladimir Vereschaka b09154ebf9 [CMake] Explicity set up RPATH for the runtime libs on Win to ARM Linux cross builds.
Since RPATH initialization was disabled for the runtime libraries to
avoid overwriting RPATH unconditionally we need to explicity set up it
for the Win to Arm Linux cross builds.

See some details here: https://reviews.llvm.org/D91099
2020-11-13 14:32:35 -08:00
Arthur Eubanks 6e098189db [DFSan][NewPM] Handle dfsan under NPM
Make it required. Since it's a module pass, optnone won't test it, so
extend the clang test to also use opt-bisect now that it's supported.

14/16 check-dfsan tests failed with NPM enabled, now all pass.

Reviewed By: leonardchan

Differential Revision: https://reviews.llvm.org/D91385
2020-11-13 13:41:38 -08:00
Duncan P. N. Exon Smith a2f2c2f3a4 Serialization: Merge three diagnostics to simplify ASTReader::getInputFile, NFC
Clean up the logic for `err_fe_{pch,module,ast}_file_modified` to use a
`select` like other ASTReader diagnostics. There should be no
functionality change here, just a cleanup.

Differential Revision: https://reviews.llvm.org/D91367
2020-11-13 16:23:04 -05:00
Heejin Ahn 902ea588ea [WebAssembly] Rename atomic.notify and *.atomic.wait
- atomic.notify -> memory.atomic.notify
- i32.atomic.wait -> memory.atomic.wait32
- i64.atomic.wait -> memory.atomic.wait64

See https://github.com/WebAssembly/threads/pull/149.

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D91447
2020-11-13 12:04:48 -08:00
Heejin Ahn 01d8715369 [WebAssembly] Remove a temporarily added RUN line
This RUN line was added as a temporary measure to undo the damage done
by D79655. Everyone's build system should be fine by now.

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D91448
2020-11-13 11:57:09 -08:00
Duncan P. N. Exon Smith b764a62f02 Serialization: Rename three AST diagnostics, NFC
All three diagnostics have a select between "PCH", "module", and "AST"
in the text. The most generic of these is "AST", so rename them from
`err_module_...` to `err_ast_...`.

Differential Revision: https://reviews.llvm.org/D91436
2020-11-13 14:09:00 -05:00
Baptiste Saleil 3f78605a8c [PowerPC] Add paired vector load and store builtins and intrinsics
This patch adds the Clang builtins and LLVM intrinsics to load and store vector pairs.

Differential Revision: https://reviews.llvm.org/D90799
2020-11-13 12:35:10 -06:00
Aaron Ballman 66b876c014 Pass the source range when diagnosing an unknown attribute
This way, the whole attribute gets highlighted with diagnostics instead
of just the scope name in an attribute like [[clang::unknown]].
2020-11-13 10:29:44 -08:00
Duncan P. N. Exon Smith d87fd096ac Serialization: Hoist the check for in-flight diagnostics in ASTReader::getInputFile, NFC
This logic seems easier to follow without the `Error()` helper, and
checking `DiagnosticsEngine::isDiagnosticInFlight` just once up front.

Differential Revision: https://reviews.llvm.org/D91366
2020-11-13 13:26:37 -05:00
Nico Weber 46ca880fca clang: Don't assert on no_unique_address fields in @encode()
Just skip (non-bitfield) zero-sized fields, like we do with empty bases.

The class->struct conversion in the test is because -std=c++20 else deletes some default methods
due to non-accessible base dtors otherwise.

As a side-effect of writing the test, I discovered that D76801 did an ABI breaking change of sorts
for Objective-C's @encode. But it's been in for a while, so I'm not sure if we want to row back on
that or now.

Fixes PR48048.

Differential Revision: https://reviews.llvm.org/D90622
2020-11-13 11:39:10 -05:00
Haojian Wu 7ad6c8414c [clang] Fix an assertion crash in delayed access check.
`TD->getTemplatedDecl()` might not be a DeclContext variant, which can
trigger an assertion inside `isa<>`.

Differential Revision: https://reviews.llvm.org/D91380
2020-11-13 14:02:57 +01:00
Jan Svoboda d2d59d2be9 Reland [clang][cli] Port ObjCMTAction to new option parsing system
Merge existing marhsalling info kinds and add some primitives to
express flag options that contribute to a bitfield.

Depends on D82574

Original patch by Daniel Grumberg.

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D82860
2020-11-13 13:42:54 +01:00
Serge Pavlov 92d7a84e12 [Driver] Add option -fproc-stat-report
The new option `-fproc-stat-info=<file>` can be used to generate report
about used memory and execution tile of each stage of compilation.
Documentation for this option can be found in `UserManual.rst`. The
option can be used in parallel builds.

Differential Revision: https://reviews.llvm.org/D78903
2020-11-13 14:15:42 +07:00
Richard Smith 7602ef768b Suppress trailing template arguments equivalent to default arguments
when printing the name of a member of a class template specialization.
2020-11-12 21:10:34 -08:00
Michael Liao 8920ef06a1 [hip] Remove the coercion on aggregate kernel arguments.
- If an aggregate argument is indirectly accessed within kernels, direct
  passing results in unpromotable `alloca`, which degrade performance
  significantly. InferAddrSpace pass is enhanced in
  [D91121](https://reviews.llvm.org/D91121) to take the assumption that
  generic pointers loaded from the constant memory could be regarded
  global ones. The need for the coercion on aggregate arguments is
  mitigated.

Differential Revision: https://reviews.llvm.org/D89980
2020-11-12 21:19:30 -05:00
Amy Huang 0c80b542d3 Some updates/fixes to the creduce script.
This was motivated by changes to llvm's `not --crash` disabling symbolization
but I ended up removing `not` from the script entirely because it
returns differently depending on  whether clang "crashes" or exits for some
other reason. The script had to choose between calling `not` and `not --crash`
and sometimes it was wrong.

The script also now disables symbolization when we don't read the stack
trace because symbolizing is kind of slow.

Differential Revision: https://reviews.llvm.org/D91372
2020-11-12 13:40:26 -08:00
Alexey Bataev 07b568a9c8 [OPENMP]Fix PR47790: segfault in frontend while parsing Objective-C with OpenMP.
Need to check if the sema is actually finishing a function decl.

Differential Revision: https://reviews.llvm.org/D91376
2020-11-12 13:26:11 -08:00
Kazushi (Jam) Marukawa 9c504ec06d [VE] Disable -fsigaddr option for VE
VE needs to support integrated assembler and "nas".  This "nas"
doesn't recognize ".sigaddr" pseudo mnemonics, so need to disable
it.  This patch disable it on VE by default.  Also add a regression
test for that.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D91350
2020-11-13 06:22:12 +09:00
Arthur Eubanks 3a7b57b7ca [NFC][NewPM] Reuse PassBuilder callbacks with -O0
This removes lots of duplicated code which was necessary before
https://reviews.llvm.org/D89158.
Now we can use PassBuilder::runRegisteredEPCallbacks().
This is mostly sanitizers.

There is likely more that can be done to simplify, but let's start with this.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D90870
2020-11-12 12:42:59 -08:00
Alexey Bataev 3c6b457bee [OPENMP]Fix PR48076: Check map types array before accessing its front.
Need to check if there are map types for the components before trying to
access them when trying to modify type mappings for combined partial
mappings.

Differential Revision: https://reviews.llvm.org/D91370
2020-11-12 12:00:29 -08:00
Anatoliy Tomilov e7c7a19826 [Frontend] Treat .cuh files as CUDA source files
to synchronize with tools/clang-format/git-clang-format

tra: Keeping them in sync does have a minor benefit of not raising a question why the two maps are different.

Differential Revision: https://reviews.llvm.org/D91034
2020-11-12 11:42:53 -08:00
Aaron Ballman b336826c1d Non-implicit attribute creation requires a source range; NFC
There are two factory functions used to create a semantic attribute,
Create() and CreateImplicit(). CreateImplicit() does not need to
specify the source range of the attribute since it's an implicitly-
generated attribute. The same logic does not apply to Create(), so
this removes the default argument from those declarations to avoid
accidentally creating a semantic attribute without source location
information.
2020-11-12 10:06:30 -08:00
Kevin P. Neal ac523d2de5 [FPEnv][Clang][Driver] Use MarshallingInfoFlag for -fexperimental-strict-floating-point
As of D80952 we are disabling strict floating point on all hosts except
those that are explicitly listed as supported. Use of strict floating point
on other hosts requires use of the -fexperimental-strict-floating-point
flag. This is to avoid bugs like "https://bugs.llvm.org/show_bug.cgi?id=45329"
(which has an incorrect link in the previous review).

In the review for D80952 I was asked to mark the -fexperimental option as
a MarshallingInfoFlag. This patch does exactly that.

Differential Revision: https://reviews.llvm.org/D88987
2020-11-12 12:51:35 -05:00
Baptiste Saleil 170e45ae18 [PowerPC] Prevent the use of MMA with P9 and earlier
We want to allow using MMA on P10 CPU only. This patch prevents the use of MMA
with the -mmma option on P9 CPUs and earlier.

Differential Revision: https://reviews.llvm.org/D91200
2020-11-12 10:36:50 -06:00
Jean-Michel Gorius 62ed69b01d [clang][docs] Remove wrongly spaced \brief in Doxygen comment (NFC) 2020-11-12 15:44:43 +01:00
Sylvain Audi 79105e4644 [clang-scan-deps] Fix for input file given as relative path in compilation database "command" entry.
Differential Revision: https://reviews.llvm.org/D91204
2020-11-12 08:48:17 -05:00
Hans Wennborg a088766508 [dllexport] Instantiate default ctor default args for explicit specializations (PR45811)
For dllexported default constructors with default arguments, we export
default constructor closures which pass in the default args. (See D8331
for a good explanation.)

For templates, that means those default args must be instantiated even
if the function isn't called. That is done by the
InstantiateDefaultCtorDefaultArgs() function, but it wasn't done for
explicit specializations, causing asserts (see bug).

Differential revision: https://reviews.llvm.org/D91089
2020-11-12 13:29:34 +01:00
Hans Wennborg b9d36540a8 [dllexport] Avoid assert for explicitly defaulted methods in explicit instantiation definitions (PR47683)
Clang was asserting due to attempting to codegen such methods twice.

Differential revision: https://reviews.llvm.org/D90849
2020-11-12 13:19:29 +01:00
Chuanqi Xu cd89c4dbdd [NFC][coroutines] remove unused argument in SemaCoroutine
Test plan: check-llvm, check-clang

Reviewers: lxfind, junparser

Differential Revision: https://reviews.llvm.org/D91243
2020-11-12 13:22:20 +08:00
Richard Smith 2d4035e493 Fix structural comparison of template template arguments to compare the
right union member.

Should fix the armv8 buildbot.
2020-11-11 19:15:21 -08:00
Qiu Chaofan 2abc33683b [PowerPC] [Clang] Define macros to identify quad-fp semantics
We have option -mabi=ieeelongdouble to set current long double to
IEEEquad semantics. Like what GCC does, we need to define
__LONG_DOUBLE_IEEE128__ macro in this case, and __LONG_DOUBLE_IBM128__
if using PPCDoubleDouble.

Reviewed By: steven.zhang

Differential Revision: https://reviews.llvm.org/D90208
2020-11-12 10:26:13 +08:00
Sam McCall 1630e50874 [Syntax] Tablegen literal expressions.
Non-mechanical changes:
 - Added FIXME to StringLiteral to cover multi-token string literals.
 - LiteralExpression::getLiteralToken() is gone. (It was never called)
   This is because we don't codegen methods in Alternatives
   It's conceptually suspect if we consider multi-token string literals, though.

Differential Revision: https://reviews.llvm.org/D91277
2020-11-12 01:26:02 +01:00
Arthur Eubanks b6ccff3d5f [NewPM] Provide method to run all pipeline callbacks, used for -O0
Some targets may add required passes via
TargetMachine::registerPassBuilderCallbacks(). We need to run those even
under -O0. As an example, BPFTargetMachine adds
BPFAbstractMemberAccessPass, a required pass.

This also allows us to clean up BackendUtil.cpp (and out-of-tree Rust
usage of the NPM) by allowing us to share added passes like coroutines
and sanitizers between -O0 and other optimization levels.

Since callbacks may end up not adding passes, we need to check if the
pass managers are empty before adding them, so PassManager now has an
isEmpty() function. For example, polly adds callbacks but doesn't always
add passes in those callbacks, so this is necessary to keep
-debug-pass-manager tests' output from changing depending on if polly is
enabled or not.

Tests are a continuation of those added in
https://reviews.llvm.org/D89083.

Reviewed By: asbirlea, Meinersbur

Differential Revision: https://reviews.llvm.org/D89158
2020-11-11 15:10:27 -08:00
Richard Smith 5f12f4ff90 Suppress printing of inline namespace names in diagnostics by default,
except where they are necessary to disambiguate the target.

This substantially improves diagnostics from the standard library,
which are otherwise full of `::__1::` noise.
2020-11-11 15:05:51 -08:00
Richard Smith e7f3e2103c Suppress printing template arguments that match default template
arguments of types by default.

This somewhat improves the worst-case printing of types like
std::string, std::vector, etc., where many irrelevant default arguments
can be included in the type as printed if we've lost the type sugar.
2020-11-11 15:05:51 -08:00
Duncan P. N. Exon Smith 4c55c3b66d Frontend: Change ComputePreambleBounds to take MemoryBufferRef, NFC
Avoid requiring an actual MemoryBuffer in ComputePreambleBounds, when
a MemoryBufferRef will do just fine.

Differential Revision: https://reviews.llvm.org/D90890
2020-11-11 17:19:51 -05:00
Florian Hahn 1d5daed199
[Matrix] Update mangling to use paramterized vendor ext type syntax.
The Itanium CXX ABI grammer has been extended to support parameterized
vendor extended types [1].

This patch updates Clang's mangling for matrix types to use the new
extension.

[1] b359d28971

Reviewed By: rjmccall

Differential Revision: https://reviews.llvm.org/D91253
2020-11-11 21:39:22 +00:00
Kazushi (Jam) Marukawa 6e0ae20f3b [VE] Support vector register in inline asm
Support a vector register constraint in inline asm of clang.
Add a regression test also.

Reviewed By: simoll

Differential Revision: https://reviews.llvm.org/D91251
2020-11-12 06:18:35 +09:00
Duncan P. N. Exon Smith 4e9af3d478 Frontend: Skip namespace around createVFSFromCompilerInvocation definition, NFC
Qualify definitions with `clang::` rather than opening/closing a namespace.

Differential Revision: https://reviews.llvm.org/D90957
2020-11-11 16:15:06 -05:00
Mehdi Amini f917356f9c Revert "[clang][cli] Port ObjCMTAction to new option parsing system"
This reverts commit 09248a5d25.

Some builds are broken. I suspect a `static constexpr` in a class missing a
definition out of class (required pre-c++17).
2020-11-11 20:01:03 +00:00
Simon Pilgrim deb543ae70 [Driver] hip-toolchain-device-only.hip - remove unused check prefix
Just use default CHECK
2020-11-11 18:00:03 +00:00
Alex Lorenz 3df3b62018 [clang] ns_error_domain attribute also supports CFString typed variables
Differential Revision: https://reviews.llvm.org/D90891
2020-11-11 08:50:30 -08:00
Simon Pilgrim e3b64eb31c [CodeGenCXX] Remove unused check prefixes 2020-11-11 16:19:53 +00:00
Simon Pilgrim c1e3d38301 [CodeGenOpenCL] Fix check prefix typo on convergent.cl test
Noticed while fixing unused prefix warnings - there isn't actually any diff in the loop unrolled ir between old/new pass managers any more, so the broken checks were superfluous
2020-11-11 15:44:59 +00:00
Simon Pilgrim 10fc39b291 [CodeGenObjC] Remove unused check prefixes 2020-11-11 15:44:58 +00:00
Simon Pilgrim fc80931b87 [CodeGenCUDA] Fix check prefix typo on device-stub.cu tests
Noticed while fixing unused prefix warnings
2020-11-11 15:44:57 +00:00
Sam McCall ea4d24c899 [Syntax] Tablegen Sequence classes. NFC
Similar to the previous patch, this doesn't convert *all* the classes that
could be converted. It also doesn't enforce any new invariants etc.

It *does* include some data we don't use yet: specific token types that are
allowed and optional/required status of sequence items. (Similar to Dmitri's
prototype). I think these are easier to add as we go than later, and serve
a useful documentation purpose.

Differential Revision: https://reviews.llvm.org/D90659
2020-11-11 16:29:19 +01:00
Sam McCall 138189ee33 [Syntax] Tablegen operator<<(NodeKind). NFC
Differential Revision: https://reviews.llvm.org/D90662
2020-11-11 16:02:01 +01:00
Simon Pilgrim 3e5533bafd [CodeGen] Remove unused check prefixes 2020-11-11 14:57:38 +00:00
Simon Pilgrim 8cb97fb9c9 [CodeGen] Fix check prefix mismatch on neon-immediate-ubsan.c tests
Noticed while fixing unused prefix warnings,
2020-11-11 14:57:37 +00:00
Nico Weber 3109ce51d4 clang-cl: Expose -f[no-]delete-null-pointer-checks as clang-cl flag 2020-11-11 09:19:02 -05:00
Elvina Yakubova 624bced7ee [OpenCL] Make Clang recognize -cl-std=1.0 as a value argument
This patch makes Clang recognize -cl-std=1.0 as a value argument,
before only -std=cl1.0 has to be used instead.

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

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D91237
2020-11-11 17:01:57 +03:00
Andrzej Warzynski fdbc7e505c [flang][driver] Make sure that `-###` is marked as supported (NFC)
`-###` has always been supported in the new flang driver. This patch
merely makes sure that it's included when printing the help screen (i.e.
`flang-new -help`).
2020-11-11 13:12:51 +00:00
Jan Svoboda 09248a5d25 [clang][cli] Port ObjCMTAction to new option parsing system
Merge existing marhsalling info kinds and add some primitives to
express flag options that contribute to a bitfield.

Depends on D82574

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D82860
2020-11-11 13:03:02 +01:00
Sam McCall 98aa067109 [Syntax] Start to move trivial Node class definitions to TableGen. NFC
This defines two node archetypes with trivial class definitions:
 - Alternatives: the generated abstract classes are trivial as all
   functionality is via LLVM RTTI
 - Unconstrained: this is a placeholder, I think all of these are going to be
   Lists but today they have no special accessors etc, so we just say
   "could contain anything", and migrate them one-by-one to Sequence later.

Compared to Dmitri's prototype, Nodes.td looks more like a class hierarchy and
less like a grammar. (E.g. variants list the Alternatives parent rather than
vice versa).
The main reasons for this:
 - the hierarchy is an important part of the API we want direct control over.
   - e.g. we may introduce abstract bases like "loop" that the grammar doesn't
     care about in order to model is-a concepts that might make refactorings
     more expressive. This is less natural in a grammar-like idiom.
   - e.g. we're likely to have to model some alternatives as variants and others
     as class hierarchies, the choice will probably be based on natural is-a
     relationships.
 - it reduces the cognitive load of switching from editing *.td to working with
   code that uses the generated classes

Differential Revision: https://reviews.llvm.org/D90543
2020-11-11 12:39:43 +01:00
Krasimir Georgiev 77b4841169 [clang-format] do not break before @tags in JS comments
In JavaScript breaking before a `@tag` in a comment puts it on a new line, and
machinery that parses these comments will fail to understand such comments.

This adapts clang-format to not break before `@`. Similar functionality exists
for not breaking before `{`.

Reviewed By: mprobst

Differential Revision: https://reviews.llvm.org/D91078
2020-11-11 12:27:15 +01:00
Sam McCall 454579e46a Reland [Syntax] Add minimal TableGen for syntax nodes. NFC
This reverts commit 09c6259d6d.
(Fixed side-effecting code being buried in an assert)
2020-11-11 11:24:47 +01:00
Faisal Vali e4d27932a5 [NFC, Refactor] Rename the (scoped) enum DeclaratorContext's enumerators to remove duplication
Since these are scoped enumerators, they have to be prefixed by DeclaratorContext, so lets remove Context from the name, and return some characters to the multiverse.

Patch was reviewed here: https://reviews.llvm.org/D91011

Thank you to aaron, bruno, wyatt and barry for indulging me.
2020-11-10 23:40:12 -06:00
Roland McGrath cf36142d34 [clang] Add missing header guard in <cpuid.h>
This header has long lacked a standard multiple inclusion guard
like other headers have, for no apparent reason.  The GCC header
of the same name likewise lacks one up through release 10.1, but
trunk GCC (release 11, and perhaps future 10.x) has fixed it
(see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96238).

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D91226
2020-11-10 19:34:25 -08:00
Akira Hatanaka d9258a21f0 Fix the data layout mangling specification for 'arm64-pc-win32-macho'
rdar://problem/70410504
2020-11-10 18:52:12 -08:00
Richard Smith c6d86b6b45 Properly collect template arguments from a class-scope function template
specialization.

Fixes a crash-on-valid if further template parameters are introduced
within the specialization (by a generic lambda).
2020-11-10 15:55:19 -08:00
Stephen Kelly 872633b285 Add utility for testing if we're matching nodes AsIs
Differential Revision: https://reviews.llvm.org/D91144
2020-11-10 23:32:30 +00:00
Richard Smith c43f8c7728 Add PrintingPolicy overload to APValue::printPretty. NFC. 2020-11-10 14:48:56 -08:00
Stephen Kelly ed2baaac56 Revert "Add utility for testing if we're matching nodes AsIs"
This reverts commit e73296d3b9.

This may have caused build bot failure.
2020-11-10 22:29:58 +00:00
Akira Hatanaka 874b0a0b9d [CodeGen] Mark calls to objc_autorelease as tail
This enables a method sending an autorelease message to an object and
returning the object in MRR to avoid adding the object to an autorelease
pool if a call to objc_retainAutoreleasedReturnValue in the caller
function accepts the hand off of the retain count.

rdar://problem/50678052

Differential Revision: https://reviews.llvm.org/D91111
2020-11-10 13:48:25 -08:00
Xun Li 19f0770923 [Coroutine][Sema] Cleanup temporaries as early as possible
The original bug was discovered in T75057860. Clang front-end emits an AST that looks like this for an co_await expression:
|- ExprWithCleanups
  |- -CoawaitExpr
    |- -MaterializeTemporaryExpr ... Awaiter
      ...
    |- -CXXMemberCallExpr ... .await_ready
      ...
    |- -CallExpr ... __builtin_coro_resume
      ...
    |- -CXXMemberCallExpr ... .await_resume
      ...

ExprWithCleanups is responsible for cleaning up (including calling dtors) for the temporaries generated in the wrapping expression).
In the above structure, the __builtin_coro_resume part (which corresponds to the code for the suspend case in the co_await with symmetric transfer), the pseudocode looks like this:
  __builtin_coro_resume(
   awaiter.await_suspend(
     from_address(
       __builtin_coro_frame())).address());

One of the temporaries that's generated as part of this code is the coroutine handle returned from awaiter.await_suspend() call. The call returns a handle  which is a prvalue (since it's a returned value on the fly). In order to call the address() method on it, it needs to be converted into an xvalue. Hence a materialized temp is created to hold it. This temp will need to be cleaned up eventually. Now, since all cleanups happen at the end of the entire co_await expression, which is after the <coro.suspend> suspension point, the compiler will think that such a temp needs to live across suspensions, and need to be put on the coroutine frame, even though it's only used temporarily just to call address() method.
Such a phenomena not only unnecessarily increases the frame size, but can lead to ASAN failures, if the coroutine was already destroyed as part of the await_suspend() call. This is because if the coroutine was already destroyed, the frame no longer exists, and one can not store anything into it. But if the temporary object is considered to need to live on the frame, it will be stored into the frame after await_suspend() returns.

A fix attempt was done in https://reviews.llvm.org/D87470. Unfortunately it is incorrect. The reason is that cleanups in Clang works more like linearly than nested. There is one current state indicating whether it needs cleanup, and an ExprWithCleanups resets that state. This means that an ExprWithCleanups must be capable of cleaning up all temporaries created  in the wrapping expression, otherwise there will be dangling temporaries cleaned up at the wrong place.
I eventually found a walk-around (https://reviews.llvm.org/D89066) that doesn't break any existing tests while fixing the issue. But it targets the final co_await only. If we ever have a co_await that's not on the final awaiter and the frame gets destroyed after suspend, we are in trouble. Hence we need a proper fix.

This patch is the proper fix. It does the folllowing things to fully resolve the issue:
1. The AST has to be generated in the order according to their nesting relationship. We should not generate AST out of order because then the code generator would incorrectly track the state of temporaries and when a cleanup is needed. So the code in buildCoawaitCalls is reorganized so that we will be generating the AST for each coawait member call in order along with their child AST.
2. await_ready() call is wrapped with an ExprWithCleanups so that temporaries in it gets cleaned up as early as possible to avoid living across suspension.
3. await_suspend() call is wrapped with an ExprWithCleanups if it's not a symmetric transfer. In the case of a symmetric transfer, in order to maintain the musttail call contract, the ExprWithCleanups is wraaped before the resume call.
4. In the end, we mark again that it needs a cleanup, so that the entire CoawaitExpr will be wrapped with a ExprWithCleanups which will clean up the Awaiter object associated with the await expression.

Differential Revision: https://reviews.llvm.org/D90990
2020-11-10 13:27:42 -08:00
Richard Smith 438a27f2e5 Move code to determine the type of an LValueBase out of ExprConstant and
into a member function on LValueBase. NFC.
2020-11-10 13:03:57 -08:00
Yang Fan 703038b35a [Sema] Fix volatile check when testing if a return object can be implicitly moved
In C++11 standard, to become implicitly movable, the expression in return
statement should be a non-volatile automatic object. CWG1579 changed the rule
to require that the expression only needs to be an automatic object. C++14
standard and C++17 standard kept this rule unchanged. C++20 standard changed
the rule back to require the expression be a non-volatile automatic object.
This should be a typo in standards, and VD should be non-volatile.

Differential Revision: https://reviews.llvm.org/D88295
2020-11-10 15:11:07 -05:00
Stephen Kelly e73296d3b9 Add utility for testing if we're matching nodes AsIs
Differential Revision: https://reviews.llvm.org/D91144
2020-11-10 19:28:11 +00:00
Haojian Wu 7d85f732b1 Fix the DeclContextLookupResult::iterator non-copyable.
The value_type is a const pointer, which makes the iteator non-copyable.
Before the patch, the normal usage like below was illegal:

```
auto It = lookupresult.begin();
...
It = lookupresult.end(); // the copy is not allowed.
```

Differential Revision: https://reviews.llvm.org/D91158
2020-11-10 20:22:45 +01:00
Alexandre Rames 58c586e701 Allow searching for prebuilt implicit modules.
This reverts commit c67656b994, and addresses the
build issue.
2020-11-10 10:14:13 -08:00
Simon Pilgrim defc59734a Add a llvm_unreachable to fix MSVC unhandled enum warning. NFCI. 2020-11-10 10:43:45 +00:00
Martin Probst 16212b8b3e clang-format: [JS] support new assignment operators.
Before:

    a && = b;

After:

    a &&= b;

These operators are new additions in ES2021.

Differential Revision: https://reviews.llvm.org/D91132
2020-11-10 09:26:46 +01:00
David Blaikie 724877e219 Roll otherwise-unused variable into assert 2020-11-09 23:27:47 -08:00
Richard Smith b637148ecb [c++20] For P0732R2 / P1907R1: Basic code generation and name
mangling support for non-type template parameters of class type and
template parameter objects.

The Itanium side of this follows the approach I proposed in
https://github.com/itanium-cxx-abi/cxx-abi/issues/47 on 2020-09-06.

The MSVC side of this was determined empirically by observing MSVC's
output.

Differential Revision: https://reviews.llvm.org/D89998
2020-11-09 22:10:27 -08:00
Haowei Wu d93287cac8 [scan-build] Supprot relative 'file' in cdb.
Excluded folders in scan build is turned to absolute path before
comapre to 'file' in cdb. 'file' in cdb might be a path relative
to 'directory', so we need to turn it to absolute path before
comparison.

Patch by Yu Shan

Differential Revision: https://reviews.llvm.org/D90362
2020-11-09 20:06:20 -08:00
Qiu Chaofan 979a4d268a [PowerPC] [Clang] Port SSE4.1-compatible insert intrinsics
This patch adds three intrinsics compatible to x86's SSE 4.1 on PowerPC
target, with tests:

- _mm_insert_epi8
- _mm_insert_epi32
- _mm_insert_epi64

The intrinsics implementation is contributed by Paul Clarke.

Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D89242
2020-11-10 10:52:13 +08:00
Michael Kruse e5dba2d7e5 [OMPIRBuilder] Start 'Create' methods with lower case. NFC.
For consistency with the IRBuilder, OpenMPIRBuilder has method names starting with 'Create'. However, the LLVM coding style has methods names starting with lower case letters, as all other OpenMPIRBuilder already methods do. The clang-tidy configuration used by Phabricator also warns about the naming violation, adding noise to the reviews.

This patch renames all `OpenMPIRBuilder::CreateXYZ` methods to `OpenMPIRBuilder::createXYZ`, and updates all in-tree callers.

I tested check-llvm, check-clang, check-mlir and check-flang to ensure that I did not miss a caller.

Reviewed By: mehdi_amini, fghanim

Differential Revision: https://reviews.llvm.org/D91109
2020-11-09 19:35:11 -06:00
Jan Svoboda dbfa69c502 Port some floating point options to new option marshalling infrastructure
This ports a number of OpenCL and fast-math flags for floating point
over to the new marshalling infrastructure.

As part of this, `Opt{In,Out}FFlag` were enhanced to allow other flags to
imply them, via `DefaultAnyOf<>`. For example:
```
defm signed_zeros : OptOutFFlag<"signed-zeros", ...,
  "LangOpts->NoSignedZero",
  DefaultAnyOf<[cl_no_signed_zeros, menable_unsafe_fp_math]>>;
```
defines `-fsigned-zeros` (`false`) and `-fno-signed-zeros` (`true`)
linked to the keypath `LangOpts->NoSignedZero`, defaulting to `false`,
but set to `true` implicitly if one of `-cl-no-signed-zeros` or
`-menable-unsafe-fp-math` is on.

Note that the initial patch was written Daniel Grumberg.

Differential Revision: https://reviews.llvm.org/D82756
2020-11-09 18:00:10 -05:00
Sam McCall 09c6259d6d Revert "[Syntax] Add minimal TableGen for syntax nodes. NFC"
This reverts commit 55120f74ca.

Segfaults during build:
http://lab.llvm.org:8011/#/builders/36/builds/1310
2020-11-09 23:59:11 +01:00
Sam McCall 55120f74ca [Syntax] Add minimal TableGen for syntax nodes. NFC
So far, only used to generate Kind and implement classof().

My plan is to have this general-purpose Nodes.inc in the style of AST
DeclNodes.inc etc, and additionally a special-purpose backend generating
the actual class definitions. But baby steps...

Differential Revision: https://reviews.llvm.org/D90540
2020-11-09 23:45:50 +01:00
Kirill Bobyrev 142c6f82fd
[clang] Simplify buildSyntaxTree API
Follow-up on https://reviews.llvm.org/D88553#inline-837013

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D90672
2020-11-09 22:49:54 +01:00
Duncan P. N. Exon Smith c56ec7bede Tooling: Remove dead code for ToolingInvocation::mapVirtualFile
Follows through on c4cb3b10dc8c50e46c9fb1b7ae95e3c3c94975d3's FIXME
dating back to 2015. Anyone using this should migrate to
InMemoryFileSystem and/or ClangTool::mapVirtualFile.

Differential Revision: https://reviews.llvm.org/D90885
2020-11-09 15:45:35 -05:00
Stephen Kelly 23f17ab5ff Fix use of directly-nested traverse() matchers 2020-11-09 19:23:17 +00:00
Stephen Kelly 121d51dc83 Fix trailing whitespace
My editor keeps on changing this and I keep having to revert it.
2020-11-09 19:12:38 +00:00
Stephen Kelly 8f354711ae Change algorithms to return iterators
Make it possible to inspect the matched node, possibly to ignore it.

Differential Revision: https://reviews.llvm.org/D90983
2020-11-09 19:12:38 +00:00
Fangrui Song e625f9c5d1 -fbasic-block-sections=list=: Suppress output if failed to open the file
Reviewed By: tmsriram

Differential Revision: https://reviews.llvm.org/D90815
2020-11-09 09:26:37 -08:00
Atmn Patel fd3cad7a60 [clang] Fix ForStmt mustprogress handling
D86841 had an error where for statements with no conditional were
required to make progress. This is not true, this patch removes that
line, and adds regression tests.

Differential Revision: https://reviews.llvm.org/D91075
2020-11-09 11:38:06 -05:00
Tyker d093401a26 [NFC] Remove string parameter of annotation attribute from AST childs.
this simplifies using annotation attributes when using clang as library
2020-11-09 16:39:59 +01:00
Krasimir Georgiev 7b7170fa57 [clang-format] avoid introducing multiline comments
In C++ with -Werror=comment, multiline comments are not allowed.
clang-format could accidentally introduce multiline comments when reflowing.
This adapts clang-format to not introduce multiline comments by not allowing a
break after `\`. Note that this does not apply to comment lines that already are
multiline comments, such as comments in macros.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D90949
2020-11-09 15:29:09 +01:00
Lucas Prates c2c2cc1360 [ARM][AArch64] Adding Neoverse V1 CPU support
Add support for the Neoverse V1 CPU to the ARM and AArch64 backends.

This is based on patches from Mark Murray and Victor Campos.

Reviewed By: dmgreen

Differential Revision: https://reviews.llvm.org/D90765
2020-11-09 13:15:40 +00:00
Hubert Tong 09fc7796e5 [NFC][tests] Replace use of GNUisms in usage of diff
... the POSIX options suffice.

This maintains compatibility with the system `diff` on platforms
like AIX.
2020-11-08 12:07:51 -05:00
Simon Pilgrim 8930032f53 Don't dereference a dyn_cast<> result - use cast<> instead. NFCI.
We were relying on the dyn_cast<> succeeding - better use cast<> and have it assert that its the correct type than dereference a null result.
2020-11-08 13:06:07 +00:00
Arthur Eubanks 226e179f74 Revert "[NewPM] Provide method to run all pipeline callbacks, used for -O0"
This reverts commit ae38540042.
As well as some follow-up test fixes.

The original change causes new-pass-manager.ll to fail when polly is enabled.
2020-11-08 00:32:35 -08:00
Stephen Kelly 4eb880439a Fix dumping of explicit template specializations
This was missing from commit 7efe07a1 (Traverse-ignore explicit template
instantiations, 2020-11-06).
2020-11-07 22:34:16 +00:00
Melanie Blower c511963d5a [clang] Fix length threshold for MicrosoftMangle md5 hash
Reviewers: rnk, dblaikie

Differential Revision: https://reviews.llvm.org/D90714
2020-11-07 07:40:24 -08:00
Melanie Blower b0de3f6787 [clang] Improve Microsoft mangling lit test with dblaikie's suggestions 2020-11-07 07:32:34 -08:00
Fangrui Song d2da05de7c [test] Fix Other/new-pass-manager.ll & clang/test/Misc/loop-opt-setup.c 2020-11-06 21:55:11 -08:00
Atmn Patel d3e75d31e3 Revert "[CodeGen] Fixes sanitizer test"
This reverts commit b1878b4641. This does
fix the test but it means that ac73b73c16 is not implemented
correctly. Reverting for now, and will be reverting the commit that
causes this to fail.
2020-11-07 00:32:12 -05:00
Atmn Patel b1878b4641 [CodeGen] Fixes sanitizer test
By turning the loop into an infinite one, the loop can't be deleted
anymore so the test will continue to pass.
2020-11-06 23:53:38 -05:00
Fangrui Song f2e479db92 [OpenMP] Fix -Wmisleading-indentation after D84192 2020-11-06 20:09:43 -08:00
Atmn Patel 569abb530e [LoopDeletion] Fixes failing test
The commit 0b17c6e447 occasionally causes this test to
fail, this fixes it.
2020-11-06 22:45:28 -05:00
Atmn Patel 0b17c6e447 [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-11-06 22:06:58 -05:00
cchen 0cab91140f [OpenMP5.0] map item can be non-contiguous for target update
In order not to modify the `tgt_target_data_update` information but still be
able to pass the extra information for non-contiguous map item (offset,
count, and stride for each dimension), this patch overload `arg` when
the maptype is set as `OMP_MAP_DESCRIPTOR`. The origin `arg` is for
passing the pointer information, however, the overloaded `arg` is an
array of descriptor_dim:

struct descriptor_dim {
  int64_t offset;
  int64_t count;
  int64_t stride
};

and the array size is the same as dimension size. In addition, since we
have count and stride information in descriptor_dim, we can replace/overload the
`arg_size` parameter by using dimension size.

For supporting `stride` in array section, we use a dummy dimension in
descriptor to store the unit size. The formula for counting the stride
in dimension D_n: `unit size * (D_0 * D_1 ... * D_n-1) * D_n.stride`.

Demonstrate how it works:
```
double arr[3][4][5];

D0: { offset = 0, count = 1, stride = 8 }                                // offset, count, dimension size always be 0, 1, 1 for this extra dimension, stride is the unit size
D1: { offset = 0, count = 2, stride = 8 * 1 * 2 = 16 }                   // stride = unit size * (product of dimension size of D0) * D1.stride = 4 * 1 * 2 = 8
D2: { offset = 2, count = 2, stride = 8 * (1 * 5) * 1 = 40  }            // stride = unit size * (product of dimension size of D0, D1) * D2.stride = 4 * 5 * 1 = 20
D3: { offset = 0, count = 2, stride = 8 * (1 * 5 * 4) * 2 = 320 }        // stride = unit size * (product of dimension size of D0, D1, D2) * D3.stride = 4 * 25 * 2 = 200

// X here means we need to offload this data, therefore, runtime will transfer
// data from offset 80, 96, 120, 136, 400, 416, 440, 456
// Runtime patch: https://reviews.llvm.org/D82245
// OOOOO OOOOO OOOOO
// OOOOO OOOOO OOOOO
// XOXOO OOOOO XOXOO
// XOXOO OOOOO XOXOO
```

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D84192
2020-11-06 21:04:37 -06:00
Elvina Yakubova c9ca3a3c66 [AArch64] Add driver tests for HiSilicon's TSV110 2020-11-07 01:51:37 +03:00
Stephen Kelly 0d6e1251d7 Add new matchers for dependent names in templates
Differential Revision: https://reviews.llvm.org/D90767
2020-11-06 21:03:20 +00:00
Kevin P. Neal 2069403cdf [FPEnv] Use strictfp metadata in casting nodes
The strictfp metadata was added to the casting AST nodes in D85960, but
we aren't using that metadata yet. This patch adds that support.

In order to avoid lots of ad-hoc passing around of the strictfp bits I
updated the IRBuilder when moving from a function that has the Expr* to a
function that lacks it. I believe we should switch to this pattern to keep
the strictfp support from being overly invasive.

For the purpose of testing that we're picking up the right metadata, I
also made my tests use a pragma to make the AST's strictfp metadata not
match the global strictfp metadata. This exposes issues that we need to
deal with in subsequent patches, and I believe this is the right method
for most all of our clang strictfp tests.

Differential Revision: https://reviews.llvm.org/D88913
2020-11-06 11:56:12 -05:00
Balazs Benics aa0dc1c3b8 [analyzer][NFCi] Mark CallEvent::getOriginExpr virtual, some cleanup
Previously we just shadowed the original implementation with a virtual
declaration - which is really bugprone in a long run.

This patch marks `CallEvent::getOriginExpr` virtual to let subclasses
override it's behavior.
At the same time, I checked all virtual functions of this class hierarchy
to make sure we don't suffer from this elsewhere.
Removes redundant declarations of `virtual` if `override` is already present.

In theory, this patch is a functional change, but no tests were broken.
I suspect that there were no meaningful changes in behavior in the
subclasses compared to the shadowed `CallEvent::getOriginExpr`.

That being said, I had a hard time coming up with unit-tests covering this.
Motivation: https://reviews.llvm.org/D74735#2370909

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D90754
2020-11-06 16:51:34 +01:00
Stephen Kelly 7efe07a12b Traverse-ignore explicit template instantiations
Continue to dump and match on explicit template specializations, but
omit explicit instantiation declarations and definitions.

Differential Revision: https://reviews.llvm.org/D90763
2020-11-06 15:25:59 +00:00
David Spickett aecd52b97b [Clang][AArch64] Remove unused prefix in constrained rounding test
This test was added in 7f38812d5b
and all the other tests make use of the COMMONIR check. So I think
this was left in by mistake for this particular test.

Reviewed By: kpn

Differential Revision: https://reviews.llvm.org/D90921
2020-11-06 14:13:46 +00:00
Krasimir Georgiev 2dbcbd357d [clang-format] do not break before { in JS comments
In JavaScript some @tags can be followed by `{`, and machinery that parses
these comments will fail to understand the comment if followed by a line break.

clang-format already handles this case by not breaking before `{` in comments.
However this was not working in cases when the column limit falls within `@tag`
or between `@tag` and `{`. This adapts clang-format for this case.

Reviewed By: mprobst

Differential Revision: https://reviews.llvm.org/D90908
2020-11-06 10:34:10 +01:00
Freddy Ye 5e312e0041 [X86] use macros to split GFNI intrinsics into different kinds
Tremont microarchitecture only has GFNI(SSE) version, not AVX and
AVX512 version. This patch is to avoid compiling fail on Windows when
using -march=tremont to invoke one of GFNI(SSE) intrinsic.

Differential Revision: https://reviews.llvm.org/D90822
2020-11-06 16:03:38 +08:00
Fangrui Song 247c5b5d69 [test] Properly test -Werror-implicit-function-declaration and -Wvec-elem-size
Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D90874
2020-11-05 20:08:23 -08:00
Stella Stamenova c67656b994 Revert "Allow searching for prebuilt implicit modules."
This reverts commit 71e108cd86.

This change caused a build failure on Windows:
http://lab.llvm.org:8011/#/builders/83/builds/570
2020-11-05 17:16:14 -08:00
Stanislav Mekhanoshin 4fcdfc4398 [AMDGPU] Simplify amdgpu-macros.cl test. NFC.
Differential Revision: https://reviews.llvm.org/D90886
2020-11-05 16:29:16 -08:00
Michael Liao 23c6d1501d [amdgpu] Add `llvm.amdgcn.endpgm` support.
- `llvm.amdgcn.endpgm` is added to enable "abort" support.

Differential Revision: https://reviews.llvm.org/D90809
2020-11-05 19:06:50 -05:00
Saleem Abdulrasool e55157874c APINotes: repair the Windows builders
Disable the test on Windows, which should've been obvious as being
needed.  The differences in diff implementations and line-endings make
this test difficult to execute on Windows.
2020-11-05 21:25:52 +00:00
Alexandre Rames 71e108cd86 Allow searching for prebuilt implicit modules.
The behavior is controlled by the `-fprebuilt-implicit-modules` option, and
allows searching for implicit modules in the prebuilt module cache paths.

The current command-line options for prebuilt modules do not allow to easily
maintain and use multiple versions of modules. Both the producer and users of
prebuilt modules are required to know the relationships between compilation
options and module file paths. Using a particular version of a prebuilt module
requires passing a particular option on the command line (e.g.
`-fmodule-file=[<name>=]<file>` or `-fprebuilt-module-path=<directory>`).

However the compiler already knows how to distinguish and automatically locate
implicit modules. Hence this proposal to introduce the
`-fprebuilt-implicit-modules` option. When set, it enables searching for
implicit modules in the prebuilt module paths (specified via
`-fprebuilt-module-path`). To not modify existing behavior, this search takes
place after the standard search for prebuilt modules. If not

Here is a workflow illustrating how both the producer and consumer of prebuilt
modules would need to know what versions of prebuilt modules are available and
where they are located.

  clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v1 <config 1 options>
  clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v2 <config 2 options>
  clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules_v3 <config 3 options>

  clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules_v1 <config 1 options>
  clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap <non-prebuilt config options>

With prebuilt implicit modules, the producer can generate prebuilt modules as
usual, all in the same output directory. The same mechanisms as for implicit
modules take care of incorporating hashes in the path to distinguish between
module versions.

Note that we do not specify the output module filename, so `-o` implicit modules are generated in the cache path `prebuilt_modules`.

  clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 1 options>
  clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 2 options>
  clang -cc1 -x c modulemap -fmodules -emit-module -fmodule-name=foo -fmodules-cache-path=prebuilt_modules <config 3 options>

The user can now simply enable prebuilt implicit modules and point to the
prebuilt modules cache. No need to "parse" command-line options to decide
what prebuilt modules (paths) to use.

  clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules -fprebuilt-implicit-modules <config 1 options>
  clang -cc1 -x c use.c -fmodules fmodule-map-file=modulemap -fprebuilt-module-path=prebuilt_modules -fprebuilt-implicit-modules <non-prebuilt config options>

This is for example particularly useful in a use-case where compilation is
expensive, and the configurations expected to be used are predictable, but not
controlled by the producer of prebuilt modules. Modules for the set of
predictable configurations can be prebuilt, and using them does not require
"parsing" the configuration (command-line options).

Reviewed By: Bigcheese

Differential Revision: https://reviews.llvm.org/D68997
2020-11-05 13:10:53 -08:00
Jan Ole Hüser d2e7dca5ca [CodeGen] Fix Bug 47499: __unaligned extension inconsistent behaviour with C and C++
For the language C++ the keyword __unaligned (a Microsoft extension) had no effect on pointers.

The reason, why there was a difference between C and C++ for the keyword __unaligned:
For C, the Method getAsCXXREcordDecl() returns nullptr. That guarantees that hasUnaligned() is called.
If the language is C++, it is not guaranteed, that hasUnaligend() is called and evaluated.

Here are some links:

The Bug: https://bugs.llvm.org/show_bug.cgi?id=47499
Thread on the cfe-dev mailing list: http://lists.llvm.org/pipermail/cfe-dev/2020-September/066783.html
Diff, that introduced the check hasUnaligned() in getNaturalTypeAlignment(): https://reviews.llvm.org/D30166

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D90630
2020-11-05 12:57:17 -08:00
Albion Fung 1af037f643 [PowerPC] Correct cpsgn's behaviour on PowerPC to match that of the ABI
This patch fixes the reversed behaviour exhibited by cpsgn on PPC. It now matches the ABI.

Differential Revision: https://reviews.llvm.org/D84962
2020-11-05 15:35:14 -05:00
Nico Weber b69af88481 [gn build] (manually) port 82f86ae01 2020-11-05 14:11:26 -05:00
Saleem Abdulrasool 82f86ae01a APINotes: add APINotesYAMLCompiler
This adds the skeleton of the YAML Compiler for APINotes.  This change
only adds the YAML IO model for the API Notes along with a new testing
tool `apinotes-test` which can be used to verify that can round trip the
YAML content properly.  It provides the basis for the future work which
will add a binary serialization and deserialization format to the data
model.

This is based on the code contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.

Differential Revision: https://reviews.llvm.org/D88859
Reviewed By: Gabor Marton
2020-11-05 18:55:13 +00:00
Fangrui Song c6a384df1f [Sema] Special case -Werror-implicit-function-declaration and reject other -Werror-
This is the only -Werror- form warning option GCC supports (gcc/c-family/c.opt).
Fortunately no other form is used anywhere.
2020-11-05 10:25:30 -08:00
Erich Keane 6b104ea4b4 Implement Lambda Conversion Operators for All CCs for MSVC.
As described here:
https://devblogs.microsoft.com/oldnewthing/20150220-00/?p=44623

In order to allow Lambdas to be used with traditional Win32 APIs, they
emit a conversion function for (what Raymond Chen claims is all) a
number of the calling conventions.  Through experimentation, we
discovered that the list isn't quite 'all'.

This patch implements this by taking the list of conversions that MSVC
emits (across 'all' architectures, I don't see any CCs on ARM), then
emits them if they are supported by the current target.

However, we also add 3 other options (which may be duplicates):
free-function, member-function, and operator() calling conventions.  We
do this because we have an extension where we generate both free and
member for these cases so th at people specifying a calling convention
on the lambda will have the expected behavior when specifying one of
those two.

MSVC doesn't seem to permit specifying calling-convention on lambdas,
but we do, so we need to make sure those are emitted as well. We do this
so that clang-only conventions are supported if the user specifies them.

Differential Revision: https://reviews.llvm.org/D90634
2020-11-05 07:25:44 -08:00
Raphael Isemann 659f4bd87e [clang] Add an option for hiding line numbers in diagnostics
Clang offers a `-f[no]-show-column` flag for hiding the column numbers when
printing diagnostics but there is no option for doing the same with line
numbers.

In LLDB having this option would be useful, as LLDB sometimes only knows the
file name for a SourceLocation and just assigns it the dummy line/column `1:1`.
These fake line/column numbers are confusing to the user and LLDB should be able
to tell clang to hide *both* the column and the line number when rendering text
diagnostics.

This patch adds a flag for also hiding the line numbers. It's not exposed via
the command line flags as it's most likely not very useful for any user and can
lead to ambiguous output when the user decides to only hide either the line or
the column number (where `file:1: ...` could now refer to both line 1 or column
1 depending on the compiler flags). LLDB can just access the DiagnosticOptions
directly when constructing its internal Clang instance.

The effect doesn't apply to Vi/MSVC style diagnostics because it's not defined
how these diagnostic styles would show an omitted line number (MSVC doesn't have
such an option and Vi's line mode is theory only supporting line numbers if I
understand it correctly).

Reviewed By: thakis, MaskRay

Differential Revision: https://reviews.llvm.org/D83038
2020-11-05 16:10:18 +01:00
Sven van Haastregt 8ac9bcc746 [OpenCL] Support vec_step in C++ for OpenCL mode
Enable the vec_step builtin in C++ for OpenCL mode for compatibility
with OpenCL C.

Differential Revision: https://reviews.llvm.org/D90766
2020-11-05 12:02:59 +00:00
Eduardo Caldas 23657d9cc3 [SyntaxTree] Add reverse links to syntax Nodes.
Rationale:
Children of a syntax tree had forward links only, because there was no
need for reverse links.

This need appeared when we started mutating the syntax tree.
On a forward list, to remove a target node in O(1) we need a pointer to the node before the target. If we don't have this "before" pointer, we have to find it, and that requires O(n).
So in order to remove a syntax node from a tree, we would similarly need to find the node before to then remove. This is both not ergonomic nor does it have a good complexity.

Differential Revision: https://reviews.llvm.org/D90240
2020-11-05 09:33:53 +00:00
Arthur Eubanks 5fd3193c88 [test] Add 'REQUIRES: bpf-registered-target' to bpf-O0.c 2020-11-04 23:19:14 -08:00
Arthur Eubanks ae38540042 [NewPM] Provide method to run all pipeline callbacks, used for -O0
Some targets may add required passes via
    TargetMachine::registerPassBuilderCallbacks(). We need to run those even
    under -O0. As an example, BPFTargetMachine adds
    BPFAbstractMemberAccessPass, a required pass.

    This also allows us to clean up BackendUtil.cpp (and out-of-tree Rust
    usage of the NPM) by allowing us to share added passes like coroutines
    and sanitizers between -O0 and other optimization levels.

    Tests are a continuation of those added in
    https://reviews.llvm.org/D89083.

    In order to prevent TargetMachines from adding unnecessary optimization
    passes at -O0, TargetMachine::registerPassBuilderCallbacks() will be
    changed to take an OptimizationLevel, but that will be done separately.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D89158
2020-11-04 22:27:16 -08:00
Serge Pavlov 20b4f4f760 [Driver] Add callback to Command execution
Summary:
Object of type `Compilation` now can keep a callback that is called
after each execution of `Command`. This must simplify adaptation of
clang in custom distributions and allow facilities like collection of
execution statistics.

Reviewers: rsmith, rjmccall, Eugene.Zelenko

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D78899
2020-11-05 12:21:40 +07:00
Atmn Patel ac73b73c16 [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction
Since C++11, the C++ standard has a forward progress guarantee
[intro.progress], so all such functions must have the `mustprogress`
requirement. In addition, from C11 and onwards, loops without a non-zero
constant conditional or no conditional are also required to make
progress (C11 6.8.5p6). This patch implements these attribute deductions
so they can be used by the optimization passes.

Differential Revision: https://reviews.llvm.org/D86841
2020-11-04 22:03:14 -05:00
Baptiste Saleil f976ba6139 [PowerPC] Add Sema checks for MMA types
The use of the new types introduced for PowerPC MMA instructions needs to be restricted.
We add a PowerPC function checking that the given type is valid in a context in which we don't allow MMA types.
This function is called from various places in Sema where we want to prevent the use of these types.

Differential Revision: https://reviews.llvm.org/D82035
2020-11-04 17:01:47 -06:00
Duncan P. N. Exon Smith 6e73cfa836 Basic: Change Module::Umbrella to a PointerUnion, NFC
Change `Module::Umbrella` from a `const void *` to a `PointerUnion` of
`FileEntry` and `DirectoryEntry`. We can drop the `HasUmbrellaDir` bit
(since `PointerUnion` includes that).

This change makes it safer to update to `FileEntryRef` and
`DirectoryEntryRef` in a future patch.

Differential Revision: https://reviews.llvm.org/D90481
2020-11-04 16:19:39 -05:00
Arthur Eubanks ab0ddbc38a Reland [NewPM] Add OptimizationLevel param to registerPipelineStartEPCallback
This allows targets to skip optional optimization passes at -O0.

Reviewed By: ychen

Differential Revision: https://reviews.llvm.org/D90777
2020-11-04 13:11:40 -08:00
Duncan P. N. Exon Smith 77a9e0a4af Basic: Split out DirectoryEntry.h, NFC
Move `DirectoryEntry` and `DirectoryEntryRef` into their own header,
similar to the creation of FileEntry.h. No functionality change here,
just preparing to include it in more places to allow wider adoption of
`DirectoryEntryRef` without requiring all of `FileManager.h`.

Differential Revision: https://reviews.llvm.org/D90478
2020-11-04 14:11:57 -05:00
cchen d0d43b58b1 [OpenMP] target nested `use_device_ptr() if()` and is_device_ptr trigger asserts
Clang now asserts for the below case:
```
void clang::CodeGen::CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata(): Assertion `std::get<0>(E) && "All ordered entries must exist!"' failed.
```

The reason why Clang hit the assert is because in
`emitTargetDataCalls`, both `BeginThenGen` and `BeginElseGen` call
`registerTargetRegionEntryInfo` and try to register the Entry in
OffloadEntriesTargetRegion with same key. If changing the expression in
if clause to any constant expression, then the assert disappear. (https://godbolt.org/z/TW7haj)

The assert itself is to avoid
user from accessing elements out of bound inside `OrderedEntries` in
`createOffloadEntriesAndInfoMetadata`.

In this patch, I add a check in `registerTargetRegionEntryInfo` to avoid
register the target region more than once.

A test case that triggers assert: https://godbolt.org/z/4cnGW8

Reviewed By: ABataev

Differential Revision: https://reviews.llvm.org/D90704
2020-11-04 12:36:57 -06:00
etiotto 7e2edf973b [compiler-rt][AIX]: Link compiler-rt profile library when -fprofile-generate is specified
This patch enhances the clang driver to link the runtime profile
library on AIX when the -fprofile-generate option is used.

Reviewed By: phosek

Differentail Revision: https://reviews.llvm.org/D90641
2020-11-04 09:54:54 -05:00
Qiu Chaofan 7faf62a80b [Clang] Add more fp128 math library function builtins
Since glibc has supported math library functions conforming IEEE 128-bit
floating point types on some platform (like ppc64le), we can fix clang's
math builtins missing this type.

Reviewed By: bkramer

Differential Revision: https://reviews.llvm.org/D90593
2020-11-04 17:58:42 +08:00
Richard Smith 09b54e2799 When re-checking an already-substituted template argument, don't lose
the reference-ness of the parameter's type.
2020-11-03 14:09:54 -08:00
Matt Morehouse a6d15d4070 Undo Revert "Ignore template instantiations if not in AsIs mode"
MaskRay already fixed the ASan bug.
2020-11-03 13:59:01 -08:00
Matt Morehouse 72531ae6e6 Revert "Ignore template instantiations if not in AsIs mode"
This reverts commit 53df3beb62 due to
check-asan failure on the buildbot.
2020-11-03 13:57:31 -08:00
Baptiste Saleil daa127d77e [PowerPC] Add MMA builtin decoding and definitions
Add MMA builtin decoding. These builtins use the new PowerPC-specific types __vector_pair and __vector_quad.
So to avoid pervasive changes, we use custom type descriptors and custom decoding for these builtins.
We also use custom code generation to expand builtin calls with pointers to simpler intrinsic calls with non-pointer types.

Differential Revision: https://reviews.llvm.org/D81748
2020-11-03 15:08:46 -06:00
Fangrui Song 96ed6793b3 [unittest][TrasnformerTest] Fix asan stack-use-after-return 2020-11-03 12:34:45 -08:00
Ben Dunbobbin 7ad6010f58 Fix - [Clang] Add the ability to map DLL storage class to visibility
415f7ee883 had a silly typo introduced when I inlined some
code into a loop from its own function.

Original commit message:

For PlayStation we offer source code compatibility with
Microsoft's dllimport/export annotations; however, our file
format is based on ELF.

To support this we translate from DLL storage class to ELF
visibility at the end of codegen in Clang.

Other toolchains have used similar strategies (e.g. see the
documentation for this ARM toolchain:

https://developer.arm.com/documentation/dui0530/i/migrating-from-rvct-v3-1-to-rvct-v4-0/changes-to-symbol-visibility-between-rvct-v3-1-and-rvct-v4-0)

This patch adds the ability to perform this translation. Options
are provided to support customizing the mapping behaviour.

Differential Revision: https://reviews.llvm.org/D89970
2020-11-03 19:13:54 +00:00
Aaron En Ye Shi ca5b31502c [HIP] Math Headers to use type promotion
Similar to libcxx implementation of cmath function
overloads, use type promotion templates to determine
return types of multi-argument math functions.

Fixes: SWDEV-256825

Reviewed By: tra, yaxunl

Differential Revision: https://reviews.llvm.org/D90409
2020-11-03 18:40:26 +00:00
Artem Belevich cdbf6bfdc7 [HIP] Use argv[0] as the default choice for the Executable name.
The path produced by getMainExecutable() may not be the right one when the files are installed in
a symlinked tree and when the real location of llvm-objdump is in a different directory.

Given that clang-offload-bundler is invoked by clang, the driver already does the job figuring out
the right path (e.g. it pays attention to -no-canonical-prefixes).
Offload bundler should use it, instead of trying to figure out the path on its
own.

Differential Revision: https://reviews.llvm.org/D90436
2020-11-03 10:31:39 -08:00
Artem Belevich be86b6773b [CUDA] Allow local static variables with target attributes.
While CUDA documentation claims that such variables are not allowed[1], NVCC has
been accepting them since CUDA-10.0[2] and some headers in CUDA-11 rely on this
working.

1. https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#static-variables-function
2. https://godbolt.org/z/zsodzc

Differential Revision: https://reviews.llvm.org/D88345
2020-11-03 10:30:38 -08:00
Tim Renouf 89d41f3a2b [AMDGPU] Add gfx1033 target
Differential Revision: https://reviews.llvm.org/D90447

Change-Id: If2650fc7f31bbdd49c76e74a9ca8e3734d769761
2020-11-03 16:27:48 +00:00
Tim Renouf ee3e642627 [AMDGPU] Add gfx90c target
This differentiates the Ryzen 4000/4300/4500/4700 series APUs that were
previously included in gfx909.

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

Change-Id: Ia901a7157eb2f73ccd9f25dbacec38427312377d
2020-11-03 16:27:43 +00:00
Nathan James b091af790f
[ASTMatchers] Made isExpandedFromMacro Polymorphic
Made the isExpandedFromMacro matcher work on Stmt's, TypeLocs and Decls in line with the other macro expansion matchers.
Also tweaked it to take a `std::string` instead of a `StringRef`.
This prevents potential use-after-free bugs if the matcher is created with a string thats destroyed before the matcher finishes matching.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D90303
2020-11-03 14:36:51 +00:00
Yaxun (Sam) Liu abd8cd9199 [CUDA][HIP] Fix linkage for -fgpu-rdc
Currently for explicit template function instantiation in CUDA/HIP device
compilation clang emits instantiated kernel with external linkage
and instantiated device function with internal linkage.

This is fine for -fno-gpu-rdc since there is only one TU.

However this causes duplicate symbols for kernels for -fgpu-rdc if
the same instantiation happen in multiple TU. Or missing symbols
if a device function calls an explicitly instantiated template function
in a different TU.

To make explicit template function instantiation work for
-fgpu-rdc we need to follow the C++ linkage paradigm, i.e.
use weak_odr linkage.

Differential Revision: https://reviews.llvm.org/D90311
2020-11-03 08:07:19 -05:00