[flang-commits] [flang] [flang] Remove materialization workaround in type converter (PR #98743)
Matthias Springer via flang-commits
flang-commits at lists.llvm.org
Sat Jul 13 06:42:48 PDT 2024
matthias-springer wrote:
Note: Type conversions do not know the context in which they are converting a type. But each pattern can be initialized with a different type converter.
That's the basic idea behind this PR. I tried the same for the workaround in `XReboxOpConversion`, but without success:
```c++
// Inside a fir.global, the input box was produced as an llvm.struct<>
// because objects cannot be handled in memory inside a fir.global body that
// must be constant foldable. However, the type translation are not
// contextual, so the fir.box<T> type of the operation that produced the
// fir.box was translated to an llvm.ptr<llvm.struct<>> and the MLIR pass
// manager inserted a builtin.unrealized_conversion_cast that was inserted
// and needs to be removed here.
if (isInGlobalOp(rewriter))
if (auto unrealizedCast =
loweredBox.getDefiningOp<mlir::UnrealizedConversionCastOp>())
loweredBox = unrealizedCast.getInputs()[0];
```
Maybe the type conversion in that pattern is truly context-specific.
https://github.com/llvm/llvm-project/pull/98743
More information about the flang-commits
mailing list