[flang] Turn on use-desc-for-alloc by default
Currently, local allocatables and contiguous/scalar pointers (and some other conditions) are lowered to a set of independent variables in FIR (one for the address, one for each bound and one for character length). The intention was to help LLVM get rids of descriptors. But LLVM knows how to do that anyway in those cases: ``` subroutine foo(x) real, target :: x(100) real, pointer, contiguous :: p(:) p => x call bar(p(50)) end subroutine ``` The output fir the option on or off is the same after llvm opt -O1, there is no descriptor anymore, the indirection is removed. ``` define void @foo_(ptr %0) local_unnamed_addr { %2 = getelementptr [100 x float], ptr %0, i64 0, i64 49 tail call void @bar_(ptr %2) ret void } ``` So the benefit of not using a descriptor in lowering is questionable, and although it is abstracted as much as possible in the so called MutableBoxValue class that represent allocatable/pointer in lowering it is still causing bugs from time to time, and will also be a bit problematic when emitting debug info for the pointer/allocatable. In HLFIR lowering, the simplification to always use a descriptor in lowering was already made. This patch allows decorrelating the impact from this change from the bigger impact HLFIR will have so that it is easier to get feedback if this causes performance issues. The lowering tests relying on the previous behavior are only updated to set back this option to true. The reason is that I think we should preserve coverage of the code dealing with the "non descriptor" approach in lowering until we actually get rid of it. The other reason is that the test will have to be or are already covered by equivalent HLFIR tests, which use descriptors. Differential Revision: https://reviews.llvm.org/D148910
Loading
Please sign in to comment