This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Test CallOp STD->LLVM conversion.
ClosedPublic

Authored by pifon2a on Aug 13 2020, 9:54 AM.

Details

Summary

This exercises the corner case that was fixed in
https://reviews.llvm.org/rG8979a9cdf226066196f1710903d13492e6929563.

The bug can be reproduced when there is a @callee with a custom type argument and @caller has a producer of this argument passed to the @callee.

Example:

func @callee(!test.test_type) -> i32
func @caller() -> i32 {
  %arg = "test.type_producer"() : () -> !test.test_type
  %out = call @callee(%arg) : (!test.test_type) -> i32
  return %out : i32
}

Even though there is a type conversion for !test.test_type, the output IR (before the fix) contained a DialectCastOp:

module {
  llvm.func @callee(!llvm.ptr<i8>) -> !llvm.i32
  llvm.func @caller() -> !llvm.i32 {
    %0 = llvm.mlir.null : !llvm.ptr<i8>
    %1 = llvm.mlir.cast %0 : !llvm.ptr<i8> to !test.test_type
    %2 = llvm.call @callee(%1) : (!test.test_type) -> !llvm.i32
    llvm.return %2 : !llvm.i32
  }
}

instead of

module {
  llvm.func @callee(!llvm.ptr<i8>) -> !llvm.i32
  llvm.func @caller() -> !llvm.i32 {
    %0 = llvm.mlir.null : !llvm.ptr<i8>
    %1 = llvm.call @callee(%0) : (!llvm.ptr<i8>) -> !llvm.i32
    llvm.return %1 : !llvm.i32
  }
}

Diff Detail

Event Timeline

pifon2a created this revision.Aug 13 2020, 9:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2020, 9:54 AM
pifon2a requested review of this revision.Aug 13 2020, 9:54 AM
pifon2a edited the summary of this revision. (Show Details)Aug 13 2020, 9:55 AM
pifon2a edited the summary of this revision. (Show Details)
pifon2a edited the summary of this revision. (Show Details)
pifon2a edited the summary of this revision. (Show Details)
pifon2a edited the summary of this revision. (Show Details)Aug 13 2020, 9:57 AM
mehdi_amini accepted this revision.Aug 13 2020, 10:08 AM

Nice, thanks for the effort!

This revision is now accepted and ready to land.Aug 13 2020, 10:08 AM
This revision was landed with ongoing or failed builds.Aug 13 2020, 10:14 AM
This revision was automatically updated to reflect the committed changes.