[PATCH] D114159: [flang][codegen] Add a conversion for `fir.coordinate_of` - part 1

Diana Picus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 25 00:08:09 PST 2021


rovka added inline comments.


================
Comment at: flang/test/Fir/convert-to-llvm.fir:1668
+// CHECK:    %[[DERIVED_CAST_2:.*]] = llvm.bitcast %[[CAST_1]] : !llvm.ptr<i8> to !llvm.ptr<struct<"derived_2", (i32, i32)>>
+// CHECK:    %[[SUBOBJECT_2_ADDR:.*]] = llvm.getelementptr %[[DERIVED_CAST_2]][%[[C0_3]], %[[COORDINATE_2]]] : (!llvm.ptr<struct<"derived_2", (i32, i32)>>, i64, i32) -> !llvm.ptr<i32>
+// FIXME: These casts seem redundant
----------------
This is very fishy, are you sure this is supposed to work? I'm following up to SUBOBJECT_1_ADDR, IIUC that's the address of field_1. It seems very bizarre to then take this ptr<i32> and cast it to <ptr<struct<"derived_2">> and index into it again. I feel like this should be an error, i.e. the thing that the second index is indexing into should be another struct or array or something, not an i32. Am I misunderstanding the coordinate_of semantics?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D114159/new/

https://reviews.llvm.org/D114159



More information about the llvm-commits mailing list