Skip to content

Commit 6f186bd

Browse files
authored
merge main into amd-staging (llvm#2819)
2 parents d362b43 + 7269d1d commit 6f186bd

File tree

213 files changed

+8459
-4072
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

+8459
-4072
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,15 +1081,15 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
10811081

10821082
if (isADR(Inst) || RelType == ELF::R_AARCH64_ADR_PREL_LO21 ||
10831083
RelType == ELF::R_AARCH64_TLSDESC_ADR_PREL21) {
1084-
return MCSpecifierExpr::create(Expr, AArch64MCExpr::VK_ABS, Ctx);
1084+
return MCSpecifierExpr::create(Expr, AArch64::S_ABS, Ctx);
10851085
} else if (isADRP(Inst) || RelType == ELF::R_AARCH64_ADR_PREL_PG_HI21 ||
10861086
RelType == ELF::R_AARCH64_ADR_PREL_PG_HI21_NC ||
10871087
RelType == ELF::R_AARCH64_TLSDESC_ADR_PAGE21 ||
10881088
RelType == ELF::R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 ||
10891089
RelType == ELF::R_AARCH64_ADR_GOT_PAGE) {
10901090
// Never emit a GOT reloc, we handled this in
10911091
// RewriteInstance::readRelocations().
1092-
return MCSpecifierExpr::create(Expr, AArch64MCExpr::VK_ABS_PAGE, Ctx);
1092+
return MCSpecifierExpr::create(Expr, AArch64::S_ABS_PAGE, Ctx);
10931093
} else {
10941094
switch (RelType) {
10951095
case ELF::R_AARCH64_ADD_ABS_LO12_NC:
@@ -1103,18 +1103,18 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
11031103
case ELF::R_AARCH64_TLSDESC_LD64_LO12:
11041104
case ELF::R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC:
11051105
case ELF::R_AARCH64_TLSLE_ADD_TPREL_LO12_NC:
1106-
return MCSpecifierExpr::create(Expr, AArch64MCExpr::VK_LO12, Ctx);
1106+
return MCSpecifierExpr::create(Expr, AArch64::S_LO12, Ctx);
11071107
case ELF::R_AARCH64_MOVW_UABS_G3:
1108-
return MCSpecifierExpr::create(Expr, AArch64MCExpr::VK_ABS_G3, Ctx);
1108+
return MCSpecifierExpr::create(Expr, AArch64::S_ABS_G3, Ctx);
11091109
case ELF::R_AARCH64_MOVW_UABS_G2:
11101110
case ELF::R_AARCH64_MOVW_UABS_G2_NC:
1111-
return MCSpecifierExpr::create(Expr, AArch64MCExpr::VK_ABS_G2_NC, Ctx);
1111+
return MCSpecifierExpr::create(Expr, AArch64::S_ABS_G2_NC, Ctx);
11121112
case ELF::R_AARCH64_MOVW_UABS_G1:
11131113
case ELF::R_AARCH64_MOVW_UABS_G1_NC:
1114-
return MCSpecifierExpr::create(Expr, AArch64MCExpr::VK_ABS_G1_NC, Ctx);
1114+
return MCSpecifierExpr::create(Expr, AArch64::S_ABS_G1_NC, Ctx);
11151115
case ELF::R_AARCH64_MOVW_UABS_G0:
11161116
case ELF::R_AARCH64_MOVW_UABS_G0_NC:
1117-
return MCSpecifierExpr::create(Expr, AArch64MCExpr::VK_ABS_G0_NC, Ctx);
1117+
return MCSpecifierExpr::create(Expr, AArch64::S_ABS_G0_NC, Ctx);
11181118
default:
11191119
break;
11201120
}
@@ -2028,7 +2028,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
20282028
Inst.setOpcode(AArch64::MOVZXi);
20292029
Inst.addOperand(MCOperand::createReg(AArch64::X16));
20302030
Inst.addOperand(MCOperand::createExpr(
2031-
MCSpecifierExpr::create(Target, AArch64MCExpr::VK_ABS_G3, *Ctx)));
2031+
MCSpecifierExpr::create(Target, AArch64::S_ABS_G3, *Ctx)));
20322032
Inst.addOperand(MCOperand::createImm(0x30));
20332033
Seq.emplace_back(Inst);
20342034

