A crash could happen due to an illegal copy removal in cases such as
%from = scf.for ... copy(%from, %to) dealloc %to
where copy removal removes the entire scf.for operation with its region, Copy, Dealloc operations. Therefore, all getDefiningOp to find the source of Copy operation are replaced with getAllocationOpInBlock. To test this crash, loop_alloc test is added. check_with_affine_dialect test is also added to check the crash issue in TensorFlow::lhlo-copy-removal (issue: https://github.com/tensorflow/mlir-hlo/issues/1). TensorFlow::lhlo-copy-removal pass is going to be replaced with mlir::copy-removal pass.