[PATCH] Add support for StackMap section for ELF/Linux systems

Philip Reames listmail at philipreames.com
Mon Jul 21 15:47:13 PDT 2014


Switching the section type to be metadata instead of readonly based on review comments.

http://reviews.llvm.org/D4574

Files:
  lib/MC/MCObjectFileInfo.cpp
  lib/Target/X86/X86AsmPrinter.cpp
  test/CodeGen/X86/stackmap-elf.ll

Index: lib/MC/MCObjectFileInfo.cpp
===================================================================
--- lib/MC/MCObjectFileInfo.cpp
+++ lib/MC/MCObjectFileInfo.cpp
@@ -582,6 +582,12 @@
   DwarfAddrSection =
     Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0,
                        SectionKind::getMetadata());
+
+  StackMapSection =
+    Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS,
+                       ELF::SHF_ALLOC,
+                       SectionKind::getMetadata());
+
 }
 
 
Index: lib/Target/X86/X86AsmPrinter.cpp
===================================================================
--- lib/Target/X86/X86AsmPrinter.cpp
+++ lib/Target/X86/X86AsmPrinter.cpp
@@ -734,6 +734,8 @@
       }
       Stubs.clear();
     }
+
+    SM.serializeToStackMapSection();
   }
 }
 
Index: test/CodeGen/X86/stackmap-elf.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/stackmap-elf.ll
@@ -0,0 +1,44 @@
+; RUN: llc < %s -mtriple=x86_64-linux-generic -disable-fp-elim | FileCheck %s
+; 
+; Note: This test file should cover only ELF specific formatting. 
+; Generic stackmap tests should go in the macho test files.
+;
+; Note: Print verbose stackmaps using -debug-only=stackmaps.
+
+; CHECK-LABEL:  .section	.llvm_stackmaps,"a", at progbits
+; CHECK-NEXT:  __LLVM_StackMaps:
+; Header
+; CHECK-NEXT:   .byte 1
+; CHECK-NEXT:   .byte 0
+; CHECK-NEXT:   .short 0
+; Num Functions
+; CHECK-NEXT:   .long 1
+; Num LargeConstants
+; CHECK-NEXT:   .long 0
+; Num Callsites
+; CHECK-NEXT:   .long 1
+
+; Functions and stack size
+; CHECK-NEXT:   .quad stackmap_elf
+; CHECK-NEXT:   .quad 8
+
+; Callsites
+; Constant arguments
+;
+; CHECK-NEXT:   .quad   1
+; CHECK-NEXT:   .long   .Ltmp{{.*}}-stackmap_elf
+; CHECK-NEXT:   .short  0
+; CHECK-NEXT:   .short  1
+; SmallConstant
+; CHECK-NEXT:   .byte   4
+; CHECK-NEXT:   .byte   8
+; CHECK-NEXT:   .short  0
+; CHECK-NEXT:   .long   155
+define void @stackmap_elf() {
+entry:
+  %0 = inttoptr i64 12345000 to i8*
+  tail call void (i64, i32, ...)* @llvm.experimental.stackmap(i64 1, i32 15, i32 155)
+  ret void
+}
+
+declare void @llvm.experimental.stackmap(i64, i32, ...)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4574.11725.patch
Type: text/x-patch
Size: 2189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140721/68fcfd45/attachment.bin>


More information about the llvm-commits mailing list