@@ -1830,14 +1830,14 @@ static void getMultiLevelStrides(const MemRefRegion ®ion,
1830
1830
}
1831
1831
}
1832
1832
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.
1841
1841
//
1842
1842
// / The copy-in nest is generated as follows as an example for a 2-d region:
1843
1843
// / for x = ...
@@ -1858,6 +1858,8 @@ generatePointWiseCopy(Location loc, Value memref, Value fastMemRef,
1858
1858
}));
1859
1859
1860
1860
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" );
1861
1863
assert (lbMaps.size () == rank && " wrong number of lb maps" );
1862
1864
assert (ubMaps.size () == rank && " wrong number of ub maps" );
1863
1865
@@ -1921,19 +1923,20 @@ emitRemarkForBlock(Block &block) {
1921
1923
return block.getParentOp ()->emitRemark ();
1922
1924
}
1923
1925
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.
1937
1940
static LogicalResult generateCopy (
1938
1941
const MemRefRegion ®ion, Block *block, Block::iterator begin,
1939
1942
Block::iterator end, Block *copyPlacementBlock,
@@ -1984,6 +1987,11 @@ static LogicalResult generateCopy(
1984
1987
SmallVector<Value, 4 > bufIndices;
1985
1988
1986
1989
unsigned rank = memRefType.getRank ();
1990
+ if (rank == 0 ) {
1991
+ LLVM_DEBUG (llvm::dbgs () << " Non-zero ranked memrefs supported\n " );
1992
+ return failure ();
1993
+ }
1994
+
1987
1995
SmallVector<int64_t , 4 > fastBufferShape;
1988
1996
1989
1997
// Compute the extents of the buffer.
0 commit comments