@@ -1830,14 +1830,14 @@ static void getMultiLevelStrides(const MemRefRegion ®ion,
18301830 }
18311831}
18321832
1833- // / Generates a point-wise copy from/to `memref' to/from `fastMemRef' and
1834- // / returns the outermost AffineForOp of the copy loop nest. `lbMaps` and
1835- // / `ubMaps` along with `lbOperands` and `ubOperands` hold the lower and upper
1836- // / bound information for the copy loop nest. `fastBufOffsets` contain the
1837- // / expressions to be subtracted out from the respective copy loop iterators in
1838- // / order to index the fast buffer. If `copyOut' is true, generates a copy-out;
1839- // / otherwise a copy-in. Builder `b` should be set to the point the copy nest is
1840- // / inserted.
1833+ // / Generates a point-wise copy from/to a non-zero ranked `memref' to/from
1834+ // / `fastMemRef' and returns the outermost AffineForOp of the copy loop nest.
1835+ // / `lbMaps` and ` ubMaps` along with `lbOperands` and `ubOperands` hold the
1836+ // / lower and upper bound information for the copy loop nest. `fastBufOffsets`
1837+ // / contain the expressions to be subtracted out from the respective copy loop
1838+ // / iterators in order to index the fast buffer. If `copyOut' is true, generates
1839+ // / a copy-out; otherwise a copy-in. Builder `b` should be set to the point the
1840+ // / copy nest is inserted.
18411841//
18421842// / The copy-in nest is generated as follows as an example for a 2-d region:
18431843// / for x = ...
@@ -1858,6 +1858,8 @@ generatePointWiseCopy(Location loc, Value memref, Value fastMemRef,
18581858 }));
18591859
18601860 unsigned rank = cast<MemRefType>(memref.getType ()).getRank ();
1861+ // A copy nest can't be generated for 0-ranked memrefs.
1862+ assert (rank != 0 && " non-zero rank memref expected" );
18611863 assert (lbMaps.size () == rank && " wrong number of lb maps" );
18621864 assert (ubMaps.size () == rank && " wrong number of ub maps" );
18631865
@@ -1921,19 +1923,20 @@ emitRemarkForBlock(Block &block) {
19211923 return block.getParentOp ()->emitRemark ();
19221924}
19231925
1924- // / Creates a buffer in the faster memory space for the specified memref region;
1925- // / generates a copy from the lower memory space to this one, and replaces all
1926- // / loads/stores in the block range [`begin', `end') of `block' to load/store
1927- // / from that buffer. Returns failure if copies could not be generated due to
1928- // / yet unimplemented cases. `copyInPlacementStart` and `copyOutPlacementStart`
1929- // / in copyPlacementBlock specify the insertion points where the incoming copies
1930- // / and outgoing copies, respectively, should be inserted (the insertion happens
1931- // / right before the insertion point). Since `begin` can itself be invalidated
1932- // / due to the memref rewriting done from this method, the output argument
1933- // / `nBegin` is set to its replacement (set to `begin` if no invalidation
1934- // / happens). Since outgoing copies could have been inserted at `end`, the
1935- // / output argument `nEnd` is set to the new end. `sizeInBytes` is set to the
1936- // / size of the fast buffer allocated.
1926+ // / Creates a buffer in the faster memory space for the specified memref region
1927+ // / (memref has to be non-zero ranked); generates a copy from the lower memory
1928+ // / space to this one, and replaces all loads/stores in the block range
1929+ // / [`begin', `end') of `block' to load/store from that buffer. Returns failure
1930+ // / if copies could not be generated due to yet unimplemented cases.
1931+ // / `copyInPlacementStart` and `copyOutPlacementStart` in copyPlacementBlock
1932+ // / specify the insertion points where the incoming copies and outgoing copies,
1933+ // / respectively, should be inserted (the insertion happens right before the
1934+ // / insertion point). Since `begin` can itself be invalidated due to the memref
1935+ // / rewriting done from this method, the output argument `nBegin` is set to its
1936+ // / replacement (set to `begin` if no invalidation happens). Since outgoing
1937+ // / copies could have been inserted at `end`, the output argument `nEnd` is set
1938+ // / to the new end. `sizeInBytes` is set to the size of the fast buffer
1939+ // / allocated.
19371940static LogicalResult generateCopy (
19381941 const MemRefRegion ®ion, Block *block, Block::iterator begin,
19391942 Block::iterator end, Block *copyPlacementBlock,
@@ -1984,6 +1987,11 @@ static LogicalResult generateCopy(
19841987 SmallVector<Value, 4 > bufIndices;
19851988
19861989 unsigned rank = memRefType.getRank ();
1990+ if (rank == 0 ) {
1991+ LLVM_DEBUG (llvm::dbgs () << " Non-zero ranked memrefs supported\n " );
1992+ return failure ();
1993+ }
1994+
19871995 SmallVector<int64_t , 4 > fastBufferShape;
19881996
19891997 // Compute the extents of the buffer.
0 commit comments