diff options
author | Dean Michael Berris <dberris@google.com> | 2017-09-08 01:47:56 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2017-09-08 01:47:56 +0000 |
commit | 711dec260fc5ad2ec48fe73351bbfb9bd6d843d8 (patch) | |
tree | be85dfa15db549ba10244cafc5cc222be368a8ee /llvm/lib/CodeGen/XRayInstrumentation.cpp | |
parent | 0ff545c018bb2a5e96583e63036bd8464d766918 (diff) | |
download | bcm5719-llvm-711dec260fc5ad2ec48fe73351bbfb9bd6d843d8.tar.gz bcm5719-llvm-711dec260fc5ad2ec48fe73351bbfb9bd6d843d8.zip |
[XRay][CodeGen][PowerPC] Fix tail exit codegen for XRay in PPC
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.
Reviewers: echristo, timshen
Subscribers: nemanjai, kbarton, llvm-commits
Differential Revision: https://reviews.llvm.org/D37570
llvm-svn: 312772
Diffstat (limited to 'llvm/lib/CodeGen/XRayInstrumentation.cpp')
-rw-r--r-- | llvm/lib/CodeGen/XRayInstrumentation.cpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/XRayInstrumentation.cpp b/llvm/lib/CodeGen/XRayInstrumentation.cpp index 0b4c6e55166..e6b65825f5b 100644 --- a/llvm/lib/CodeGen/XRayInstrumentation.cpp +++ b/llvm/lib/CodeGen/XRayInstrumentation.cpp @@ -14,8 +14,8 @@ // //===---------------------------------------------------------------------===// -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Triple.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineDominators.h" @@ -109,22 +109,13 @@ void XRayInstrumentation::replaceRetWithPatchableRet( void XRayInstrumentation::prependRetWithPatchableExit( MachineFunction &MF, const TargetInstrInfo *TII) { - for (auto &MBB : MF) { - for (auto &T : MBB.terminators()) { - unsigned Opc = 0; + for (auto &MBB : MF) + for (auto &T : MBB.terminators()) if (T.isReturn()) { - Opc = TargetOpcode::PATCHABLE_FUNCTION_EXIT; - } - if (TII->isTailCall(T)) { - Opc = TargetOpcode::PATCHABLE_TAIL_CALL; - } - if (Opc != 0) { - // Prepend the return instruction with PATCHABLE_FUNCTION_EXIT or - // PATCHABLE_TAIL_CALL . - BuildMI(MBB, T, T.getDebugLoc(), TII->get(Opc)); + // Prepend the return instruction with PATCHABLE_FUNCTION_EXIT. + BuildMI(MBB, T, T.getDebugLoc(), + TII->get(TargetOpcode::PATCHABLE_FUNCTION_EXIT)); } - } - } } bool XRayInstrumentation::runOnMachineFunction(MachineFunction &MF) { @@ -143,7 +134,7 @@ bool XRayInstrumentation::runOnMachineFunction(MachineFunction &MF) { // Count the number of MachineInstr`s in MachineFunction int64_t MICount = 0; - for (const auto& MBB : MF) + for (const auto &MBB : MF) MICount += MBB.size(); // Check if we have a loop. |