Commit Graph

93683 Commits

Author SHA1 Message Date
Fangrui Song 16524d2f1b [Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition
Many options (-fsyntax-only, -E, -S, etc) skip the link action phase which the
existing condition does not account for.

Since the code no longer specifies OPT_c, I think a single RUN line about -c
not leading to a warning is sufficient. Adding one for all of -E,
-fsyntax-only, -S would be excessive.

Reviewed By: benshi001

Differential Revision: https://reviews.llvm.org/D122553
2022-03-28 09:43:36 -07:00
Eric Li e334f044cd [libTooling] Support TransformerResult<void> in consumer callbacks
Support `TransformerResult<void>` in the consumer callback, which
allows generic code to more naturally use the `Transformer` interface
(instead of needing to specialize on `void`).

This also delete the specialization that existed within `Transformer`
itself, instead replacing it with an `std::function` adapter.

Reviewed By: ymandel

Differential Revision: https://reviews.llvm.org/D122499
2022-03-28 15:39:46 +00:00
Ranjeet Singh 4df69c1ff1 [ARM] Make testcase warning pattern match more specific
Make the warning more specific as downstream compilers could produce other warnings.

Reviewed By: tstellar

Differential Revision: https://reviews.llvm.org/D122487
2022-03-28 14:44:15 +01:00
Jake Egan f5a9b5cc12 [NFC][tests][AIX] XFAIL test for lack of visibility support
With the addition of `__attribute__((visibility("hidden")))` to the test, the test fails because AIX's current default behaviour is to ignore hidden visibility, so the expected error is not seen. This patch marks the test `XFAIL` on AIX for now.

Reviewed By: cebowleratibm

Differential Revision: https://reviews.llvm.org/D122519
2022-03-28 09:43:48 -04:00
Erich Keane 281b7eeb14 Update www_status/add test for P1972:
This seems to have been implemented/supported correctly back in Clang
10, so update the documentation and add the test from the paper.
2022-03-28 06:31:04 -07:00
Mikhail Goncharov 8a2a966520 Return -no-canonical-prefixes for riskv32/64 test
W/o -no-canonical-prefixes CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
does not match clang output for some setups.

See da62a5c661.
2022-03-28 11:23:14 +02:00
Balázs Kéri c5d83cdca4 [clang][ASTImporter] Fix a bug when importing CXXDefaultInitExpr.
The "in-class initializer" expression should be set in the field of a
default initialization expression before this expression node is created.
The `CXXDefaultInitExpr` objects are created after the AST is loaded and
at import not present in the "To" AST. And the in-class initializers of
the used fields can be missing too, these must be set at import.

This fixes a github issue #54061.

Reviewed By: martong

Differential Revision: https://reviews.llvm.org/D120824
2022-03-28 10:55:26 +02:00
Fangrui Song c0eb9b4cde Revert D121984 "[RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support"
This reverts commit ad57e10dbc and 1967fd8d5e

llvm/lib/Support/RISCVVIntrinsicUtils.cpp introduced llvm/TableGen includes,
a circular dependency https://llvm.org/docs/CodingStandards.html#library-layering
I think this particular instance is serious and should be reverted.
2022-03-28 01:17:37 -07:00
Iain Sandoe 85b1354098 [C++20][Modules][HU 5/5] Add fdirectives-only mode for preprocessing output.
When the -fdirectives-only option is used together with -E, the preprocessor
output reflects evaluation of if/then/else directives.

As such, it preserves defines and undefs of macros that are still live after
such processing.  The intent is that this output could be consumed as input
to generate considered a C++20 header unit.

We strip out any (unused) defines that come from built-in, built-in-file or
command line; these are re-added when the preprocessed source is consumed.

Differential Revision: https://reviews.llvm.org/D121099
2022-03-28 07:38:22 +01:00
Kito Cheng ad57e10dbc [RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support
This patch is split from https://reviews.llvm.org/D111617, we need those
stuffs on clang, so must moving those stuff to llvm/Support.

Reviewed By: khchen

Differential Revision: https://reviews.llvm.org/D121984
2022-03-28 14:35:28 +08:00
Florian Hahn 8b245ab41d
[Clang,TBAA] Add test cases for nested pointers and TBAA data. 2022-03-27 19:59:37 +01:00
Iain Sandoe d9cea8d3a8 [C++20][Modules][HU 4/5] Handle pre-processed header units.
We wish to support emitting a pre-processed output for an importable
header unit, that can be consumed to produce the same header units as
the original source.

This means that ee need to find the original filename used to produce
the re-preprocessed output, so that it can be assigned as the module
name.  This is peeked from the first line of the pre-processed source
when the action sets up the files.

Differential Revision: https://reviews.llvm.org/D121098
2022-03-27 09:38:06 +01:00
Iain Sandoe f8846229c4 [C++20][Modules][HU 3/5] Emit module macros for header units.
For header units we build the top level module directly from the header
that it represents and macros defined in this TU need to be emitted (when
such a definition is live at the end of the TU).

Differential Revision: https://reviews.llvm.org/D121097
2022-03-26 16:30:40 +00:00
Aaron Ballman bfa2f25d35 [C11] Correct the resulting type for an assignment expression
In C, assignment expressions result in an rvalue whose type is the type
of the lhs of the assignment after it undergoes lvalue to rvalue
conversion. lvalue to rvalue conversion in C strips all qualifiers
including _Atomic.

We used getUnqualifiedType() which does not strip the _Atomic qualifier
when we should have used getAtomicUnqualifiedType(). This corrects the
usage and adds some comments to getUnqualifiedType() to make it more
clear that it does not strip _Atomic and that's on purpose (see C11
6.2.5p27).

This addresses Issue 48742.
2022-03-26 08:03:11 -04:00
Mark de Wever c3b672a34c [Clang][doc] Fix __builtin_assume wording.
D117296 removed wording for __builtin_assume, D120205 restored the
wording, but the last sentence was only partly restored. This restores
the rest of the last sentence.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D122423
2022-03-26 13:02:40 +01:00
Iain Sandoe 0687578728 [C++20][Modules][HU 2/5] Support searching Header Units in user or system search paths.
This is support for the user-facing options to create importable header units
from headers in the user or system search paths (or to be given an absolute path).

This means that an incomplete header path will be passed by the driver and the
lookup carried out using the search paths present when the front end is run.

To support this, we introduce file fypes for c++-{user,system,header-unit}-header.
These terms are the same as the ones used by GCC, to minimise the differences for
tooling (and users).

The preprocessor checks for headers before issuing a warning for
"#pragma once" in a header build.  We ensure that the importable header units
are recognised as headers in order to avoid such warnings.

Differential Revision: https://reviews.llvm.org/D121096
2022-03-26 10:17:17 +00:00
Fangrui Song c37accf0a2 [Option] Avoid using the default argument for the 3-argument hasFlag. NFC
The default argument true is error-prone: I think many would think the
default is false.
2022-03-26 00:57:06 -07:00
Fangrui Song da62a5c661 [Driver][test] Clean up riscv* tests
See `D119309` for the guideline (-target, -no-canonical-prefixes, unneeded -o
with -###).
2022-03-25 23:59:31 -07:00
Joseph Huber 392bb8cf1f [OpenMP] Fix AMDGPU globals test 2022-03-25 23:05:41 -04:00
Joseph Huber 9d3550c517 [OpenMP] Add AMDGPU calling convention to ctor / dtor functions
This patch adds the necessary AMDGPU calling convention to the ctor /
dtor kernels. These are fundamentally device kenels called by the host
on image load. Without this calling convention information the AMDGPU
plugin is unable to identify them.

Depends on D122504

Fixes #54091

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D122515
2022-03-25 22:44:20 -04:00
Joseph Huber 3c6d32ec6c [OpenMP] Make Ctor / Dtor functions have external visibility
The default construction of constructor functions by LLVM tends to make
them have internal linkage. When we call a ctor / dtor function in the
target region we are actually creating a kernel that is called at
registration. Because the ctor is a kernel we need to make sure it's
externally visible so we can actually call it. This prevented AMDGPU
from correctly using constructors while NVPTX could use them simply
because it ignored internal visibility.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D122504
2022-03-25 22:44:17 -04:00
David Blaikie 34b9b1ea48 Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static"
Some functions can end up non-externally visible despite not being
declared "static" or in an unnamed namespace in C++ - such as by having
parameters that are of non-external types.

Such functions aren't mistakenly intended to be defining some function
that needs a declaration. They could be maybe more legible (except for
the operator new example) with an explicit static, but that's a
stylistic thing outside what should be addressed by a warning.

This reapplies 275c56226d - once we figure
out what to do about the change in behavior for -Wnon-c-typedef-for-linkage
(this reverts the revert commit 85ee1d3ca1)

Differential Revision: https://reviews.llvm.org/D121328
2022-03-25 23:53:19 +00:00
Fangrui Song afaefb671f [Driver][Linux] Remove D.Dir+"/../lib" from default search paths for LLVM_ENABLE_RUNTIMES builds
The rule was added in 2014 to support -stdlib=libc++ and -lc++ without
specifying -L, when D.Dir is not a well-known system library directory like
/usr/lib /usr/lib64. This rule turns out to get in the way with (-m32 for
64-bit clang) or (-m64 for 32-bit clang) for Gentoo :
https://github.com/llvm/llvm-project/issues/54515

Nowadays LLVM_ENABLE_RUNTIMES is the only recommended way building libc++ and
LLVM_ENABLE_PROJECTS=libc++ is deprecated. LLVM_ENABLE_RUNTIMES builds libc++
in D.Dir+"/../lib/${triple}/". The rule is unneeded. Also reverts D108286.

Gentoo uses a modified LLVM_ENABLE_RUNTIMES that installs libc++.so in
well-known paths like /usr/lib64 and /usr/lib which are already covered by
nearby search paths.

Implication: if a downstream package needs something like -lLLVM-15git and uses
libLLVM-15git.so not in a well-known path, it needs to supply -L
D.Dir+"/../lib" explicitly (e.g. via LLVMConfig.cmake), instead of relying on
the previous default search path.

Reviewed By: mgorny

Differential Revision: https://reviews.llvm.org/D122444
2022-03-25 14:56:18 -07:00
Florian Hahn bb9bdef4df
[Clang] Use pattern to match profile metadata in test.
Make the test more robust to slightly different metadata numbering by
using a pattern instead of hard coding the ids.
2022-03-25 21:05:58 +00:00
William S. Moses 89525cbf28 [Clang] Add helper method to determine if a nonvirtual base has an entry in the LLVM struct
This patch adds a helper method to determine if a nonvirtual base has an entry in the LLVM struct. Such a base may not have an entry
if the base does not have any fields/bases itself that would change the size of the struct. This utility method is useful for other frontends (Polygeist) that use Clang as an API to generate code.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D122502
2022-03-25 16:32:12 -04:00
Paul Robinson 6aa0397758 Remove dead code in driver parsing -gsimple-template-names= options
While -g[no-]simple-template-names is a driver option, the fancier
-gsimple-template-names={simple,mangled} option is cc1-only, so code
to handle it in the driver is dead.

Differential Revision: https://reviews.llvm.org/D122503
2022-03-25 13:23:24 -07:00
Sam McCall 57ee624d79 [cmake] Provide CURRENT_TOOLS_DIR centrally, replacing CLANG_TOOLS_DIR
CLANG_TOOLS_DIR holds the the current bin/ directory, maybe with a %(build_mode)
placeholder. It is used to add the just-built binaries to $PATH for lit tests.
In most cases it equals LLVM_TOOLS_DIR, which is used for the same purpose.
But for a standalone build of clang, CLANG_TOOLS_DIR points at the build tree
and LLVM_TOOLS_DIR points at the provided LLVM binaries.

Currently CLANG_TOOLS_DIR is set in clang/test/, clang-tools-extra/test/, and
other things always built with clang. This is a few cryptic lines of CMake in
each place. Meanwhile LLVM_TOOLS_DIR is provided by configure_site_lit_cfg().

This patch moves CLANG_TOOLS_DIR to configure_site_lit_cfg() and renames it:
 - there's nothing clang-specific about the value
 - it will also replace LLD_TOOLS_DIR, LLDB_TOOLS_DIR etc (not in this patch)

It also defines CURRENT_LIBS_DIR. While I removed the last usage of
CLANG_LIBS_DIR in e4cab4e24d, there are LLD_LIBS_DIR usages etc that
may be live, and I'd like to mechanically update them in a followup patch.

Differential Revision: https://reviews.llvm.org/D121763
2022-03-25 20:22:01 +01:00
Corentin Jabot 26e201b796 [Clang] Fix error in Documentation introduced by 3784e8cc [nfc].
The documentation contained extra space.
Also remove https://github.com/llvm/llvm-project/issues/54296
from the list of issues by 3784e8cc as this commit did not
fix it (nor was it supposed to).
2022-03-25 19:38:36 +01:00
Corentin Jabot 3784e8ccfb [Clang] Fix Unevaluated Lambdas
Unlike other types, when lambdas are instanciated,
they are recreated from scratch.
When an unevaluated lambdas appear in the type of a function,
parameter it is instanciated in the wrong declaration context,
as parameters are transformed before the function.

To support lambda in function parameters, we try to
compute whether they are dependant without looking at the
declaration context.

This is a short term stopgap solution to avoid clang
iceing. A better fix might be to inject some kind of
transparent declaration with correctly computed dependency
for function parameters, variable templates, etc.

Fixes https://github.com/llvm/llvm-project/issues/50376
Fixes https://github.com/llvm/llvm-project/issues/51414
Fixes https://github.com/llvm/llvm-project/issues/51416
Fixes https://github.com/llvm/llvm-project/issues/51641
Fixes https://github.com/llvm/llvm-project/issues/54296

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D121532
2022-03-25 19:16:45 +01:00
Florian Hahn 171cdba867
[Clang,TBAA] Use pattern for metadata reference in test.
Update the single check line that still had a hard-coded metadata
reference. This makes it more robust to slight changes in the metadata
numbering.
2022-03-25 18:12:39 +00:00
Emil Kieri 35b89bc24c [clang][driver] Disable non-functional --version option for clang -cc1
This patch removes --version as a clang -cc1 option.
  clang --version
and
  clang --cc1 -version
remain valid. This behaviour is consistent with clang -cc1as.

Previously, clang -cc1 accepted both --version and -version, but
only -version was acted upon. The call
  clang -cc1 --version
stalled without any message: --version was an accepted option but
triggered no action, and the driver waited for standard input.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D122344
2022-03-25 19:04:27 +01:00
Nathan James b97f26083b Reland "[ASTMatchers] Output currently processing match and nodes on crash"
This reverts commit cff34ccb60.

This relands commit d89f9e963e
2022-03-25 17:53:58 +00:00
Gulfem Savrun Yeniceri c7f91e227a [InstrProfiling] No runtime hook for unused funcs
CoverageMappingModuleGen generates a coverage mapping record
even for unused functions with internal linkage, e.g.
static int foo() { return 100; }
Clang frontend eliminates such functions, but InstrProfiling pass
still pulls in profile runtime since there is a coverage record.
Fuchsia uses runtime counter relocation, and pulling in profile
runtime for unused functions causes a linker error:
undefined hidden symbol: __llvm_profile_counter_bias.
Since 389dc94d4b, we do not hook profile runtime for the binaries
that none of its translation units have been instrumented in Fuchsia.
This patch extends that for the instrumented binaries that
consist of only unused functions.

Differential Revision: https://reviews.llvm.org/D122336
2022-03-25 17:03:03 +00:00
Yitzhak Mandelbaum a184a0d8aa [clang][dataflow] Add support for disabling warnings on smart pointers.
This patch provides the user with the ability to disable all checked of accesses
to optionals that are the pointees of smart pointers. Since smart pointers are
not modeled (yet), the system cannot distinguish safe from unsafe accesses to
optionals through smart pointers. This results in false positives whenever
optionals are used through smart pointers. The patch gives the user the choice
of ignoring all positivess in these cases.

Differential Revision: https://reviews.llvm.org/D122143
2022-03-25 16:44:34 +00:00
Joseph Huber b9f67d44ba [OpenMP] Replace device kernel linkage with weak_odr
Currently the device kernels all have weak linkage to prevent linkage
errors on multiple defintions. However, this prevents some optimizations
from adequately analyzing them because of the nature of weak linkage.
This patch replaces the weak linkage with weak_odr linkage so we can
statically assert that multiple declarations of the same kernel will
have the same definition.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D122443
2022-03-25 11:29:15 -04:00
Iain Sandoe cf396c56e7 [C++20][Modules] Correct an assert for modules-ts.
When adding the support for modules partitions we added an assert that the
actual status of Global Module Fragments matches the state machine that is
driven by the module; keyword.

That does not apply to the modules-ts case, where there is an implicit GMF.

Differential Revision: https://reviews.llvm.org/D122394
2022-03-25 14:55:13 +00:00
Adam Czachorowski 7e45912618 [clang] Do not crash on arrow operator on dependent type.
There seems to be more than one way to get to that state. I included to
example cases in the test, both were noticed recently.

There is room for improvement, for example by creating RecoveryExpr in
place of the bad initializer, but for now let's stop the crashes.

Differential Revision: https://reviews.llvm.org/D121824
2022-03-25 15:48:08 +01:00
Johannes Doerfert a81fff8afd Reapply "[Intrinsics] Add `nocallback` to the default intrinsic attributes"
This reverts commit c5f789050d and
reapplies 7aea3ea8c3 with additional test
changes.
2022-03-25 09:36:50 -05:00
Aaron Ballman 635dde8117 Fix clang Sphinx build bot 2022-03-25 07:13:26 -04:00
Simon Pilgrim ce2b36e123 [clang] CheckSizelessVectorOperands - use castAs<> instead of getAs<> to avoid dereference of nullptr
Move the only uses of the cast to where they are dereferenced.
2022-03-25 10:23:30 +00:00
Marek Kurdej 311a00c390 [clang-format] Clean up DefinitionBlockSeparatorTest. NFC. 2022-03-25 10:59:46 +01:00
Dávid Bolvanský 520c8ca9d2 [Clang] Added release note for improved -Wunused-but-set-variable warning 2022-03-25 10:45:28 +01:00
Iain Sandoe 6c0e60e884 [C++20][Modules][HU 1/5] Introduce header units as a module type.
This is the first in a series of patches that introduce C++20 importable
header units.

These differ from clang header modules in that:
 (a) they are identifiable by an internal name
 (b) they represent the top level source for a single header - although
     that might include or import other headers.

We name importable header units with the path by which they are specified
(although that need not be the absolute path for the file).

So "foo/bar.h" would have a name "foo/bar.h".  Header units are made a
separate module type so that we can deal with diagnosing places where they
are permitted but a named module is not.

Differential Revision: https://reviews.llvm.org/D121095
2022-03-25 09:17:14 +00:00
Nathan Ridge 56a54910c5 [clang] Propagate requires-clause from constructor template to implicit deduction guide
Fixes https://github.com/clangd/clangd/issues/890

Differential Revision: https://reviews.llvm.org/D113874
2022-03-25 02:46:22 -04:00
Ben Shi b62ea9b38b [AVR] Add more devices
Synchronize device list with avr-gcc 7.3.0 and avrlibc 2.0.0.

Reviewed By: aykevl

Differential Revision: https://reviews.llvm.org/D122401
2022-03-25 01:43:41 +00:00
Akira Hatanaka 350d43f1ef Fix a bug where an extended vector of __fp16 was being converted to a
generic vector type

rdar://86109177
2022-03-24 18:06:10 -07:00
Hubert Tong ce21c926f8 [Clang] Work with multiple pragmas weak before definition
Update `WeakUndeclaredIdentifiers` to hold a collection of weak
aliases per identifier instead of only one.

This also allows the "used" state to be removed from `WeakInfo`
because it is really only there as an alternative to removing
processed map entries, and we can represent that using an empty set
now. The serialization code is updated for the removal of the field.
Additionally, a PCH test is added for the new functionality.

The records are grouped by the "target" identifier, which was already
being used as a key for lookup purposes. We also store only one record
per alias name; combined, this means that diagnostics are grouped by
the "target" and limited to one per alias (which should be acceptable).

Fixes PR28611.
Fixes llvm/llvm-project#28985.

Reviewed By: aaron.ballman, cebowleratibm

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

Co-authored-by: Rachel Craik <rcraik@ca.ibm.com>
Co-authored-by: Jamie Schmeiser <schmeise@ca.ibm.com>
2022-03-24 20:17:49 -04:00
Tom Stellard fed96f31bb Re-commit: Driver: Don't warn on -mbranch-protection when linking
This is a re-commit of 98fd3b3598.  The
newly added test was failing on the bots, and I've fixed the test now so
that it doesn't actually invoke the linker.
2022-03-24 16:57:42 -07:00
Joseph Huber bfda79341b [OpenMP] Add a semantic check for updating hidden or internal values
A previous patch removed the compiler generating offloading entries
for variables that were declared on the device but were internal or
hidden. This allowed us to compile programs but turns any attempt to run
'#pragma omp target update' on one of those variables a silent failure.
This patch adds a check in the semantic analysis for if the user is
attempting the update a variable on the device from the host that is not
externally visible.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D122403
2022-03-24 19:38:30 -04:00
Zixu Wang 826e661a96 [NFC][clang][extract-api] Rename variable
Rename a local variable name to avoid potential ambiguity/conflict for
some compilers.
2022-03-24 15:12:40 -07:00
Zixu Wang e5a7d272ab [NFC][clang][extract-api] Add missing virtual anchors
Add missing virtual method anchors for structs in ExtractAPI/API.h
2022-03-24 14:30:14 -07:00
Jennifer Yu a6cdac48ff Eliminate extra set of simd variant function attribute.
Current clang generates extra set of simd variant function attribute
with extra 'v' encoding.
For example:
_ZGVbN2v__Z5add_1Pf vs _ZGVbN2vv__Z5add_1Pf
The problem is due to declaration of ParamAttrs following:
    llvm::SmallVector<ParamAttrTy, 8> ParamAttrs(ParamPositions.size());
where ParamPositions.size() is grown after following assignment:
    Pos = ParamPositions[PVD];
So the PVD is not find in ParamPositions.

The problem is ParamPositions need to set for each FD decl. To fix this

Move ParamPositions's init inside while loop for each FD.

Differential Revision: https://reviews.llvm.org/D122338
2022-03-24 13:27:28 -07:00
Stanislav Mekhanoshin 6e3e14f600 [AMDGPU] Support gfx940 smfmac instructions
Differential Revision: https://reviews.llvm.org/D122191
2022-03-24 12:40:42 -07:00
Kirill Stoimenov dd67e6972f [ASan] Reland of D116182 to always link asan_static library.
After landing D121813 the binary size increase introduced by this change can be minimized by using --gc-sections link options. D121813 allows each individual callbacks to be optimized out if not used.

Reviewed By: vitalybuka, MaskRay

Differential Revision: https://reviews.llvm.org/D122407
2022-03-24 19:32:23 +00:00
wangyihan 7faa95624e [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct
Fix clang crash and add bitfield support in __builtin_dump_struct.

In clang13.0.x, a struct with three or more members and a bitfield at
the same time will cause a crash. In clang15.x, as long as the struct
has one bitfield, it will cause a crash in clang.

Open issue: https://github.com/llvm/llvm-project/issues/54462

Differential Revision: https://reviews.llvm.org/D122248
2022-03-24 12:23:29 -07:00
Yaxun (Sam) Liu d41445113b [CUDA][HIP] Fix hostness check with -fopenmp
CUDA/HIP determines whether a function can be called based on
the device/host attributes of callee and caller. Clang assumes the
caller is CurContext. This is correct in most cases, however, it is
not correct in OpenMP parallel region when CUDA/HIP program
is compiled with -fopenmp. This causes incorrect overloading
resolution and missed diagnostics.

To get the correct caller, clang needs to chase the parent chain
of DeclContext starting from CurContext until a function decl
or a lambda decl is reached. Sema API is adapted to achieve that
and used to determine the caller in hostness check.

Reviewed by: Artem Belevich, Richard Smith

Differential Revision: https://reviews.llvm.org/D121765
2022-03-24 15:19:47 -04:00
Stanislav Mekhanoshin 27439a7642 [AMDGPU] New gfx940 mfma instructions
Differential Revision: https://reviews.llvm.org/D122044
2022-03-24 12:12:52 -07:00
Johannes Doerfert c5f789050d Revert "[Intrinsics] Add `nocallback` to the default intrinsic attributes"
This reverts commit 7aea3ea8c3 as it
breaks the buildbots.

I didn't see these failures in the pre-merge checks, looking into it.
2022-03-24 14:04:41 -05:00
David Blaikie 7b498beef0 DebugInfo: Classify noreturn function types as non-reconstructible
This information isn't preserved in the DWARF description of function
types (though probably should be - it's preserved on the function
declarations/definitions themselves through the DW_AT_noreturn attribute
- but we should move or also include that in the subroutine type itself
too - but for now, with it not being there, the DWARF is lossy and
can't be reconstructed)
2022-03-24 18:53:14 +00:00
Johannes Doerfert 7aea3ea8c3 [Intrinsics] Add `nocallback` to the default intrinsic attributes
Most intrinsics, especially "default" ones, will not call back into the
IR module. `nocallback` encodes this nicely. As it was not used before,
this patch also makes use of `nocallback` in the Attributor which
results in many more `norecurse` deductions.

Tablegen part is mechanical, test updates by script.

Differential Revision: https://reviews.llvm.org/D118680
2022-03-24 13:50:54 -05:00
Gulfem Savrun Yeniceri 6bb836af2a Revert "[clang][deps] NFC: De-duplicate clang-cl tests"
This reverts commit 30cb49b44e.
It caused test failures on Fuchsia Toolchain Mac builds:
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-mac-x64/b8818888168677577537/overview
2022-03-24 18:10:08 +00:00
Daniel Grumberg 0ee06c31aa [clang][extract-api] Stop allocating APIRecords via BumpPtrAllocator
Using a BumpPtrAllocator introduced memory leaks for APIRecords as they
contain a std::vector. This meant that we needed to always keep a
reference to the records in APISet and arrange for their destructor to
get called appropriately. This was further complicated by the need for
records to own sub-records as these subrecords would still need to be
allocated via the BumpPtrAllocator and the owning record would now need
to arrange for the destructor of its subrecords to be called
appropriately.

Since APIRecords contain a std::vector so whenever elements get added to
that there is an associated heap allocation regardless. Since
performance isn't currently our main priority it makes sense to use
regular unique_ptr to keep track of APIRecords, this way we don't need
to arrange for destructors to get called.

The BumpPtrAllocator is still used for strings such as USRs so that we
can easily de-duplicate them as necessary.

Differential Revision: https://reviews.llvm.org/D122331
2022-03-24 17:44:00 +00:00
Mike Rice f82ec5532b [OpenMP] Initial parsing/sema for the 'omp target parallel loop' construct
Adds basic parsing/sema/serialization support for the
 #pragma omp target parallel loop directive.

Differential Revision: https://reviews.llvm.org/D122359
2022-03-24 09:19:00 -07:00
Aaron Ballman 5b164a3a9b Diagnose use of a naked attribute on a member function in ms-mode
This matches the behavior of cl.exe.
2022-03-24 11:52:43 -04:00
Aaron Ballman 488c772920 Fix a crash with variably-modified parameter types in a naked function
Naked functions have no prolog, so it's not valid to emit prolog code
to evaluate the variably-modified type. This fixes Issue 50541.
2022-03-24 10:39:14 -04:00
Sven van Haastregt 677d0e7495 [OpenCL] opencl-c.h: remove x/y/z arg names
This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the identifiers "x", "y" and
"z".

Continues the direction set out in D119560.
2022-03-24 13:55:41 +00:00
Qiu Chaofan 895e5b2d80 [NFC] Format and uglify PowerPC intrinsics headers
This change formats PowerPC intrinsics wrapper headers into LLVM style,
and add extra prefix '__' to all variables to prevent conflict with user
code.
2022-03-24 21:14:55 +08:00
Nathan Sidwell de867c6d6e [clang] Reformat
Reformat some misindentation that is coincidentally close to a piece
being worked on.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D122314
2022-03-24 05:56:23 -07:00
Aaron Ballman 4d20781b69 Typo fix in the documentation; NFC 2022-03-24 08:56:14 -04:00
Qiu Chaofan 406bde9a15 [PowerPC] [Clang] Add SSE4 and BMI intrinsics implementation
Reviewed By: jsji

Differential Revision: https://reviews.llvm.org/D119407
2022-03-24 20:03:08 +08:00
Daniil Kovalev 828b63c309 [NVPTX] Enhance vectorization of ld.param & st.param
Since function parameters and return values are passed via param space, we
can force special alignment for values hold in it which will add vectorization
options. This change may be done if the function has private or internal
linkage. Special alignment is forced during 2 phases.

1) Instruction selection lowering. Here we use special alignment for function
   prototypes (changing both own return value and parameters alignment), call
   lowering (changing both callee's return value and parameters alignment).

2) IR pass nvptx-lower-args. Here we change alignment of byval parameters that
   belong to param space (or are casted to it). We only handle cases when all
   uses of such parameters are loads from it. For such loads, we can change the
   alignment according to special type alignment and the load offset. Then,
   load-store-vectorizer IR pass will perform vectorization where alignment
   allows it.

Special alignment calculated as maximum from default ABI type alignment and
alignment 16. Alignment 16 is chosen because it's the maximum size of
vectorized ld.param & st.param.

Before specifying such special alignment, we should check if it is a multiple
of the alignment that the type already has. For example, if a value has an
enforced alignment of 64, default ABI alignment of 4 and special alignment
of 16, we should preserve 64.

This patch will be followed by a refactoring patch that removes duplicating
code in handling byval and non-byval arguments.

Differential Revision: https://reviews.llvm.org/D120129
2022-03-24 12:36:52 +03:00
Dávid Bolvanský 2af845a651 Relands "[Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators" 2022-03-24 10:34:44 +01:00
Daniil Kovalev a034878564 Revert "[NVPTX] Enhance vectorization of ld.param & st.param"
This reverts commit f854434f0f.

Placed URL to wrong differential revision in commit message.
2022-03-24 12:32:06 +03:00
Daniil Kovalev f854434f0f [NVPTX] Enhance vectorization of ld.param & st.param
Since function parameters and return values are passed via param space, we
can force special alignment for values hold in it which will add vectorization
options. This change may be done if the function has private or internal
linkage. Special alignment is forced during 2 phases.

1) Instruction selection lowering. Here we use special alignment for function
   prototypes (changing both own return value and parameters alignment), call
   lowering (changing both callee's return value and parameters alignment).

2) IR pass nvptx-lower-args. Here we change alignment of byval parameters that
   belong to param space (or are casted to it). We only handle cases when all
   uses of such parameters are loads from it. For such loads, we can change the
   alignment according to special type alignment and the load offset. Then,
   load-store-vectorizer IR pass will perform vectorization where alignment
   allows it.

Special alignment calculated as maximum from default ABI type alignment and
alignment 16. Alignment 16 is chosen because it's the maximum size of
vectorized ld.param & st.param.

Before specifying such special alignment, we should check if it is a multiple
of the alignment that the type already has. For example, if a value has an
enforced alignment of 64, default ABI alignment of 4 and special alignment
of 16, we should preserve 64.

This patch will be followed by a refactoring patch that removes duplicating
code in handling byval and non-byval arguments.

Differential Revision: https://reviews.llvm.org/D121549
2022-03-24 12:25:36 +03:00
Krasimir Georgiev be5c3ca7fb Revert "[clang-format] Correctly recognize arrays in template parameter list."
This reverts commit 126b37a713.

Regressed some ObjC patterns, see comments on https://reviews.llvm.org/D121584.
2022-03-24 10:14:13 +01:00
Qiu Chaofan d00e8400e2 [Clang] Add option to set alternative toolchain path
In some cases, we need to set alternative toolchain path other than the
default with system (headers, libraries, dynamic linker prefix, ld path,
etc.), e.g., to pick up newer components, but keep sysroot at the same
time (to pick up extra packages).

This change introduces a new option --overlay-platform-toolchain to set
up such alternative toolchain path.

Reviewed By: hubert.reinterpretcast

Differential Revision: https://reviews.llvm.org/D121992
2022-03-24 17:01:35 +08:00
Tobias Hieta 67d9276b16 [clang-cl] Ignore /Wv and /Wv:17 flags
MSVC supports passing /Wv and /Wv:17 to ignore warnings added
since that version. Clang doesn't have a option like this - but
we can ignore this flag instead of error.

MSVC documentation: https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level

Reviewed By: hans, mstorsjo

Differential Revision: https://reviews.llvm.org/D122298
2022-03-24 09:42:34 +01:00
Dávid Bolvanský 1c13bbdde6 [NFCI] Fix set-but-unused warning in UnwrappedLineParser.cpp 2022-03-24 08:13:29 +01:00
Dávid Bolvanský 48285c20eb [NFCI] Fix set-but-unused warning in ClangAttrEmitter.cpp 2022-03-24 08:13:28 +01:00
Timm Bäder 711e3a5691 [clang][parse] Move source range into ParsedAttibutesView
Move the SourceRange from the old ParsedAttributesWithRange into
ParsedAttributesView, so we have source range information available
everywhere we use attributes.

This also removes ParsedAttributesWithRange (replaced by simply using
ParsedAttributes) and ParsedAttributesVieWithRange (replaced by using
ParsedAttributesView).

Differential Revision: https://reviews.llvm.org/D121201
2022-03-24 08:11:57 +01:00
Dávid Bolvanský a683ba4ff5 [NFCI] Fix set-but-unused warning in CGOpenMPRuntime.cpp 2022-03-24 07:49:21 +01:00
Dávid Bolvanský dc46fa41d4 [NFCI] Fix set-but-unused warning in ExprConstant.cpp 2022-03-24 07:47:50 +01:00
Dávid Bolvanský 5b6b840531 Revert "[Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators"
This reverts commit 460fc440ad.
2022-03-24 07:44:51 +01:00
Kai Luo b8388fa319 [clang][NFC] Fix warning of integer comparison
```
warning: comparison of integers of different signs: 'const unsigned long' and 'const int' [-Wsign-compare]
```

Fix https://lab.llvm.org/buildbot/#/builders/57/builds/16220.
2022-03-24 14:06:45 +08:00
Ben Shi 86c1d075bb [clang][AVR] Implement standard calling convention for AVR and AVRTiny
This patch implements avr-gcc's calling convention:
https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention

Reviewed By: aykevl

Differential Revision: https://reviews.llvm.org/D120720
2022-03-24 03:41:01 +00:00
Joseph Huber d912232741 [CUDA][FIX] Fix name conflict in getNVPTXTargetFeatures
Summary:
There was a naming conflict in the getNVPTXTargetFeatures function that
prevented some compilers from correctly disambiguating between the
enumeration and variable of the same name. Rename the variable to avoid
this.
2022-03-23 23:07:51 -04:00
owenca f74413d163 [clang-format] Fix invalid code generation with comments in lambda
Fixes #51234 and #54496

Differential Revision: https://reviews.llvm.org/D122301
2022-03-23 19:40:24 -07:00
Chuanqi Xu 8474668608 [C++20] [Modules] Make the linkage consistent for template and its
specialization

Before the patch, the compiler would crash for the test due to
inconsistent linkage.

This patch tries to avoid it by make the linkage consistent for template
and its specialization. After the patch, the behavior of compiler would
be partially correct for the case.
The correct one is:

```
export template<class T>
void f() {}

template<>
void f<int>() {}
```

In this case, the linkage for both declaration should be external (the
wording I get by consulting in WG21 is "the linkage for name f should be
external").

And for the case:
```
template<class T>
void f() {}

export template<>
void f<int>() {}
```

Compiler should reject it. This isn't done now. After all, this patch would
stop a crash.

Reviewed By: iains, aaron.ballman, dblaikie

Differential Revision: https://reviews.llvm.org/D120397
2022-03-24 10:24:14 +08:00
Ben Shi 51585aa240 [clang][AVR] Implement standard calling convention for AVR and AVRTiny
This patch implements avr-gcc's calling convention:
https://gcc.gnu.org/wiki/avr-gcc#Calling_Convention

Reviewed By: aykevl

Differential Revision: https://reviews.llvm.org/D120720
2022-03-24 02:08:22 +00:00
Xiang1 Zhang 287dad13ab [InlineAsm] Fix mangle problem when global variable used in inline asm
(Add modifier P for ARR[BaseReg+IndexReg+..])

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D120887
2022-03-24 09:41:23 +08:00
Xiang1 Zhang 8a6b644c79 [Inline asm] Fix mangle problem when variable used in inline asm.
(Connect InlineAsm Memory Operand with its real value not just name)
Revert 2 history bugfix patch:

Revert "[X86][MS-InlineAsm] Make the constraint *m to be simple place holder"
This patch revert https://reviews.llvm.org/D115225 which mainly
fix problems intrduced by https://reviews.llvm.org/D113096

This reverts commit d7c07f60b3.

Revert "Reland "[X86][MS-InlineAsm] Use exact conditions to recognize MS global variables""
This patch revert https://reviews.llvm.org/D116090 which fix problem
intrduced by https://reviews.llvm.org/D115225

This reverts commit 24c68ea1eb.

Reviewed By: skan

Differential Revision: https://reviews.llvm.org/D120886
2022-03-24 09:41:22 +08:00
Julian Lettner 64902d335c Reland "Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO"
For MachO, lower `@llvm.global_dtors` into `@llvm_global_ctors` with
`__cxa_atexit` calls to avoid emitting the deprecated `__mod_term_func`.

Reuse the existing `WebAssemblyLowerGlobalDtors.cpp` to accomplish this.

Enable fallback to the old behavior via Clang driver flag
(`-fregister-global-dtors-with-atexit`) or llc / code generation flag
(`-lower-global-dtors-via-cxa-atexit`).  This escape hatch will be
removed in the future.

Differential Revision: https://reviews.llvm.org/D121736
2022-03-23 18:36:55 -07:00
Zequan Wu 581dc3c729 Revert "Lower `@llvm.global_dtors` using `__cxa_atexit` on MachO"
This reverts commit 22570bac69.
2022-03-23 16:11:54 -07:00
Joseph Huber 0d16c23af1 [OpenMP] Do not create offloading entries for internal or hidden symbols
Currently we create offloading entries to register device variables with
the host. When we register a variable we will look up the symbol in the
device image and map the device address to the host address. This is a
problem when the symbol is declared with hidden visibility or internal
linkage. This means the symbol is not accessible externally and we
cannot get its address. We should still allow static variables to be
declared on the device, but ew should not create an offloading entry for
them so they exist independently on the host and device.

Fixes #54309

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D122352
2022-03-23 18:27:16 -04:00
Keith Smiley 955cff803e reland: [AArch64] Add support for -march=native for Apple M1 CPU
This reverts commit fc3cdd0b29.

The issue was imports being scoped to specific architectures for Apple
platforms.
2022-03-23 15:19:17 -07:00
Fabian Wolff 528e6eba2f [clang] Improve diagnostic for reopened inline namespace
Reviewed By: cor3ntin, aaron.ballman

Differential Revision: https://reviews.llvm.org/D122278
2022-03-23 22:30:45 +01:00
Keith Smiley fc3cdd0b29 Revert "[AArch64] Add support for -march=native for Apple M1 CPU"
This reverts commit fcca10c69a.
2022-03-23 14:27:02 -07:00
Dávid Bolvanský d90a3fcacd [Clang] Added testcases for -Wunused-but-set-parameter
Clang now emits warnings for them after D122271 (shared logic with -Wunused-but-set-variable)
2022-03-23 22:14:38 +01:00
Keith Smiley fcca10c69a [AArch64] Add support for -march=native for Apple M1 CPU
This improves the getHostCPUName check for Apple M1 CPUs, which
previously would always be considered cyclone instead. This also enables
`-march=native` support when building on M1 CPUs which would previously
fail. This isn't as sophisticated as the X86 CPU feature checking which
consults the CPU via getHostCPUFeatures, but this is still better than
before. This CPU selection could also be invalid if this was run on an
iOS device instead, ideally we can improve those cases as they come up.

Differential Revision: https://reviews.llvm.org/D119788
2022-03-23 14:06:59 -07:00
Dávid Bolvanský 460fc440ad [Clang] -Wunused-but-set-variable warning - handle also pre/post unary operators
Clang fails to diagnose:
```
void test() {
    int j = 0;
    for (int i = 0; i < 1000; i++)
            j++;
    return;
}
```

Reason: Missing support for UnaryOperator.

We should not warn with volatile variables... so add check for it.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D122271
2022-03-23 22:05:36 +01:00
Erich Keane 3fb101a691 [NFC] Replace a not-null-check && isa with isa_and_nonnull 2022-03-23 13:09:28 -07:00
Daniel Grumberg f833aab0d0 [clang][extract-api] Enable processing of multiple headers
Before actually executing the ExtractAPIAction, clear the
CompilationInstance's input list and replace it with a single
synthesized file that just includes (or imports in ObjC) all the inputs.

Depends on D122141

Differential Revision: https://reviews.llvm.org/D122175
2022-03-23 19:05:19 +00:00
Arthur Eubanks 9bd66b312c [PassManager][Coroutine] Run passes under -O0 conditionally and run GlobalDCE
CoroSplit lowers various coroutine intrinsics. It's a CGSCC pass and
CGSCC passes don't run on unreachable functions. Normally GlobalDCE will
come along and delete unreachable functions, but we don't run GlobalDCE
under -O0, so an unreachable function with coroutine intrinsics may
never have CoroSplit run on it.

This patch adds GlobalDCE when coroutines intrinsics are present. It
also now runs all coroutine passes conditional when coroutine intrinsics
are present. This should also solve the -O0 regression reported in
D105877 due to LazyCallGraph construction.

Fixes https://github.com/llvm/llvm-project/issues/54117

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D122275
2022-03-23 11:03:26 -07:00
Aaron Ballman e4a42c5b64 Change __auto_type behavior with qualifiers to match GCC behavior
Currently, Clang handles some qualifiers correctly for __auto_type, but
it does not handle the restrict or _Atomic qualifiers in the same way
that GCC does. This patch handles those qualifiers so that they attach
to the deduced type the same as const and volatile already do.

This fixes https://github.com/llvm/llvm-project/issues/53652
2022-03-23 13:25:31 -04:00
Zixu Wang 5bb5704c1b [clang][extract-api] Add struct support
- Add `StructFieldRecord` and `StructRecord` to store API information
  for structs
- Implement `VisitRecordDecl` in `ExtractAPIVisitor`
- Implement Symbol Graph serialization for struct records.
- Add test case for struct records.

Depends on D121873

Differential Revision: https://reviews.llvm.org/D122202
2022-03-23 09:45:06 -07:00
Zixu Wang 71b4c22612 [clang][extract-api] Add enum support
Add support for enum records
- Add `EnumConstantRecord` and `EnumRecord` to store API information for
  enums
- Implement `VisitEnumDecl` in `ExtractAPIVisitor`
- Implement serializatin for enum records and `MemberOf` relationship
- Add test case for enum records
- Few other improvements

Depends on D122160

Differential Revision: https://reviews.llvm.org/D121873
2022-03-23 09:41:21 -07:00
Nick Desaulniers 5a2e56b70e [Clang][NeonEmitter] emit ret decl first for -Wdeclaration-after-statement
The generated arm_neon.h header isn't -Wdeclaration-after-statement
compliant when targeting -mbig-endian. Update the generator to declare
the return value, if any, first before any other arguments that might
need to be "reversed" from little endian to big.

Another approach would have been to try to ignore this warning in system
headers, though that might not be precise for tokens involved in macro
expansion. See also: https://reviews.llvm.org/D116833#3236209.

Link: https://github.com/ClangBuiltLinux/linux/issues/1603
Fixes: https://github.com/llvm/llvm-project/issues/54062

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D122189
2022-03-23 09:40:43 -07:00
PoYao Chang 355f1c75aa [Clang] Fix PR28101
Fixes https://github.com/llvm/llvm-project/issues/28475 (PR28101)
by setting identifier for invalid member variables with template parameters,
so that the invalid declarators would not crash clang.

See also: https://github.com/llvm/llvm-project/commit/942c03910a

Differential Revision: https://reviews.llvm.org/D115248
2022-03-24 00:38:45 +08:00
Daniel Grumberg 5ef2ec7e4e [clang][extract-api] Suppprt for the module name property in SymbolGraph
Adds `--product-name=` flag to the clang driver. This gets forwarded to
cc1 only when we are performing a ExtractAPI Action. This is used to
populate the `name` field of the module object in the generated SymbolGraph.

Differential Revision: https://reviews.llvm.org/D122141
2022-03-23 16:34:08 +00:00
Junfeng Dong 72acd042ba Pass split-machine-functions to code generator when flto is used
-fsplit-machine-functions is an optimization in codegen phase. when -flto is use, clang generate IR bitcode in .o files, and linker will call into these codegen optimization passes. Current clang driver doesn't pass this option to linker when both -fsplit-machine-functions and -flto are used, so the optimization is silently ignored.  My fix generates linker option -plugin-opt=-split-machine-functions for this case. It allows the linker to pass "split-machine-functions" to code generator to turn on that optimization.  It works for both gold and lld.

Reviewed By: hoy, wenlei

Differential Revision: https://reviews.llvm.org/D121969
2022-03-23 08:55:30 -07:00
Marek Kurdej 4e88cb6825 [clang-format] Handle attributes before case label. Relanded.
Fixes https://github.com/llvm/llvm-project/issues/53110.

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

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

Relanding as the original patch provoked an infinite loop in JavaScript/TypeScript.
A reproducer test case was added and the issue fixed.
2022-03-23 16:24:24 +01:00
Roy Jacobson 94fd00f41e [Concepts] Fix placeholder constraints when references are involved
Placeholder types were not checked for constraint satisfaction when modified by references or pointers.
The behavior now matches that of GCC and MSVC.

Are there other modifiers we might need to "peel"? I'm not sure my approach to this is the 'right' way to fix this, the loop feels a bit clunky.

GitHub issues [[ https://github.com/llvm/llvm-project/issues/54443 | #54443 ]], [[ https://github.com/llvm/llvm-project/issues/53911 | #53911 ]]

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D122083
2022-03-23 11:14:58 -04:00
Hubert Tong da167a53c8 [Clang][NFC] Some `const` for `IdentifierInfo *`s feeding `DeclarationName`
`DeclarationName` already takes `const IdentifierInfo *`. Propagate the
`const` outward to various APIs.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D122261
2022-03-23 11:07:56 -04:00
Jan Svoboda 30cb49b44e [clang][deps] NFC: De-duplicate clang-cl tests
In D92191, a bunch of test cases were added to check `clang-scan-deps` works in `clang-cl` mode as well.

We don't need to duplicate all test cases, though. Testing the few special cases we have in `clang-scan-deps` for `clang-cl` should be good enough:

1. Deducing output path (and therefore target name in our make output).
2. Ignoring `-Xclang` arguments in step 1.
3. Deducing resource directory by invoking the compiler executuable.

This test de-duplicates the extra clang-cl test cases.

Reviewed By: dexonsmith, saudi

Differential Revision: https://reviews.llvm.org/D121812
2022-03-23 15:42:11 +01:00
Jan Svoboda 26053ce05a [clang][deps] Create lit substitution for deps-to-rsp
This patch gets rid of the ridiculous relative path we use to invoke the `module-deps-to-rsp.py` script and creates proper lit substitution, cleaning up the tests.

Reviewed By: dexonsmith

Differential Revision: https://reviews.llvm.org/D121525
2022-03-23 15:42:10 +01:00
Nikita Popov a8690ba9d0 [CGExpr] Perform bitcast unconditionally
The way the check is written is not compatible with opaque
pointers -- while we don't need to change the IR pointer type,
we do need to change the element type stored in the Address.
2022-03-23 15:39:39 +01:00
Nikita Popov ba36556145 [InstrProfiling] Account for missing bitcast/GEP
This code is supposed to clean up a constexpr bitcast/GEP, but
with opaque pointers this ends up dropping references to the
global.
2022-03-23 15:39:39 +01:00
Nikita Popov 5c6752d4ad [CGObjCMac] Check global value type instead of poitner type
As we're going to reassign the initializer, we actually need the
value types to match, not just the pointer types. This is only
relevant with opaque pointers.
2022-03-23 15:39:39 +01:00
Nikita Popov beee09687f [CGBlocks] Don't assume presence of bitcast
With opaque pointers, the bitcast constexpr will not be present.
2022-03-23 15:39:39 +01:00
Corentin Jabot 9f63cd763e [Clang][NFC] Cleanup dcl.constexpr/p3 tests
* Check for warnings instead of using -Werror, to avoid masking the
type of diagnostic emitted

* use different -verify labels instead of using conditional
compilation of diagnostic checks

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D122265
2022-03-23 15:37:48 +01:00
David Truby 683fc6203c [clang][AArc64][SVE] Implement vector-scalar operators
This patch extends the support for C/C++ operators for SVE
types to allow one of the arguments to be a scalar, in which
case a vector splat is performed.

Differential Revision: https://reviews.llvm.org/D121829
2022-03-23 14:20:48 +00:00
Danny Mösch a749e3295d Replace links to archived mailing lists by links to Discourse forums 2022-03-23 10:10:20 -04:00
Jan Svoboda 59dadd178b [clang][lex] Fix failures with Microsoft header search rules
`HeaderSearch` currently assumes `LookupFileCache` is eventually populated in `LookupFile`. However, that's not always the case with `-fms-compatibility` and its early returns.

This patch adds a defensive check that the iterator pulled out of the cache is actually valid before using it.

(This bug was introduced in D119721. Before that, the cache was initialized to `0` - essentially the `search_dir_begin()` iterator.)

Reviewed By: dexonsmith, erichkeane

Differential Revision: https://reviews.llvm.org/D122237
2022-03-23 14:49:17 +01:00
Vince Bridgers 9ef7ac51af [analyzer] Fix crash in RangedConstraintManager.cpp
This change fixes a crash in RangedConstraintManager.cpp:assumeSym due to an
unhandled BO_Div case.

clang: <root>clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp:51:
  virtual clang::ento::ProgramStateRef
  clang::ento::RangedConstraintManager::assumeSym(clang::ento::ProgramStateRef,
    clang::ento::SymbolRef, bool):
  Assertion `BinaryOperator::isComparisonOp(Op)' failed.

Reviewed By: NoQ

Differential Revision: https://reviews.llvm.org/D122277
2022-03-23 08:26:40 -05:00
Vince Bridgers 5fdc4dd777 [analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)
This is a NFC refactoring to change makeIntValWithPtrWidth
and remove getZeroWithPtrWidth to use types when forming values to match
pointer widths. Some targets may have different pointer widths depending
upon address space, so this needs to be comprehended.

Reviewed By: steakhal

Differential Revision: https://reviews.llvm.org/D120134
2022-03-23 08:26:37 -05:00
Marek Kurdej a45ad3ca8c [clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.
Fixes https://github.com/llvm/llvm-project/issues/54418.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D121916
2022-03-23 13:17:50 +01:00
Aaron Ballman b26466d001 Update the C and C++ status pages now that Clang 14 is out 2022-03-23 07:59:52 -04:00
Zahira Ammarguellat b0bc93da92 Revert "[clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable""."
This reverts commit 56d46b36fc.

The LIT test SemaCXX/attr-trivial-abi.cpp is failing with 32bit build on
Windows. All the lines with the ifdef WIN32 are asserting but they are
not expected to. It looks like the LIT test was not tested on a	32bit
build of the compiler.
2022-03-23 04:54:00 -07:00
David Spickett c3b98194df Reland "[llvm][AArch64] Insert "bti j" after call to setjmp"
This reverts commit edb7ba714a.

This changes BLR_BTI to take variable_ops meaning that we can accept
a register or a label. The pattern still expects one argument so we'll
never get more than one. Then later we can check the type of the operand
to choose BL or BLR to emit.

(this is what BLR_RVMARKER does but I missed this detail of it first time around)

Also require NoSLSBLRMitigation which I missed in the first version.
2022-03-23 11:43:43 +00:00
Nikita Popov c070d5ceff [CGOpenMPRuntime] Remove uses of deprecated Address constructor
And as these are the last remaining uses, also remove the
constructor itself.
2022-03-23 12:40:44 +01:00
Aaron Ballman 0254f59fef Forgot to add a release note for WG14 N2412.
This support was completed in bf7d9970ba
2022-03-23 07:39:53 -04:00
Sven van Haastregt 22548032be [OpenCL] opencl-c.h: remove arg names for vload/vstore builtins
This simplifies completeness comparisons against OpenCLBuiltins.td and
also makes the header no longer "claim" the identifiers "data" and
"offset".

Continues the direction set out in D119560.
2022-03-23 11:12:50 +00:00
Nikita Popov 8b62dd3cd6 Reapply [CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()
This requires some adjustment in caller code, because there was
a confusion regarding the meaning of the PtrTy argument: This
argument is the type of the pointer being loaded, not the addresses
being loaded from.

Reapply after fixing the specified pointer type for one call in
47eb4f7dcd, where the used type is
important for determining alignment.
2022-03-23 12:06:11 +01:00
Nikita Popov aaf2bccf1f [CodeGen][OpenMP] Add alignment to test (NFC)
Check which alignments are generated for loads/stores.
2022-03-23 12:01:00 +01:00
Nikita Popov 47eb4f7dcd [CGOpenMPRuntime] Specify correct type in EmitLoadOfPointerLValue()
Perform a bitcast first, so we can specify the correct pointer type
inf EmitLoadOfPointerLValue(), rather than using a dummy void pointer.
2022-03-23 11:51:14 +01:00
David Spickett edb7ba714a Revert "[llvm][AArch64] Insert "bti j" after call to setjmp"
This reverts commit eb5ecbbcbb
due to failures on buildbots with expensive checks enabled.
2022-03-23 10:43:20 +00:00
Nikita Popov ba2be802b0 [CGOpenMPRuntime] Reuse getDepobjElements() (NFC)
There were two more places repeating this code, reuse the helper.
This requires moving the static functions into the class.
2022-03-23 11:31:49 +01:00
David Spickett eb5ecbbcbb [llvm][AArch64] Insert "bti j" after call to setjmp
Some implementations of setjmp will end with a br instead of a ret.
This means that the next instruction after a call to setjmp must be
a "bti j" (j for jump) to make this work when branch target identification
is enabled.

The BTI extension was added in armv8.5-a but the bti instruction is in the
hint space. This means we can emit it for any architecture version as long
as branch target enforcement flags are passed.

The starting point for the hint number is 32 then call adds 2, jump adds 4.
Hence "hint #36" for a "bti j" (and "hint #34" for the "bti c" you see
at the start of functions).

The existing Arm command line option -mno-bti-at-return-twice has been
applied to AArch64 as well.

Support is added to SelectionDAG Isel and GlobalIsel. FastIsel will
defer to SelectionDAG.

Based on the change done for M profile Arm in https://reviews.llvm.org/D112427

Fixes #48888

Reviewed By: danielkiss

Differential Revision: https://reviews.llvm.org/D121707
2022-03-23 09:51:02 +00:00
Nikita Popov a451a29127 [CodeGen][OpenMP] Add alignment to test (NFC)
Check which alignments are generated for loads and stores.
2022-03-23 10:28:04 +01:00
Nikita Popov 27f6cee12d Revert "[CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()"
This reverts commit 767ec883e3.

This results in a some incorrect alignments which are not covered
by existing tests.
2022-03-23 10:24:39 +01:00
Tobias Hieta 09c0685a04 [NFC] Remove trailing whitespaces in clang/Driver/Options.td 2022-03-23 10:23:33 +01:00
Tom Stellard 1089cdda77 Revert "Driver: Don't warn on -mbranch-protection when linking"
This reverts commit 98fd3b3598.

This patch broke multiple bots.
2022-03-22 23:36:57 -07:00
Tom Stellard 98fd3b3598 Driver: Don't warn on -mbranch-protection when linking
The -mbranch-protection definition in Options.td was not given a Group,
so this was causing clang to emit a -Wunused-command-line-argument
warning when this flag was passed to the linker driver.  This was a
problem, because some build systems, like cmake, automatically pass the
C flags to the linker.  Therefore, any program that was compiled with
-Werror and -mbranch-protection would fail to link with the error:

argument unused during compilation: '-mbranch-protection=standard' [-Werror,-Wunused-command-line-argument]

Reviewed By: vhscampos

Differential Revision: https://reviews.llvm.org/D121983
2022-03-22 23:17:42 -07:00
Phoebe Wang 32103608fc [Inline-asm] Add diagnosts for unsupported inline assembly arguments
GCC supports power-of-2 size structures for the arguments. Clang supports fewer than GCC. But Clang always crashes for the unsupported cases.

This patch adds sema checks to do the diagnosts to solve these crashes.

Reviewed By: jyu2

Differential Revision: https://reviews.llvm.org/D107141
2022-03-23 11:25:19 +08:00
Ben Shi 6edfe45a63 [AVR] Add more devices
Synchronize AVR device lists with gcc-avr-5.4.0 and avr-libc-2.0.0.

Reviewed By: dylanmckay, aykevl

Differential Revision: https://reviews.llvm.org/D121359
2022-03-23 02:00:15 +00:00
Akira Hatanaka 818e72d1b0 [NFC][Clang][OpaquePtr] Remove calls to Address::deprecated in
TargetInfo.cpp

Differential Revision: https://reviews.llvm.org/D122199
2022-03-22 18:39:16 -07:00
Zixu Wang b62d40216f [NFC][clang][extract-api] Use proper name string for Objective-C language
Change the Symbol Graph serializer for ExtractAPI to use `objective-c`
for the language name string for Objective-C, to align with clang
frontend standards.
2022-03-22 14:18:26 -07:00
Mike Rice 2cedaee6f7 [OpenMP] Initial parsing/sema for the 'omp parallel loop' construct
Adds basic parsing/sema/serialization support for the
  #pragma omp parallel loop directive.

 Differential Revision: https://reviews.llvm.org/D122247
2022-03-22 13:55:47 -07:00
Zixu Wang 89f6b26f1b [clang][extract-api] Refactor ExtractAPI and improve docs
- The name SymbolGraph is inappropriate and confusing for the new library
  for clang-extract-api. Refactor and rename things to make it clear that
  ExtractAPI is the core functionality and SymbolGraph is one serializer
  for the API information.
- Add documentation comments to ExtractAPI classes and methods to improve
  readability and clearness of the ExtractAPI work.

Differential Revision: https://reviews.llvm.org/D122160
2022-03-22 13:21:57 -07:00
Corentin Jabot 8f057362a8 [Clang][NFC] Add braces to help readability
In CheckConstexprFunctionStmt, as discussed in
D111400.
2022-03-22 20:12:20 +01:00