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",@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, ...)