Skip to content

Commit ba60214

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web' (55 commits)
2 parents c268c01 + 5187038 commit ba60214

File tree

168 files changed

+3881
-1754
lines changed

Some content is hidden

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

168 files changed

+3881
-1754
lines changed

clang/include/clang/AST/OpenACCClause.h

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -837,23 +837,43 @@ class OpenACCClauseWithVarList : public OpenACCClauseWithExprs {
837837

838838
class OpenACCPrivateClause final
839839
: public OpenACCClauseWithVarList,
840-
private llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {
840+
private llvm::TrailingObjects<OpenACCPrivateClause, Expr *, VarDecl *> {
841841
friend TrailingObjects;
842842

843843
OpenACCPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
844-
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
844+
ArrayRef<Expr *> VarList,
845+
ArrayRef<VarDecl *> InitRecipes, SourceLocation EndLoc)
845846
: OpenACCClauseWithVarList(OpenACCClauseKind::Private, BeginLoc,
846847
LParenLoc, EndLoc) {
847-
setExprs(getTrailingObjects(VarList.size()), VarList);
848+
assert(VarList.size() == InitRecipes.size());
849+
setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
850+
llvm::uninitialized_copy(InitRecipes, getTrailingObjects<VarDecl *>());
848851
}
849852

850853
public:
851854
static bool classof(const OpenACCClause *C) {
852855
return C->getClauseKind() == OpenACCClauseKind::Private;
853856
}
857+
// Gets a list of 'made up' `VarDecl` objects that can be used by codegen to
858+
// ensure that we properly initialize each of these variables.
859+
ArrayRef<VarDecl *> getInitRecipes() {
860+
return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(),
861+
getExprs().size()};
862+
}
863+
864+
ArrayRef<VarDecl *> getInitRecipes() const {
865+
return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(),
866+
getExprs().size()};
867+
}
868+
854869
static OpenACCPrivateClause *
855870
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
856-
ArrayRef<Expr *> VarList, SourceLocation EndLoc);
871+
ArrayRef<Expr *> VarList, ArrayRef<VarDecl *> InitRecipes,
872+
SourceLocation EndLoc);
873+
874+
size_t numTrailingObjects(OverloadToken<Expr *>) const {
875+
return getExprs().size();
876+
}
857877
};
858878

