rjmccall added a comment.

In D100591#2692978 <https://reviews.llvm.org/D100591#2692978>, @asavonic wrote:

> In D100591#2692599 <https://reviews.llvm.org/D100591#2692599>, @rjmccall 
> wrote:
>
>> I think the right thing to do here is to recognize generally that we're 
>> emitting a mandatory tail call, and so suppress *all* the normal 
>> transformations on the return value.
>
> I assume it can be tricky to detect such call. The final decision (tail call 
> vs normal call) is made before instruction selection, after all LLVM IR 
> optimization passes. So we can miss tail calls that are not obvious on 
> non-optimized code, or get false-positive results for calls that a backend 
> decides to emit as normal calls.

Well, I mean in the frontend.  I certainly wouldn't expect the backend to 
recognize the pattern I described and somehow turn it into a tail call!

> In any case, this patch can be useful not only for tail calls: `trunc + zext` 
> sequence generated to round a return value can be problematic for other cases 
> as well.

Sure, I can imagine that it's hard to eliminate the extra zext in the backend.  
Maybe we should have an undef_extend?

You should get backend sign-off before making Swift generate non-target-legal 
return types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100591

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to