Skip to content

Commit aa2759c

Browse files
committed
merge main into amd-staging
Change-Id: Icd889ec2aaa5fc9434845387b58f36ca410fd5b8
2 parents e3ea278 + 375bb38 commit aa2759c

File tree

367 files changed

+7483
-2423
lines changed

Some content is hidden

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

367 files changed

+7483
-2423
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,6 +2580,7 @@ struct CFISnapshot {
25802580
case MCCFIInstruction::OpNegateRAStateWithPC:
25812581
case MCCFIInstruction::OpLLVMDefAspaceCfa:
25822582
case MCCFIInstruction::OpLabel:
2583+
case MCCFIInstruction::OpValOffset:
25832584
llvm_unreachable("unsupported CFI opcode");
25842585
break;
25852586
case MCCFIInstruction::OpRememberState:
@@ -2719,6 +2720,7 @@ struct CFISnapshotDiff : public CFISnapshot {
27192720
case MCCFIInstruction::OpNegateRAStateWithPC:
27202721
case MCCFIInstruction::OpLLVMDefAspaceCfa:
27212722
case MCCFIInstruction::OpLabel:
2723+
case MCCFIInstruction::OpValOffset:
27222724
llvm_unreachable("unsupported CFI opcode");
27232725
return false;
27242726
case MCCFIInstruction::OpRememberState:
@@ -2869,6 +2871,7 @@ BinaryFunction::unwindCFIState(int32_t FromState, int32_t ToState,
28692871
case MCCFIInstruction::OpNegateRAStateWithPC:
28702872
case MCCFIInstruction::OpLLVMDefAspaceCfa:
28712873
case MCCFIInstruction::OpLabel:
2874+
case MCCFIInstruction::OpValOffset:
28722875
llvm_unreachable("unsupported CFI opcode");
28732876
break;
28742877
case MCCFIInstruction::OpGnuArgsSize:

clang/include/clang/Lex/HeaderSearchOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ class HeaderSearchOptions {
255255
LLVM_PREFERRED_TYPE(bool)
256256
unsigned ModulesHashContent : 1;
257257

258+
/// Whether AST files should only contain the preprocessor information.
259+
LLVM_PREFERRED_TYPE(bool)
260+
unsigned ModulesSerializeOnlyPreprocessor : 1;
261+
258262
/// Whether we should include all things that could impact the module in the
259263
/// hash.
260264
///
@@ -288,6 +292,7 @@ class HeaderSearchOptions {
288292
ModulesSkipHeaderSearchPaths(false),
289293
ModulesSkipPragmaDiagnosticMappings(false),
290294
ModulesPruneNonAffectingModuleMaps(true), ModulesHashContent(false),
295+
ModulesSerializeOnlyPreprocessor(false),
291296
ModulesStrictContextHash(false), ModulesIncludeVFSUsage(false),
292297
AllowModuleMapSubdirectorySearch(true) {}
293298

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ class ASTWriter : public ASTDeserializationListener,
564564
void WriteHeaderSearch(const HeaderSearch &HS);
565565
void WritePreprocessorDetail(PreprocessingRecord &PPRec,
566566
uint64_t MacroOffsetsBase);
567-
void WriteSubmodules(Module *WritingModule, ASTContext &Context);
567+
void WriteSubmodules(Module *WritingModule, ASTContext *Context);
568568

569569
void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
570570
bool isModule);
@@ -585,7 +585,7 @@ class ASTWriter : public ASTDeserializationListener,
585585
void WriteComments(ASTContext &Context);
586586
void WriteSelectors(Sema &SemaRef);
587587
void WriteReferencedSelectorsPool(Sema &SemaRef);
588-
void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
588+
void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver *IdResolver,
589589
bool IsModule);
590590
void WriteDeclAndTypes(ASTContext &Context);
591591
void PrepareWritingSpecialDecls(Sema &SemaRef);
@@ -642,7 +642,7 @@ class ASTWriter : public ASTDeserializationListener,
642642
void WriteDeclAbbrevs();
643643
void WriteDecl(ASTContext &Context, Decl *D);
644644

645-
ASTFileSignature WriteASTCore(Sema &SemaRef, StringRef isysroot,
645+
ASTFileSignature WriteASTCore(Sema *SemaPtr, StringRef isysroot,
646646
Module *WritingModule);
647647

648648
public:
@@ -662,10 +662,13 @@ class ASTWriter : public ASTDeserializationListener,
662662
/// include timestamps in the output file.
663663
time_t getTimestampForOutput(const FileEntry *E) const;
664664

665-
/// Write a precompiled header for the given semantic analysis.
665+
/// Write a precompiled header or a module with the AST produced by the
666+
/// \c Sema object, or a dependency scanner module with the preprocessor state
667+
/// produced by the \c Preprocessor object.
666668
///
667-
/// \param SemaRef a reference to the semantic analysis object that processed
668-
/// the AST to be written into the precompiled header.
669+
/// \param Subject The \c Sema object that processed the AST to be written, or
670+
/// in the case of a dependency scanner module the \c Preprocessor that holds
671+
/// the state.
669672
///
670673
/// \param WritingModule The module that we are writing. If null, we are
671674
/// writing a precompiled header.
@@ -676,8 +679,9 @@ class ASTWriter : public ASTDeserializationListener,
676679
///
677680
/// \return the module signature, which eventually will be a hash of
678681
/// the module but currently is merely a random 32-bit number.
679-
ASTFileSignature WriteAST(Sema &SemaRef, StringRef OutputFile,
680-
Module *WritingModule, StringRef isysroot,
682+
ASTFileSignature WriteAST(llvm::PointerUnion<Sema *, Preprocessor *> Subject,
683+
StringRef OutputFile, Module *WritingModule,
684+
StringRef isysroot,
681685
bool ShouldCacheASTInMemory = false);
682686

683687
/// Emit a token.
@@ -925,9 +929,9 @@ class PCHGenerator : public SemaConsumer {
925929
void anchor() override;
926930

927931
Preprocessor &PP;
932+
llvm::PointerUnion<Sema *, Preprocessor *> Subject;
928933
std::string OutputFile;
929934
std::string isysroot;
930-
Sema *SemaPtr;
931935
std::shared_ptr<PCHBuffer> Buffer;
932936
llvm::BitstreamWriter Stream;
933937
ASTWriter Writer;
@@ -942,9 +946,7 @@ class PCHGenerator : public SemaConsumer {
942946
bool isComplete() const { return Buffer->IsComplete; }
943947
PCHBuffer *getBufferPtr() { return Buffer.get(); }
944948
StringRef getOutputFile() const { return OutputFile; }
945-
DiagnosticsEngine &getDiagnostics() const {
946-
return SemaPtr->getDiagnostics();
947-
}
949+
DiagnosticsEngine &getDiagnostics() const;
948950
Preprocessor &getPreprocessor() { return PP; }
949951

950952
virtual Module *getEmittingModule(ASTContext &Ctx);
@@ -960,7 +962,7 @@ class PCHGenerator : public SemaConsumer {
960962
bool GeneratingReducedBMI = false);
961963
~PCHGenerator() override;
962964

963-
void InitializeSema(Sema &S) override { SemaPtr = &S; }
965+
void InitializeSema(Sema &S) override;
964966
void HandleTranslationUnit(ASTContext &Ctx) override;
965967
void HandleVTable(CXXRecordDecl *RD) override { Writer.handleVTable(RD); }
966968
ASTMutationListener *GetASTMutationListener() override;

clang/include/clang/Serialization/ModuleFile.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,20 @@ enum ModuleKind {
6262

6363
/// The input file info that has been loaded from an AST file.
6464
struct InputFileInfo {
65-
std::string FilenameAsRequested;
66-
std::string Filename;
65+
StringRef UnresolvedImportedFilenameAsRequested;
66+
StringRef UnresolvedImportedFilename;
67+
6768
uint64_t ContentHash;
6869
off_t StoredSize;
6970
time_t StoredTime;
7071
bool Overridden;
7172
bool Transient;
7273
bool TopLevel;
7374
bool ModuleMap;
75+
76+
bool isValid() const {
77+
return !UnresolvedImportedFilenameAsRequested.empty();
78+
}
7479
};
7580

7681
/// The input file that has been loaded from this AST file, along with

clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ struct ModuleDeps {
120120
/// additionally appear in \c FileDeps as a dependency.
121121
std::string ClangModuleMapFile;
122122

123-
/// A collection of absolute paths to files that this module directly depends
124-
/// on, not including transitive dependencies.
125-
llvm::StringSet<> FileDeps;
126-
127123
/// A collection of absolute paths to module map files that this module needs
128124
/// to know about. The ordering is significant.
129125
std::vector<std::string> ModuleMapFileDeps;
@@ -143,13 +139,25 @@ struct ModuleDeps {
143139
/// an entity from this module is used.
144140
llvm::SmallVector<Module::LinkLibrary, 2> LinkLibraries;
145141

142+
/// Invokes \c Cb for all file dependencies of this module. Each provided
143+
/// \c StringRef is only valid within the individual callback invocation.
144+
void forEachFileDep(llvm::function_ref<void(StringRef)> Cb) const;
145+
146146
/// Get (or compute) the compiler invocation that can be used to build this
147147
/// module. Does not include argv[0].
148148
const std::vector<std::string> &getBuildArguments();
149149

150150
private:
151+
friend class ModuleDepCollector;
151152
friend class ModuleDepCollectorPP;
152153

154+
/// The base directory for relative paths in \c FileDeps.
155+
std::string FileDepsBaseDir;
156+
157+
/// A collection of paths to files that this module directly depends on, not
158+
/// including transitive dependencies.
159+
std::vector<std::string> FileDeps;
160+
153161
std::variant<std::monostate, CowCompilerInvocation, std::vector<std::string>>
154162
BuildInfo;
155163
};

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2359,7 +2359,7 @@ bool ASTUnit::Save(StringRef File) {
23592359

23602360
static bool serializeUnit(ASTWriter &Writer, SmallVectorImpl<char> &Buffer,
23612361
Sema &S, raw_ostream &OS) {
2362-
Writer.WriteAST(S, std::string(), nullptr, "");
2362+
Writer.WriteAST(&S, std::string(), nullptr, "");
23632363

23642364
// Write the generated bitstream to "Out".
23652365
if (!Buffer.empty())

clang/lib/Headers/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,12 @@ set(x86_files
279279
cpuid.h
280280
)
281281

282+
set(gpu_files
283+
gpuintrin.h
284+
nvptxintrin.h
285+
amdgpuintrin.h
286+
)
287+
282288
set(windows_only_files
283289
intrin0.h
284290
intrin.h
@@ -307,6 +313,7 @@ set(files
307313
${systemz_files}
308314
${ve_files}
309315
${x86_files}
316+
${gpu_files}
310317
${webassembly_files}
311318
${windows_only_files}
312319
${utility_files}
@@ -531,6 +538,7 @@ add_header_target("systemz-resource-headers" "${systemz_files};${zos_wrapper_fil
531538
add_header_target("ve-resource-headers" "${ve_files}")
532539
add_header_target("webassembly-resource-headers" "${webassembly_files}")
533540
add_header_target("x86-resource-headers" "${x86_files}")
541+
add_header_target("gpu-resource-headers" "${gpu_files}")
534542

535543
# Other header groupings
536544
add_header_target("hlsl-resource-headers" ${hlsl_files})
@@ -717,6 +725,12 @@ install(
717725
EXCLUDE_FROM_ALL
718726
COMPONENT x86-resource-headers)
719727

728+
install(
729+
FILES ${gpu_files}
730+
DESTINATION ${header_install_dir}
731+
EXCLUDE_FROM_ALL
732+
COMPONENT gpu-resource-headers)
733+
720734
if(NOT CLANG_ENABLE_HLSL)
721735
set(EXCLUDE_HLSL EXCLUDE_FROM_ALL)
722736
endif()

0 commit comments

Comments
 (0)