Skip to content

Commit 797c62e

Browse files
authored
Merge branch 'main' into fix-win-oop
2 parents dbabd92 + 8548fa0 commit 797c62e

File tree

214 files changed

+4182
-1666
lines changed

Some content is hidden

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

214 files changed

+4182
-1666
lines changed

clang/include/clang/Basic/DiagnosticFrontendKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ def err_fe_unable_to_load_plugin : Error<
115115
"unable to load plugin '%0': '%1'">;
116116
def err_fe_unable_to_create_target : Error<
117117
"unable to create target: '%0'">;
118+
def err_fe_unable_to_create_subtarget : Error<
119+
"unable to create subtarget: '%0'%select{ with features '%2'|}1">;
118120
def err_fe_unable_to_interface_with_target : Error<
119121
"unable to interface with target machine">;
120122
def err_fe_unable_to_open_output : Error<
@@ -132,6 +134,8 @@ def err_fe_no_pch_in_dir : Error<
132134
"no suitable precompiled header file found in directory '%0'">;
133135
def err_fe_action_not_available : Error<
134136
"action %0 not compiled in">;
137+
def err_fe_cir_not_built : Error<"clang IR support not available, rebuild "
138+
"clang with -DCLANG_ENABLE_CIR=ON">;
135139
def err_fe_invalid_multiple_actions : Error<
136140
"'%0' action ignored; '%1' action specified previously">;
137141
def err_fe_invalid_alignment : Error<

clang/include/clang/Basic/OffloadArch.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ enum class OffloadArch {
103103
GFX1200,
104104
GFX1201,
105105
GFX1250,
106+
GFX1251,
106107
AMDGCNSPIRV,
107108
Generic, // A processor model named 'generic' if the target backend defines a
108109
// public one.

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14102,6 +14102,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1410214102
return Success(Result, E);
1410314103
}
1410414104
}
14105+
llvm_unreachable("Fully covered switch above");
1410514106
}
1410614107
case Builtin::BIstrlen:
1410714108
case Builtin::BIwcslen:

