Skip to content

Commit 14c4d99

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:02cbae4fe068 into amd-gfx:5118390a1fcc
Local branch amd-gfx 5118390 Merged main:202dda8e5c3f into amd-gfx:6034dce6d758 Remote branch main 02cbae4 [RISCV] Work on subreg for insert_vector_elt when vlen is known (llvm#72666) (llvm#73680)
2 parents 5118390 + 02cbae4 commit 14c4d99

File tree

87 files changed

+1653
-1981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1653
-1981
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,9 @@ Bug Fixes in This Version
637637
- Fix crash during code generation of C++ coroutine initial suspend when the return
638638
type of await_resume is not trivially destructible.
639639
Fixes (`#63803 <https://github.com/llvm/llvm-project/issues/63803>`_)
640+
- ``__is_trivially_relocatable`` no longer returns true for non-object types
641+
such as references and functions.
642+
Fixes (`#67498 <https://github.com/llvm/llvm-project/issues/67498>`_)
640643
- Fix crash when the object used as a ``static_assert`` message has ``size`` or ``data`` members
641644
which are not member functions.
642645
- Support UDLs in ``static_assert`` message.

clang/include/clang/Frontend/ASTUnit.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -691,18 +691,16 @@ class ASTUnit {
691691
/// lifetime is expected to extend past that of the returned ASTUnit.
692692
///
693693
/// \returns - The initialized ASTUnit or null if the AST failed to load.
694-
static std::unique_ptr<ASTUnit>
695-
LoadFromASTFile(const std::string &Filename,
696-
const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad,
697-
IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
698-
const FileSystemOptions &FileSystemOpts,
699-
std::shared_ptr<HeaderSearchOptions> HSOpts,
700-
bool UseDebugInfo = false, bool OnlyLocalDecls = false,
701-
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
702-
bool AllowASTWithCompilerErrors = false,
703-
bool UserFilesAreVolatile = false,
704-
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
705-
llvm::vfs::getRealFileSystem());
694+
static std::unique_ptr<ASTUnit> LoadFromASTFile(
695+
const std::string &Filename, const PCHContainerReader &PCHContainerRdr,
696+
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
697+
const FileSystemOptions &FileSystemOpts,
698+
std::shared_ptr<HeaderSearchOptions> HSOpts, bool OnlyLocalDecls = false,
699+
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
700+
bool AllowASTWithCompilerErrors = false,
701+
bool UserFilesAreVolatile = false,
702+
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
703+
llvm::vfs::getRealFileSystem());
706704

707705
private:
708706
/// Helper function for \c LoadFromCompilerInvocation() and

clang/lib/AST/Type.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,6 +2649,8 @@ bool QualType::isTriviallyRelocatableType(const ASTContext &Context) const {
26492649

26502650
if (BaseElementType->isIncompleteType()) {
26512651
return false;
2652+
} else if (!BaseElementType->isObjectType()) {
2653+
return false;
26522654
} else if (const auto *RD = BaseElementType->getAsRecordDecl()) {
26532655
return RD->canPassInRegisters();
26542656
} else {

clang/lib/Frontend/ASTMerge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void ASTMergeAction::ExecuteAction() {
4848
/*ShouldOwnClient=*/true));
4949
std::unique_ptr<ASTUnit> Unit = ASTUnit::LoadFromASTFile(
5050
ASTFiles[I], CI.getPCHContainerReader(), ASTUnit::LoadEverything, Diags,
51-
CI.getFileSystemOpts(), CI.getHeaderSearchOptsPtr(), false);
51+
CI.getFileSystemOpts(), CI.getHeaderSearchOptsPtr());
5252

5353
if (!Unit)
5454
continue;

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -790,10 +790,9 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
790790
const std::string &Filename, const PCHContainerReader &PCHContainerRdr,
791791
WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
792792
const FileSystemOptions &FileSystemOpts,
793-
std::shared_ptr<HeaderSearchOptions> HSOpts, bool UseDebugInfo,
794-
bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
795-
bool AllowASTWithCompilerErrors, bool UserFilesAreVolatile,
796-
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
793+
std::shared_ptr<HeaderSearchOptions> HSOpts, bool OnlyLocalDecls,
794+
CaptureDiagsKind CaptureDiagnostics, bool AllowASTWithCompilerErrors,
795+
bool UserFilesAreVolatile, IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
797796
std::unique_ptr<ASTUnit> AST(new ASTUnit(true));
798797

799798
// Recover resources if we crash before exiting this method.

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
621621
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
622622
std::string(InputFile), CI.getPCHContainerReader(),
623623
ASTUnit::LoadPreprocessorOnly, ASTDiags, CI.getFileSystemOpts(),
624-
/*HeaderSearchOptions=*/nullptr, CI.getCodeGenOpts().DebugTypeExtRefs);
624+
/*HeaderSearchOptions=*/nullptr);
625625
if (!AST)
626626
return false;
627627

