Description
The new version of llvm added verification on affine.apply to check that the symbol parameter can not be a loop index. For example (for illustration only):
#map = affine_map<(d0)[s0] -> (d0 + s0)>
affine.for %arg0 = 0, 10 {
affine.for %arg1 = 0, 20 {
%1 = affine.apply #map(%arg1)[%arg0]
}
}
The result of %1 will be arg0+arg1. It is correct when lowered to scf, though it is not correct for affine specification, because the arg0 is not a symbol but a loop induction variable. The new version of llvm added verifier to detect such error.
Such error may occur when SymbolIndexExpr is used on loop induction variable. It could be a simple mistake, or a little bit complicated one when the inner loop nest is created with another create.Krnl.Iterate nested inside the outer loop nest. In each create.krnl.iterate, its own loop induction variables are in parameters. But the outer loop induction variables are not explicitly specified. The code-generation has to be careful in choosing DimIndexExpr or SymIndexExpr for the Values outside the current loop nest.
If the creation of inner loop nest is really called by different call site and it is not clear whether some of the incoming Value is not loop induction variable or not, we can wrap the loop nests with KrnlRegionOp to limit the range of affine loops. I tried this approach on lowering ConvOp. It works. But this approach may disable some optimizations for affine loop nests.