llvm.org GIT mirror llvm / e906921
Implement requiredTransitive The PassManager did not implement the transitivity of requiredTransitive. This was unnoticed since 2006. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123942 91177308-0d34-0410-b5e6-96231b3b80d8 Tobias Grosser 9 years ago
2 changed file(s) with 56 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
499499 void
500500 PMTopLevelManager::setLastUser(const SmallVectorImpl &AnalysisPasses,
501501 Pass *P) {
502 unsigned PDepth = 0;
503 if (P->getResolver())
504 PDepth = P->getResolver()->getPMDataManager().getDepth();
505
502506 for (SmallVectorImpl::const_iterator I = AnalysisPasses.begin(),
503507 E = AnalysisPasses.end(); I != E; ++I) {
504508 Pass *AP = *I;
506510
507511 if (P == AP)
508512 continue;
513
514 // Update the last users of passes that are required transitive by AP.
515 AnalysisUsage *AnUsage = findAnalysisUsage(AP);
516 const AnalysisUsage::VectorType &IDs = AnUsage->getRequiredTransitiveSet();
517 SmallVector LastUses;
518 SmallVector LastPMUses;
519 for (AnalysisUsage::VectorType::const_iterator I = IDs.begin(),
520 E = IDs.end(); I != E; ++I) {
521 Pass *AnalysisPass = findAnalysisPass(*I);
522 assert(AnalysisPass && "Expected analysis pass to exist.");
523 AnalysisResolver *AR = AnalysisPass->getResolver();
524 assert(AR && "Expected analysis resolver to exist.");
525 unsigned APDepth = AR->getPMDataManager().getDepth();
526
527 if (PDepth == APDepth)
528 LastUses.push_back(AnalysisPass);
529 else if (PDepth > APDepth)
530 LastPMUses.push_back(AnalysisPass);
531 }
532
533 setLastUser(LastUses, P);
534
535 // If this pass has a corresponding pass manager, push higher level
536 // analysis to this pass manager.
537 if (P->getResolver())
538 setLastUser(LastPMUses, P->getResolver()->getPMDataManager().getAsPass());
539
509540
510541 // If AP is the last user of other passes then make P last user of
511542 // such passes.
513544 LUE = LastUser.end(); LUI != LUE; ++LUI) {
514545 if (LUI->second == AP)
515546 // DenseMap iterator is not invalidated here because
516 // this is just updating exisitng entry.
547 // this is just updating existing entries.
517548 LastUser[LUI->first] = P;
518549 }
519550 }
0 ; RUN: opt -indvars -scalar-evolution -analyze %s
1 ; This test checks if the SCEV analysis is printed out at all.
2 ; It failed once as the RequiredTransitive option was not implemented
3 ; correctly.
4
5 define i32 @main() nounwind {
6 entry:
7 br label %for.cond
8
9 for.cond: ; preds = %for.inc, %entry
10 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ] ; [#uses=3]
11 %exitcond = icmp ne i64 %indvar1, 1024 ; [#uses=1]
12 br i1 %exitcond, label %for.body, label %for.end
13
14 for.body: ; preds = %for.cond
15 br label %for.inc
16
17 for.inc: ; preds = %for.body
18 %indvar.next2 = add i64 %indvar1, 1 ; [#uses=1]
19 br label %for.cond
20
21 for.end: ; preds = %for.cond
22 ret i32 0
23 }