diff options
author | Dean Michael Berris <dberris@google.com> | 2016-08-04 07:37:28 +0000 |
---|---|---|
committer | Dean Michael Berris <dberris@google.com> | 2016-08-04 07:37:28 +0000 |
commit | 7e9abea2aea8639b78eb34dbe6131bb88900bdc7 (patch) | |
tree | 8b665bbed5b76bc325b232fa75a3673cc002ab9d /llvm/lib/Target/X86/X86MCInstLower.cpp | |
parent | b0e32f1ba1742d1d355721ec3f1c2f48842bfa83 (diff) | |
download | bcm5719-llvm-7e9abea2aea8639b78eb34dbe6131bb88900bdc7.tar.gz bcm5719-llvm-7e9abea2aea8639b78eb34dbe6131bb88900bdc7.zip |
[XRay] Align entry and return sleds to 2 byte boundaries
This should ensure that we can atomically write two bytes (on top of the
retq and the one past it) and have those two bytes not straddle cache
lines.
We also move the label past the alignment instruction so that we can refer
to the actual first instruction, as opposed to potential padding before the
aligned instruction.
Update the tests to allow us to reflect the new order of assembly.
Reviewers: rSerge, echristo, majnemer
Subscribers: llvm-commits, mehdi_amini
Differential Revision: https://reviews.llvm.org/D23101
llvm-svn: 277701
Diffstat (limited to 'llvm/lib/Target/X86/X86MCInstLower.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86MCInstLower.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp index 18f9b3e2e2a..58033eeedc2 100644 --- a/llvm/lib/Target/X86/X86MCInstLower.cpp +++ b/llvm/lib/Target/X86/X86MCInstLower.cpp @@ -1038,8 +1038,8 @@ void X86AsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI, X86MCInstLower &MCIL) { // We want to emit the following pattern: // + // .p2align 1, ... // .Lxray_sled_N: - // .palign 2, ... // jmp .tmpN // # 9 bytes worth of noops // .tmpN @@ -1051,8 +1051,8 @@ void X86AsmPrinter::LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI, // call <relative offset, 32-bits> // 5 bytes // auto CurSled = OutContext.createTempSymbol("xray_sled_", true); + OutStreamer->EmitCodeAlignment(2); OutStreamer->EmitLabel(CurSled); - OutStreamer->EmitCodeAlignment(4); auto Target = OutContext.createTempSymbol(); // Use a two-byte `jmp`. This version of JMP takes an 8-bit relative offset as @@ -1074,12 +1074,14 @@ void X86AsmPrinter::LowerPATCHABLE_RET(const MachineInstr &MI, // // We should emit the RET followed by sleds. // + // .p2align 1, ... // .Lxray_sled_N: // ret # or equivalent instruction // # 10 bytes worth of noops // // This just makes sure that the alignment for the next instruction is 2. auto CurSled = OutContext.createTempSymbol("xray_sled_", true); + OutStreamer->EmitCodeAlignment(2); OutStreamer->EmitLabel(CurSled); unsigned OpCode = MI.getOperand(0).getImm(); MCInst Ret; |