llvm-project
263802c5 - [flang] Enhance show_descriptor intrinsic to avoid extra descriptor copies (#173461)

Commit
11 days ago
[flang] Enhance show_descriptor intrinsic to avoid extra descriptor copies (#173461) Originally, the argument to show_descriptor() intrinsic was declared with the passing mechanism of "asBox". This resulted in `fir.load` instruction to be emitted to pass descriptor "asBox", which resulted in extra llvm.memcpy in LLVM IR. The current change eliminates this, so that show_descriptor() prints information about the original descriptor, not about its copy. The current change modifies the passing mechanism of the argument to show_intrinsic() to "asInquired". The lowering of show_descriptor() now passes the reference to a descriptor directly to the runtime routine. If descriptor is passed as a value in SSA register, then it's spilled on the stack and its address is passed to the runtime routine. If a non-descriptor value is passed to show_descriptor(), then this value is spilled to the stack, wrapped into a descriptor that is also spilled to the stack, and the resulting descriptor pointer is passed to show_descriptor(). show_descriptor() LIT test was modified to correspond to the new implementation and additional test cases were added to it.
Parents
Loading