Skip to content

Commit 3ed9728

Browse files
authored
Merge branch 'main' into wmemmove
2 parents e652fd9 + 46adbff commit 3ed9728

File tree

213 files changed

+3769
-2693
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

+3769
-2693
lines changed

.github/workflows/containers/github-action-ci-windows/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RUN powershell -Command \
8585
RUN git config --system core.longpaths true & \
8686
git config --global core.autocrlf false
8787
88-
ARG RUNNER_VERSION=2.324.0
88+
ARG RUNNER_VERSION=2.325.0
8989
ENV RUNNER_VERSION=$RUNNER_VERSION
9090
9191
RUN powershell -Command \

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ WORKDIR /home/gha
8686

8787
FROM ci-container as ci-container-agent
8888

89-
ENV GITHUB_RUNNER_VERSION=2.324.0
89+
ENV GITHUB_RUNNER_VERSION=2.325.0
9090

9191
RUN mkdir actions-runner && \
9292
cd actions-runner && \

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ struct MissingFeatures {
3434
static bool opGlobalThreadLocal() { return false; }
3535
static bool opGlobalConstant() { return false; }
3636
static bool opGlobalWeakRef() { return false; }
37-
static bool opGlobalLinkage() { return false; }
3837
static bool opGlobalUnnamedAddr() { return false; }
3938
static bool opGlobalSection() { return false; }
4039
static bool opGlobalVisibility() { return false; }
4140
static bool opGlobalDLLImportExport() { return false; }
4241
static bool opGlobalPartition() { return false; }
42+
static bool opGlobalUsedOrCompilerUsed() { return false; }
4343

4444
static bool supportIFuncAttr() { return false; }
4545
static bool supportVisibility() { return false; }
4646
static bool hiddenVisibility() { return false; }
4747
static bool protectedVisibility() { return false; }
48+
static bool defaultVisibility() { return false; }
4849

4950
// Load/store attributes
5051
static bool opLoadStoreThreadLocal() { return false; }
@@ -77,6 +78,9 @@ struct MissingFeatures {
7778
static bool opFuncLinkage() { return false; }
7879
static bool opFuncVisibility() { return false; }
7980
static bool opFuncNoProto() { return false; }
81+
static bool opFuncCPUAndFeaturesAttributes() { return false; }
82+
static bool opFuncSection() { return false; }
83+
static bool opFuncSetComdat() { return false; }
8084

8185
// CallOp handling
8286
static bool opCallBuiltinFunc() { return false; }
@@ -136,7 +140,6 @@ struct MissingFeatures {
136140
// Misc
137141
static bool cxxABI() { return false; }
138142
static bool cirgenABIInfo() { return false; }
139-
static bool cirgenTargetInfo() { return false; }
140143
static bool abiArgInfo() { return false; }
141144
static bool tryEmitAsConstant() { return false; }
142145
static bool constructABIArgDirectExtend() { return false; }
@@ -199,6 +202,7 @@ struct MissingFeatures {
199202
static bool cleanupsToDeactivate() { return false; }
200203
static bool stackBase() { return false; }
201204
static bool deferredDecls() { return false; }
205+
static bool setTargetAttributes() { return false; }
202206

203207
// Missing types
204208
static bool dataMemberType() { return false; }

clang/include/clang/Lex/HLSLRootSignatureTokenKinds.def

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
#ifndef SHADER_VISIBILITY_ENUM
5454
#define SHADER_VISIBILITY_ENUM(NAME, LIT) ENUM(NAME, LIT)
5555
#endif
56+
#ifndef FILTER_ENUM
57+
#define FILTER_ENUM(NAME, LIT) ENUM(NAME, LIT)
58+
#endif
5659
#ifndef TEXTURE_ADDRESS_MODE_ENUM
5760
#define TEXTURE_ADDRESS_MODE_ENUM(NAME, LIT) ENUM(NAME, LIT)
5861
#endif
@@ -110,6 +113,7 @@ KEYWORD(numDescriptors)
110113
KEYWORD(offset)
111114

112115
// StaticSampler Keywords:
116+
KEYWORD(filter)
113117
KEYWORD(mipLODBias)
114118
KEYWORD(addressU)
115119
KEYWORD(addressV)
@@ -162,6 +166,44 @@ SHADER_VISIBILITY_ENUM(Pixel, "SHADER_VISIBILITY_PIXEL")
162166
SHADER_VISIBILITY_ENUM(Amplification, "SHADER_VISIBILITY_AMPLIFICATION")
163167
SHADER_VISIBILITY_ENUM(Mesh, "SHADER_VISIBILITY_MESH")
164168

169+
// Filter Enums:
170+
FILTER_ENUM(MinMagMipPoint, "FILTER_MIN_MAG_MIP_POINT")
171+
FILTER_ENUM(MinMagPointMipLinear, "FILTER_MIN_MAG_POINT_MIP_LINEAR")
172+
FILTER_ENUM(MinPointMagLinearMipPoint, "FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT")
173+
FILTER_ENUM(MinPointMagMipLinear, "FILTER_MIN_POINT_MAG_MIP_LINEAR")
174+
FILTER_ENUM(MinLinearMagMipPoint, "FILTER_MIN_LINEAR_MAG_MIP_POINT")
175+
FILTER_ENUM(MinLinearMagPointMipLinear, "FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR")
176+
FILTER_ENUM(MinMagLinearMipPoint, "FILTER_MIN_MAG_LINEAR_MIP_POINT")
177+
FILTER_ENUM(MinMagMipLinear, "FILTER_MIN_MAG_MIP_LINEAR")
178+
FILTER_ENUM(Anisotropic, "FILTER_ANISOTROPIC")
179+
FILTER_ENUM(ComparisonMinMagMipPoint, "FILTER_COMPARISON_MIN_MAG_MIP_POINT")
180+
FILTER_ENUM(ComparisonMinMagPointMipLinear, "FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR")
181+
FILTER_ENUM(ComparisonMinPointMagLinearMipPoint, "FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT")
182+
FILTER_ENUM(ComparisonMinPointMagMipLinear, "FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR")
183+
FILTER_ENUM(ComparisonMinLinearMagMipPoint, "FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT")
184+
FILTER_ENUM(ComparisonMinLinearMagPointMipLinear, "FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR")
185+
FILTER_ENUM(ComparisonMinMagLinearMipPoint, "FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT")
186+
FILTER_ENUM(ComparisonMinMagMipLinear, "FILTER_COMPARISON_MIN_MAG_MIP_LINEAR")
187+
FILTER_ENUM(ComparisonAnisotropic, "FILTER_COMPARISON_ANISOTROPIC")
188+
FILTER_ENUM(MinimumMinMagMipPoint, "FILTER_MINIMUM_MIN_MAG_MIP_POINT")
189+
FILTER_ENUM(MinimumMinMagPointMipLinear, "FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR")
190+
FILTER_ENUM(MinimumMinPointMagLinearMipPoint, "FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT")
191+
FILTER_ENUM(MinimumMinPointMagMipLinear, "FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR")
192+
FILTER_ENUM(MinimumMinLinearMagMipPoint, "FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT")
193+
FILTER_ENUM(MinimumMinLinearMagPointMipLinear, "FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR")
194+
FILTER_ENUM(MinimumMinMagLinearMipPoint, "FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT")
195+
FILTER_ENUM(MinimumMinMagMipLinear, "FILTER_MINIMUM_MIN_MAG_MIP_LINEAR")
196+
FILTER_ENUM(MinimumAnisotropic, "FILTER_MINIMUM_ANISOTROPIC")
197+
FILTER_ENUM(MaximumMinMagMipPoint, "FILTER_MAXIMUM_MIN_MAG_MIP_POINT")
198+
FILTER_ENUM(MaximumMinMagPointMipLinear, "FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR")
199+
FILTER_ENUM(MaximumMinPointMagLinearMipPoint, "FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT")
200+
FILTER_ENUM(MaximumMinPointMagMipLinear, "FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR")
201+
FILTER_ENUM(MaximumMinLinearMagMipPoint, "FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT")
202+
FILTER_ENUM(MaximumMinLinearMagPointMipLinear, "FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR")
203+
FILTER_ENUM(MaximumMinMagLinearMipPoint, "FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT")
204+
FILTER_ENUM(MaximumMinMagMipLinear, "FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR")
205+
FILTER_ENUM(MaximumAnisotropic, "FILTER_MAXIMUM_ANISOTROPIC")
206+
165207
// Texture Address Mode Enums:
166208
TEXTURE_ADDRESS_MODE_ENUM(Wrap, "TEXTURE_ADDRESS_WRAP")
167209
TEXTURE_ADDRESS_MODE_ENUM(Mirror, "TEXTURE_ADDRESS_MIRROR")
@@ -189,6 +231,7 @@ STATIC_BORDER_COLOR_ENUM(OpaqueWhiteUint, "STATIC_BORDER_COLOR_OPAQUE_WHITE_UINT
189231
#undef STATIC_BORDER_COLOR_ENUM
190232
#undef COMPARISON_FUNC_ENUM
191233
#undef TEXTURE_ADDRESS_MODE_ENUM
234+
#undef FILTER_ENUM
192235
#undef SHADER_VISIBILITY_ENUM
193236
#undef DESCRIPTOR_RANGE_FLAG_ENUM
194237
#undef DESCRIPTOR_RANGE_FLAG_ENUM_OFF

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,11 @@ class RootSignatureParser {
111111

112112
struct ParsedStaticSamplerParams {
113113
std::optional<llvm::hlsl::rootsig::Register> Reg;
114-
std::optional<float> MipLODBias;
114+
std::optional<llvm::hlsl::rootsig::SamplerFilter> Filter;
115115
std::optional<llvm::hlsl::rootsig::TextureAddressMode> AddressU;
116116
std::optional<llvm::hlsl::rootsig::TextureAddressMode> AddressV;
117117
std::optional<llvm::hlsl::rootsig::TextureAddressMode> AddressW;
118+
std::optional<float> MipLODBias;
118119
std::optional<uint32_t> MaxAnisotropy;
119120
std::optional<llvm::hlsl::rootsig::ComparisonFunc> CompFunc;
120121
std::optional<llvm::hlsl::rootsig::StaticBorderColor> BorderColor;
@@ -132,6 +133,7 @@ class RootSignatureParser {
132133

133134
/// Parsing methods of various enums
134135
std::optional<llvm::hlsl::rootsig::ShaderVisibility> parseShaderVisibility();
136+
std::optional<llvm::hlsl::rootsig::SamplerFilter> parseSamplerFilter();
135137
std::optional<llvm::hlsl::rootsig::TextureAddressMode>
136138
parseTextureAddressMode();
137139
std::optional<llvm::hlsl::rootsig::ComparisonFunc> parseComparisonFunc();

clang/lib/Basic/NoSanitizeList.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool NoSanitizeList::containsPrefix(SanitizerMask Mask, StringRef Prefix,
4444

4545
bool NoSanitizeList::containsGlobal(SanitizerMask Mask, StringRef GlobalName,
4646
StringRef Category) const {
47-
return SSCL->inSection(Mask, "global", GlobalName, Category);
47+
return containsPrefix(Mask, "global", GlobalName, Category);
4848
}
4949

5050
bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName,
@@ -54,7 +54,7 @@ bool NoSanitizeList::containsType(SanitizerMask Mask, StringRef MangledTypeName,
5454

5555
bool NoSanitizeList::containsFunction(SanitizerMask Mask,
5656
StringRef FunctionName) const {
57-
return SSCL->inSection(Mask, "fun", FunctionName);
57+
return containsPrefix(Mask, "fun", FunctionName, {});
5858
}
5959

6060
bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
@@ -64,7 +64,7 @@ bool NoSanitizeList::containsFile(SanitizerMask Mask, StringRef FileName,
6464

6565
bool NoSanitizeList::containsMainFile(SanitizerMask Mask, StringRef FileName,
6666
StringRef Category) const {
67-
return SSCL->inSection(Mask, "mainfile", FileName, Category);
67+
return containsPrefix(Mask, "mainfile", FileName, Category);
6868
}
6969

7070
bool NoSanitizeList::containsLocation(SanitizerMask Mask, SourceLocation Loc,

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,36 @@ cir::GlobalOp CIRGenModule::createGlobalOp(CIRGenModule &cgm,
317317
return g;
318318
}
319319

320+
void CIRGenModule::setCommonAttributes(GlobalDecl gd, mlir::Operation *gv) {
321+
const Decl *d = gd.getDecl();
322+
if (isa_and_nonnull<NamedDecl>(d))
323+
setGVProperties(gv, dyn_cast<NamedDecl>(d));
324+
assert(!cir::MissingFeatures::defaultVisibility());
325+
assert(!cir::MissingFeatures::opGlobalUsedOrCompilerUsed());
326+
}
327+
328+
void CIRGenModule::setNonAliasAttributes(GlobalDecl gd, mlir::Operation *op) {
329+
setCommonAttributes(gd, op);
330+
331+
assert(!cir::MissingFeatures::opGlobalUsedOrCompilerUsed());
332+
assert(!cir::MissingFeatures::opGlobalSection());
333+
assert(!cir::MissingFeatures::opFuncCPUAndFeaturesAttributes());
334+
assert(!cir::MissingFeatures::opFuncSection());
335+
336+
assert(!cir::MissingFeatures::setTargetAttributes());
337+
}
338+
339+
static void setLinkageForGV(cir::GlobalOp &gv, const NamedDecl *nd) {
340+
// Set linkage and visibility in case we never see a definition.
341+
LinkageInfo lv = nd->getLinkageAndVisibility();
342+
// Don't set internal linkage on declarations.
343+
// "extern_weak" is overloaded in LLVM; we probably should have
344+
// separate linkage types for this.
345+
if (isExternallyVisible(lv.getLinkage()) &&
346+
(nd->hasAttr<WeakAttr>() || nd->isWeakImported()))
347+
gv.setLinkage(cir::GlobalLinkageKind::ExternalWeakLinkage);
348+
}
349+
320350
/// If the specified mangled name is not in the module,
321351
/// create and return an mlir GlobalOp with the specified type (TODO(cir):
322352
/// address space).
@@ -387,7 +417,8 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef mangledName, mlir::Type ty,
387417

388418
gv.setAlignmentAttr(getSize(astContext.getDeclAlign(d)));
389419
assert(!cir::MissingFeatures::opGlobalConstant());
390-
assert(!cir::MissingFeatures::opGlobalLinkage());
420+
421+
setLinkageForGV(gv, d);
391422

392423
if (d->getTLSKind())
393424
errorNYI(d->getSourceRange(), "thread local global variable");
@@ -555,8 +586,6 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
555586
errorNYI(vd->getSourceRange(), "annotate global variable");
556587
}
557588

558-
assert(!cir::MissingFeatures::opGlobalLinkage());
559-
560589
if (langOpts.CUDA) {
561590
errorNYI(vd->getSourceRange(), "CUDA global variable");
562591
}
@@ -577,6 +606,12 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
577606
assert(!cir::MissingFeatures::opGlobalDLLImportExport());
578607
if (linkage == cir::GlobalLinkageKind::CommonLinkage)
579608
errorNYI(initExpr->getSourceRange(), "common linkage");
609+
610+
setNonAliasAttributes(vd, gv);
611+
612+
assert(!cir::MissingFeatures::opGlobalThreadLocal());
613+
614+
maybeSetTrivialComdat(*vd, gv);
580615
}
581616

582617
void CIRGenModule::emitGlobalDefinition(clang::GlobalDecl gd,
@@ -668,6 +703,15 @@ static bool shouldBeInCOMDAT(CIRGenModule &cgm, const Decl &d) {
668703
llvm_unreachable("No such linkage");
669704
}
670705

706+
void CIRGenModule::maybeSetTrivialComdat(const Decl &d, mlir::Operation *op) {
707+
if (!shouldBeInCOMDAT(*this, d))
708+
return;
709+
if (auto globalOp = dyn_cast_or_null<cir::GlobalOp>(op))
710+
globalOp.setComdat(true);
711+
712+
assert(!cir::MissingFeatures::opFuncSetComdat());
713+
}
714+
671715
// TODO(CIR): this could be a common method between LLVM codegen.
672716
static bool isVarDeclStrongDefinition(const ASTContext &astContext,
673717
CIRGenModule &cgm, const VarDecl *vd,
@@ -830,10 +874,10 @@ CIRGenModule::getCIRLinkageVarDefinition(const VarDecl *vd, bool isConstant) {
830874
return getCIRLinkageForDeclarator(vd, linkage, isConstant);
831875
}
832876

833-
static cir::GlobalOp generateStringLiteral(mlir::Location loc,
834-
mlir::TypedAttr c, CIRGenModule &cgm,
835-
StringRef globalName,
836-
CharUnits alignment) {
877+
static cir::GlobalOp
878+
generateStringLiteral(mlir::Location loc, mlir::TypedAttr c,
879+
cir::GlobalLinkageKind lt, CIRGenModule &cgm,
880+
StringRef globalName, CharUnits alignment) {
837881
assert(!cir::MissingFeatures::addressSpace());
838882

839883
// Create a global variable for this string
@@ -843,7 +887,8 @@ static cir::GlobalOp generateStringLiteral(mlir::Location loc,
843887

844888
// Set up extra information and add to the module
845889
gv.setAlignmentAttr(cgm.getSize(alignment));
846-
assert(!cir::MissingFeatures::opGlobalLinkage());
890+
gv.setLinkageAttr(
891+
cir::GlobalLinkageKindAttr::get(cgm.getBuilder().getContext(), lt));
847892
assert(!cir::MissingFeatures::opGlobalThreadLocal());
848893
assert(!cir::MissingFeatures::opGlobalUnnamedAddr());
849894
CIRGenModule::setInitializer(gv, c);
@@ -907,7 +952,8 @@ cir::GlobalOp CIRGenModule::getGlobalForStringLiteral(const StringLiteral *s,
907952
mlir::Location loc = getLoc(s->getSourceRange());
908953
auto typedC = llvm::cast<mlir::TypedAttr>(c);
909954
cir::GlobalOp gv =
910-
generateStringLiteral(loc, typedC, *this, uniqueName, alignment);
955+
generateStringLiteral(loc, typedC, cir::GlobalLinkageKind::PrivateLinkage,
956+
*this, uniqueName, alignment);
911957
setDSOLocal(static_cast<mlir::Operation *>(gv));
912958

913959
assert(!cir::MissingFeatures::sanitizers());

clang/lib/CIR/CodeGen/CIRGenModule.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ class CIRGenModule : public CIRGenTypeCache {
149149
cir::GlobalOp getGlobalForStringLiteral(const StringLiteral *s,
150150
llvm::StringRef name = ".str");
151151

152+
/// Set attributes which are common to any form of a global definition (alias,
153+
/// Objective-C method, function, global variable).
154+
///
155+
/// NOTE: This should only be called for definitions.
156+
void setCommonAttributes(GlobalDecl gd, mlir::Operation *op);
157+
152158
const TargetCIRGenInfo &getTargetCIRGenInfo();
153159

154160
/// Helpers to convert the presumed location of Clang's SourceLocation to an
@@ -209,6 +215,7 @@ class CIRGenModule : public CIRGenTypeCache {
209215
void emitTentativeDefinition(const VarDecl *d);
210216

211217
bool supportsCOMDAT() const;
218+
void maybeSetTrivialComdat(const clang::Decl &d, mlir::Operation *op);
212219

213220
static void setInitializer(cir::GlobalOp &op, mlir::Attribute value);
214221

@@ -285,6 +292,8 @@ class CIRGenModule : public CIRGenTypeCache {
285292
// An ordered map of canonical GlobalDecls to their mangled names.
286293
llvm::MapVector<clang::GlobalDecl, llvm::StringRef> mangledDeclNames;
287294
llvm::StringMap<clang::GlobalDecl, llvm::BumpPtrAllocator> manglings;
295+
296+
void setNonAliasAttributes(GlobalDecl gd, mlir::Operation *op);
288297
};
289298
} // namespace CIRGen
290299

0 commit comments

Comments
 (0)