Skip to content

Commit 0e64686

Browse files
committed
merge main into amd-staging
Change-Id: I173254c42c74fd9cce73019491d4ad90a8ca7313
2 parents e73cdd0 + bf08d02 commit 0e64686

File tree

213 files changed

+4938
-2585
lines changed

Some content is hidden

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

213 files changed

+4938
-2585
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,11 @@ Arm and AArch64 Support
351351
improvements for most targets. We have not changed the default behavior for
352352
ARMv6, but may revisit that decision in the future. Users can restore the old
353353
behavior with -m[no-]unaligned-access.
354+
- An alias identifier (rdma) has been added for targeting the AArch64
355+
Architecture Extension which uses Rounding Doubling Multiply Accumulate
356+
instructions (rdm). The identifier is available on the command line as
357+
a feature modifier for -march and -mcpu as well as via target attributes
358+
like ``target_version`` or ``target_clones``.
354359

355360
Android Support
356361
^^^^^^^^^^^^^^^

clang/include/clang/APINotes/APINotesWriter.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
8+
//
9+
// This file defines the \c APINotesWriter class that writes out source
10+
// API notes data providing additional information about source code as
11+
// a separate input, such as the non-nil/nilable annotations for
12+
// method parameters.
13+
//
14+
//===----------------------------------------------------------------------===//
915
#ifndef LLVM_CLANG_APINOTES_WRITER_H
1016
#define LLVM_CLANG_APINOTES_WRITER_H
1117

@@ -20,11 +26,16 @@ namespace clang {
2026
class FileEntry;
2127

2228
namespace api_notes {
29+
30+
/// A class that writes API notes data to a binary representation that can be
31+
/// read by the \c APINotesReader.
2332
class APINotesWriter {
2433
class Implementation;
2534
std::unique_ptr<Implementation> Implementation;
2635

2736
public:
37+
/// Create a new API notes writer with the given module name and
38+
/// (optional) source file.
2839
APINotesWriter(llvm::StringRef ModuleName, const FileEntry *SF);
2940
~APINotesWriter();
3041

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10264,15 +10264,10 @@ def err_block_on_vm : Error<
1026410264
def err_sizeless_nonlocal : Error<
1026510265
"non-local variable with sizeless type %0">;
1026610266

10267-
def err_vec_builtin_non_vector_all : Error<
10268-
"all arguments to %0 must be vectors">;
10269-
def err_vec_builtin_incompatible_vector_all : Error<
10270-
"all arguments to %0 must have vectors of the same type">;
10271-
1027210267
def err_vec_builtin_non_vector : Error<
10273-
"first two arguments to %0 must be vectors">;
10268+
"%select{first two|all}1 arguments to %0 must be vectors">;
1027410269
def err_vec_builtin_incompatible_vector : Error<
10275-
"first two arguments to %0 must have the same type">;
10270+
"%select{first two|all}1 arguments to %0 must have the same type">;
1027610271
def err_vsx_builtin_nonconstant_argument : Error<
1027710272
"argument %0 to %1 must be a 2-bit unsigned literal (i.e. 0, 1, 2 or 3)">;
1027810273

@@ -12215,8 +12210,8 @@ def err_acc_construct_appertainment
1221512210
: Error<"OpenACC construct '%0' cannot be used here; it can only "
1221612211
"be used in a statement context">;
1221712212
def err_acc_branch_in_out_compute_construct
12218-
: Error<"invalid %select{branch|return}0 %select{out of|into}1 OpenACC "
12219-
"Compute Construct">;
12213+
: Error<"invalid %select{branch|return|throw}0 %select{out of|into}1 "
12214+
"OpenACC Compute Construct">;
1222012215
def note_acc_branch_into_compute_construct
1222112216
: Note<"invalid branch into OpenACC Compute Construct">;
1222212217
def note_acc_branch_out_of_compute_construct

clang/include/clang/Driver/Options.td

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,13 @@ multiclass BoolGOption<string flag_base, KeyPathAndMacro kpm,
550550
Group<g_Group>;
551551
}
552552

553+
multiclass BoolMOption<string flag_base, KeyPathAndMacro kpm,
554+
Default default, FlagDef flag1, FlagDef flag2,
555+
BothFlags both = BothFlags<[]>> {
556+
defm NAME : BoolOption<"m", flag_base, kpm, default, flag1, flag2, both>,
557+
Group<m_Group>;
558+
}
559+
553560
// Works like BoolOption except without marshalling
554561
multiclass BoolOptionWithoutMarshalling<string prefix = "", string spelling_base,
555562
FlagDef flag1_base, FlagDef flag2_base,
@@ -4683,11 +4690,10 @@ def mretpoline : Flag<["-"], "mretpoline">, Group<m_Group>,
46834690
Visibility<[ClangOption, CLOption]>;
46844691
def mno_retpoline : Flag<["-"], "mno-retpoline">, Group<m_Group>,
46854692
Visibility<[ClangOption, CLOption]>;
4686-
defm speculative_load_hardening : BoolOption<"m", "speculative-load-hardening",
4693+
defm speculative_load_hardening : BoolMOption<"speculative-load-hardening",
46874694
CodeGenOpts<"SpeculativeLoadHardening">, DefaultFalse,
46884695
PosFlag<SetTrue, [], [ClangOption, CC1Option]>,
4689-
NegFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption]>>,
4690-
Group<m_Group>;
4696+
NegFlag<SetFalse>, BothFlags<[], [ClangOption, CLOption]>>;
46914697
def mlvi_hardening : Flag<["-"], "mlvi-hardening">, Group<m_Group>,
46924698
Visibility<[ClangOption, CLOption]>,
46934699
HelpText<"Enable all mitigations for Load Value Injection (LVI)">;
@@ -4904,13 +4910,13 @@ def mexec_model_EQ : Joined<["-"], "mexec-model=">, Group<m_wasm_Features_Driver
49044910
"explicitly terminated.">;
49054911
} // let Flags = [TargetSpecific]
49064912

