This is an archive of the discontinued LLVM Phabricator instance.

[XRay][CodeGen][PowerPC] Fix tail exit codegen for XRay in PPC
ClosedPublic

Authored by dberris on Sep 7 2017, 7:25 AM.

Details

Summary

This fixes code-gen for XRay in PPC. The regression wasn't caught by
codegen tests which we add in this change.

What happened was the following:

  • For tail exits, we used to unconditionally prepend the returns/exits with a pseudo-instruction that gets lowered to the instrumentation sled (and leave the actual return/exit instruction as-is).
  • Changes to the XRay instrumentation pass caused the tail exits to suddenly also emit the tail exit pseudo-instruction, since the check for whether a return instruction was also a call instruction meant it was a tail exit instruction.
  • None of the tests caught the regression either due to non-existent tests, or the tests being disabled/removed for continuous breakage.

This change re-introduces some of the basic tests and verifies that
we're back to a state that allows the back-end to generate appropriate
XRay instrumented binaries for PPC in the presence of tail exits.

Diff Detail

Repository
rL LLVM

Event Timeline

dberris created this revision.Sep 7 2017, 7:25 AM
timshen added inline comments.Sep 7 2017, 4:29 PM
lib/CodeGen/XRayInstrumentation.cpp
118 ↗(On Diff #114177)

This is actively removing PATCHABLE_TAIL_CALL emits, and it affects all architectures.

Can we add x86 tests for tracking the decisions we've made?

dberris marked an inline comment as done.Sep 7 2017, 5:25 PM
dberris added inline comments.
lib/CodeGen/XRayInstrumentation.cpp
118 ↗(On Diff #114177)

Note that this function only gets called for non-X86 architectures (where prepending is the correct solution).

We already have tests in X86 for the tail call exit sled lowering. Those pass with this change.

timshen added inline comments.Sep 7 2017, 6:10 PM
lib/CodeGen/XRayInstrumentation.cpp
118 ↗(On Diff #114177)

We have other non-x86 targets like aarch64, right? How do those targets test this?

dberris marked an inline comment as done.Sep 7 2017, 6:17 PM
dberris added inline comments.
lib/CodeGen/XRayInstrumentation.cpp
118 ↗(On Diff #114177)

Yes, we have the following tests aside from the ones we're adding here.

test/CodeGen/ARM/xray-tail-call-sled.ll
test/CodeGen/AArch64/xray-tail-call-sled.ll

Or did you mean we need a test for tail calls out to hidden/external functions?

timshen added inline comments.Sep 7 2017, 6:20 PM
lib/CodeGen/XRayInstrumentation.cpp
118 ↗(On Diff #114177)

What does "out to" mean?

Yes. I was surprised that aarch64 tests are not affected by this patch. I guess that tests are missing and we should add them, but my guess can be wrong?

dberris added inline comments.Sep 7 2017, 6:26 PM
lib/CodeGen/XRayInstrumentation.cpp
118 ↗(On Diff #114177)

What does "out to" mean?

I meant, since the callee is only declared and not defined in the same TU.

I suspect the aarch64 tests weren't affected, because TII->isTailCall(T) might not be true for the machine instruction that's used to represent the tail call.

I'm happy to add the tests later if that matters for aarch64, just so we can ensure that if anything changes in this codepath that might affect that target, that we can catch breakages of this form too.

timshen accepted this revision.Sep 7 2017, 6:29 PM
timshen added inline comments.
lib/CodeGen/XRayInstrumentation.cpp
118 ↗(On Diff #114177)

I'm happy to add the tests later if that matters for aarch64, just so we can ensure that if anything changes in this codepath that might affect that target, that we can catch breakages of this form too.

SGTM.

This revision is now accepted and ready to land.Sep 7 2017, 6:29 PM
This revision was automatically updated to reflect the committed changes.