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

Philip Reames listmail at philipreames.com
Thu Jul 17 15:32:49 PDT 2014


Hi atrick, ributzka,

This patch emits the StackMap section on ELF systems.  This is required to support llvm.experimental.stackmap and llvm.experimental.patchpoint.  

Careful review is appreciated.  I don't know the areas I'm touching well and may have gotten things wrong.  A couple of things for specific review:
- Are the flags to getELFSection correct?
- Should I change the name of label following the section start?

Worth noting is that previous versions of this patch have been proposed but not submitted several times.  For example, one was proposed here:
http://comments.gmane.org/gmane.comp.compilers.llvm.cvs/171038

The code in this change set is original.

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::getReadOnly());
+
 }
 
 
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.11615.patch
Type: text/x-patch
Size: 2189 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140717/a383fa89/attachment.bin>


More information about the llvm-commits mailing list