@@ -689,8 +689,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
689689
std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromASTFile(
690690
std::string(InputFile), CI.getPCHContainerReader(),
691691
ASTUnit::LoadEverything, Diags, CI.getFileSystemOpts(),
692-
CI.getHeaderSearchOptsPtr(),
693-
CI.getCodeGenOpts().DebugTypeExtRefs);
692+
CI.getHeaderSearchOptsPtr());
694693

695694
if (!AST)
696695
return false;
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify %s
22

3-
struct S; // expected-note 2 {{forward declaration of 'S'}}
3+
struct S; // expected-note 6 {{forward declaration of 'S'}}
44

55
void f() {
66
__is_pod(S); // expected-error{{incomplete type 'S' used in type trait expression}}
77
__is_pod(S[]); // expected-error{{incomplete type 'S' used in type trait expression}}
8+
9+
__is_trivially_copyable(S); // expected-error{{incomplete type 'S' used in type trait expression}}
10+
__is_trivially_copyable(S[]); // expected-error{{incomplete type 'S' used in type trait expression}}
11+
12+
__is_trivially_relocatable(S); // expected-error{{incomplete type 'S' used in type trait expression}}
13+
__is_trivially_relocatable(S[]); // expected-error{{incomplete type 'S' used in type trait expression}}
814
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
2+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
3+
4+
// expected-no-diagnostics
5+
6+
static_assert(!__is_pod(void), "");
7+
static_assert(!__is_pod(int&), "");
8+
static_assert(!__is_pod(int()), "");
9+
10+
static_assert(!__is_trivially_copyable(void), "");
11+
static_assert(!__is_trivially_copyable(int&), "");
12+
static_assert(!__is_trivially_copyable(int()), "");
13+
14+
static_assert(!__is_trivially_relocatable(void), "");
15+
static_assert(!__is_trivially_relocatable(int&), "");
16+
static_assert(!__is_trivially_relocatable(int()), "");

clang/tools/c-index-test/core_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static bool printSourceSymbolsFromModule(StringRef modulePath,
276276
CompilerInstance::createDiagnostics(new DiagnosticOptions());
277277
std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
278278
std::string(modulePath), *pchRdr, ASTUnit::LoadASTOnly, Diags,
279-
FileSystemOpts, HSOpts, /*UseDebugInfo=*/false,
279+
FileSystemOpts, HSOpts,
280280
/*OnlyLocalDecls=*/true, CaptureDiagsKind::None,
281281
/*AllowASTWithCompilerErrors=*/true,
282282
/*UserFilesAreVolatile=*/false);

clang/tools/libclang/CIndex.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,8 +3877,8 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,
38773877
std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
38783878
ast_filename, CXXIdx->getPCHContainerOperations()->getRawReader(),
38793879
ASTUnit::LoadEverything, Diags, FileSystemOpts, HSOpts,
3880-
/*UseDebugInfo=*/false, CXXIdx->getOnlyLocalDecls(),
3881-
CaptureDiagsKind::All, /*AllowASTWithCompilerErrors=*/true,
3880+
CXXIdx->getOnlyLocalDecls(), CaptureDiagsKind::All,
3881+
/*AllowASTWithCompilerErrors=*/true,
38823882
/*UserFilesAreVolatile=*/true);
38833883
*out_TU = MakeCXTranslationUnit(CXXIdx, std::move(AU));
38843884
return *out_TU ? CXError_Success : CXError_Failure;

clang/unittests/Frontend/ASTUnitTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ TEST_F(ASTUnitTest, SaveLoadPreservesLangOptionsInPrintingPolicy) {
9393

9494
std::unique_ptr<ASTUnit> AU = ASTUnit::LoadFromASTFile(
9595
std::string(ASTFileName.str()), PCHContainerOps->getRawReader(),
96-
ASTUnit::LoadEverything, Diags, FileSystemOptions(), HSOpts,
97-
/*UseDebugInfo=*/false);
96+
ASTUnit::LoadEverything, Diags, FileSystemOptions(), HSOpts);
9897

