rjmccall added a comment.

Hmm.  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.  The conditions on mandatory tail calls 
should make that possible, and it seems like it would be necessary for a lot of 
types.  Aggregates especially come to mind — if an aggregate is returned in 
registers, we're probably going to generate code like

  %0 = alloca %struct.foo
  %1 = call {i64,i64} @function()
  %2 = bitcast %0 to {i64,i64}*
  store %1, %2
  %3 = bitcast %0 to {i64,i64}*
  %4 = load %3
  ret %4

(Actually, probably much worse, with a lot of extract_values and so on.)  I 
assume that is going to completely break TCO, and we really need to generate

  %0 = call {i64,i64} @function()
  ret %0

The *only* way we can do that is to recognize that the call has to be done 
differently in IRGen.


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