859879
class OpenACCFirstPrivateClause final

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13851,7 +13851,8 @@ def err_acc_device_type_multiple_archs
1385113851
def warn_acc_var_referenced_lacks_op
1385213852
: Warning<"variable of type %0 referenced in OpenACC '%1' clause does not "
1385313853
"have a %enum_select<AccVarReferencedReason>{%DefCtor{default "
13854-
"constructor}|%Dtor{destructor}}2; reference has no effect">,
13854+
"constructor}|%CopyCtor{copy constructor}|%Dtor{destructor}}2; "
13855+
"reference has no effect">,
1385513856
InGroup<DiagGroup<"openacc-var-lacks-operation">>,
1385613857
DefaultError;
1385713858

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,6 @@ class SemaOpenACC : public SemaBase {
176176

177177
void checkFor();
178178

179-
// void checkRangeFor(); ?? ERICH
180-
// const ValueDecl *checkInit();
181-
// void checkCond(const ValueDecl *Init);
182-
// void checkInc(const ValueDecl *Init);
183179
public:
184180
// Checking for non-instantiation version of a Range-for.
185181
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
@@ -241,6 +237,10 @@ class SemaOpenACC : public SemaBase {
241237
SourceLocation ClauseLoc,
242238
ArrayRef<const OpenACCClause *> Clauses);
243239

240+
// Creates a VarDecl with a proper default init for the purposes of a
241+
// `private` clause, so it can be used to generate a recipe later.
242+
VarDecl *CreateInitRecipe(const Expr *VarExpr);
243+
244244
public:
245245
ComputeConstructInfo &getActiveComputeConstructInfo() {
246246
return ActiveComputeConstructInfo;

clang/lib/AST/ByteCode/ByteCodeEmitter.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ int32_t ByteCodeEmitter::getOffset(LabelTy Label) {
135135
/// Helper to write bytecode and bail out if 32-bit offsets become invalid.
136136
/// Pointers will be automatically marshalled as 32-bit IDs.
137137
template <typename T>
138-
static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
139-
bool &Success) {
138+
static void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code,
139+
const T &Val, bool &Success) {
140140
size_t ValPos = Code.size();
141141
size_t Size;
142142

@@ -153,7 +153,7 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
153153
// Access must be aligned!
154154
assert(aligned(ValPos));
155155
assert(aligned(ValPos + Size));
156-
Code.resize(ValPos + Size);
156+
Code.resize_for_overwrite(ValPos + Size);
157157

158158
if constexpr (!std::is_pointer_v<T>) {
159159
new (Code.data() + ValPos) T(Val);
@@ -166,7 +166,7 @@ static void emit(Program &P, std::vector<std::byte> &Code, const T &Val,
166166
/// Emits a serializable value. These usually (potentially) contain
167167
/// heap-allocated memory and aren't trivially copyable.
168168
template <typename T>
169-
static void emitSerialized(std::vector<std::byte> &Code, const T &Val,
169+
static void emitSerialized(llvm::SmallVectorImpl<std::byte> &Code, const T &Val,
170170
bool &Success) {
171171
size_t ValPos = Code.size();
172172
size_t Size = align(Val.bytesToSerialize());
@@ -179,32 +179,32 @@ static void emitSerialized(std::vector<std::byte> &Code, const T &Val,
179179
// Access must be aligned!
180180
assert(aligned(ValPos));
181181
assert(aligned(ValPos + Size));
182-
Code.resize(ValPos + Size);
182+
Code.resize_for_overwrite(ValPos + Size);
183183

184184
Val.serialize(Code.data() + ValPos);
185185
}
186186

187187
template <>
188-
void emit(Program &P, std::vector<std::byte> &Code, const Floating &Val,
189-
bool &Success) {
188+
void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code,
189+
const Floating &Val, bool &Success) {
190190
emitSerialized(Code, Val, Success);
191191
}
192192

193193
template <>
194-
void emit(Program &P, std::vector<std::byte> &Code,
194+
void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code,
195195
const IntegralAP<false> &Val, bool &Success) {
196196
emitSerialized(Code, Val, Success);
197197
}
198198

199199
template <>
200-
void emit(Program &P, std::vector<std::byte> &Code, const IntegralAP<true> &Val,
201-
bool &Success) {
200+
void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code,
201+
const IntegralAP<true> &Val, bool &Success) {
202202
emitSerialized(Code, Val, Success);
203203
}
204204

205205
template <>
206-
void emit(Program &P, std::vector<std::byte> &Code, const FixedPoint &Val,
207-
bool &Success) {
206+
void emit(Program &P, llvm::SmallVectorImpl<std::byte> &Code,
207+
const FixedPoint &Val, bool &Success) {
208208
emitSerialized(Code, Val, Success);
209209
}
210210

clang/lib/AST/ByteCode/ByteCodeEmitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class ByteCodeEmitter {
8888
/// Location of label relocations.
8989
llvm::DenseMap<LabelTy, llvm::SmallVector<unsigned, 5>> LabelRelocs;
9090
/// Program code.
91-
std::vector<std::byte> Code;
91+
llvm::SmallVector<std::byte> Code;
9292
/// Opcode to expression mapping.
9393
SourceMap SrcMap;
9494

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5914,7 +5914,7 @@ bool Compiler<Emitter>::emitLambdaStaticInvokerBody(const CXXMethodDecl *MD) {
59145914

59155915
const CXXRecordDecl *ClosureClass = MD->getParent();
59165916
const CXXMethodDecl *LambdaCallOp = ClosureClass->getLambdaCallOperator();
5917-
assert(ClosureClass->captures_begin() == ClosureClass->captures_end());
5917+
assert(ClosureClass->captures().empty());
59185918
const Function *Func = this->getFunction(LambdaCallOp);
59195919
if (!Func)
59205920
return false;

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ bool Context::isPotentialConstantExpr(State &Parent, const FunctionDecl *FD) {
4545
Compiler<ByteCodeEmitter>(*this, *P).compileFunc(
4646
FD, const_cast<Function *>(Func));
4747

48-
++EvalID;
49-
// And run it.
50-
if (!Run(Parent, Func))
48+
if (!Func->isValid())
5149
return false;
5250

53-
return Func->isValid();
51+
++EvalID;
52+
// And run it.
53+
return Run(Parent, Func);
5454
}
5555

5656
void Context::isPotentialConstantExprUnevaluated(State &Parent, const Expr *E,
@@ -474,7 +474,7 @@ const Function *Context::getOrCreateFunction(const FunctionDecl *FuncDecl) {
474474
IsLambdaStaticInvoker = true;
475475

476476
const CXXRecordDecl *ClosureClass = MD->getParent();
477-
assert(ClosureClass->captures_begin() == ClosureClass->captures_end());
477+
assert(ClosureClass->captures().empty());
478478
if (ClosureClass->isGenericLambda()) {
479479
const CXXMethodDecl *LambdaCallOp = ClosureClass->getLambdaCallOperator();
480480
assert(MD->isFunctionTemplateSpecialization() &&

clang/lib/AST/ByteCode/Function.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class Function final {
236236
bool HasRVO, bool IsLambdaStaticInvoker);
237237

238238
/// Sets the code of a function.
239-
void setCode(unsigned NewFrameSize, std::vector<std::byte> &&NewCode,
239+
void setCode(unsigned NewFrameSize, llvm::SmallVector<std::byte> &&NewCode,
240240
SourceMap &&NewSrcMap, llvm::SmallVector<Scope, 2> &&NewScopes,
241241
bool NewHasBody) {
242242
FrameSize = NewFrameSize;
@@ -266,7 +266,7 @@ class Function final {
266266
/// Size of the argument stack.
267267
unsigned ArgSize;
268268
/// Program code.
269-
std::vector<std::byte> Code;
269+
llvm::SmallVector<std::byte> Code;
270270
/// Opcode-to-expression mapping.
271271
SourceMap SrcMap;
272272
/// List of block descriptors.

clang/lib/AST/DeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,7 @@ CXXRecordDecl::getVisibleConversionFunctions() const {
19831983
ASTContext &Ctx = getASTContext();
19841984

19851985
ASTUnresolvedSet *Set;
1986-
if (bases_begin() == bases_end()) {
1986+
if (bases().empty()) {
19871987
// If root class, all conversions are visible.
19881988
Set = &data().Conversions.get(Ctx);
19891989
} else {

clang/lib/AST/DeclPrinter.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ void DeclPrinter::VisitObjCMethodDecl(ObjCMethodDecl *OMD) {
14491449
lastPos = pos + 1;
14501450
}
14511451

1452-
if (OMD->param_begin() == OMD->param_end())
1452+
if (OMD->parameters().empty())
14531453
Out << name;
14541454

14551455
if (OMD->isVariadic())
@@ -1486,8 +1486,7 @@ void DeclPrinter::VisitObjCImplementationDecl(ObjCImplementationDecl *OID) {
14861486
}
14871487
Indentation -= Policy.Indentation;
14881488
Out << "}\n";
1489-
}
1490-
else if (SID || (OID->decls_begin() != OID->decls_end())) {
1489+
} else if (SID || !OID->decls().empty()) {
14911490
Out << "\n";
14921491
eolnOut = true;
14931492
}
@@ -1546,8 +1545,7 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
15461545
}
15471546
Indentation -= Policy.Indentation;
15481547
Out << "}\n";
1549-
}
1550-
else if (SID || (OID->decls_begin() != OID->decls_end())) {
1548+
} else if (SID || !OID->decls().empty()) {
15511549
Out << "\n";
15521550
eolnOut = true;
15531551
}

0 commit comments

Comments
 (0)