Use recently added hlfir.associate/hlfir.end_associate to deal
with the cases where the actual argument is an expression.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Aside from nits and questions, all builds and tests correctly and looks good.
flang/include/flang/Optimizer/Builder/HLFIRTools.h | ||
---|---|---|
185 | There's an extra space character after Return. | |
flang/lib/Lower/Bridge.cpp | ||
1112–1116 | I don't understand this code. This else corresponds to the if that tests to see if we're generating HLFIR. But since the code is calling createSubroutineCall, I'm concerned that we're not handling the case for a function call. Does createSubroutineCall handle both functions and subroutines? | |
flang/lib/Lower/ConvertCall.cpp | ||
406–415 | I wonder if this is the right test. We need to handle the case where we have an elemental function call that doesn't have any array arguments but which returns an array. | |
417–425 | I'm curious. What's different about lowering of statement functions? | |
flang/lib/Optimizer/Builder/HLFIRTools.cpp | ||
173 | There's an extra space character after numerical. | |
177 | "mismatch" should be "mismatches". |
Thanks for the review @PeteSteinfeld
flang/include/flang/Optimizer/Builder/HLFIRTools.h | ||
---|---|---|
185 | Thanks ! | |
flang/lib/Lower/Bridge.cpp | ||
1112–1116 | There cannot be function calls here, this code (in genFIR(const Fortran::parser::CallStmt &stmt)) deals with fortran call statement lowering. Only subroutines can be called in a call statement. Function calls lowering happen when lowering an Expr<T> that is a FunctionRef<T>. The else case basically keeps the current lowering code during the transition. | |
flang/lib/Lower/ConvertCall.cpp | ||
406–415 |
My understanding is that this is not possible ("C15101: The result of an elemental function shall be scalar" and "15.8.2 point 1: If there are no actual arguments or the actual arguments are all scalar, the result is scalar."), do you have a specific use case in mind ? Note that a elemental function references can be assigned to an array, but in that case (when all arguments are scalars) the function returns a scalar that is assigned to all the left hand side elements. So there is no elemental aspect to deal with in such calls, the elemental aspects happen in the assignment. | |
417–425 | They are (and still will) be handled very differently: the statement function expression is inlined directly in lowering: we do not generate a function body and symbol for them. That is because it would be more hassle to outline statement functions than it is to inline them on the spot: statement functions do not have a body in the parse tree that would allow using the bridge code to generate a FIR function for them, it would need ad-hoc handling, whereas we already know how to lower an expression given what the referred symbols mapped to. |
There's an extra space character after Return.