Skip to content

Commit fb4ff85

Browse files
committed
merge main into amd-staging
2 parents 556d3f7 + cef9ed5 commit fb4ff85

File tree

224 files changed

+118066
-61805
lines changed

Some content is hidden

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

224 files changed

+118066
-61805
lines changed

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ static bool isPublic(const clang::AccessSpecifier AS,
261261
const clang::Linkage Link) {
262262
if (AS == clang::AccessSpecifier::AS_private)
263263
return false;
264-
else if ((Link == clang::Linkage::Module) ||
265-
(Link == clang::Linkage::External))
264+
if ((Link == clang::Linkage::Module) || (Link == clang::Linkage::External))
266265
return true;
267266
return false; // otherwise, linkage is some form of internal linkage
268267
}

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,8 +1836,11 @@ def err_hlsl_virtual_function
18361836
def err_hlsl_virtual_inheritance
18371837
: Error<"virtual inheritance is unsupported in HLSL">;
18381838

1839-
// HLSL Root Siganture diagnostic messages
1839+
// HLSL Root Signature Parser Diagnostics
18401840
def err_hlsl_unexpected_end_of_params
18411841
: Error<"expected %0 to denote end of parameters, or, another valid parameter of %1">;
1842+
def err_hlsl_rootsig_repeat_param : Error<"specified the same parameter '%0' multiple times">;
1843+
def err_hlsl_rootsig_missing_param : Error<"did not specify mandatory parameter '%0'">;
1844+
def err_hlsl_number_literal_overflow : Error<"integer literal is too large to be represented as a 32-bit %select{signed |}0 integer type">;
18421845

18431846
} // end of Parser diagnostics

clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ class CIR_Attr<string name, string attrMnemonic, list<Trait> traits = []>
2727
let mnemonic = attrMnemonic;
2828
}
2929

30+
class CIR_TypedAttr<string name, string attrMnemonic, list<Trait> traits = []>
31+
: CIR_Attr<name, attrMnemonic, !listconcat(traits, [TypedAttrInterface])> {
32+
33+
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
34+
35+
let builders = [
36+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
37+
return $_get(type.getContext(), type);
38+
}]>
39+
];
40+
41+
let assemblyFormat = [{}];
42+
}
43+
3044
class CIRUnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
3145
: CIR_Attr<name, attrMnemonic, traits> {
3246
let returnType = "bool";
@@ -64,43 +78,23 @@ def CIR_BoolAttr : CIR_Attr<"Bool", "bool", [TypedAttrInterface]> {
6478
// ZeroAttr
6579
//===----------------------------------------------------------------------===//
6680

67-
def ZeroAttr : CIR_Attr<"Zero", "zero", [TypedAttrInterface]> {
81+
def ZeroAttr : CIR_TypedAttr<"Zero", "zero"> {
6882
let summary = "Attribute to represent zero initialization";
6983
let description = [{
7084
The ZeroAttr is used to indicate zero initialization on structs.
7185
}];
72-
73-
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
74-
75-
let builders = [
76-
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
77-
return $_get(type.getContext(), type);
78-
}]>
79-
];
80-
81-
let assemblyFormat = [{}];
8286
}
8387

8488
//===----------------------------------------------------------------------===//
8589
// UndefAttr
8690
//===----------------------------------------------------------------------===//
8791

88-
def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> {
92+
def UndefAttr : CIR_TypedAttr<"Undef", "undef"> {
8993
let summary = "Represent an undef constant";
9094
let description = [{
9195
The UndefAttr represents an undef constant, corresponding to LLVM's notion
9296
of undef.
9397
}];
94-
95-
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
96-
97-
let builders = [
98-
AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
99-
return $_get(type.getContext(), type);
100-
}]>
101-
];
102-
103-
let assemblyFormat = [{}];
10498
}
10599

