[PATCH] D145209: [DAE] Don't change the return type if we have virtual musttail calls

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 2 22:22:24 PST 2023


mtrofin marked an inline comment as done.
mtrofin added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp:526
+      // In addition, if the called function is virtual, we can't change
+      // the return type.
+      if (!TC->getCalledFunction())
----------------
efriedma wrote:
> Please explain why this matters.  Intuitively, whether a function is virtual shouldn't affect liveness... do we handle the non-virtual case somewhere else?
Not sure I understand. It's about virtual musttail calls, not just virtual. "Liveness" in this pass means "it can't change".

Without the patch, the test fails in the validator, because the module is transformed to:

```
define internal void @test(ptr %fptr, i32 %a, i32 %b) {
  %r = musttail call i32 %fptr(ptr %fptr, i32 %a, i32 0)
  ret void
}

```

The error is what the test checks isn't present: `cannot guarantee tail call due to mismatched parameter counts`

The patch is actually incomplete - about to update it. This marking needs to be also propagated to users of the function.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145209



More information about the llvm-commits mailing list