This is an archive of the discontinued LLVM Phabricator instance.

Preserve argument locations when cloning a region.
ClosedPublic

Authored by dominikgrewe on Jan 15 2022, 11:26 AM.

Details

Summary

Preserve argument locations when cloning a region.

Diff Detail

Event Timeline

dominikgrewe created this revision.Jan 15 2022, 11:26 AM
dominikgrewe requested review of this revision.Jan 15 2022, 11:26 AM

Good catch! Could you add a simple test for this?

mehdi_amini added a comment.EditedJan 15 2022, 1:46 PM

Thanks!

Can you add a test?
This should do it:

// Test block arguments location propagation.
// Use two call-sites to force cloning.
func @func_with_block_args_location(%arg0 : i32) {
  br ^bb1(%arg0 : i32)
^bb1(%x : i32 loc("foo")):
  "test.foo" (%x) : (i32) -> () loc("bar")
  return
}

// INLINE-LOC-LABEL: func @func_with_block_args_location_callee1
// INLINE-LOC: br
// INLINE-LOC: ^bb{{[0-9]+}}(%{{.*}}: i32 loc("foo")
func @func_with_block_args_location_callee1(%arg0 : i32) {
  call @func_with_block_args_location(%arg0) : (i32) -> ()
  return
}

// CHECK-LABEL: func @func_with_block_args_location_callee2
func @func_with_block_args_location_callee2(%arg0 : i32) {
  call @func_with_block_args_location(%arg0) : (i32) -> ()
  return
}

in mlir/test/Transforms/inlining.mlir

Thanks for the neat test! I've added it to the CL.

mehdi_amini accepted this revision.Jan 16 2022, 1:14 PM

LG, I assume I need to land this for you!

This revision is now accepted and ready to land.Jan 16 2022, 1:14 PM
This revision was automatically updated to reflect the committed changes.