@@ -122,6 +122,8 @@ MemDGNodeIntervalBuilder::getBotMemDGNode(const Interval<Instruction> &Intvl,
122122Interval<MemDGNode>
123123MemDGNodeIntervalBuilder::make (const Interval<Instruction> &Instrs,
124124 DependencyGraph &DAG) {
125+ if (Instrs.empty ())
126+ return {};
125127 auto *TopMemN = getTopMemDGNode (Instrs, DAG);
126128 // If we couldn't find a mem node in range TopN - BotN then it's empty.
127129 if (TopMemN == nullptr )
@@ -529,8 +531,8 @@ Interval<Instruction> DependencyGraph::extend(ArrayRef<Instruction *> Instrs) {
529531 }
530532 }
531533 };
532- if (DAGInterval. empty ()) {
533- assert (NewInterval == InstrsInterval && " Expected empty DAGInterval! " );
534+ auto MemDAGInterval = MemDGNodeIntervalBuilder::make (DAGInterval, * this );
535+ if (MemDAGInterval. empty ()) {
534536 FullScan (NewInterval);
535537 }
536538 // 2. The new section is below the old section.
@@ -550,8 +552,7 @@ Interval<Instruction> DependencyGraph::extend(ArrayRef<Instruction *> Instrs) {
550552 // range including both NewInterval and DAGInterval until DstN, for each DstN.
551553 else if (DAGInterval.bottom ()->comesBefore (NewInterval.top ())) {
552554 auto DstRange = MemDGNodeIntervalBuilder::make (NewInterval, *this );
553- auto SrcRangeFull = MemDGNodeIntervalBuilder::make (
554- DAGInterval.getUnionInterval (NewInterval), *this );
555+ auto SrcRangeFull = MemDAGInterval.getUnionInterval (DstRange);
555556 for (MemDGNode &DstN : DstRange) {
556557 auto SrcRange =
557558 Interval<MemDGNode>(SrcRangeFull.top (), DstN.getPrevNode ());
@@ -589,7 +590,7 @@ Interval<Instruction> DependencyGraph::extend(ArrayRef<Instruction *> Instrs) {
589590 // When scanning for deps with destination in DAGInterval we need to
590591 // consider sources from the NewInterval only, because all intra-DAGInterval
591592 // dependencies have already been created.
592- auto DstRangeOld = MemDGNodeIntervalBuilder::make (DAGInterval, * this ) ;
593+ auto DstRangeOld = MemDAGInterval ;
593594 auto SrcRange = MemDGNodeIntervalBuilder::make (NewInterval, *this );
594595 for (MemDGNode &DstN : DstRangeOld)
595596 scanAndAddDeps (DstN, SrcRange);
0 commit comments