4907-
defm amdgpu_ieee : BoolOption<"m", "amdgpu-ieee",
4913+
defm amdgpu_ieee : BoolMOption<"amdgpu-ieee",
49084914
CodeGenOpts<"EmitIEEENaNCompliantInsts">, DefaultTrue,
49094915
PosFlag<SetTrue, [], [ClangOption], "Sets the IEEE bit in the expected default floating point "
49104916
" mode register. Floating point opcodes that support exception flag "
49114917
"gathering quiet and propagate signaling NaN inputs per IEEE 754-2008. "
49124918
"This option changes the ABI. (AMDGPU only)">,
4913-
NegFlag<SetFalse, [], [ClangOption, CC1Option]>>, Group<m_Group>;
4919+
NegFlag<SetFalse, [], [ClangOption, CC1Option]>>;
49144920

49154921
def mcode_object_version_EQ : Joined<["-"], "mcode-object-version=">, Group<m_Group>,
49164922
HelpText<"Specify code object ABI version. Defaults to 5. (AMDGPU only)">,
@@ -4931,14 +4937,14 @@ defm wavefrontsize64 : SimpleMFlag<"wavefrontsize64",
49314937
"Specify wavefront size 64", "Specify wavefront size 32",
49324938
" mode (AMDGPU only)">;
49334939

4934-
defm unsafe_fp_atomics : BoolOption<"m", "unsafe-fp-atomics",
4940+
defm unsafe_fp_atomics : BoolMOption<"unsafe-fp-atomics",
49354941
TargetOpts<"AllowAMDGPUUnsafeFPAtomics">, DefaultFalse,
49364942
PosFlag<SetTrue, [], [ClangOption, CC1Option],
49374943
"Enable generation of unsafe floating point "
49384944
"atomic instructions. May generate more efficient code, but may not "
49394945
"respect rounding and denormal modes, and may give incorrect results "
49404946
"for certain memory destinations. (AMDGPU only)">,
4941-
NegFlag<SetFalse>>, Group<m_Group>;
4947+
NegFlag<SetFalse>>;
49424948

49434949
// TODO: Remove during upstreaming target id.
49444950
def mxnack : Flag<["-"], "mxnack">, Group<m_amdgpu_Features_Group>,
@@ -5031,11 +5037,10 @@ def mrop_protect : Flag<["-"], "mrop-protect">,
50315037
def mprivileged : Flag<["-"], "mprivileged">,
50325038
Group<m_ppc_Features_Group>;
50335039

