[all-commits] [llvm/llvm-project] 084072: [Flang] Temporary fix for conversion materialization

kiranchandramohan via All-commits all-commits at lists.llvm.org
Thu Jun 9 03:13:17 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 08407255b2d29968f050e5c2ac81fe85f66ea34f
      https://github.com/llvm/llvm-project/commit/08407255b2d29968f050e5c2ac81fe85f66ea34f
  Author: Kiran Chandramohan <kiran.chandramohan at arm.com>
  Date:   2022-06-09 (Thu, 09 Jun 2022)

  Changed paths:
    M flang/lib/Optimizer/CodeGen/TypeConverter.h
    M flang/test/Fir/convert-to-llvm.fir

  Log Message:
  -----------
  [Flang] Temporary fix for conversion materialization

Simply add a source and target materialization handler that do nothing
and that override the default handlers that would add illegal
LLVM::DialectCastOp otherwise.

This is the simplest workaround, but not an actual fix, something may be
inconsistent after D82831 (most likely fir lowering to llvm happens in a
way that mlir infrastructure is not expecting in D82831).

Here is a minimal reproducer of what the issue was:
```
func @foop(%a : !fir.real<4>) -> ()
func @bar(%a : !fir.real<2>) {
  %1 = fir.convert %a : (!fir.real<2>) -> !fir.real<4>
  call @foop(%1) : (!fir.real<4>) -> ()
  return
}
```
tco -o - output was:
```
error: 'llvm.mlir.cast' op type must be non-index integer types, float types, or vector of mentioned types.
llvm.func @foop(!llvm.float)
llvm.func @bar(%arg0: !llvm.half) {
  %0 = llvm.fpext %arg0 : !llvm.half to !llvm.float
  %1 = llvm.mlir.cast %0 : !llvm.float to !fir.real<4>
  llvm.call @foop(%1) : (!fir.real<4>) -> ()
  llvm.return
}
```
This patch disable the introduction of the llvm.mlir.cast and preserve the previous behavior.

Also fixes https://github.com/llvm/llvm-project/issues/55210.

Note: This is part of upstreaming from the fir-dev branch of
https://github.com/flang-compiler/f18-llvm-project.

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D127212

Co-authored-by: Jean Perier <jperier at nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>




More information about the All-commits mailing list