@@ -2037,7 +2037,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
20372037
Inst.addOperand(MCOperand::createReg(AArch64::X16));
20382038
Inst.addOperand(MCOperand::createReg(AArch64::X16));
20392039
Inst.addOperand(MCOperand::createExpr(
2040-
MCSpecifierExpr::create(Target, AArch64MCExpr::VK_ABS_G2_NC, *Ctx)));
2040+
MCSpecifierExpr::create(Target, AArch64::S_ABS_G2_NC, *Ctx)));
20412041
Inst.addOperand(MCOperand::createImm(0x20));
20422042
Seq.emplace_back(Inst);
20432043

@@ -2046,7 +2046,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
20462046
Inst.addOperand(MCOperand::createReg(AArch64::X16));
20472047
Inst.addOperand(MCOperand::createReg(AArch64::X16));
20482048
Inst.addOperand(MCOperand::createExpr(
2049-
MCSpecifierExpr::create(Target, AArch64MCExpr::VK_ABS_G1_NC, *Ctx)));
2049+
MCSpecifierExpr::create(Target, AArch64::S_ABS_G1_NC, *Ctx)));
20502050
Inst.addOperand(MCOperand::createImm(0x10));
20512051
Seq.emplace_back(Inst);
20522052

@@ -2055,7 +2055,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
20552055
Inst.addOperand(MCOperand::createReg(AArch64::X16));
20562056
Inst.addOperand(MCOperand::createReg(AArch64::X16));
20572057
Inst.addOperand(MCOperand::createExpr(
2058-
MCSpecifierExpr::create(Target, AArch64MCExpr::VK_ABS_G0_NC, *Ctx)));
2058+
MCSpecifierExpr::create(Target, AArch64::S_ABS_G0_NC, *Ctx)));
20592059
Inst.addOperand(MCOperand::createImm(0));
20602060
Seq.emplace_back(Inst);
20612061

clang/include/clang/AST/Decl.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "llvm/ADT/PointerUnion.h"
4242
#include "llvm/ADT/StringRef.h"
4343
#include "llvm/ADT/iterator_range.h"
44+
#include "llvm/BinaryFormat/DXContainer.h"
4445
#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
4546
#include "llvm/Support/Casting.h"
4647
#include "llvm/Support/Compiler.h"
@@ -5181,6 +5182,8 @@ class HLSLRootSignatureDecl final
51815182
llvm::hlsl::rootsig::RootElement> {
51825183
friend TrailingObjects;
51835184

5185+
llvm::dxbc::RootSignatureVersion Version;
5186+
51845187
unsigned NumElems;
51855188

51865189
llvm::hlsl::rootsig::RootElement *getElems() { return getTrailingObjects(); }
@@ -5190,16 +5193,20 @@ class HLSLRootSignatureDecl final
51905193
}
51915194

51925195
HLSLRootSignatureDecl(DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5196+
llvm::dxbc::RootSignatureVersion Version,
51935197
unsigned NumElems);
51945198

51955199
public:
51965200
static HLSLRootSignatureDecl *
51975201
Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5202+
llvm::dxbc::RootSignatureVersion Version,
51985203
ArrayRef<llvm::hlsl::rootsig::RootElement> RootElements);
51995204

52005205
static HLSLRootSignatureDecl *CreateDeserialized(ASTContext &C,
52015206
GlobalDeclID ID);
52025207

