Skip to content

Commit 3e4395e

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
CONFLICT (add/add): Merge conflict in clang/test/CodeGenSYCL/convergent.cpp
2 parents c31a762 + 9263931 commit 3e4395e

File tree

170 files changed

+1334
-1255
lines changed

Some content is hidden

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

170 files changed

+1334
-1255
lines changed

clang/include/clang/AST/Mangle.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,11 @@ class MangleContext {
123123
void mangleBlock(const DeclContext *DC, const BlockDecl *BD,
124124
raw_ostream &Out);
125125

126-
void mangleObjCMethodNameWithoutSize(const ObjCMethodDecl *MD, raw_ostream &);
127-
void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &);
126+
void mangleObjCMethodName(const ObjCMethodDecl *MD, raw_ostream &OS,
127+
bool includePrefixByte = true,
128+
bool includeCategoryNamespace = true);
129+
void mangleObjCMethodNameAsSourceName(const ObjCMethodDecl *MD,
130+
raw_ostream &);
128131

129132
virtual void mangleStaticGuardVariable(const VarDecl *D, raw_ostream &) = 0;
130133

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2516,7 +2516,7 @@ void CXXNameMangler::mangleRefQualifier(RefQualifierKind RefQualifier) {
25162516
}
25172517

25182518
void CXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) {
2519-
Context.mangleObjCMethodName(MD, Out);
2519+
Context.mangleObjCMethodNameAsSourceName(MD, Out);
25202520
}
25212521

25222522
static bool isTypeSubstitutable(Qualifiers Quals, const Type *Ty,

clang/lib/AST/Mangle.cpp

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
175175
const TargetInfo &TI = Context.getTargetInfo();
176176
if (CC == CCM_Other || (MCXX && TI.getCXXABI() == TargetCXXABI::Microsoft)) {
177177
if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D))
178-
mangleObjCMethodName(OMD, Out);
178+
mangleObjCMethodNameAsSourceName(OMD, Out);
179179
else
180180
mangleCXXName(GD, Out);
181181
return;
@@ -192,7 +192,7 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
192192
if (!MCXX)
193193
Out << D->getIdentifier()->getName();
194194
else if (const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D))
195-
mangleObjCMethodName(OMD, Out);
195+
mangleObjCMethodNameAsSourceName(OMD, Out);
196196
else
197197
mangleCXXName(GD, Out);
198198

