Skip to content

Commit

Permalink
Bug fixes for rebase onto version 8.
Browse files Browse the repository at this point in the history
  • Loading branch information
neboat committed Jun 5, 2019
1 parent 4089a08 commit 262c52f
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 70 deletions.
8 changes: 4 additions & 4 deletions include/clang/AST/ExprCilk.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class CilkSpawnExpr : public Expr {
SourceLocation getSpawnLoc() const { return SpawnLoc; }
void setSpawnLoc(SourceLocation L) { SpawnLoc = L; }

SourceLocation getLocStart() const LLVM_READONLY {
return SpawnedExpr->getLocStart();
SourceLocation getBeginLoc() const LLVM_READONLY {
return SpawnedExpr->getBeginLoc();
}
SourceLocation getLocEnd() const LLVM_READONLY {
return SpawnedExpr->getLocEnd();
SourceLocation getEndLoc() const LLVM_READONLY {
return SpawnedExpr->getEndLoc();
}
SourceLocation getExprLoc() const LLVM_READONLY {
return cast<Expr>(SpawnedExpr)->getExprLoc();
Expand Down
22 changes: 12 additions & 10 deletions include/clang/AST/StmtCilk.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ class CilkSpawnStmt : public Stmt {
SourceLocation getSpawnLoc() const { return SpawnLoc; }
void setSpawnLoc(SourceLocation L) { SpawnLoc = L; }

SourceLocation getLocStart() const LLVM_READONLY { return SpawnLoc; }
SourceLocation getLocEnd() const LLVM_READONLY {
return SpawnedStmt->getLocEnd();
SourceLocation getBeginLoc() const LLVM_READONLY { return SpawnLoc; }
SourceLocation getEndLoc() const LLVM_READONLY {
return SpawnedStmt->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand All @@ -67,16 +67,18 @@ class CilkSyncStmt : public Stmt {
SourceLocation SyncLoc;

public:
CilkSyncStmt(SourceLocation SL) : Stmt(CilkSyncStmtClass), SyncLoc(SL) {}
CilkSyncStmt(SourceLocation SL) : Stmt(CilkSyncStmtClass) {
setSyncLoc(SL);
}

// \brief Build an empty _Cilk_sync statement.
// Build an empty _Cilk_sync statement.
explicit CilkSyncStmt(EmptyShell Empty) : Stmt(CilkSyncStmtClass, Empty) { }

SourceLocation getSyncLoc() const { return SyncLoc; }
void setSyncLoc(SourceLocation L) { SyncLoc = L; }

SourceLocation getLocStart() const LLVM_READONLY { return SyncLoc; }
SourceLocation getLocEnd() const LLVM_READONLY { return SyncLoc; }
SourceLocation getBeginLoc() const LLVM_READONLY { return getSyncLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY { return getSyncLoc(); }

static bool classof(const Stmt *T) {
return T->getStmtClass() == CilkSyncStmtClass;
Expand Down Expand Up @@ -150,9 +152,9 @@ class CilkForStmt : public Stmt {
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }

SourceLocation getLocStart() const LLVM_READONLY { return CilkForLoc; }
SourceLocation getLocEnd() const LLVM_READONLY {
return SubExprs[BODY]->getLocEnd();
SourceLocation getBeginLoc() const LLVM_READONLY { return getCilkForLoc(); }
SourceLocation getEndLoc() const LLVM_READONLY {
return getBody()->getEndLoc();
}

static bool classof(const Stmt *T) {
Expand Down
3 changes: 2 additions & 1 deletion include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -2910,7 +2910,8 @@ def LoopHint : Attr {
let Args = [EnumArgument<"Option", "OptionType",
["vectorize", "vectorize_width", "interleave", "interleave_count",
"unroll", "unroll_count", "unroll_and_jam", "unroll_and_jam_count",
"pipeline", "pipeline_initiation_interval", "distribute"],
"pipeline", "pipeline_initiation_interval", "distribute",
"grainsize"],
["Vectorize", "VectorizeWidth", "Interleave", "InterleaveCount",
"Unroll", "UnrollCount", "UnrollAndJam", "UnrollAndJamCount",
"PipelineDisabled", "PipelineInitiationInterval", "Distribute",
Expand Down
81 changes: 35 additions & 46 deletions lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6054,56 +6054,45 @@ ExpectedStmt ASTNodeImporter::VisitObjCAutoreleasePoolStmt(
*ToSubStmtOrErr);
}

Stmt *ASTNodeImporter::VisitCilkSpawnStmt(CilkSpawnStmt *S) {
SourceLocation SpawnLoc = Importer.Import(S->getSpawnLoc());
Stmt *Child = Importer.Import(S->getSpawnedStmt());
if (!Child && S->getSpawnedStmt())
return nullptr;
return new (Importer.getToContext()) CilkSpawnStmt(SpawnLoc, Child);
ExpectedStmt ASTNodeImporter::VisitCilkSpawnStmt(CilkSpawnStmt *S) {
ExpectedSLoc ToSpawnLocOrErr = import(S->getSpawnLoc());
if (!ToSpawnLocOrErr)
return ToSpawnLocOrErr.takeError();
ExpectedStmt ToChildOrErr = import(S->getSpawnedStmt());
if (!ToChildOrErr)
return ToChildOrErr.takeError();
return new (Importer.getToContext()) CilkSpawnStmt(*ToSpawnLocOrErr,
*ToChildOrErr);
}

Stmt *ASTNodeImporter::VisitCilkSyncStmt(CilkSyncStmt *S) {
SourceLocation SyncLoc = Importer.Import(S->getSyncLoc());
return new (Importer.getToContext()) CilkSyncStmt(SyncLoc);
ExpectedStmt ASTNodeImporter::VisitCilkSyncStmt(CilkSyncStmt *S) {
ExpectedSLoc ToSyncLocOrErr = import(S->getSyncLoc());
if (!ToSyncLocOrErr)
return ToSyncLocOrErr.takeError();
return new (Importer.getToContext()) CilkSyncStmt(*ToSyncLocOrErr);
}

Stmt *ASTNodeImporter::VisitCilkForStmt(CilkForStmt *S) {
Stmt *ToInit = Importer.Import(S->getInit());
if (!ToInit && S->getInit())
return nullptr;
Expr *ToCondition = Importer.Import(S->getCond());
if (!ToCondition && S->getCond())
return nullptr;
// VarDecl *ToConditionVariable = nullptr;
// if (VarDecl *FromConditionVariable = S->getConditionVariable()) {
// ToConditionVariable =
// dyn_cast_or_null<VarDecl>(Importer.Import(FromConditionVariable));
// if (!ToConditionVariable)
// return nullptr;
// }
VarDecl *ToLoopVariable = nullptr;
if (VarDecl *FromLoopVariable = S->getLoopVariable()) {
ToLoopVariable =
dyn_cast_or_null<VarDecl>(Importer.Import(FromLoopVariable));
if (!ToLoopVariable)
return nullptr;
}
Expr *ToInc = Importer.Import(S->getInc());
if (!ToInc && S->getInc())
return nullptr;
Stmt *ToBody = Importer.Import(S->getBody());
if (!ToBody && S->getBody())
return nullptr;
SourceLocation ToForLoc = Importer.Import(S->getCilkForLoc());
SourceLocation ToLParenLoc = Importer.Import(S->getLParenLoc());
SourceLocation ToRParenLoc = Importer.Import(S->getRParenLoc());
return new (Importer.getToContext()) CilkForStmt(Importer.getToContext(),
ToInit,
ToCondition,
// ToConditionVariable,
ToInc, ToLoopVariable, ToBody,
ToForLoc, ToLParenLoc,
ToRParenLoc);
ExpectedStmt ASTNodeImporter::VisitCilkForStmt(CilkForStmt *S) {
auto Imp = importSeq(
S->getInit(), S->getCond(), /*S->getConditionVariable(),*/ S->getInc(),
S->getLoopVariable(), S->getBody(), S->getCilkForLoc(), S->getLParenLoc(),
S->getRParenLoc());
if (!Imp)
return Imp.takeError();

Stmt *ToInit;
Expr *ToCond, *ToInc;
// VarDecl *ToConditionVariable;
VarDecl *ToLoopVariable;
Stmt *ToBody;
SourceLocation ToCilkForLoc, ToLParenLoc, ToRParenLoc;
std::tie(
ToInit, ToCond, /*ToConditionVariable,*/ ToInc, ToLoopVariable, ToBody,
ToCilkForLoc, ToLParenLoc, ToRParenLoc) = *Imp;

return new (Importer.getToContext()) CilkForStmt(
Importer.getToContext(), ToInit, ToCond, /*ToConditionVariable,*/ ToInc,
ToLoopVariable, ToBody, ToCilkForLoc, ToLParenLoc, ToRParenLoc);
}

//----------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *M) {
default:
break;
}
}
EmitAnyExprToMem(E, Object, Qualifiers(), /*IsInit*/true);
}
pushTemporaryCleanup(*this, M, E, Object);
Expand Down
4 changes: 4 additions & 0 deletions lib/CodeGen/CGLoopInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs,
MDString::get(Ctx, "llvm.loop.pipeline.initiationinterval"),
ConstantAsMetadata::get(ConstantInt::get(
Type::getInt32Ty(Ctx), Attrs.PipelineInitiationInterval))};
Args.push_back(MDNode::get(Ctx, Vals));
}

// Setting tapir.loop.spawn.strategy
if (Attrs.SpawnStrategy != LoopAttributes::Sequential) {
Metadata *Vals[] = {MDString::get(Ctx, "tapir.loop.spawn.strategy"),
Expand Down Expand Up @@ -367,6 +370,7 @@ void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx,
break;
case LoopHintAttr::PipelineInitiationInterval:
setPipelineInitiationInterval(ValueInt);
break;
case LoopHintAttr::TapirGrainsize:
setTapirGrainsize(ValueInt);
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2506,7 +2506,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,

Opts.Cilk = Args.hasArg(OPT_fcilkplus);

if (Opts.Cilk && (Opts.ObjC1 || Opts.ObjC2))
if (Opts.Cilk && Opts.ObjC)
Diags.Report(diag::err_drv_cilk_objc);

if (Args.hasArg(OPT_fgnu89_inline)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Parse/ParseCilk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ StmtResult Parser::ParseCilkForStatement(SourceLocation *TrailingElseLoc) {
}

bool C99orCXXorObjC = getLangOpts().C99 || getLangOpts().CPlusPlus ||
getLangOpts().ObjC1;
getLangOpts().ObjC;

// A _Cilk_for statement is a block. Start the loop scope.
//
Expand Down
8 changes: 4 additions & 4 deletions lib/Sema/SemaStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3026,7 +3026,7 @@ static Expr *GetCilkForStride(Sema &S, llvm::SmallPtrSetImpl<VarDecl *> &Decls,

static void CheckCilkForInit(Sema &S, Stmt *First) {
if (!isa<DeclStmt>(First))
S.Diag(First->getLocStart(), diag::err_cilk_for_initializer_expected_decl);
S.Diag(First->getBeginLoc(), diag::err_cilk_for_initializer_expected_decl);
}

/// Rewrite the loop control of simple _Cilk_for loops into a form that LLVM
Expand Down Expand Up @@ -3074,7 +3074,7 @@ StmtResult Sema::HandleSimpleCilkForStmt(SourceLocation CilkForLoc,
// Get the loop variable initialization.
Expr *LoopVarInit = LoopVar->getInit();
if (!LoopVarInit) {
Diag(First->getLocStart(),
Diag(First->getBeginLoc(),
diag::err_cilk_for_control_variable_not_initialized);
return StmtEmpty();
}
Expand Down Expand Up @@ -3314,7 +3314,7 @@ StmtResult Sema::LiftCilkForLoopLimit(SourceLocation CilkForLoc,
// Create a new VarDecl that stores the result of the lifted
// expression.
Scope *S = getCurScope();
SourceLocation EndLoc = ToExtract->getLocStart();
SourceLocation EndLoc = ToExtract->getBeginLoc();
QualType EndType = LoopVar->getType();
QualType EndInitType = ToExtract->getType();
// Hijacking this method for handling range loops to build the
Expand Down Expand Up @@ -3355,7 +3355,7 @@ StmtResult Sema::LiftCilkForLoopLimit(SourceLocation CilkForLoc,
// Borrowed from SemaDeclCXX.cpp and modified.
static void SearchForReturnInStmt(Sema &Self, Stmt *S) {
if (isa<ReturnStmt>(S))
Self.Diag(S->getLocStart(),
Self.Diag(S->getBeginLoc(),
diag::err_cilk_for_cannot_return);

for (Stmt *SubStmt : S->children()) {
Expand Down
5 changes: 3 additions & 2 deletions lib/Sema/SemaStmtAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A,
bool PragmaCilk = PragmaNameLoc->Ident->getName() == "cilk";
if (PragmaCilk &&
St->getStmtClass() != Stmt::CilkForStmtClass) {
S.Diag(St->getLocStart(), diag::err_pragma_cilk_precedes_noncilk)
S.Diag(St->getBeginLoc(), diag::err_pragma_cilk_precedes_noncilk)
<< "#pragma cilk";
return nullptr;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A,
.Default(LoopHintAttr::TapirGrainsize);
if (Option == LoopHintAttr::TapirGrainsize) {
assert(ValueExpr && "Attribute must have a valid value expression.");
if (S.CheckLoopHintExpr(ValueExpr, St->getLocStart()))
if (S.CheckLoopHintExpr(ValueExpr, St->getBeginLoc()))
return nullptr;
State = LoopHintAttr::Numeric;
} else
Expand Down Expand Up @@ -266,6 +266,7 @@ CheckForIncompatibleAttributes(Sema &S,
case LoopHintAttr::PipelineDisabled:
case LoopHintAttr::PipelineInitiationInterval:
Category = Pipeline;
break;
case LoopHintAttr::TapirGrainsize:
Category = TapirGrainsize;
break;
Expand Down
3 changes: 2 additions & 1 deletion tools/libclang/CXCursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ CXCursor cxcursor::MakeCXCursor(const Stmt *S, const Decl *Parent,
case Stmt::CoroutineBodyStmtClass:
case Stmt::CoreturnStmtClass:
K = CXCursor_UnexposedStmt;

break;

case Stmt::CilkSpawnStmtClass:
K = CXCursor_CilkSpawnStmt;
break;
Expand Down

0 comments on commit 262c52f

Please sign in to comment.