clang/lib/AST/QualTypeNames.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ static bool getFullyQualifiedTemplateName(const ASTContext &Ctx,
5858
NestedNameSpecifier NNS = std::nullopt;
5959

6060
TemplateDecl *ArgTDecl = TName.getAsTemplateDecl();
61-
// ArgTDecl won't be NULL because we asserted that this isn't a
62-
// dependent context very early in the call chain.
63-
assert(ArgTDecl != nullptr);
61+
if (!ArgTDecl) // ArgTDecl can be null in dependent contexts.
62+
return false;
63+
6464
QualifiedTemplateName *QTName = TName.getAsQualifiedTemplateName();
6565

6666
if (QTName &&
@@ -252,6 +252,9 @@ createNestedNameSpecifierForScopeOf(const ASTContext &Ctx, const Decl *Decl,
252252
bool WithGlobalNsPrefix) {
253253
assert(Decl);
254254

255+
// Some declaration cannot be qualified.
256+
if (Decl->isTemplateParameter())
257+
return std::nullopt;
255258
const DeclContext *DC = Decl->getDeclContext()->getRedeclContext();
256259
const auto *Outer = dyn_cast<NamedDecl>(DC);
257260
const auto *OuterNS = dyn_cast<NamespaceDecl>(DC);

clang/lib/Basic/OffloadArch.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static const OffloadArchToStringMap ArchNames[] = {
9191
GFX(1200), // gfx1200
9292
GFX(1201), // gfx1201
9393
GFX(1250), // gfx1250
94+
GFX(1251), // gfx1251
9495
{OffloadArch::AMDGCNSPIRV, "amdgcnspirv", "compute_amdgcn"},
9596
// Intel CPUs
9697
{OffloadArch::GRANITERAPIDS, "graniterapids", ""},

clang/lib/Basic/Targets/NVPTX.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts,
240240
case OffloadArch::GFX1200:
241241
case OffloadArch::GFX1201:
242242
case OffloadArch::GFX1250:
243+
case OffloadArch::GFX1251:
243244
case OffloadArch::AMDGCNSPIRV:
244245
case OffloadArch::Generic:
245246
case OffloadArch::GRANITERAPIDS:

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,9 @@ void CGHLSLRuntime::emitInitListOpaqueValues(CodeGenFunction &CGF,
922922

923923
std::optional<LValue> CGHLSLRuntime::emitResourceArraySubscriptExpr(
924924
const ArraySubscriptExpr *ArraySubsExpr, CodeGenFunction &CGF) {
925-
assert(ArraySubsExpr->getType()->isHLSLResourceRecord() ||
926-
ArraySubsExpr->getType()->isHLSLResourceRecordArray() &&
927-
"expected resource array subscript expression");
925+
assert((ArraySubsExpr->getType()->isHLSLResourceRecord() ||
926+
ArraySubsExpr->getType()->isHLSLResourceRecordArray()) &&
927+
"expected resource array subscript expression");
928928

929929
// Let clang codegen handle local resource array subscripts,
930930
// or when the subscript references on opaque expression (as part of

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,7 @@ void CGOpenMPRuntimeGPU::processRequiresDirective(const OMPRequiresDecl *D) {
23362336
case OffloadArch::GFX1200:
23372337
case OffloadArch::GFX1201:
23382338
case OffloadArch::GFX1250:
2339+
case OffloadArch::GFX1251:
23392340
case OffloadArch::AMDGCNSPIRV:
23402341
case OffloadArch::Generic:
23412342
case OffloadArch::GRANITERAPIDS:

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4610,12 +4610,6 @@ void CodeGenModule::emitMultiVersionFunctions() {
46104610
}
46114611
llvm::Function *ResolverFunc = cast<llvm::Function>(ResolverConstant);
46124612

4613-
ResolverFunc->setLinkage(getMultiversionLinkage(*this, GD));
4614-
4615-
if (!ResolverFunc->hasLocalLinkage() && supportsCOMDAT())
4616-
ResolverFunc->setComdat(
4617-
getModule().getOrInsertComdat(ResolverFunc->getName()));
4618-
46194613
const TargetInfo &TI = getTarget();
46204614
llvm::stable_sort(
46214615
Options, [&TI](const CodeGenFunction::FMVResolverOption &LHS,
@@ -4624,6 +4618,11 @@ void CodeGenModule::emitMultiVersionFunctions() {
46244618
});
46254619
CodeGenFunction CGF(*this);
46264620
CGF.EmitMultiVersionResolver(ResolverFunc, Options);
4621+
4622+
setMultiVersionResolverAttributes(ResolverFunc, GD);
4623+
if (!ResolverFunc->hasLocalLinkage() && supportsCOMDAT())
4624+
ResolverFunc->setComdat(
4625+
getModule().getOrInsertComdat(ResolverFunc->getName()));
46274626
}
46284627

46294628
// Ensure that any additions to the deferred decls list caused by emitting a
@@ -4674,7 +4673,7 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
46744673

46754674
auto *ResolverFunc = cast<llvm::Function>(GetOrCreateLLVMFunction(
46764675
ResolverName, ResolverType, ResolverGD, /*ForVTable=*/false));
4677-
ResolverFunc->setLinkage(getMultiversionLinkage(*this, GD));
4676+
46784677
if (supportsCOMDAT())
46794678
ResolverFunc->setComdat(
46804679
getModule().getOrInsertComdat(ResolverFunc->getName()));
@@ -4740,6 +4739,7 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
47404739

47414740
CodeGenFunction CGF(*this);
47424741
CGF.EmitMultiVersionResolver(ResolverFunc, Options);
4742+
setMultiVersionResolverAttributes(ResolverFunc, GD);
47434743

47444744
if (getTarget().supportsIFunc()) {
47454745
llvm::GlobalValue::LinkageTypes Linkage = getMultiversionLinkage(*this, GD);
@@ -4858,6 +4858,26 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
48584858
return Resolver;
48594859
}
48604860

4861+
void CodeGenModule::setMultiVersionResolverAttributes(llvm::Function *Resolver,
4862+
GlobalDecl GD) {
4863+
const NamedDecl *D = dyn_cast_or_null<NamedDecl>(GD.getDecl());
4864+
Resolver->setLinkage(getMultiversionLinkage(*this, GD));
4865+
4866+
// Function body has to be emitted before calling setGlobalVisibility
4867+
// for Resolver to be considered as definition.
4868+
setGlobalVisibility(Resolver, D);
4869+
4870+
setDSOLocal(Resolver);
4871+
4872+
// Set the default target-specific attributes, such as PAC and BTI ones on
4873+
// AArch64. Not passing Decl to prevent setting unrelated attributes,
4874+
// as Resolver can be shared by multiple declarations.
4875+
// FIXME Some targets may require a non-null D to set some attributes
4876+
// (such as "stackrealign" on X86, even when it is requested via
4877+
// "-mstackrealign" command line option).
4878+
getTargetCodeGenInfo().setTargetAttributes(/*D=*/nullptr, Resolver, *this);
4879+
}
4880+
48614881
bool CodeGenModule::shouldDropDLLAttribute(const Decl *D,
48624882
const llvm::GlobalValue *GV) const {
48634883
auto SC = GV->getDLLStorageClass();

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,15 @@ class CodeGenModule : public CodeGenTypeCache {
18511851
// that feature and for a regular function (llvm::GlobalValue) otherwise.
18521852
llvm::Constant *GetOrCreateMultiVersionResolver(GlobalDecl GD);
18531853

1854+
// Set attributes to a resolver function generated by Clang.
1855+
// GD is either the cpu_dispatch declaration or an arbitrarily chosen
1856+
// function declaration that triggered the implicit generation of this
1857+
// resolver function.
1858+
//
1859+
/// NOTE: This should only be called for definitions.
1860+
void setMultiVersionResolverAttributes(llvm::Function *Resolver,
1861+
GlobalDecl GD);
1862+
18541863
// In scenarios where a function is not known to be a multiversion function
18551864
// until a later declaration, it is sometimes necessary to change the
18561865
// previously created mangled name to align with requirements of whatever

0 commit comments

Comments
 (0)