@@ -275,7 +275,7 @@ void MangleContext::mangleBlock(const DeclContext *DC, const BlockDecl *BD,
275275
SmallString<64> Buffer;
276276
llvm::raw_svector_ostream Stream(Buffer);
277277
if (const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(DC)) {
278-
mangleObjCMethodName(Method, Stream);
278+
mangleObjCMethodNameAsSourceName(Method, Stream);
279279
} else {
280280
assert((isa<NamedDecl>(DC) || isa<BlockDecl>(DC)) &&
281281
"expected a NamedDecl or BlockDecl");
@@ -304,29 +304,38 @@ void MangleContext::mangleBlock(const DeclContext *DC, const BlockDecl *BD,
304304
mangleFunctionBlock(*this, Buffer, BD, Out);
305305
}
306306

307-
void MangleContext::mangleObjCMethodNameWithoutSize(const ObjCMethodDecl *MD,
308-
raw_ostream &OS) {
309-
const ObjCContainerDecl *CD =
310-
dyn_cast<ObjCContainerDecl>(MD->getDeclContext());
311-
assert (CD && "Missing container decl in GetNameForMethod");
307+
void MangleContext::mangleObjCMethodName(const ObjCMethodDecl *MD,
308+
raw_ostream &OS,
309+
bool includePrefixByte,
310+
bool includeCategoryNamespace) {
311+
// \01+[ContainerName(CategoryName) SelectorName]
312+
if (includePrefixByte) {
313+
OS << '\01';
314+
}
312315
OS << (MD->isInstanceMethod() ? '-' : '+') << '[';
313-
if (const ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(CD)) {
316+
if (const auto *CID = dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext())) {
314317
OS << CID->getClassInterface()->getName();
315-
OS << '(' << *CID << ')';
316-
} else {
318+
if (includeCategoryNamespace) {
319+
OS << '(' << *CID << ')';
320+
}
321+
} else if (const auto *CD =
322+
dyn_cast<ObjCContainerDecl>(MD->getDeclContext())) {
317323
OS << CD->getName();
324+
} else {
325+
llvm_unreachable("Unexpected ObjC method decl context");
318326
}
319327
OS << ' ';
320328
MD->getSelector().print(OS);
321329
OS << ']';
322330
}
323331

324-
void MangleContext::mangleObjCMethodName(const ObjCMethodDecl *MD,
325-
raw_ostream &Out) {
332+
void MangleContext::mangleObjCMethodNameAsSourceName(const ObjCMethodDecl *MD,
333+
raw_ostream &Out) {
326334
SmallString<64> Name;
327335
llvm::raw_svector_ostream OS(Name);
328336

329-
mangleObjCMethodNameWithoutSize(MD, OS);
337+
mangleObjCMethodName(MD, OS, /*includePrefixByte=*/false,
338+
/*includeCategoryNamespace=*/true);
330339
Out << OS.str().size() << OS.str();
331340
}
332341

@@ -352,7 +361,8 @@ class ASTNameGenerator::Implementation {
352361
if (writeFuncOrVarName(VD, FrontendBufOS))
353362
return true;
354363
} else if (auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
355-
MC->mangleObjCMethodNameWithoutSize(MD, OS);
364+
MC->mangleObjCMethodName(MD, OS, /*includePrefixByte=*/false,
365+
/*includeCategoryNamespace=*/true);
356366
return false;
357367
} else if (auto *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
358368
writeObjCClassName(ID, FrontendBufOS);

clang/lib/AST/MicrosoftMangle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,7 @@ void MicrosoftCXXNameMangler::mangleSourceName(StringRef Name) {
13231323
}
13241324

13251325
void MicrosoftCXXNameMangler::mangleObjCMethodName(const ObjCMethodDecl *MD) {
1326-
Context.mangleObjCMethodName(MD, Out);
1326+
Context.mangleObjCMethodNameAsSourceName(MD, Out);
13271327
}
13281328

13291329
void MicrosoftCXXNameMangler::mangleTemplateInstantiationName(

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,7 @@ void CodeGenModule::ConstructAttributeList(
21502150
// Attach attributes to sret.
21512151
if (IRFunctionArgs.hasSRetArg()) {
21522152
llvm::AttrBuilder SRETAttrs;
2153-
SRETAttrs.addStructRetAttr(getTypes().ConvertTypeForMem(RetTy));
2153+
SRETAttrs.addAttribute(llvm::Attribute::StructRet);
21542154
hasUsedSRet = true;
21552155
if (RetAI.getInReg())
21562156
SRETAttrs.addAttribute(llvm::Attribute::InReg);
@@ -2285,7 +2285,7 @@ void CodeGenModule::ConstructAttributeList(
22852285
// Add 'sret' if we haven't already used it for something, but
22862286
// only if the result is void.
22872287
if (!hasUsedSRet && RetTy->isVoidType()) {
2288-
Attrs.addStructRetAttr(getTypes().ConvertTypeForMem(ParamType));
2288+
Attrs.addAttribute(llvm::Attribute::StructRet);
22892289
hasUsedSRet = true;
22902290
}
22912291

clang/lib/CodeGen/CGObjCMac.cpp

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "clang/AST/Attr.h"
2121
#include "clang/AST/Decl.h"
2222
#include "clang/AST/DeclObjC.h"
23+
#include "clang/AST/Mangle.h"
2324
#include "clang/AST/RecordLayout.h"
2425
#include "clang/AST/StmtObjC.h"
2526
#include "clang/Basic/CodeGenOptions.h"
@@ -924,13 +925,6 @@ class CGObjCCommonMac : public CodeGen::CGObjCRuntime {
924925

925926
llvm::StringMap<llvm::GlobalVariable *> NSConstantStringMap;
926927

927-
/// GetNameForMethod - Return a name for the given method.
928-
/// \param[out] NameOut - The return value.
929-
void GetNameForMethod(const ObjCMethodDecl *OMD,
930-
const ObjCContainerDecl *CD,
931-
SmallVectorImpl<char> &NameOut,
932-
bool ignoreCategoryNamespace = false);
933-
934928
/// GetMethodVarName - Return a unique constant for the given
935929
/// selector's name. The return value has type char *.
936930
llvm::Constant *GetMethodVarName(Selector Sel);
@@ -4008,7 +4002,10 @@ llvm::Function *CGObjCCommonMac::GenerateMethod(const ObjCMethodDecl *OMD,
40084002
Method = GenerateDirectMethod(OMD, CD);
40094003
} else {
40104004
SmallString<256> Name;
4011-
GetNameForMethod(OMD, CD, Name);
4005+
llvm::raw_svector_ostream OS(Name);
4006+
const auto &MC = CGM.getContext().createMangleContext();
4007+
MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
4008+
/*includeCategoryNamespace=*/true);
40124009

40134010
CodeGenTypes &Types = CGM.getTypes();
40144011
llvm::FunctionType *MethodTy =
@@ -4061,7 +4058,10 @@ CGObjCCommonMac::GenerateDirectMethod(const ObjCMethodDecl *OMD,
40614058
I->second = Fn;
40624059
} else {
40634060
SmallString<256> Name;
4064-
GetNameForMethod(OMD, CD, Name, /*ignoreCategoryNamespace*/ true);
4061+
llvm::raw_svector_ostream OS(Name);
4062+
const auto &MC = CGM.getContext().createMangleContext();
4063+
MC->mangleObjCMethodName(OMD, OS, /*includePrefixByte=*/true,
4064+
/*includeCategoryNamespace=*/false);
40654065

40664066
Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage,
40674067
Name.str(), &CGM.getModule());
@@ -5715,21 +5715,6 @@ CGObjCCommonMac::GetPropertyTypeString(const ObjCPropertyDecl *PD,
57155715
return GetPropertyName(&CGM.getContext().Idents.get(TypeStr));
57165716
}
57175717

5718-
void CGObjCCommonMac::GetNameForMethod(const ObjCMethodDecl *D,
5719-
const ObjCContainerDecl *CD,
5720-
SmallVectorImpl<char> &Name,
5721-
bool ignoreCategoryNamespace) {
5722-
llvm::raw_svector_ostream OS(Name);
5723-
assert (CD && "Missing container decl in GetNameForMethod");
5724-
OS << '\01' << (D->isInstanceMethod() ? '-' : '+')
5725-
<< '[' << CD->getName();
5726-
if (!ignoreCategoryNamespace)
5727-
if (const ObjCCategoryImplDecl *CID =
5728-
dyn_cast<ObjCCategoryImplDecl>(D->getDeclContext()))
5729-
OS << '(' << *CID << ')';
5730-
OS << ' ' << D->getSelector().getAsString() << ']';
5731-
}
5732-
57335718
void CGObjCMac::FinishModule() {
57345719
EmitModuleInfo();
57355720

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,27 +2007,36 @@ void Generic_GCC::GCCInstallationDetector::init(
20072007
// installation available. GCC installs are ranked by version number.
20082008
Version = GCCVersion::Parse("0.0.0");
20092009
for (const std::string &Prefix : Prefixes) {
2010-
if (!D.getVFS().exists(Prefix))
2010+
auto &VFS = D.getVFS();
2011+
if (!VFS.exists(Prefix))
20112012
continue;
20122013
for (StringRef Suffix : CandidateLibDirs) {
20132014
const std::string LibDir = Prefix + Suffix.str();
2014-
if (!D.getVFS().exists(LibDir))
2015+
if (!VFS.exists(LibDir))
20152016
continue;
2017+
// Maybe filter out <libdir>/gcc and <libdir>/gcc-cross.
2018+
bool GCCDirExists = VFS.exists(LibDir + "/gcc");
2019+
bool GCCCrossDirExists = VFS.exists(LibDir + "/gcc-cross");
20162020
// Try to match the exact target triple first.
2017-
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TargetTriple.str());
2021+
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, TargetTriple.str(),
2022+
false, GCCDirExists, GCCCrossDirExists);
20182023
// Try rest of possible triples.
20192024
for (StringRef Candidate : ExtraTripleAliases) // Try these first.
2020-
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate);
2025+
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate, false,
2026+
GCCDirExists, GCCCrossDirExists);
20212027
for (StringRef Candidate : CandidateTripleAliases)
2022-
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate);
2028+
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate, false,
2029+
GCCDirExists, GCCCrossDirExists);
20232030
}
20242031
for (StringRef Suffix : CandidateBiarchLibDirs) {
20252032
const std::string LibDir = Prefix + Suffix.str();
2026-
if (!D.getVFS().exists(LibDir))
2033+
if (!VFS.exists(LibDir))
20272034
continue;
2035+
bool GCCDirExists = VFS.exists(LibDir + "/gcc");
2036+
bool GCCCrossDirExists = VFS.exists(LibDir + "/gcc-cross");
20282037
for (StringRef Candidate : CandidateBiarchTripleAliases)
2029-
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate,
2030-
/*NeedsBiarchSuffix=*/ true);
2038+
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate, true,
2039+
GCCDirExists, GCCCrossDirExists);
20312040
}
20322041
}
20332042
}
@@ -2518,7 +2527,7 @@ bool Generic_GCC::GCCInstallationDetector::ScanGCCForMultilibs(
25182527
void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
25192528
const llvm::Triple &TargetTriple, const ArgList &Args,
25202529
const std::string &LibDir, StringRef CandidateTriple,
2521-
bool NeedsBiarchSuffix) {
2530+
bool NeedsBiarchSuffix, bool GCCDirExists, bool GCCCrossDirExists) {
25222531
llvm::Triple::ArchType TargetArch = TargetTriple.getArch();
25232532
// Locations relative to the system lib directory where GCC's triple-specific
25242533
// directories might reside.
@@ -2532,11 +2541,10 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
25322541
bool Active;
25332542
} Suffixes[] = {
25342543
// This is the normal place.
2535-
{"gcc/" + CandidateTriple.str(), "../..", true},
2544+
{"gcc/" + CandidateTriple.str(), "../..", GCCDirExists},
25362545

25372546
// Debian puts cross-compilers in gcc-cross.
2538-
{"gcc-cross/" + CandidateTriple.str(), "../..",
2539-
TargetTriple.getOS() != llvm::Triple::Solaris},
2547+
{"gcc-cross/" + CandidateTriple.str(), "../..", GCCCrossDirExists},
25402548

25412549
// The Freescale PPC SDK has the gcc libraries in
25422550
// <sysroot>/usr/lib/<triple>/x.y.z so have a look there as well. Only do

clang/lib/Driver/ToolChains/Gnu.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,8 @@ class LLVM_LIBRARY_VISIBILITY Generic_GCC : public ToolChain {
276276
const llvm::opt::ArgList &Args,
277277
const std::string &LibDir,
278278
StringRef CandidateTriple,
279-
bool NeedsBiarchSuffix = false);
279+
bool NeedsBiarchSuffix, bool GCCDirExists,
280+
bool GCCCrossDirExists);
280281

281282
bool ScanGentooConfigs(const llvm::Triple &TargetTriple,
282283
const llvm::opt::ArgList &Args,

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5921,6 +5921,7 @@ void Sema::ActOnStartOfFunctionDefinitionInOpenMPDeclareVariantScope(
59215921
continue;
59225922

59235923
QualType UDeclTy = UDecl->getType();
5924+
// TODO: Verify types for templates eventually.
59245925
if (!UDeclTy->isDependentType()) {
59255926
QualType NewType = Context.mergeFunctionTypes(
59265927
FType, UDeclTy, /* OfBlockPointer */ false,
@@ -6008,8 +6009,6 @@ ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope *Scope,
60086009
TargetOMPContext OMPCtx(Context, std::move(DiagUnknownTrait),
60096010
getCurFunctionDecl());
60106011

6011-
QualType CalleeFnType = CalleeFnDecl->getType();
6012-
60136012
SmallVector<Expr *, 4> Exprs;
60146013
SmallVector<VariantMatchInfo, 4> VMIs;
60156014
while (CalleeFnDecl) {
@@ -6062,19 +6061,8 @@ ExprResult Sema::ActOnOpenMPCall(ExprResult Call, Scope *Scope,
60626061
}
60636062
NewCall = BuildCallExpr(Scope, BestExpr, LParenLoc, ArgExprs, RParenLoc,
60646063
ExecConfig);
6065-
if (NewCall.isUsable()) {
6066-
if (CallExpr *NCE = dyn_cast<CallExpr>(NewCall.get())) {
6067-
FunctionDecl *NewCalleeFnDecl = NCE->getDirectCallee();
6068-
QualType NewType = Context.mergeFunctionTypes(
6069-
CalleeFnType, NewCalleeFnDecl->getType(),
6070-
/* OfBlockPointer */ false,
6071-
/* Unqualified */ false, /* AllowCXX */ true);
6072-
if (!NewType.isNull())
6073-
break;
6074-
// Don't use the call if the function type was not compatible.
6075-
NewCall = nullptr;
6076-
}
6077-
}
6064+
if (NewCall.isUsable())
6065+
break;
60786066
}
60796067

60806068
VMIs.erase(VMIs.begin() + BestIdx);

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,6 @@ static void instantiateOMPDeclareVariantAttr(
445445
New->getLocation());
446446
if (!SubstFD)
447447
return;
448-
QualType NewType = S.Context.mergeFunctionTypes(
449-
SubstFD->getType(), FD->getType(),
450-
/* OfBlockPointer */ false,
451-
/* Unqualified */ false, /* AllowCXX */ true);
452-
if (NewType.isNull())
453-
return;
454448
S.InstantiateFunctionDefinition(
455449
New->getLocation(), SubstFD, /* Recursive */ true,
456450
/* DefinitionRequired */ false, /* AtEndOfTU */ false);

0 commit comments

Comments
 (0)