5034-
defm regnames : BoolOption<"m", "regnames",
5040+
defm regnames : BoolMOption<"regnames",
50355041
CodeGenOpts<"PPCUseFullRegisterNames">, DefaultFalse,
50365042
PosFlag<SetTrue, [], [ClangOption, CC1Option], "Use full register names when writing assembly output">,
5037-
NegFlag<SetFalse, [], [ClangOption], "Use only register numbers when writing assembly output">>,
5038-
Group<m_Group>;
5043+
NegFlag<SetFalse, [], [ClangOption], "Use only register numbers when writing assembly output">>;
50395044
} // let Flags = [TargetSpecific]
50405045
def maix_small_local_exec_tls : Flag<["-"], "maix-small-local-exec-tls">,
50415046
Group<m_ppc_Features_Group>,
@@ -5077,10 +5082,10 @@ def mxcoff_build_id_EQ : Joined<["-"], "mxcoff-build-id=">, Group<Link_Group>, M
50775082
def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, Group<m_Group>,
50785083
HelpText<"Not emit the visibility attribute for asm in AIX OS or give all symbols 'unspecified' visibility in XCOFF object file">,
50795084
Flags<[TargetSpecific]>, Visibility<[ClangOption, CC1Option]>;
5080-
defm backchain : BoolOption<"m", "backchain",
5085+
defm backchain : BoolMOption<"backchain",
50815086
CodeGenOpts<"Backchain">, DefaultFalse,
50825087
PosFlag<SetTrue, [], [ClangOption], "Link stack frames through backchain on System Z">,
5083-
NegFlag<SetFalse>, BothFlags<[], [ClangOption, CC1Option]>>, Group<m_Group>;
5088+
NegFlag<SetFalse>, BothFlags<[], [ClangOption, CC1Option]>>;
50845089

