Commit Graph

94073 Commits

Author SHA1 Message Date
Yaxun (Sam) Liu 04fb81674e [CUDA][HIP] Externalize kernels with internal linkage
This patch is a continuation of https://reviews.llvm.org/D123353.

Not only kernels in anonymous namespace, but also template
kernels with template arguments in anonymous namespace
need to be externalized.

To be more generic, this patch checks the linkage of a kernel
assuming the kernel does not have __global__ attribute. If
the linkage is internal then clang will externalize it.

This patch also fixes the postfix for externalized symbol
since nvptx does not allow '.' in symbol name.

Reviewed by: Artem Belevich

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

Fixes: https://github.com/llvm/llvm-project/issues/54560
2022-04-22 17:05:36 -04:00
Nico Weber c94a02e0e2 [git-clang-format] Change run line from python to python3
Several systems no longer ship `python`.

Differential Revision: https://reviews.llvm.org/D124280
2022-04-22 15:14:51 -04:00
Nico Weber a45764f2f9 [git-clang-format] Add some examples to the help text
Differential Revision: https://reviews.llvm.org/D124282
2022-04-22 15:14:04 -04:00
Vitaly Buka 2518d4f6d8 [nfc][msan] Add D123875 into release notes 2022-04-22 11:14:28 -07:00
Tom Eccles 225b91e6cb Fix crash getting name of a template decl
NamedDecl::getIdentifier can return a nullptr when
DeclarationName::isIdentifier is false, which leads to a null pointer
dereference when TypePrinter::printTemplateId calls ->getName().

NamedDecl::getName does the same thing in the successful case and
returns an empty string in the failure case.

This crash affects the llvm 14 packages on llvm.org.
2022-04-22 13:03:28 -04:00
Christopher Di Bella e9a902c7f7 Revert "Revert "Revert "[clang][pp] adds '#pragma include_instead'"""
> Includes regression test for problem noted by @hans.
> is reverts commit 973de71.
>
> Differential Revision: https://reviews.llvm.org/D106898

Feature implemented as-is is fairly expensive and hasn't been used by
libc++. A potential reimplementation is possible if libc++ become
interested in this feature again.

Differential Revision: https://reviews.llvm.org/D123885
2022-04-22 16:37:20 +00:00
owenca c9e7eec7bc [clang-format][NFC] Use isComment() in setCommentLineLevels()
Also replace an unnecessary check with assert() in the unwrapped
line parser.

Differential Revision: https://reviews.llvm.org/D124215
2022-04-22 09:21:28 -07:00
Iain Sandoe 4c4ff004a2 [C++20][Modules][Driver][HU 2/N] Add fmodule-header, fmodule-header=
These command-line flags are alternates to providing the -x
c++-*-header indicators that we are building a header unit.

Act on fmodule-header= for headers on the c/l:

If we have x.hh -fmodule-header, then we should treat that header
as a header unit input (equivalent to -xc++-header-unit-header x.hh).

Likewise, for fmodule-header={user,system} the source should be now
recognised as a header unit input (since this can affect the job list
that we need).

It's not practical to recognise a header without any suffix so
-fmodule-header=system foo isn't going to happen. Although
-fmodule-header=system foo.hh will work OK.  However we can make it
work if the user indicates that the item without a suffix is a valid
header. (so -fmodule-header=system -xc++-header vector)

Differential Revision: https://reviews.llvm.org/D121589
2022-04-22 14:14:19 +01:00
Byoungchan Lee f69328049e [cc1as] Add support for emitting the build version load command for -darwin-target-variant
This patch extends cc1as to export the build version load command with
LC_VERSION_MIN_MACOSX.
This is especially important for Mac Catalyst as Mac Catalyst uses
the MacOS's compiler rt built-ins.

Differential Revision: https://reviews.llvm.org/D121868
2022-04-22 08:38:07 -04:00
Haojian Wu 864752cfeb [AST] QualifiedTemplateName::getTemplateDecl cleanup.
This is a followup cleanup of 1234b1c6d8