9998
if (!AU)
10099
FAIL() << "failed to load ASTUnit";

compiler-rt/lib/sanitizer_common/sanitizer_platform.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,12 @@
263263
#if SANITIZER_WINDOWS64 && SANITIZER_ARM64
264264
# define SANITIZER_WINDOWS_ARM64 1
265265
# define SANITIZER_WINDOWS_x64 0
266-
#else
266+
#elif SANITIZER_WINDOWS64 && !SANITIZER_ARM64
267267
# define SANITIZER_WINDOWS_ARM64 0
268268
# define SANITIZER_WINDOWS_x64 1
269+
#else
270+
# define SANITIZER_WINDOWS_ARM64 0
271+
# define SANITIZER_WINDOWS_x64 0
269272
#endif
270273

271274
#if SANITIZER_SOLARIS && SANITIZER_WORDSIZE == 32

libc/docs/dev/api_test.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
========
44
API Test
55
========
6+
7+
.. warning::
8+
This page is severely out of date. Much of the information it contains may be
9+
incorrect. Please only remove this warning once the page has been updated.
10+
611
The implementation of libc-project is unique because our public C header files
712
are generated using information from ground truth captured in TableGen files.
813
Unit tests only exercise the internal C++ implementations and don't ensure the

libc/docs/dev/clang_tidy_checks.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
LLVM libc clang-tidy checks
44
===========================
5+
6+
7+
.. warning::
8+
This page is severely out of date. Much of the information it contains may be
9+
incorrect. Please only remove this warning once the page has been updated.
10+
511
These are the clang-tidy checks designed to help enforce implementation
612
standards.
713
The configuration file is ``src/.clang-tidy``.

libc/docs/dev/header_generation.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Generating Public and Internal headers
22
======================================
33

4+
.. warning::
5+
This page is severely out of date. Much of the information it contains may be
6+
incorrect. Please only remove this warning once the page has been updated.
7+
48
Other libc implementations make use of preprocessor macro tricks to make header
59
files platform agnostic. When macros aren't suitable, they rely on build
610
system tricks to pick the right set of files to compile and export. While these

libc/docs/dev/implementation_standard.rst

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -5,81 +5,69 @@ LLVM-libc entrypoints are defined in the entrypoints document. In this document,
55
we explain how the entrypoints are implemented. The source layout document
66
explains that, within the high level ``src`` directory, there exists one
77
directory for every public header file provided by LLVM-libc. The
8-
implementations of related group of entrypoints will also live in a directory of
9-
their own. This directory will have a name indicative of the related group of
10-
entrypoints, and will be under the directory corresponding to the header file of
11-
the entrypoints. For example, functions like ``fopen`` and ``fclose`` cannot be
12-
tested independent of each other and hence will live in a directory named
13-
``src/stdio/file_operations``. On the other hand, the implementation of the
14-
``round`` function from ``math.h`` can be tested by itself, so it will live in
15-
the directory of its own named ``src/math/round/``.
8+
implementations of entrypoints live in the directory for the header they belong
9+
to. Some entrypoints are platform specific, and so their implementations are in
10+
a subdirectory with the name of the platform (e.g. ``stdio/linux/remove.cpp``).
1611

1712
Implementation of entrypoints can span multiple ``.cpp`` and ``.h`` files, but
1813
there will be at least one header file with name of the form
19-
``<entrypoint name>.h`` for every entrypoint. This header file is called as the
20-
implementation header file. For the ``round`` function, the path to the
21-
implementation header file will be ``src/math/round/round.h``. The rest of this
22-
document explains the structure of implementation header files and ``.cpp``
23-
files.
14+
``<entrypoint name>.h`` for every entrypoint. This header file is called the
15+
implementation header file. For the ``isalpha`` function, the path to the
16+
implementation header file is ``src/ctype/isalpha.h``.
2417

2518
Implementation Header File Structure
2619
------------------------------------
2720

28-
We will use the ``round`` function from the public ``math.h`` header file as an
29-
example. The ``round`` function will be declared in an internal header file
30-
``src/math/round/round.h`` as follows::
21+
We will use the ``isalpha`` function from the public ``ctype.h`` header file as an
22+
example. The ``isalpha`` function will be declared in an internal header file
23+
``src/ctype/isalpha.h`` as follows::
3124

