diff options
Diffstat (limited to 'lib/AST/StmtProfile.cpp')
-rw-r--r-- | lib/AST/StmtProfile.cpp | 119 |
1 files changed, 107 insertions, 12 deletions
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index da996920c420..175a43abbf61 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -18,6 +18,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" +#include "clang/AST/ExprOpenMP.h" #include "clang/AST/StmtVisitor.h" #include "llvm/ADT/FoldingSet.h" using namespace clang; @@ -261,6 +262,7 @@ class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> { /// \brief Process clauses with list of variables. template <typename T> void VisitOMPClauseList(T *Node); + public: OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { } #define OPENMP_CLAUSE(Name, Class) \ @@ -288,6 +290,11 @@ void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) { Profiler->VisitStmt(C->getSafelen()); } +void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) { + if (C->getSimdlen()) + Profiler->VisitStmt(C->getSimdlen()); +} + void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) { if (C->getNumForLoops()) Profiler->VisitStmt(C->getNumForLoops()); @@ -306,7 +313,10 @@ void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) { } } -void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *) {} +void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) { + if (auto *Num = C->getNumForLoops()) + Profiler->VisitStmt(Num); +} void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {} @@ -324,6 +334,12 @@ void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {} void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {} +void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {} + +void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {} + +void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {} + template<typename T> void OMPClauseProfiler::VisitOMPClauseList(T *Node) { for (auto *E : Node->varlists()) { @@ -369,6 +385,9 @@ void OMPClauseProfiler::VisitOMPReductionClause( C->getQualifierLoc().getNestedNameSpecifier()); Profiler->VisitName(C->getNameInfo().getName()); VisitOMPClauseList(C); + for (auto *E : C->privates()) { + Profiler->VisitStmt(E); + } for (auto *E : C->lhs_exprs()) { Profiler->VisitStmt(E); } @@ -381,6 +400,9 @@ void OMPClauseProfiler::VisitOMPReductionClause( } void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) { VisitOMPClauseList(C); + for (auto *E : C->privates()) { + Profiler->VisitStmt(E); + } for (auto *E : C->inits()) { Profiler->VisitStmt(E); } @@ -428,6 +450,31 @@ void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) { void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) { VisitOMPClauseList(C); } +void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) { + Profiler->VisitStmt(C->getDevice()); +} +void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) { + VisitOMPClauseList(C); +} +void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) { + Profiler->VisitStmt(C->getNumTeams()); +} +void OMPClauseProfiler::VisitOMPThreadLimitClause( + const OMPThreadLimitClause *C) { + Profiler->VisitStmt(C->getThreadLimit()); +} +void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) { + Profiler->VisitStmt(C->getPriority()); +} +void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) { + Profiler->VisitStmt(C->getGrainsize()); +} +void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) { + Profiler->VisitStmt(C->getNumTasks()); +} +void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) { + Profiler->VisitStmt(C->getHint()); +} } void @@ -533,6 +580,10 @@ void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) { VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) { + VisitOMPExecutableDirective(S); +} + void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) { VisitOMPExecutableDirective(S); } @@ -546,6 +597,20 @@ void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) { VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) { + VisitOMPLoopDirective(S); +} + +void StmtProfiler::VisitOMPTaskLoopSimdDirective( + const OMPTaskLoopSimdDirective *S) { + VisitOMPLoopDirective(S); +} + +void StmtProfiler::VisitOMPDistributeDirective( + const OMPDistributeDirective *S) { + VisitOMPLoopDirective(S); +} + void StmtProfiler::VisitExpr(const Expr *S) { VisitStmt(S); } @@ -610,22 +675,22 @@ void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) { VisitType(S->getTypeSourceInfo()->getType()); unsigned n = S->getNumComponents(); for (unsigned i = 0; i < n; ++i) { - const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i); + const OffsetOfNode &ON = S->getComponent(i); ID.AddInteger(ON.getKind()); switch (ON.getKind()) { - case OffsetOfExpr::OffsetOfNode::Array: + case OffsetOfNode::Array: // Expressions handled below. break; - case OffsetOfExpr::OffsetOfNode::Field: + case OffsetOfNode::Field: VisitDecl(ON.getField()); break; - case OffsetOfExpr::OffsetOfNode::Identifier: + case OffsetOfNode::Identifier: ID.AddPointer(ON.getFieldName()); break; - - case OffsetOfExpr::OffsetOfNode::Base: + + case OffsetOfNode::Base: // These nodes are implicit, and therefore don't need profiling. break; } @@ -646,6 +711,10 @@ void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) { VisitExpr(S); } +void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) { + VisitExpr(S); +} + void StmtProfiler::VisitCallExpr(const CallExpr *S) { VisitExpr(S); } @@ -824,6 +893,7 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, case OO_Arrow: case OO_Call: case OO_Conditional: + case OO_Coawait: case NUM_OVERLOADED_OPERATORS: llvm_unreachable("Invalid operator call kind"); @@ -985,7 +1055,6 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, BinaryOp = BO_Comma; return Stmt::BinaryOperatorClass; - case OO_ArrowStar: BinaryOp = BO_PtrMemI; return Stmt::BinaryOperatorClass; @@ -997,7 +1066,6 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, llvm_unreachable("Invalid overloaded operator expression"); } - void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) { if (S->isTypeDependent()) { // Type-dependent operator calls are profiled like their underlying @@ -1092,6 +1160,11 @@ void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) { VisitDecl(S->getPropertyDecl()); } +void StmtProfiler::VisitMSPropertySubscriptExpr( + const MSPropertySubscriptExpr *S) { + VisitExpr(S); +} + void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) { VisitExpr(S); ID.AddBoolean(S->isImplicit()); @@ -1169,7 +1242,6 @@ void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) { VisitDecl(S->getOperatorDelete()); } - void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) { VisitExpr(S); VisitType(S->getAllocatedType()); @@ -1203,8 +1275,7 @@ void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) { VisitName(S->getName()); ID.AddBoolean(S->hasExplicitTemplateArgs()); if (S->hasExplicitTemplateArgs()) - VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(), - S->getExplicitTemplateArgs().NumTemplateArgs); + VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); } void @@ -1290,6 +1361,14 @@ void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { VisitExpr(S); VisitDecl(S->getPack()); + if (S->isPartiallySubstituted()) { + auto Args = S->getPartialArguments(); + ID.AddInteger(Args.size()); + for (const auto &TA : Args) + VisitTemplateArgument(TA); + } else { + ID.AddInteger(0); + } } void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr( @@ -1323,6 +1402,22 @@ void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) { ID.AddInteger(S->getOperator()); } +void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) { + VisitStmt(S); +} + +void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) { + VisitStmt(S); +} + +void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) { + VisitExpr(S); +} + +void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) { + VisitExpr(S); +} + void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) { VisitExpr(E); } |