[PATCH] D23398: [XRay] Synthesize a reference to the xray_instr_map

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 21:52:33 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL279204: [XRay] Synthesize a reference to the xray_instr_map (authored by dberris).

Changed prior to commit:
  https://reviews.llvm.org/D23398?vs=68297&id=68646#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23398

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

Index: llvm/trunk/test/CodeGen/X86/xray-attribute-instrumentation.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/xray-attribute-instrumentation.ll
+++ llvm/trunk/test/CodeGen/X86/xray-attribute-instrumentation.ll
@@ -12,3 +12,9 @@
 ; CHECK-NEXT:  retq
 ; CHECK-NEXT:  nopw %cs:512(%rax,%rax)
 }
+; CHECK:       .p2align 4, 0x90
+; CHECK-NEXT:  .quad .Lxray_synthetic_0
+; CHECK-NEXT:  .section xray_instr_map,{{.*}}
+; CHECK-LABEL: Lxray_synthetic_0:
+; CHECK:       .quad .Lxray_sled_0
+; CHECK:       .quad .Lxray_sled_1
Index: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
===================================================================
--- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
@@ -1109,7 +1109,19 @@
       Section = OutContext.getELFSection("xray_instr_map", ELF::SHT_PROGBITS,
                                          ELF::SHF_ALLOC);
     }
+
+    // Before we switch over, we force a reference to a label inside the
+    // xray_instr_map section. Since EmitXRayTable() is always called just
+    // before the function's end, we assume that this is happening after the
+    // last return instruction.
+    //
+    // We then align the reference to 16 byte boundaries, which we determined
+    // experimentally to be beneficial to avoid causing decoder stalls.
+    MCSymbol *Tmp = OutContext.createTempSymbol("xray_synthetic_", true);
+    OutStreamer->EmitCodeAlignment(16);
+    OutStreamer->EmitSymbolValue(Tmp, 8, false);
     OutStreamer->SwitchSection(Section);
+    OutStreamer->EmitLabel(Tmp);
     for (const auto &Sled : Sleds) {
       OutStreamer->EmitSymbolValue(Sled.Sled, 8);
       OutStreamer->EmitSymbolValue(CurrentFnSym, 8);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23398.68646.patch
Type: text/x-patch
Size: 1773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160819/34aacb27/attachment.bin>


More information about the llvm-commits mailing list