32-
// --- round.h --- //
33-
#ifndef LLVM_LIBC_SRC_MATH_ROUND_ROUND_H
34-
#define LLVM_LIBC_SRC_MATH_ROUND_ROUND_H
25+
// --- isalpha.h --- //
26+
#ifndef LLVM_LIBC_SRC_CTYPE_ISALPHA_H
27+
#define LLVM_LIBC_SRC_CTYPE_ISALPHA_H
3528

3629
namespace LIBC_NAMESPACE {
3730

38-
double round(double);
31+
int isalpha(int c);
3932

4033
} // namespace LIBC_NAMESPACE
4134

42-
#endif LLVM_LIBC_SRC_MATH_ROUND_ROUND_H
35+
#endif LLVM_LIBC_SRC_CTYPE_ISALPHA_H
4336

44-
Notice that the ``round`` function declaration is nested inside the namespace
45-
``LIBC_NAMESPACE``. All implementation constructs in LLVM-libc are declared within
46-
the namespace ``LIBC_NAMESPACE``.
37+
Notice that the ``isalpha`` function declaration is nested inside the namespace
38+
``LIBC_NAMESPACE``. All implementation constructs in LLVM-libc are declared
39+
within the namespace ``LIBC_NAMESPACE``.
4740

4841
``.cpp`` File Structure
4942
-----------------------
5043

51-
The implementation can span multiple ``.cpp`` files. However, the signature of
52-
the entrypoint function should make use of a special macro. For example, the
53-
``round`` function from ``math.h`` should be defined as follows, say in the file
54-
``src/math/math/round.cpp``::
44+
The main ``.cpp`` file is named ``<entrypoint name>.cpp`` and is usually in the
45+
same folder as the header. It contains the signature of the entrypoint function,
46+
which must be defined with the ``LLVM_LIBC_FUNCTION`` macro. For example, the
47+
``isalpha`` function from ``ctype.h`` is defined as follows, in the file
48+
``src/ctype/isalpha.cpp``::
5549

56-
// --- round.cpp --- //
50+
// --- isalpha.cpp --- //
5751

5852
namespace LIBC_NAMESPACE {
5953

60-
double LLVM_LIBC_ENTRYPOINT(round)(double d) {
54+
LLVM_LIBC_FUNCTION(int, isalpha, (int c)) {
6155
// ... implementation goes here.
6256
}
6357

6458
} // namespace LIBC_NAMESPACE
6559

66-
Notice the use of the macro ``LLVM_LIBC_ENTRYPOINT``. This macro helps us define
67-
an C alias symbol for the C++ implementation. The C alias need not be added by
68-
the macro by itself. For example, for ELF targets, the macro is defined as
69-
follows::
60+
Notice the use of the macro ``LLVM_LIBC_FUNCTION``. This macro helps us define
61+
a C alias symbol for the C++ implementation. For example, for a library build,
62+
the macro is defined as follows::
7063

71-
#define ENTRYPOINT_SECTION_ATTRIBUTE(name) \
72-
__attribute__((section(".llvm.libc.entrypoint."#name)))
73-
#define LLVM_LIBC_ENTRYPOINT(name) ENTRYPOINT_SECTION_ATTRIBUTE(name) name
64+
#define LLVM_LIBC_FUNCTION(type, name, arglist)
65+
LLVM_LIBC_FUNCTION_IMPL(type, name, arglist)
66+
#define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist)
67+
LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name)
68+
__##name##_impl__ __asm__(#name);
69+
decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]];
70+
type __##name##_impl__ arglist
7471

75-
The macro places the C++ function in a unique section with name
76-
``.llvm.libc.entrypoint.<function name>``. This allows us to add a C alias using
77-
a post build step. For example, for the ``round`` function, one can use
78-
``objcopy`` to add an alias symbol as follows::
79-
80-
objcopy --add-symbol round=.llvm.libc.entrypoint.round:0,function round.o
81-
82-
NOTE: We use a post build ``objcopy`` step to add an alias instead of using
83-
the ``__attribute__((alias))``. For C++, this ``alias`` attribute requires
84-
mangled names of the referees. Using the post build ``objcopy`` step helps
85-
us avoid putting mangled names with ``alias`` attributes.
72+
The LLVM_LIBC_FUNCTION_ATTR macro is normally defined to nothing, but can be
73+
defined by vendors who want to set their own attributes.

0 commit comments

Comments
 (0)