[PATCH] D90689: [CodeExtractor] Replace uses of extracted bitcasts in out-of-region lifetime markers

Giorgis Georgakoudis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 10:48:06 PST 2020


ggeorgakoudis added a comment.

In D90689#2371522 <https://reviews.llvm.org/D90689#2371522>, @vsk wrote:

> In the example, what pass/component is responsible for creating `%1 = bitcast i32* %0 to i8*`?
>
> If it's CodeExtractor itself, it would be nice to solve the problem earlier by getting rid of bitcasts which only exist to wire up lifetime markers. I tried doing that in 26ee8aff2 <https://reviews.llvm.org/rG26ee8aff2b85ee28a2b2d0b1860d878b512fbdef>, but had to revert (099bffe7f <https://reviews.llvm.org/rG099bffe7f7df41d66195ce33e91888a4a16c6b4a>) because llvm doesn't support specializing its lifetime intrinsics on opaque pointer types. That's a bug, I think: if we fix that, perhaps this whole problem goes away.
>
> OTOH, if this `%1 = bitcast i32* %0 to i8*` value comes from a frontend or another pass, I think the approach taken in this patch is reasonable. Please add a test (perhaps in the CodeExtractor unittest).

Many thanks for the quick reply @vsk! The `bitcast` is generated by the frontend, not by CodeExtractor. Our use case is outlining a merged parallel region that includes sequential code which include bitcasts like that. I am going to add a unit test.

I have two questions about the CodeExtractor.

1. I have second thoughts on changing the IR within the `findAllocas`. Should I create a helper data structure, e.g., `ReplaceBitcastUses` as in for `SinkCands`, and do the transformation inside the `extractCodeRegion` caller?
2. Is the assumption that `findAllocas` is always called before `findInputsOutputs`? If `findAllocas` is not called, my concern is that `findInputsOutputs` will report an output on the use of the `bitcast` although this output would be removed if `findAllocas` has been called. This problem does not appear for `extractCodeRegion` because it always calls `findAllocas` but there may be other modules using the CodeExtractor interface. I could change `findInputsOutputs` not to include `bitcast` uses to lifetime markers as outputs regardless of whether `findAllocas` has been called. Is that reasonable or does that create other problems?

Thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90689



More information about the llvm-commits mailing list