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