[flang] Avoid opaque pointer issue with character array substring addressing
When addressing a substring of a character array, codegen emits two GEPs: one for to compute the address of the base element, and a second one to address the first characters from that element. The first GEP still returns the LLVM array type (if the FIR array type could be translated to an array type. Therefore) so zero indexes must be added to the second GEP in this case to cover for the Fortran array dimensions before inserting the susbtring offset index. Surprisingly, the previous code worked ok when MLIR emits none opaque pointers. But with opaque pointers, the two GEPs are folded in an invalid GEP where the substring offset becomes an offset for the outer array dimension. Note that I tried to fix the issue by modifying the first GEP to return the element type, but this still gave bad results (here something might be wrong with opaque pointer in MLIR or LLVM). Differential Revision: https://reviews.llvm.org/D129079
Loading
Please sign in to comment