If possible the shape is gotten from the definition of the hlfir.expr
argument. Otherwise one is synthesized from the extent information in
the hlfir::ExprType.
The simple cases should already have been resolved during lowering. This
is mostly intended for cases where shape information is added in between
lowering and the end of bufferization (for example transformational
intrinsics).
Depends on: D146832
I think you can get away with a much simpler approach that will cover all cases: the ShapeOfOp operand was translated to an hlfir::Entity that is a variable: you can "simply" call genShape on it (it knows of to retrieve the fir.shape from variables, or to emit fir.box_dim as needed):