106100
//===----------------------------------------------------------------------===//

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "clang/Frontend/CompilerInvocation.h"
1717
#include "clang/Frontend/PCHContainerOperations.h"
1818
#include "clang/Frontend/Utils.h"
19+
#include "clang/Lex/DependencyDirectivesScanner.h"
1920
#include "clang/Lex/HeaderSearchOptions.h"
2021
#include "clang/Lex/ModuleLoader.h"
2122
#include "llvm/ADT/ArrayRef.h"
@@ -99,6 +100,9 @@ class CompilerInstance : public ModuleLoader {
99100
/// The cache of PCM files.
100101
IntrusiveRefCntPtr<ModuleCache> ModCache;
101102

103+
/// Functor for getting the dependency preprocessor directives of a file.
104+
std::unique_ptr<DependencyDirectivesGetter> GetDependencyDirectives;
105+
102106
/// The preprocessor.
103107
std::shared_ptr<Preprocessor> PP;
104108

@@ -697,6 +701,11 @@ class CompilerInstance : public ModuleLoader {
697701
/// and replace any existing one with it.
698702
void createPreprocessor(TranslationUnitKind TUKind);
699703

704+
void setDependencyDirectivesGetter(
705+
std::unique_ptr<DependencyDirectivesGetter> Getter) {
706+
GetDependencyDirectives = std::move(Getter);
707+
}
708+
700709
std::string getSpecificModuleCachePath(StringRef ModuleHash);
701710
std::string getSpecificModuleCachePath() {
702711
return getSpecificModuleCachePath(getInvocation().getModuleHash());

clang/include/clang/Lex/DependencyDirectivesScanner.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "llvm/ADT/ArrayRef.h"
2222

2323
namespace clang {
24+
class FileManager;
2425

2526
namespace tok {
2627
enum TokenKind : unsigned short;
@@ -135,6 +136,19 @@ void printDependencyDirectivesAsSource(
135136
ArrayRef<dependency_directives_scan::Directive> Directives,
136137
llvm::raw_ostream &OS);
137138

139+
/// Functor that returns the dependency directives for a given file.
140+
class DependencyDirectivesGetter {
141+
public:
142+
/// Clone the getter for a new \c FileManager instance.
143+
virtual std::unique_ptr<DependencyDirectivesGetter>
144+
cloneFor(FileManager &FileMgr) = 0;
145+
146+
/// Get the dependency directives for the given file.
147+
virtual std::optional<ArrayRef<dependency_directives_scan::Directive>>
148+
operator()(FileEntryRef File) = 0;
149+
150+
virtual ~DependencyDirectivesGetter() = default;
151+
};
138152
} // end namespace clang
139153

140154
#endif // LLVM_CLANG_LEX_DEPENDENCYDIRECTIVESSCANNER_H

clang/include/clang/Lex/Preprocessor.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ class Preprocessor {
140140
friend class VariadicMacroScopeGuard;
141141

142142
llvm::unique_function<void(const clang::Token &)> OnToken;
143+
/// Functor for getting the dependency preprocessor directives of a file.
144+
///
145+
/// These are directives derived from a special form of lexing where the
146+
/// source input is scanned for the preprocessor directives that might have an
147+
/// effect on the dependencies for a compilation unit.
148+
DependencyDirectivesGetter *GetDependencyDirectives = nullptr;
143149
const PreprocessorOptions &PPOpts;
144150
DiagnosticsEngine *Diags;
145151
const LangOptions &LangOpts;
@@ -1326,6 +1332,10 @@ class Preprocessor {
13261332
OnToken = std::move(F);
13271333
}
13281334

1335+
void setDependencyDirectivesGetter(DependencyDirectivesGetter &Get) {
1336+
GetDependencyDirectives = &Get;
1337+
}
1338+
13291339
void setPreprocessToken(bool Preprocess) { PreprocessToken = Preprocess; }
13301340

13311341
bool isMacroDefined(StringRef Id) {

clang/include/clang/Lex/PreprocessorOptions.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,19 +189,6 @@ class PreprocessorOptions {
189189
/// with support for lifetime-qualified pointers.
190190
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary = ARCXX_nolib;
191191

192-
/// Function for getting the dependency preprocessor directives of a file.
193-
///
194-
/// These are directives derived from a special form of lexing where the
195-
/// source input is scanned for the preprocessor directives that might have an
196-
/// effect on the dependencies for a compilation unit.
197-
///
198-
/// Enables a client to cache the directives for a file and provide them
199-
/// across multiple compiler invocations.
200-
/// FIXME: Allow returning an error.
201-
std::function<std::optional<ArrayRef<dependency_directives_scan::Directive>>(
202-
FileEntryRef)>
203-
DependencyDirectivesForFile;
204-
205192
/// Set up preprocessor for RunAnalysis action.
206193
bool SetUpStaticAnalyzer = false;
207194

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,31 @@ class RootSignatureParser {
4040
private:
4141
DiagnosticsEngine &getDiags() { return PP.getDiagnostics(); }
4242

43-
// All private Parse.* methods follow a similar pattern:
43+
// All private parse.* methods follow a similar pattern:
4444
// - Each method will start with an assert to denote what the CurToken is
4545
// expected to be and will parse from that token forward
4646
//
4747
// - Therefore, it is the callers responsibility to ensure that you are
4848
// at the correct CurToken. This should be done with the pattern of:
4949
//
50-
// if (TryConsumeExpectedToken(RootSignatureToken::Kind))
51-
// if (Parse.*())
52-
// return true;
50+
// if (tryConsumeExpectedToken(RootSignatureToken::Kind)) {
51+
// auto ParsedObject = parse.*();
52+
// if (!ParsedObject.has_value())
53+
// return std::nullopt;
54+
// ...
55+
// }
5356
//
5457
// or,
5558
//
56-
// if (ConsumeExpectedToken(RootSignatureToken::Kind, ...))
57-
// return true;
58-
// if (Parse.*())
59-
// return true;
59+
// if (consumeExpectedToken(RootSignatureToken::Kind, ...))
60+
// return std::nullopt;
61+
// auto ParsedObject = parse.*();
62+
// if (!ParsedObject.has_value())
63+
// return std::nullopt;
64+
// ...
6065
//
61-
// - All methods return true if a parsing error is encountered. It is the
62-
// callers responsibility to propogate this error up, or deal with it
66+
// - All methods return std::nullopt if a parsing error is encountered. It
67+
// is the callers responsibility to propogate this error up, or deal with it
6368
// otherwise
6469
//
6570
// - An error will be raised if the proceeding tokens are not what is
@@ -69,6 +74,23 @@ class RootSignatureParser {
6974
bool parseDescriptorTable();
7075
bool parseDescriptorTableClause();
7176

77+
/// Parameter arguments (eg. `bReg`, `space`, ...) can be specified in any
78+
/// order and only exactly once. `ParsedClauseParams` denotes the current
79+
/// state of parsed params
80+
struct ParsedClauseParams {
81+
std::optional<llvm::hlsl::rootsig::Register> Reg;
82+
std::optional<uint32_t> Space;
83+
};
84+
std::optional<ParsedClauseParams>
85+
parseDescriptorTableClauseParams(RootSignatureToken::Kind RegType);
86+
87+
std::optional<uint32_t> parseUIntParam();
88+
std::optional<llvm::hlsl::rootsig::Register> parseRegister();
89+
90+
/// Use NumericLiteralParser to convert CurToken.NumSpelling into a unsigned
91+
/// 32-bit integer
92+
std::optional<uint32_t> handleUIntLiteral();
93+
7294
/// Invoke the Lexer to consume a token and update CurToken with the result
7395
void consumeNextToken() { CurToken = Lexer.consumeToken(); }
7496

clang/include/clang/Sema/ScopeInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,9 @@ class LambdaScopeInfo final :
949949

950950
SourceLocation PotentialThisCaptureLocation;
951951

952+
/// Variables that are potentially ODR-used in CUDA/HIP.
953+
llvm::SmallPtrSet<VarDecl *, 4> CUDAPotentialODRUsedVars;
954+
952955
LambdaScopeInfo(DiagnosticsEngine &Diag)
953956
: CapturingScopeInfo(Diag, ImpCap_None) {
954957
Kind = SK_Lambda;

clang/include/clang/Sema/SemaCUDA.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ class SemaCUDA : public SemaBase {
274274
/// parameters specified via <<<>>>.
275275
std::string getConfigureFuncName() const;
276276

277+
/// Record variables that are potentially ODR-used in CUDA/HIP.
278+
void recordPotentialODRUsedVariable(MultiExprArg Args,
279+
OverloadCandidateSet &CandidateSet);
280+
277281
private:
278282
unsigned ForceHostDeviceDepth = 0;
279283

0 commit comments

Comments
 (0)