50855090
def mno_warn_nonportable_cfstrings : Flag<["-"], "mno-warn-nonportable-cfstrings">, Group<m_Group>;
50865091
def mno_omit_leaf_frame_pointer : Flag<["-"], "mno-omit-leaf-frame-pointer">, Group<m_Group>;
@@ -7065,7 +7070,7 @@ def msmall_data_limit : Separate<["-"], "msmall-data-limit">,
70657070
def funwind_tables_EQ : Joined<["-"], "funwind-tables=">,
70667071
HelpText<"Generate unwinding tables for all functions">,
70677072
MarshallingInfoInt<CodeGenOpts<"UnwindTables">>;
7068-
defm constructor_aliases : BoolOption<"m", "constructor-aliases",
7073+
defm constructor_aliases : BoolMOption<"constructor-aliases",
70697074
CodeGenOpts<"CXXCtorDtorAliases">, DefaultFalse,
70707075
PosFlag<SetTrue, [], [ClangOption], "Enable">,
70717076
NegFlag<SetFalse, [], [ClangOption], "Disable">,

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ class CompilerInstance : public ModuleLoader {
225225
// of the context or else not CompilerInstance specific.
226226
bool ExecuteAction(FrontendAction &Act);
227227

228+
/// At the end of a compilation, print the number of warnings/errors.
229+
void printDiagnosticStats();
230+
228231
/// Load the list of plugins requested in the \c FrontendOptions.
229232
void LoadRequestedPlugins();
230233

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ class CompilerInvocationBase {
201201
/// @}
202202
};
203203

204+
class CowCompilerInvocation;
205+
204206
/// Helper class for holding the data necessary to invoke the compiler.
205207
///
206208
/// This class is designed to represent an abstract "invocation" of the
@@ -220,6 +222,9 @@ class CompilerInvocation : public CompilerInvocationBase {
220222
}
221223
~CompilerInvocation() = default;
222224

225+
explicit CompilerInvocation(const CowCompilerInvocation &X);
226+
CompilerInvocation &operator=(const CowCompilerInvocation &X);
227+
223228
/// Const getters.
224229
/// @{
225230
// Note: These need to be pulled in manually. Otherwise, they get hidden by

clang/include/clang/InstallAPI/Context.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
#include "clang/Basic/Diagnostic.h"
1313
#include "clang/Basic/FileManager.h"
1414
#include "clang/InstallAPI/HeaderFile.h"
15+
#include "llvm/ADT/DenseMap.h"
1516
#include "llvm/TextAPI/InterfaceFile.h"
16-
#include "llvm/TextAPI/RecordVisitor.h"
17-
#include "llvm/TextAPI/RecordsSlice.h"
1817

1918
namespace clang {
2019
namespace installapi {
20+
class FrontendRecordsSlice;
2121

2222
/// Struct used for generating validating InstallAPI.
2323
/// The attributes captured represent all necessary information
@@ -37,7 +37,7 @@ struct InstallAPIContext {
3737
HeaderType Type = HeaderType::Unknown;
3838

3939
/// Active TargetSlice for symbol record collection.
40-
std::shared_ptr<llvm::MachO::RecordsSlice> Slice;
40+
std::shared_ptr<FrontendRecordsSlice> Slice;
4141

4242
/// FileManager for all I/O operations.
4343
FileManager *FM = nullptr;
@@ -50,6 +50,30 @@ struct InstallAPIContext {
5050

5151
/// What encoding to write output as.
5252
llvm::MachO::FileType FT = llvm::MachO::FileType::TBD_V5;
53+
54+
/// Populate entries of headers that should be included for TextAPI
55+
/// generation.
56+
void addKnownHeader(const HeaderFile &H);
57+
58+
/// Record visited files during frontend actions to determine whether to
59+
/// include their declarations for TextAPI generation.
60+
///
61+
/// \param FE Header that is being parsed.
62+
/// \param PP Preprocesser used for querying how header was imported.
63+
/// \return Access level of header if it should be included for TextAPI
64+
/// generation.
65+
std::optional<HeaderType> findAndRecordFile(const FileEntry *FE,
66+
const Preprocessor &PP);
67+
68+
private:
69+
using HeaderMap = llvm::DenseMap<const FileEntry *, HeaderType>;
70+
71+
// Collection of parsed header files and their access level. If set to
72+
// HeaderType::Unknown, they are not used for TextAPI generation.
73+
HeaderMap KnownFiles;
74+
75+
// Collection of expected header includes and the access level for them.
76+
llvm::DenseMap<StringRef, HeaderType> KnownIncludes;
5377
};
5478

5579
} // namespace installapi

clang/include/clang/InstallAPI/Frontend.h

Lines changed: 62 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define LLVM_CLANG_INSTALLAPI_FRONTEND_H
1515

1616
#include "clang/AST/ASTConsumer.h"
17+
#include "clang/AST/Availability.h"
1718
#include "clang/Frontend/CompilerInstance.h"
1819
#include "clang/Frontend/FrontendActions.h"
1920
#include "clang/InstallAPI/Context.h"
@@ -24,23 +25,78 @@
2425
namespace clang {
2526
namespace installapi {
2627

28+
using SymbolFlags = llvm::MachO::SymbolFlags;
29+
using RecordLinkage = llvm::MachO::RecordLinkage;
30+
using GlobalRecord = llvm::MachO::GlobalRecord;
31+
using ObjCInterfaceRecord = llvm::MachO::ObjCInterfaceRecord;
32+
33+
// Represents a collection of frontend records for a library that are tied to a
34+
// darwin target triple.
35+
class FrontendRecordsSlice : public llvm::MachO::RecordsSlice {
36+
public:
37+
FrontendRecordsSlice(const llvm::Triple &T)
38+
: llvm::MachO::RecordsSlice({T}) {}
39+
40+
/// Add non-ObjC global record with attributes from AST.
41+
///
42+
/// \param Name The name of symbol.
43+
/// \param Linkage The linkage of symbol.
44+
/// \param GV The kind of global.
45+
/// \param Avail The availability information tied to the active target
46+
/// triple.
47+
/// \param D The pointer to the declaration from traversing AST.
48+
/// \param Access The intended access level of symbol.
49+
/// \param Flags The flags that describe attributes of the symbol.
50+
/// \return The non-owning pointer to added record in slice.
51+
GlobalRecord *addGlobal(StringRef Name, RecordLinkage Linkage,
52+
GlobalRecord::Kind GV,
53+
const clang::AvailabilityInfo Avail, const Decl *D,
54+
const HeaderType Access,
55+
SymbolFlags Flags = SymbolFlags::None);
56+
57+
/// Add ObjC Class record with attributes from AST.
58+
///
59+
/// \param Name The name of class, not symbol.
60+
/// \param Linkage The linkage of symbol.
61+
/// \param Avail The availability information tied to the active target
62+
/// triple.
63+
/// \param D The pointer to the declaration from traversing AST.
64+
/// \param Access The intended access level of symbol.
65+
/// \param IsEHType Whether declaration has an exception attribute.
66+
/// \return The non-owning pointer to added record in slice.
67+
ObjCInterfaceRecord *addObjCInterface(StringRef Name, RecordLinkage Linkage,
68+
const clang::AvailabilityInfo Avail,
69+
const Decl *D, HeaderType Access,
70+
bool IsEHType);
71+
72+
private:
73+
/// Frontend information captured about records.
74+
struct FrontendAttrs {
75+
const AvailabilityInfo Avail;
76+
const Decl *D;
77+
const HeaderType Access;
78+
};
79+
80+
/// Mapping of records stored in slice to their frontend attributes.
81+
llvm::DenseMap<llvm::MachO::Record *, FrontendAttrs> FrontendRecords;
82+
};
83+
2784
/// Create a buffer that contains all headers to scan
2885
/// for global symbols with.
29-
std::unique_ptr<llvm::MemoryBuffer>
30-
createInputBuffer(const InstallAPIContext &Ctx);
86+
std::unique_ptr<llvm::MemoryBuffer> createInputBuffer(InstallAPIContext &Ctx);
3187

3288
class InstallAPIAction : public ASTFrontendAction {
3389
public:
34-
explicit InstallAPIAction(llvm::MachO::RecordsSlice &Records)
35-
: Records(Records) {}
90+
explicit InstallAPIAction(InstallAPIContext &Ctx) : Ctx(Ctx) {}
3691

3792
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
3893
StringRef InFile) override {
39-
return std::make_unique<InstallAPIVisitor>(CI.getASTContext(), Records);
94+
return std::make_unique<InstallAPIVisitor>(
95+
CI.getASTContext(), Ctx, CI.getSourceManager(), CI.getPreprocessor());
4096
}
4197

4298
private:
43-
llvm::MachO::RecordsSlice &Records;
99+
InstallAPIContext &Ctx;
44100
};
45101
} // namespace installapi
46102
} // namespace clang

clang/include/clang/InstallAPI/Visitor.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#include "clang/AST/RecursiveASTVisitor.h"
1818
#include "clang/Basic/TargetInfo.h"
1919
#include "clang/Frontend/FrontendActions.h"
20+
#include "clang/InstallAPI/Context.h"
2021
#include "llvm/ADT/Twine.h"
21-
#include "llvm/TextAPI/RecordsSlice.h"
2222

2323
namespace clang {
2424
namespace installapi {
@@ -27,20 +27,29 @@ namespace installapi {
2727
class InstallAPIVisitor final : public ASTConsumer,
2828
public RecursiveASTVisitor<InstallAPIVisitor> {
2929
public:
30-
InstallAPIVisitor(ASTContext &ASTCtx, llvm::MachO::RecordsSlice &Slice)
31-
: Slice(Slice),
30+
InstallAPIVisitor(ASTContext &ASTCtx, InstallAPIContext &Ctx,
31+
SourceManager &SrcMgr, Preprocessor &PP)
32+
: Ctx(Ctx), SrcMgr(SrcMgr), PP(PP),
3233
MC(ItaniumMangleContext::create(ASTCtx, ASTCtx.getDiagnostics())),
3334
Layout(ASTCtx.getTargetInfo().getDataLayoutString()) {}
3435
void HandleTranslationUnit(ASTContext &ASTCtx) override;
3536

3637
/// Collect global variables.
3738
bool VisitVarDecl(const VarDecl *D);
3839

40+
/// Collect Objective-C Interface declarations.
41+
/// Every Objective-C class has an interface declaration that lists all the
42+
/// ivars, properties, and methods of the class.
43+
bool VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D);
44+
3945
private:
4046
std::string getMangledName(const NamedDecl *D) const;
4147
std::string getBackendMangledName(llvm::Twine Name) const;
48+
std::optional<HeaderType> getAccessForDecl(const NamedDecl *D) const;
4249

43-
llvm::MachO::RecordsSlice &Slice;
50+
InstallAPIContext &Ctx;
51+
SourceManager &SrcMgr;
52+
Preprocessor &PP;
4453
std::unique_ptr<clang::ItaniumMangleContext> MC;
4554
StringRef Layout;
4655
};

0 commit comments

Comments
 (0)