@@ -219,10 +219,18 @@ TBRAnalyzer::VarData::VarData(QualType QT, const ASTContext& C,
219219 const auto * recordDecl = recordType->getDecl ();
220220 auto & newArrMap = m_Val.m_ArrData ;
221221 newArrMap = std::unique_ptr<ArrMap>(new ArrMap ());
222- for (const auto * field : recordDecl->fields ()) {
223- const auto varType = field->getType ();
224- (*newArrMap)[getProfileID (field)] = VarData (varType, C);
225- }
222+
223+ // FIXME: For some reason if a variable is of kokkos-type we enter an infinite loop.
224+ bool isInKokkosNS = false ;
225+ if (const auto *ns = llvm::dyn_cast<clang::NamespaceDecl>(recordDecl->getDeclContext ()))
226+ if (ns->getName () == " Kokkos" )
227+ isInKokkosNS = true ;
228+
229+ if (!isInKokkosNS)
230+ for (const auto * field : recordDecl->fields ()) {
231+ const auto varType = field->getType ();
232+ (*newArrMap)[getProfileID (field)] = VarData (varType, C);
233+ }
226234 }
227235}
228236
@@ -280,19 +288,28 @@ void TBRAnalyzer::copyVarToCurBlock(const clang::VarDecl* VD) {
280288}
281289
282290void TBRAnalyzer::addVar (const clang::VarDecl* VD , bool forceNonRefType) {
291+ llvm::errs () << " \n ==============21\n " ;
283292 auto & curBranch = getCurBlockVarsData ();
284293
285294 QualType varType;
286295 if (const auto * arrayParam = dyn_cast<ParmVarDecl>(VD ))
287296 varType = arrayParam->getOriginalType ();
288297 else
289298 varType = VD ->getType ();
299+
290300 // If varType represents auto or auto*, get the type of init.
291301 if (utils::IsAutoOrAutoPtrType (varType))
292302 varType = VD ->getInit ()->getType ();
293303
304+ llvm::errs () << " \n ==============type\n " ;
305+
306+ varType->dump ();
307+
294308 curBranch[VD ] =
295309 VarData (varType, m_ADContext->getASTContext (), forceNonRefType);
310+
311+
312+ llvm::errs () << " \n ==============22\n " ;
296313}
297314
298315void TBRAnalyzer::markLocation (const clang::Expr* E) {
@@ -314,6 +331,7 @@ void TBRAnalyzer::setIsRequired(const clang::Expr* E, bool isReq) {
314331}
315332
316333void TBRAnalyzer::Analyze (const FunctionDecl* FD ) {
334+ llvm::errs () << " \n ===========start\n " ;
317335 m_BlockData.resize (m_ADContext->getCFG ()->size ());
318336 m_BlockPassCounter.resize (m_ADContext->getCFG ()->size (), 0 );
319337
@@ -339,6 +357,7 @@ void TBRAnalyzer::Analyze(const FunctionDecl* FD) {
339357 addVar (paramsRef[i], /* forceNonRefType=*/ true );
340358 // Add the entry block to the queue.
341359 m_CFGQueue.insert (m_CurBlockID);
360+ llvm::errs () << " \n ===========1\n " ;
342361
343362 // Visit CFG blocks in the queue until it's empty.
344363 while (!m_CFGQueue.empty ()) {
@@ -349,6 +368,8 @@ void TBRAnalyzer::Analyze(const FunctionDecl* FD) {
349368 CFGBlock& nextBlock = *getCFGBlockByID (m_CurBlockID);
350369 VisitCFGBlock (nextBlock);
351370 }
371+ llvm::errs () << " \n ===========end\n " ;
372+
352373#ifndef NDEBUG
353374 for (int id = m_CurBlockID; id >= 0 ; --id) {
354375 LLVM_DEBUG (llvm::dbgs () << " \n -----BLOCK" << id << " -----\n\n " );
@@ -584,13 +605,21 @@ bool TBRAnalyzer::VisitDeclRefExpr(DeclRefExpr* DRE) {
584605}
585606
586607bool TBRAnalyzer::VisitDeclStmt (DeclStmt* DS ) {
608+
587609 for (auto * D : DS ->decls ()) {
610+ llvm::errs () << " \n ===========2\n " ;
611+
588612 if (auto * VD = dyn_cast<VarDecl>(D)) {
613+ VD ->dump ();
589614 addVar (VD );
615+ llvm::errs () << " \n ===========3\n " ;
616+
590617 if (clang::Expr* init = VD ->getInit ()) {
618+
591619 setMode (Mode::kMarkingMode );
592620 TraverseStmt (init);
593621 resetMode ();
622+
594623 auto & VDExpr = getCurBlockVarsData ()[VD ];
595624 // if the declared variable is ref type attach its VarData to the
596625 // VarData of the RHS variable.
@@ -601,6 +630,7 @@ bool TBRAnalyzer::VisitDeclStmt(DeclStmt* DS) {
601630 VDExpr.m_Val .m_RefData = ExprsToStore[0 ];
602631 }
603632 }
633+
604634 }
605635 return true ;
606636}
0 commit comments