[PATCH] D23101: Align XRay return sleds to 2 byte boundaries

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 23:50:15 PDT 2016


dberris updated this revision to Diff 66762.
dberris added a comment.

- Emit label after alignment directive
- Adjust test to new order


https://reviews.llvm.org/D23101

Files:
  lib/Target/X86/X86MCInstLower.cpp
  test/CodeGen/X86/xray-attribute-instrumentation.ll

Index: test/CodeGen/X86/xray-attribute-instrumentation.ll
===================================================================
--- test/CodeGen/X86/xray-attribute-instrumentation.ll
+++ test/CodeGen/X86/xray-attribute-instrumentation.ll
@@ -1,12 +1,13 @@
 ; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
 
 define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
+; CHECK:       .p2align 1, 0x90
 ; CHECK-LABEL: Lxray_sled_0:
-; CHECK-NEXT:  .p2align 2, 0x90
 ; CHECK-NEXT:  .ascii "\353\t"
 ; CHECK-NEXT:  nopw 512(%rax,%rax)
 ; CHECK-LABEL: Ltmp0:
   ret i32 0
+; CHECK:       .p2align 1, 0x90
 ; CHECK-LABEL: Lxray_sled_1:
 ; CHECK-NEXT:  retq
 ; CHECK-NEXT:  nopw %cs:512(%rax,%rax)
Index: lib/Target/X86/X86MCInstLower.cpp
===================================================================
--- lib/Target/X86/X86MCInstLower.cpp
+++ lib/Target/X86/X86MCInstLower.cpp
@@ -1038,8 +1038,8 @@
                                                   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 @@
   //   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 @@
   //
   // 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23101.66762.patch
Type: text/x-patch
Size: 2095 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160804/6c3525be/attachment.bin>


More information about the llvm-commits mailing list