5208+
llvm::dxbc::RootSignatureVersion getVersion() const { return Version; }
5209+
52035210
ArrayRef<llvm::hlsl::rootsig::RootElement> getRootElements() const {
52045211
return {getElems(), NumElems};
52055212
}

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,13 @@ class CodeGenOptions : public CodeGenOptionsBase {
503503

504504
/// A list of functions that are replacable by the loader.
505505
std::vector<std::string> LoaderReplaceableFunctionNames;
506+
/// The name of a file that contains functions which will be compiled for
507+
/// hotpatching. See -fms-secure-hotpatch-functions-file.
508+
std::string MSSecureHotPatchFunctionsFile;
509+
510+
/// A list of functions which will be compiled for hotpatching.
511+
/// See -fms-secure-hotpatch-functions-list.
512+
std::vector<std::string> MSSecureHotPatchFunctionsList;
506513

507514
public:
508515
// Define accessors/mutators for code generation options of enumeration type.

clang/include/clang/Basic/LangOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "clang/Basic/Visibility.h"
2525
#include "llvm/ADT/FloatingPointMode.h"
2626
#include "llvm/ADT/StringRef.h"
27+
#include "llvm/BinaryFormat/DXContainer.h"
2728
#include "llvm/TargetParser/Triple.h"
2829
#include <optional>
2930
#include <string>
@@ -623,6 +624,10 @@ class LangOptions : public LangOptionsBase {
623624
// implementation on real-world examples.
624625
std::string OpenACCMacroOverride;
625626

627+
/// The HLSL root signature version for dxil.
628+
llvm::dxbc::RootSignatureVersion HLSLRootSigVer =
629+
llvm::dxbc::RootSignatureVersion::V1_1;
630+
626631
// Indicates if the wasm-opt binary must be ignored in the case of a
627632
// WebAssembly target.
628633
bool NoWasmOpt = false;

clang/include/clang/Driver/Options.td

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,6 +3957,24 @@ def fms_hotpatch : Flag<["-"], "fms-hotpatch">, Group<f_Group>,
39573957
Visibility<[ClangOption, CC1Option, CLOption]>,
39583958
HelpText<"Ensure that all functions can be hotpatched at runtime">,
39593959
MarshallingInfoFlag<CodeGenOpts<"HotPatch">>;
3960+
3961+
// See llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
3962+
def fms_secure_hotpatch_functions_file
3963+
: Joined<["-"], "fms-secure-hotpatch-functions-file=">,
3964+
Group<f_Group>,
3965+
Visibility<[ClangOption, CC1Option, CLOption]>,
3966+
MarshallingInfoString<CodeGenOpts<"MSSecureHotPatchFunctionsFile">>,
3967+
HelpText<"Path to a file that contains a list of mangled names of "
3968+
"functions that should be hot-patched for Windows Secure "
3969+
"Hot-Patching">;
3970+
def fms_secure_hotpatch_functions_list
3971+
: CommaJoined<["-"], "fms-secure-hotpatch-functions-list=">,
3972+
Group<f_Group>,
3973+
Visibility<[ClangOption, CC1Option, CLOption]>,
3974+
MarshallingInfoStringVector<CodeGenOpts<"MSSecureHotPatchFunctionsList">>,
3975+
HelpText<"List of mangled symbol names of functions that should be "
3976+
"hot-patched for Windows Secure Hot-Patching">;
3977+
39603978
def fpcc_struct_return : Flag<["-"], "fpcc-struct-return">, Group<f_Group>,
39613979
Visibility<[ClangOption, CC1Option]>,
39623980
HelpText<"Override the default ABI to return all structs on the stack">;
@@ -9584,6 +9602,20 @@ def fcgl : DXCFlag<"fcgl">, Alias<emit_pristine_llvm>;
95849602
def enable_16bit_types : DXCFlag<"enable-16bit-types">, Alias<fnative_half_type>,
95859603
HelpText<"Enable 16-bit types and disable min precision types."
95869604
"Available in HLSL 2018 and shader model 6.2.">;
9605+
def fdx_rootsignature_version :
9606+
Joined<["-"], "fdx-rootsignature-version=">,
9607+
Group<dxc_Group>,
9608+
Visibility<[ClangOption, CC1Option]>,
9609+
HelpText<"Root Signature Version">,
9610+
Values<"rootsig_1_0,rootsig_1_1">,
9611+
NormalizedValuesScope<"llvm::dxbc::RootSignatureVersion">,
9612+
NormalizedValues<["V1_0", "V1_1"]>,
9613+
MarshallingInfoEnum<LangOpts<"HLSLRootSigVer">, "V1_1">;
9614+
def dxc_rootsig_ver :
9615+
Separate<["/", "-"], "force-rootsig-ver">,
9616+
Alias<fdx_rootsignature_version>,
9617+
Group<dxc_Group>,
9618+
Visibility<[DXCOption]>;
95879619
def hlsl_entrypoint : Option<["-"], "hlsl-entry", KIND_SEPARATE>,
95889620
Group<dxc_Group>,
95899621
Visibility<[ClangOption, CC1Option]>,

clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/Support/VirtualFileSystem.h"
1919
#include <mutex>
2020
#include <optional>
21+
#include <variant>
2122

2223
namespace clang {
2324
namespace tooling {
@@ -220,13 +221,34 @@ class DependencyScanningFilesystemSharedCache {
220221
CacheShard &getShardForFilename(StringRef Filename) const;
221222
CacheShard &getShardForUID(llvm::sys::fs::UniqueID UID) const;
222223

223-
/// Visits all cached entries and re-stat an entry using FS if
224-
/// it is negatively stat cached. If re-stat succeeds on a path,
225-
/// the path is added to InvalidPaths, indicating that the cache
226-
/// may have erroneously negatively cached it. The caller can then
227-
/// use InvalidPaths to issue diagnostics.
228-
std::vector<StringRef>
229-
getInvalidNegativeStatCachedPaths(llvm::vfs::FileSystem &UnderlyingFS) const;
224+
struct OutOfDateEntry {
225+
// A null terminated string that contains a path.
226+
const char *Path = nullptr;
227+
228+
struct NegativelyCachedInfo {};
229+
struct SizeChangedInfo {
230+
uint64_t CachedSize = 0;
231+
uint64_t ActualSize = 0;
232+
};
233+
234+
std::variant<NegativelyCachedInfo, SizeChangedInfo> Info;
235+
236+
OutOfDateEntry(const char *Path)
237+
: Path(Path), Info(NegativelyCachedInfo{}) {}
238+
239+
OutOfDateEntry(const char *Path, uint64_t CachedSize, uint64_t ActualSize)
240+
: Path(Path), Info(SizeChangedInfo{CachedSize, ActualSize}) {}
241+
};
242+
243+
/// Visits all cached entries and re-stat an entry using UnderlyingFS to check
244+
/// if the cache contains out-of-date entries. An entry can be out-of-date for
245+
/// two reasons:
246+
/// 1. The entry contains a stat error, indicating the file did not exist
247+
/// in the cache, but the file exists on the UnderlyingFS.
248+
/// 2. The entry is associated with a file whose size is different from the
249+
/// size of the file on the same path on the UnderlyingFS.
250+
std::vector<OutOfDateEntry>
251+
getOutOfDateEntries(llvm::vfs::FileSystem &UnderlyingFS) const;
230252

231253
private:
232254
std::unique_ptr<CacheShard[]> CacheShards;

clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "clang/Tooling/JSONCompilationDatabase.h"
1616
#include "llvm/ADT/DenseSet.h"
1717
#include "llvm/ADT/MapVector.h"
18+
#include "llvm/ADT/STLExtras.h"
1819
#include <functional>
1920
#include <optional>
2021
#include <string>
@@ -56,6 +57,9 @@ struct TranslationUnitDeps {
5657
/// determined that the differences are benign for this compilation.
5758
std::vector<ModuleID> ClangModuleDeps;
5859

60+
/// A list of the C++20 named modules this translation unit depends on.
61+
std::vector<std::string> NamedModuleDeps;
62+
5963
/// The sequence of commands required to build the translation unit. Commands
6064
/// should be executed in order.
6165
///
@@ -188,13 +192,23 @@ class FullDependencyConsumer : public DependencyConsumer {
188192
ContextHash = std::move(Hash);
189193
}
190194

195+
void handleProvidedAndRequiredStdCXXModules(
196+
std::optional<P1689ModuleInfo> Provided,
197+
std::vector<P1689ModuleInfo> Requires) override {
198+
ModuleName = Provided ? Provided->ModuleName : "";
199+
llvm::transform(Requires, std::back_inserter(NamedModuleDeps),
200+
[](const auto &Module) { return Module.ModuleName; });
201+
}
202+
191203
TranslationUnitDeps takeTranslationUnitDeps();
192204
ModuleDepsGraph takeModuleGraphDeps();
193205

194206
private:
195207
std::vector<std::string> Dependencies;
196208
std::vector<PrebuiltModuleDep> PrebuiltModuleDeps;
197209
llvm::MapVector<ModuleID, ModuleDeps> ClangModuleDeps;
210+
std::string ModuleName;
211+
std::vector<std::string> NamedModuleDeps;
198212
std::vector<ModuleID> DirectModuleDeps;
199213
std::vector<Command> Commands;
200214
std::string ContextHash;

clang/lib/AST/Decl.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5878,21 +5878,21 @@ bool HLSLBufferDecl::buffer_decls_empty() {
58785878
// HLSLRootSignatureDecl Implementation
58795879
//===----------------------------------------------------------------------===//
58805880

5881-
HLSLRootSignatureDecl::HLSLRootSignatureDecl(DeclContext *DC,
5882-
SourceLocation Loc,
5883-
IdentifierInfo *ID,
5884-
unsigned NumElems)
5881+
HLSLRootSignatureDecl::HLSLRootSignatureDecl(
5882+
DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5883+
llvm::dxbc::RootSignatureVersion Version, unsigned NumElems)
58855884
: NamedDecl(Decl::Kind::HLSLRootSignature, DC, Loc, DeclarationName(ID)),
5886-
NumElems(NumElems) {}
5885+
Version(Version), NumElems(NumElems) {}
58875886

58885887
HLSLRootSignatureDecl *HLSLRootSignatureDecl::Create(
58895888
ASTContext &C, DeclContext *DC, SourceLocation Loc, IdentifierInfo *ID,
5889+
llvm::dxbc::RootSignatureVersion Version,
58905890
ArrayRef<llvm::hlsl::rootsig::RootElement> RootElements) {
58915891
HLSLRootSignatureDecl *RSDecl =
58925892
new (C, DC,
58935893
additionalSizeToAlloc<llvm::hlsl::rootsig::RootElement>(
58945894
RootElements.size()))
5895-
HLSLRootSignatureDecl(DC, Loc, ID, RootElements.size());
5895+
HLSLRootSignatureDecl(DC, Loc, ID, Version, RootElements.size());
58965896
auto *StoredElems = RSDecl->getElems();
58975897
llvm::uninitialized_copy(RootElements, StoredElems);
58985898
return RSDecl;
@@ -5901,7 +5901,9 @@ HLSLRootSignatureDecl *HLSLRootSignatureDecl::Create(
59015901
HLSLRootSignatureDecl *
59025902
HLSLRootSignatureDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID) {
59035903
HLSLRootSignatureDecl *Result = new (C, ID)
5904-
HLSLRootSignatureDecl(nullptr, SourceLocation(), nullptr, /*NumElems=*/0);
5904+
HLSLRootSignatureDecl(nullptr, SourceLocation(), nullptr,
5905+
/*Version*/ llvm::dxbc::RootSignatureVersion::V1_1,
5906+
/*NumElems=*/0);
59055907
return Result;
59065908
}
59075909

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3041,6 +3041,16 @@ void TextNodeDumper::VisitHLSLBufferDecl(const HLSLBufferDecl *D) {
30413041
void TextNodeDumper::VisitHLSLRootSignatureDecl(
30423042
const HLSLRootSignatureDecl *D) {
30433043
dumpName(D);
3044+
OS << " version: ";
3045+
switch (D->getVersion()) {
3046+
case llvm::dxbc::RootSignatureVersion::V1_0:
3047+
OS << "1.0";
3048+
break;
3049+
case llvm::dxbc::RootSignatureVersion::V1_1:
3050+
OS << "1.1";
3051+
break;
3052+
}
3053+
OS << ", ";
30443054
llvm::hlsl::rootsig::dumpRootElements(OS, D->getRootElements());
30453055
}
30463056

0 commit comments

Comments
 (0)