Differential Revision: https://reviews.llvm.org/D124238
2022-04-22 14:28:48 +02:00
Nico Weber 8dbc6b5600 Revert "[randstruct] Check final randomized layout ordering"
This reverts commit a7815d33bf.
Test fails on Windows, see comments on https://reviews.llvm.org/D124199
2022-04-22 08:27:32 -04:00
Ying Yi b09ba42620 Bug 51277: [DWARF] DW_AT_alignment incorrect when
attribute((__aligned__)) is present but ignored`

In the original code, the 'getDeclAlignIfRequired' function is used.
The 'getDeclAlignIfRequired' function will return the max alignment
of all aligned attributes if the type has aligned attributes. The
function doesn't consider the type at all.

The 'getTypeAlignIfRequired' function uses the type's alignment value,
which also used by the 'alignof' function. I think we should use the
function of 'getTypeAlignIfRequired'.

Reviewed By: dblaikie, jmorse, wolfgangp

Differential Revision: https://reviews.llvm.org/D124006
2022-04-22 12:15:00 +01:00
Iain Sandoe 5c6a146498 [C++20][Modules][Driver][HU 1/N] Initial handling for -xc++-{system,user}-header.
This adds file types and handling for three input types, representing a C++20
header unit source:

 1. When provided with a complete pathname for the header.
 2. For a header to be looked up (by the frontend) in the user search paths
 3. For a header to be looked up in the system search paths.

We also add a pre-processed file type (although that is a single type, regardless
of the original input type).

These types may be specified with -xc++-{user,system,header-unit}-header xxxx.

These types allow us to disambiguate header unit jobs from PCH ones, and thus
we handle these differently from other header jobs in two ways:

 1. The job construction is altered to build a C++20 header unit (rather than a
    PCH file, as would be the case for other headers).
 2. When the type is "user" or "system" we defer checking for the file until the
    front end is run, since we need to look up the header in the relevant paths
    which are not known at this point.

Differential Revision: https://reviews.llvm.org/D121588
2022-04-22 09:24:29 +01:00
Michael Liao 036aeac36c [Testing] Fix the shared build. NFC. 2022-04-22 02:46:54 -04:00
Brad Smith 7898c79b74 Fix test for c7ee0b8bda
OpenBSD/sparc is dead and support was removed awhile ago.
2022-04-22 02:27:10 -04:00
Mark Kettenis c7ee0b8bda [Clang] Fix the guaranteed alignment of memory returned by malloc/new on OpenBSD
The guaranteed alignment is 16 bytes on OpenBSD.
2022-04-22 02:03:55 -04:00
Jun Zhang 3b3dd76d8d
Use range based for loop in Sema::CheckParameterPacksForExpansion. NFC
Signed-off-by: Jun Zhang <jun@junz.org>
2022-04-22 13:31:31 +08:00
Xiang1 Zhang afa536e33e [x86] Support 3 builtin functions for 32-bits mode
_mm_cvtsi128_si64, _mm_cvtsi64_si128, _mm_extract_epi64

Reviewed By:RKSimon, Topper Craig
Differential Revision: https://reviews.llvm.org/D124067
2022-04-22 11:28:28 +08:00
Bill Wendling a7815d33bf [randstruct] Check final randomized layout ordering
This uses "llvm::shuffle" to stop differences in shuffle ordering on
different platforms.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D124199
2022-04-21 19:41:00 -07:00
Xiang1 Zhang 6454ff35e0 [Clang Format] emmintrin.h smmintrin.h (NFC) 2022-04-22 09:29:52 +08:00
Xiang1 Zhang caf5ad5da7 Revert "[x86] Support 3 builtin functions for 32-bits mode"
This reverts commit a69c219a8c.
2022-04-22 09:11:40 +08:00
Xiang1 Zhang a69c219a8c [x86] Support 3 builtin functions for 32-bits mode
_mm_cvtsi128_si64, _mm_cvtsi64_si128, _mm_extract_epi64
2022-04-22 09:06:25 +08:00
Joseph Huber 3348991106 [OpenMP] Properly guard linker input using the new driver
Summary:
A new offloading action builder line was added that wasn't guarded with
the new driver for OpenMP. This doesn't affect anything now but could
potentially cause problems.
2022-04-21 18:50:26 -04:00
Paul Kirth b8786413d8 Revert "[clang][safestack] Remove triple from stack usage test"
This reverts commit 414f84ba29.

Requires deirectives had already been added to the test, and CC1 tests
should use a target triple.

Differential Revision: https://reviews.llvm.org/D124210
2022-04-21 22:47:56 +00:00
Shafik Yaghmour 5ff992bca2 [DEBUG-INFO] Change how we handle auto return types for lambda operator() to be consistent with gcc
D70524 added support for auto return types for C++ member functions. I was
implementing support on the LLDB side for looking up the deduced type.

I ran into trouble with some cases with respect to lambdas. I looked into
how gcc was handling these cases and it appears gcc emits the deduced return type for lambdas.

So I am changing out behavior to match that.

Differential Revision: https://reviews.llvm.org/D123319
2022-04-21 14:58:50 -07:00
Paul Kirth 414f84ba29 [clang][safestack] Remove triple from stack usage test
Supplying the target triple caused breakeages for compilers that don't support
the supplied triple.

Reviewed By: mysterymath

Differential Revision: https://reviews.llvm.org/D124203
2022-04-21 21:58:24 +00:00
owenca 221c2b68dd [clang-format] Fix a crash on AllowShortFunctionsOnASingleLine
Fixes #55008.

Differential Revision: https://reviews.llvm.org/D124152
2022-04-21 14:56:30 -07:00
Sam McCall 713800d331 [Testing] Fix standalone builds after a7691dee2d 2022-04-21 23:22:46 +02:00
Richard Smith f6a5ab6c8c Use builtin recognition to detect std::move / std::forward.
Replaces some prior ad-hoc detection strategies and generally cleans up
a little. No functional change intended.
2022-04-21 14:21:07 -07:00
owenca 7343f768d1 [clang-format][NFC] Clean up code in token annotator
Differential Revision: https://reviews.llvm.org/D123741
2022-04-21 14:17:38 -07:00
Vitaly Buka b580c0e019 [msan] Update Use-after-destruction documentation
Reviewed By: kda, eugenis

Differential Revision: https://reviews.llvm.org/D124058
2022-04-21 14:02:02 -07:00
Douglas Yung 311929267d Mark test stack-usage-safestack.c as requiring x86.
This should fix buildbots that don't build the x86 target.
2022-04-21 13:58:39 -07:00
Sam McCall 480c59c11a [Testing] fix shared lib build after a7691dee2d
We still want clang_target_link_libraries for the clang deps.
2022-04-21 22:50:33 +02:00
Sam McCall a7691dee2d [Testing] TestAST, a helper for writing straight-line AST tests
Tests that need ASTs have to deal with the awkward control flow of
FrontendAction in some way. There are a few idioms used:
 - don't bother with unit tests, use clang -dump-ast
 - create an ASTConsumer by hand, which is bulky
 - use ASTMatchFinder - works pretty well if matchers are actually
   needed, very strange if they are not
 - use ASTUnit - this yields nice straight-line code, but ASTUnit is a
   terrifically complicated library not designed for this purpose

TestAST provides a very simple way to write straight-line tests: specify
the code/flags and it provides an AST that is kept alive until the
object is destroyed.
It's loosely modeled after TestTU in clangd, which we've successfully
used for a variety of tests.

I've updated a couple of clang tests to use this helper, IMO they're clearer.

Differential Revision: https://reviews.llvm.org/D123668
2022-04-21 21:46:45 +02:00
Sam McCall e80ee1829c Reland [Frontend] avoid copy of PCH data when PrecompiledPreamble stores it in memory
This reverts commit eadf352707.

The reland fixes a couple of places in clang that were unneccesarily
requesting a null-terminated buffer of the PCH, and hitting assertions.
2022-04-21 21:15:39 +02:00
Sam McCall eadf352707 Revert "[Frontend] avoid copy of PCH data when PrecompiledPreamble stores it in memory"
This reverts commit 6e22dac2e2.

Seems to cause bot failures e.g.
https://lab.llvm.org/buildbot/#/builders/109/builds/37071
2022-04-21 20:22:47 +02:00
Ulrich Weigand 1283ccb610 Support z16 processor name
The recently announced IBM z16 processor implements the architecture
already supported as "arch14" in LLVM.  This patch adds support for
"z16" as an alternate architecture name for arch14.
2022-04-21 19:58:22 +02:00
Sam McCall 6e22dac2e2 [Frontend] avoid copy of PCH data when PrecompiledPreamble stores it in memory
Instead of unconditionally copying the PCHBuffer into an ostream which can be
backed either by a string or a file, just make the PCHBuffer itself the
in-memory storage.

Differential Revision: https://reviews.llvm.org/D124180
2022-04-21 19:52:59 +02:00
Wael Yehia f296b4c444 [AIX] Always pass namedsects option when linking with PGO.
Differential Revision: https://reviews.llvm.org/D124046
2022-04-21 17:01:37 +00:00
Jacob Lambert afcc6baac5 [clang][HIP] Updating driver to enable archive/bitcode to bitcode linking when targeting HIPAMD toolchain
Differential Revision: https://reviews.llvm.org/D124151
2022-04-21 09:24:33 -07:00
Sam McCall af3fb07154 [Frontend] Simplify PrecompiledPreamble::PCHStorage. NFC
- Remove fiddly union, preambles are heavyweight
- Remove fiddly move constructors in TempPCHFile and PCHStorage, use unique_ptr
- Remove unneccesary accessors on PCHStorage
- Remove trivial InMemoryStorage
- Move implementation details into cpp file

This is a prefactoring, followup change will change the in-memory PCHStorage to
avoid extra string copies while creating it.

Differential Revision: https://reviews.llvm.org/D124177
2022-04-21 18:10:13 +02:00
Paul Robinson f80e369f61 [PS4] Driver: use correct --shared option 2022-04-21 08:19:42 -07:00
Aaron Ballman 408226f20a Fix Sphinx build 2022-04-21 08:52:29 -04:00
Sven van Haastregt 87a258366e [OpenCL] Guard read_write images with TypeExtension
Ensure that any `read_write` image type carries the
`__opencl_c_read_write_images` upon construction of the `ImageType`.
2022-04-21 10:52:41 +01:00
Haojian Wu 1234b1c6d8 [AST] Support template declaration found through using-decl for QualifiedTemplateName.
This is a followup of https://reviews.llvm.org/D123127, adding support
for the QualifiedTemplateName.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D123775
2022-04-21 10:53:23 +02:00
Xiang Li b02d88d5af [HLSL] Add shader attribute
Shader attribute is for shader library identify entry functions.
Here's an example,

[shader("pixel")]
float ps_main() : SV_Target {
  return 1;
}

When compile this shader to library target like -E lib_6_3, compiler needs to know ps_main is an entry function for pixel shader. Shader attribute is to offer the information.

A new attribute HLSLShader is added to support shader attribute. It has an EnumArgument which included all possible shader stages.

Reviewed By: aaron.ballman, MaskRay

Differential Revision: https://reviews.llvm.org/D123907
2022-04-20 23:46:43 -07:00
Chuanqi Xu ce2257d69f [C++20] [Modules] Judge current module correctly
Now the implementation would accept following code:
```
//--- impl.cppm
module M:impl;
class A {};

