diff options
Diffstat (limited to 'clang/lib/AST/StmtProfile.cpp')
-rw-r--r-- | clang/lib/AST/StmtProfile.cpp | 152 |
1 files changed, 142 insertions, 10 deletions
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp index 2aa5106e90fae..bf3b43b816f17 100644 --- a/clang/lib/AST/StmtProfile.cpp +++ b/clang/lib/AST/StmtProfile.cpp @@ -19,6 +19,7 @@ #include "clang/AST/ExprObjC.h" #include "clang/AST/ExprOpenMP.h" #include "clang/AST/ODRHash.h" +#include "clang/AST/OpenMPClause.h" #include "clang/AST/StmtVisitor.h" #include "llvm/ADT/FoldingSet.h" using namespace clang; @@ -413,9 +414,8 @@ class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> { public: OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { } -#define OPENMP_CLAUSE(Name, Class) \ - void Visit##Class(const Class *C); -#include "clang/Basic/OpenMPKinds.def" +#define OMP_CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(const Class *C); +#include "llvm/Frontend/OpenMP/OMPKinds.def" void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C); void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C); }; @@ -471,6 +471,11 @@ void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) { Profiler->VisitStmt(C->getNumForLoops()); } +void OMPClauseProfiler::VisitOMPDetachClause(const OMPDetachClause *C) { + if (Expr *Evt = C->getEventHandler()) + Profiler->VisitStmt(Evt); +} + void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { } @@ -517,12 +522,22 @@ void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {} void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {} +void OMPClauseProfiler::VisitOMPAcqRelClause(const OMPAcqRelClause *) {} + +void OMPClauseProfiler::VisitOMPAcquireClause(const OMPAcquireClause *) {} + +void OMPClauseProfiler::VisitOMPReleaseClause(const OMPReleaseClause *) {} + +void OMPClauseProfiler::VisitOMPRelaxedClause(const OMPRelaxedClause *) {} + void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {} void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {} void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {} +void OMPClauseProfiler::VisitOMPDestroyClause(const OMPDestroyClause *) {} + template<typename T> void OMPClauseProfiler::VisitOMPClauseList(T *Node) { for (auto *E : Node->varlists()) { @@ -594,6 +609,20 @@ void OMPClauseProfiler::VisitOMPReductionClause( if (E) Profiler->VisitStmt(E); } + if (C->getModifier() == clang::OMPC_REDUCTION_inscan) { + for (auto *E : C->copy_ops()) { + if (E) + Profiler->VisitStmt(E); + } + for (auto *E : C->copy_array_temps()) { + if (E) + Profiler->VisitStmt(E); + } + for (auto *E : C->copy_array_elems()) { + if (E) + Profiler->VisitStmt(E); + } + } } void OMPClauseProfiler::VisitOMPTaskReductionClause( const OMPTaskReductionClause *C) { @@ -710,6 +739,10 @@ OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) { void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) { VisitOMPClauseList(C); } +void OMPClauseProfiler::VisitOMPDepobjClause(const OMPDepobjClause *C) { + if (const Expr *Depobj = C->getDepobj()) + Profiler->VisitStmt(Depobj); +} void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) { VisitOMPClauseList(C); } @@ -765,6 +798,10 @@ void OMPClauseProfiler::VisitOMPUseDevicePtrClause( const OMPUseDevicePtrClause *C) { VisitOMPClauseList(C); } +void OMPClauseProfiler::VisitOMPUseDeviceAddrClause( + const OMPUseDeviceAddrClause *C) { + VisitOMPClauseList(C); +} void OMPClauseProfiler::VisitOMPIsDevicePtrClause( const OMPIsDevicePtrClause *C) { VisitOMPClauseList(C); @@ -775,6 +812,28 @@ void OMPClauseProfiler::VisitOMPNontemporalClause( for (auto *E : C->private_refs()) Profiler->VisitStmt(E); } +void OMPClauseProfiler::VisitOMPInclusiveClause(const OMPInclusiveClause *C) { + VisitOMPClauseList(C); +} +void OMPClauseProfiler::VisitOMPExclusiveClause(const OMPExclusiveClause *C) { + VisitOMPClauseList(C); +} +void OMPClauseProfiler::VisitOMPUsesAllocatorsClause( + const OMPUsesAllocatorsClause *C) { + for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) { + OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I); + Profiler->VisitStmt(D.Allocator); + if (D.AllocatorTraits) + Profiler->VisitStmt(D.AllocatorTraits); + } +} +void OMPClauseProfiler::VisitOMPAffinityClause(const OMPAffinityClause *C) { + if (const Expr *Modifier = C->getModifier()) + Profiler->VisitStmt(Modifier); + for (const Expr *E : C->varlists()) + Profiler->VisitStmt(E); +} +void OMPClauseProfiler::VisitOMPOrderClause(const OMPOrderClause *C) {} } // namespace void @@ -875,6 +934,14 @@ void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) { VisitOMPExecutableDirective(S); } +void StmtProfiler::VisitOMPDepobjDirective(const OMPDepobjDirective *S) { + VisitOMPExecutableDirective(S); +} + +void StmtProfiler::VisitOMPScanDirective(const OMPScanDirective *S) { + VisitOMPExecutableDirective(S); +} + void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) { VisitOMPExecutableDirective(S); } @@ -1155,10 +1222,24 @@ void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) { VisitExpr(S); } +void StmtProfiler::VisitMatrixSubscriptExpr(const MatrixSubscriptExpr *S) { + VisitExpr(S); +} + void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) { VisitExpr(S); } +void StmtProfiler::VisitOMPArrayShapingExpr(const OMPArrayShapingExpr *S) { + VisitExpr(S); +} + +void StmtProfiler::VisitOMPIteratorExpr(const OMPIteratorExpr *S) { + VisitExpr(S); + for (unsigned I = 0, E = S->numOfIterators(); I < E; ++I) + VisitDecl(S->getIteratorDecl(I)); +} + void StmtProfiler::VisitCallExpr(const CallExpr *S) { VisitExpr(S); } @@ -1335,9 +1416,52 @@ void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { void StmtProfiler::VisitConceptSpecializationExpr( const ConceptSpecializationExpr *S) { VisitExpr(S); - VisitDecl(S->getFoundDecl()); - VisitTemplateArguments(S->getTemplateArgsAsWritten()->getTemplateArgs(), - S->getTemplateArgsAsWritten()->NumTemplateArgs); + VisitDecl(S->getNamedConcept()); + for (const TemplateArgument &Arg : S->getTemplateArguments()) + VisitTemplateArgument(Arg); +} + +void StmtProfiler::VisitRequiresExpr(const RequiresExpr *S) { + VisitExpr(S); + ID.AddInteger(S->getLocalParameters().size()); + for (ParmVarDecl *LocalParam : S->getLocalParameters()) + VisitDecl(LocalParam); + ID.AddInteger(S->getRequirements().size()); + for (concepts::Requirement *Req : S->getRequirements()) { + if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req)) { + ID.AddInteger(concepts::Requirement::RK_Type); + ID.AddBoolean(TypeReq->isSubstitutionFailure()); + if (!TypeReq->isSubstitutionFailure()) + VisitType(TypeReq->getType()->getType()); + } else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req)) { + ID.AddInteger(concepts::Requirement::RK_Compound); + ID.AddBoolean(ExprReq->isExprSubstitutionFailure()); + if (!ExprReq->isExprSubstitutionFailure()) + Visit(ExprReq->getExpr()); + // C++2a [expr.prim.req.compound]p1 Example: + // [...] The compound-requirement in C1 requires that x++ is a valid + // expression. It is equivalent to the simple-requirement x++; [...] + // We therefore do not profile isSimple() here. + ID.AddBoolean(ExprReq->getNoexceptLoc().isValid()); + const concepts::ExprRequirement::ReturnTypeRequirement &RetReq = + ExprReq->getReturnTypeRequirement(); + if (RetReq.isEmpty()) { + ID.AddInteger(0); + } else if (RetReq.isTypeConstraint()) { + ID.AddInteger(1); + Visit(RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()); + } else { + assert(RetReq.isSubstitutionFailure()); + ID.AddInteger(2); + } + } else { + ID.AddInteger(concepts::Requirement::RK_Nested); + auto *NestedReq = cast<concepts::NestedRequirement>(Req); + ID.AddBoolean(NestedReq->isSubstitutionFailure()); + if (!NestedReq->isSubstitutionFailure()) + Visit(NestedReq->getConstraintExpr()); + } + } } static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, @@ -1350,7 +1474,6 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, case OO_Array_New: case OO_Array_Delete: case OO_Arrow: - case OO_Call: case OO_Conditional: case NUM_OVERLOADED_OPERATORS: llvm_unreachable("Invalid operator call kind"); @@ -1492,8 +1615,8 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, return Stmt::BinaryOperatorClass; case OO_Spaceship: - // FIXME: Update this once we support <=> expressions. - llvm_unreachable("<=> expressions not supported yet"); + BinaryOp = BO_Cmp; + return Stmt::BinaryOperatorClass; case OO_AmpAmp: BinaryOp = BO_LAnd; @@ -1524,6 +1647,9 @@ static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, case OO_Subscript: return Stmt::ArraySubscriptExprClass; + case OO_Call: + return Stmt::CallExprClass; + case OO_Coawait: UnaryOp = UO_Coawait; return Stmt::UnaryOperatorClass; @@ -1564,7 +1690,7 @@ void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) { SC == Stmt::CompoundAssignOperatorClass) ID.AddInteger(BinaryOp); else - assert(SC == Stmt::ArraySubscriptExprClass); + assert(SC == Stmt::ArraySubscriptExprClass || SC == Stmt::CallExprClass); return; } @@ -1627,6 +1753,10 @@ void StmtProfiler::VisitBuiltinBitCastExpr(const BuiltinBitCastExpr *S) { VisitType(S->getTypeInfoAsWritten()->getType()); } +void StmtProfiler::VisitCXXAddrspaceCastExpr(const CXXAddrspaceCastExpr *S) { + VisitCXXNamedCastExpr(S); +} + void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) { VisitCallExpr(S); } @@ -1947,6 +2077,8 @@ void StmtProfiler::VisitSourceLocExpr(const SourceLocExpr *E) { VisitExpr(E); } +void StmtProfiler::VisitRecoveryExpr(const RecoveryExpr *E) { VisitExpr(E); } + void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) { VisitExpr(S); } |