//--- M.cppm
export module M;
import :impl;

//--- Use.cpp
import M;
void test() {
    A a; // Expected error. A is not visible here.
}
```

which is clearly wrong.  The root cause is the implementation of
`isInCurrentModule` would return true if the module is a partition! So
in the above example, although Use.cpp is not a module unit,
`isInCurrentModule ` would still return true when the compiler tries to
see if the owning module of `A` is the current module. I believe this is
an oversight. This patch tries to fix this problem.

Reviewed By: iains

Differential Revision: https://reviews.llvm.org/D123837
2022-04-21 11:09:55 +08:00
Chuanqi Xu 483efc9ad0 [Pipelines] Remove Legacy Passes in Coroutines
The legacy passes are deprecated now and would be removed in near
future. This patch tries to remove legacy passes in coroutines.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D123918
2022-04-21 10:59:11 +08:00
Richard Smith 72315d02c4 Treat `std::move`, `forward`, etc. as builtins.
This is extended to all `std::` functions that take a reference to a
value and return a reference (or pointer) to that same value: `move`,
`forward`, `move_if_noexcept`, `as_const`, `addressof`, and the
libstdc++-specific function `__addressof`.

We still require these functions to be declared before they can be used,
but don't instantiate their definitions unless their addresses are
taken. Instead, code generation, constant evaluation, and static
analysis are given direct knowledge of their effect.

This change aims to reduce various costs associated with these functions
-- per-instantiation memory costs, compile time and memory costs due to
creating out-of-line copies and inlining them, code size at -O0, and so
on -- so that they are not substantially more expensive than a cast.
Most of these improvements are very small, but I measured a 3% decrease
in -O0 object file size for a simple C++ source file using the standard
library after this change.

We now automatically infer the `const` and `nothrow` attributes on these
now-builtin functions, in particular meaning that we get a warning for
an unused call to one of these functions.

In C++20 onwards, we disallow taking the addresses of these functions,
per the C++20 "addressable function" rule. In earlier language modes, a
compatibility warning is produced but the address can still be taken.

The same infrastructure is extended to the existing MSVC builtin
`__GetExceptionInfo`, which is now only recognized in namespace `std`
like it always should have been.

This is a re-commit of
  fc30901096,
  a571f82a50,
  64c045e25b, and
  de6ddaeef3,
and reverts aa643f455a.
This change also includes a workaround for users using libc++ 3.1 and
earlier (!!), as apparently happens on AIX, where std::move sometimes
returns by value.

Reviewed By: aaron.ballman

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

Revert "Fixup D123950 to address revert of D123345"

This reverts commit aa643f455a.
2022-04-20 17:58:31 -07:00
David Tenty aa643f455a Fixup D123950 to address revert of D123345
Since D123345 got reverted Builtin::BIaddressof and Builtin::BI__addressof don't exist and cause build breaks.
2022-04-20 19:59:07 -04:00