Index: llvm/include/llvm/Object/StackMapParser.h =================================================================== --- llvm/include/llvm/Object/StackMapParser.h +++ llvm/include/llvm/Object/StackMapParser.h @@ -20,7 +20,7 @@ namespace llvm { template -class StackMapV2Parser { +class StackMapV3Parser { public: template class AccessorIterator { @@ -49,7 +49,7 @@ /// Accessor for function records. class FunctionAccessor { - friend class StackMapV2Parser; + friend class StackMapV3Parser; public: /// Get the function address. @@ -81,7 +81,7 @@ /// Accessor for constants. class ConstantAccessor { - friend class StackMapV2Parser; + friend class StackMapV3Parser; public: /// Return the value of this constant. @@ -105,7 +105,7 @@ /// Accessor for location records. class LocationAccessor { - friend class StackMapV2Parser; + friend class StackMapV3Parser; friend class RecordAccessor; public: @@ -115,8 +115,8 @@ } /// Get the Size for this location. - uint8_t getSize() const { - return read(P + SizeOffset); + uint16_t getSize() const { + return read(P + SizeOffset); } @@ -154,17 +154,17 @@ } static const int KindOffset = 0; - static const int SizeOffset = KindOffset + sizeof(uint8_t); - static const int DwarfRegNumOffset = SizeOffset + sizeof(uint8_t); - static const int SmallConstantOffset = DwarfRegNumOffset + sizeof(uint16_t); - static const int LocationAccessorSize = sizeof(uint64_t); + static const int SizeOffset = KindOffset + sizeof(uint16_t); + static const int DwarfRegNumOffset = SizeOffset + sizeof(uint16_t); + static const int SmallConstantOffset = DwarfRegNumOffset + sizeof(uint32_t); + static const int LocationAccessorSize = sizeof(uint64_t) + sizeof(uint32_t); const uint8_t *P; }; /// Accessor for stackmap live-out fields. class LiveOutAccessor { - friend class StackMapV2Parser; + friend class StackMapV3Parser; friend class RecordAccessor; public: @@ -195,7 +195,7 @@ /// Accessor for stackmap records. class RecordAccessor { - friend class StackMapV2Parser; + friend class StackMapV3Parser; public: using location_iterator = AccessorIterator; @@ -270,8 +270,9 @@ RecordAccessor(const uint8_t *P) : P(P) {} unsigned getNumLiveOutsOffset() const { - return LocationListOffset + LocationSize * getNumLocations() + - sizeof(uint16_t); + unsigned LocOffset = + ((LocationListOffset + LocationSize * getNumLocations()) + 7) & ~0x7; + return LocOffset + sizeof(uint16_t); } unsigned getSizeInBytes() const { @@ -291,20 +292,20 @@ InstructionOffsetOffset + sizeof(uint32_t) + sizeof(uint16_t); static const unsigned LocationListOffset = NumLocationsOffset + sizeof(uint16_t); - static const unsigned LocationSize = sizeof(uint64_t); + static const unsigned LocationSize = sizeof(uint64_t) + sizeof(uint32_t); static const unsigned LiveOutSize = sizeof(uint32_t); const uint8_t *P; }; - /// Construct a parser for a version-2 stackmap. StackMap data will be read + /// Construct a parser for a version-3 stackmap. StackMap data will be read /// from the given array. - StackMapV2Parser(ArrayRef StackMapSection) + StackMapV3Parser(ArrayRef StackMapSection) : StackMapSection(StackMapSection) { ConstantsListOffset = FunctionListOffset + getNumFunctions() * FunctionSize; - assert(StackMapSection[0] == 2 && - "StackMapV2Parser can only parse version 2 stackmaps"); + assert(StackMapSection[0] == 3 && + "StackMapV3Parser can only parse version 3 stackmaps"); unsigned CurrentRecordOffset = ConstantsListOffset + getNumConstants() * ConstantSize; @@ -321,7 +322,7 @@ using record_iterator = AccessorIterator; /// Get the version number of this stackmap. (Always returns 2). - unsigned getVersion() const { return 2; } + unsigned getVersion() const { return 3; } /// Get the number of functions in the stack map. uint32_t getNumFunctions() const { Index: llvm/test/Object/stackmap-dump.test =================================================================== --- llvm/test/Object/stackmap-dump.test +++ llvm/test/Object/stackmap-dump.test @@ -1,174 +1,174 @@ -RUN: llvm-readobj -stackmap %p/Inputs/stackmap-test.macho-x86-64 | FileCheck %s +RUN: llvm-readobj -stackmap %p/Inputs/stackmap-test.elf-x86-64 | FileCheck %s ; Note: the macho object file in this test was generated in the following way: ; llc -mtriple=x86_64-apple-darwin %p/test/CodeGen/X86/stackmap.ll -o stackmap.s -; clang -c stackmap.s -o %p/test/Object/Inputs/stackmap-test.macho-x86-64 - -CHECK: LLVM StackMap Version: 2 -CHECK-NEXT: Num Functions: 16 -CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 24, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 2 -CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 4 -CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 1 -CHECK-NEXT: Function address: 0, stack size: 18446744073709551615, callsite record count: 1 -CHECK-NEXT: Num Constants: 3 -CHECK-NEXT: #1: 2147483648 -CHECK-NEXT: #2: 4294967295 -CHECK-NEXT: #3: 4294967296 -CHECK-NEXT: Num Records: 20 -CHECK-NEXT: Record ID: 1, instruction offset: 4 -CHECK-NEXT: 12 locations: -CHECK-NEXT: #1: Constant 4294967295 -CHECK-NEXT: #2: Constant 4294967295 -CHECK-NEXT: #3: Constant 65536 -CHECK-NEXT: #4: Constant 2000000000 -CHECK-NEXT: #5: Constant 2147483647 -CHECK-NEXT: #6: Constant 4294967295 -CHECK-NEXT: #7: Constant 4294967295 -CHECK-NEXT: #8: Constant 0 -CHECK-NEXT: #9: ConstantIndex #0 (2147483648) -CHECK-NEXT: #10: ConstantIndex #1 (4294967295) -CHECK-NEXT: #11: ConstantIndex #2 (4294967296) -CHECK-NEXT: #12: Constant 4294967295 -CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] - -CHECK: Record ID: 3, instruction offset: 22 -CHECK-NEXT: 2 locations: -CHECK-NEXT: #1: Register R#3 -CHECK-NEXT: #2: Register R#14 -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 4, instruction offset: 10 -CHECK-NEXT: 2 locations: -CHECK-NEXT: #1: Register R#5 -CHECK-NEXT: #2: Register R#4 -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 5, instruction offset: 4 -CHECK-NEXT: 2 locations: -CHECK-NEXT: #1: Register R#0 -CHECK-NEXT: #2: Register R#5 -CHECK-NEXT: 2 live-outs: [ R#0 (8-bytes) R#7 (8-bytes) ] - -CHECK: Record ID: 6, instruction offset: 4 -CHECK-NEXT: 2 locations: -CHECK-NEXT: #1: Register R#4 -CHECK-NEXT: #2: Register R#2 -CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] - -CHECK: Record ID: 7, instruction offset: 10 -CHECK-NEXT: 2 locations: -CHECK-NEXT: #1: Register R#2 -CHECK-NEXT: #2: Register R#8 -CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] - -CHECK: Record ID: 8, instruction offset: 10 -CHECK-NEXT: 2 locations: -CHECK-NEXT: #1: Register R#2 -CHECK-NEXT: #2: Register R#8 -CHECK-NEXT: 2 live-outs: [ R#0 (8-bytes) R#7 (8-bytes) ] - -CHECK: Record ID: 11, instruction offset: 42 -CHECK-NEXT: 17 locations: -CHECK-NEXT: #1: Register R#9 -CHECK-NEXT: #2: Register R#14 -CHECK-NEXT: #3: Register R#10 -CHECK-NEXT: #4: Register R#3 -CHECK-NEXT: #5: Register R#0 -CHECK-NEXT: #6: Register R#13 -CHECK-NEXT: #7: Register R#12 -CHECK-NEXT: #8: Register R#15 -CHECK-NEXT: #9: Indirect [R#6 + 72] -CHECK-NEXT: #10: Indirect [R#6 + 80] -CHECK-NEXT: #11: Indirect [R#6 + 88] -CHECK-NEXT: #12: Indirect [R#6 + 96] -CHECK-NEXT: #13: Indirect [R#6 + 104] -CHECK-NEXT: #14: Indirect [R#6 + 112] -CHECK-NEXT: #15: Indirect [R#6 + 120] -CHECK-NEXT: #16: Indirect [R#6 + 128] -CHECK-NEXT: #17: Indirect [R#6 + 136] -CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] - -CHECK: Record ID: 12, instruction offset: 62 -CHECK-NEXT: 17 locations: -CHECK-NEXT: #1: Register R#0 -CHECK-NEXT: #2: Register R#14 -CHECK-NEXT: #3: Register R#10 -CHECK-NEXT: #4: Register R#9 -CHECK-NEXT: #5: Register R#8 -CHECK-NEXT: #6: Register R#4 -CHECK-NEXT: #7: Register R#1 -CHECK-NEXT: #8: Register R#2 -CHECK-NEXT: #9: Register R#5 -CHECK-NEXT: #10: Register R#3 -CHECK-NEXT: #11: Register R#13 -CHECK-NEXT: #12: Register R#12 -CHECK-NEXT: #13: Register R#15 -CHECK-NEXT: #14: Indirect [R#6 + 112] -CHECK-NEXT: #15: Indirect [R#6 + 120] -CHECK-NEXT: #16: Indirect [R#6 + 128] -CHECK-NEXT: #17: Indirect [R#6 + 136] -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 13, instruction offset: 50 -CHECK-NEXT: 1 locations: -CHECK-NEXT: #1: Indirect [R#6 + -48] -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 14, instruction offset: 24 -CHECK-NEXT: 2 locations: -CHECK-NEXT: #1: Register R#0 -CHECK-NEXT: #2: Register R#3 -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 15, instruction offset: 4 -CHECK-NEXT: 1 locations: -CHECK-NEXT: #1: Constant 33 -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 16, instruction offset: 32 -CHECK-NEXT: 1 locations: -CHECK-NEXT: #1: Direct R#6 + -32 -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 17, instruction offset: 32 -CHECK-NEXT: 2 locations: -CHECK-NEXT: #1: Direct R#6 + -8 -CHECK-NEXT: #2: Direct R#6 + -40 -CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] - -CHECK: Record ID: 4294967295, instruction offset: 4 -CHECK-NEXT: 0 locations: -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 4294967296, instruction offset: 4 -CHECK-NEXT: 0 locations: -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 9223372036854775807, instruction offset: 4 -CHECK-NEXT: 0 locations: -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 18446744073709551615, instruction offset: 4 -CHECK-NEXT: 0 locations: -CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] - -CHECK: Record ID: 16, instruction offset: 18 -CHECK-NEXT: 1 locations: -CHECK-NEXT: #1: Indirect [R#6 + -44] -CHECK-NEXT: 0 live-outs: [ ] - -CHECK: Record ID: 0, instruction offset: 26 -CHECK-NEXT: 0 locations: -CHECK-NEXT: 0 live-outs: [ ] +; clang -c stackmap.s -o %p/test/Object/Inputs/stackmap-test.elf-x86-64 + +CHECK: LLVM StackMap Version: 3 +CHECK-NEXT: Num Functions: 16 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 24, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 2 +CHECK-NEXT: Function address: 0, stack size: 8, callsite record count: 4 +CHECK-NEXT: Function address: 0, stack size: 56, callsite record count: 1 +CHECK-NEXT: Function address: 0, stack size: 18446744073709551615, callsite record count: 1 +CHECK-NEXT: Num Constants: 3 +CHECK-NEXT: #1: 2147483648 +CHECK-NEXT: #2: 4294967295 +CHECK-NEXT: #3: 4294967296 +CHECK-NEXT: Num Records: 20 +CHECK-NEXT: Record ID: 1, instruction offset: 4 +CHECK-NEXT: 12 locations: +CHECK-NEXT: #1: Constant 4294967295 +CHECK-NEXT: #2: Constant 4294967295 +CHECK-NEXT: #3: Constant 65536 +CHECK-NEXT: #4: Constant 2000000000 +CHECK-NEXT: #5: Constant 2147483647 +CHECK-NEXT: #6: Constant 4294967295 +CHECK-NEXT: #7: Constant 4294967295 +CHECK-NEXT: #8: Constant 0 +CHECK-NEXT: #9: ConstantIndex #0 (2147483648) +CHECK-NEXT: #10: ConstantIndex #1 (4294967295) +CHECK-NEXT: #11: ConstantIndex #2 (4294967296) +CHECK-NEXT: #12: Constant 4294967295 +CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] + +CHECK: Record ID: 3, instruction offset: 22 +CHECK-NEXT: 2 locations: +CHECK-NEXT: #1: Register R#3 +CHECK-NEXT: #2: Register R#14 +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 4, instruction offset: 10 +CHECK-NEXT: 2 locations: +CHECK-NEXT: #1: Register R#5 +CHECK-NEXT: #2: Register R#4 +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 5, instruction offset: 4 +CHECK-NEXT: 2 locations: +CHECK-NEXT: #1: Register R#0 +CHECK-NEXT: #2: Register R#5 +CHECK-NEXT: 2 live-outs: [ R#0 (8-bytes) R#7 (8-bytes) ] + +CHECK: Record ID: 6, instruction offset: 4 +CHECK-NEXT: 2 locations: +CHECK-NEXT: #1: Register R#4 +CHECK-NEXT: #2: Register R#2 +CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] + +CHECK: Record ID: 7, instruction offset: 10 +CHECK-NEXT: 2 locations: +CHECK-NEXT: #1: Register R#2 +CHECK-NEXT: #2: Register R#8 +CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] + +CHECK: Record ID: 8, instruction offset: 10 +CHECK-NEXT: 2 locations: +CHECK-NEXT: #1: Register R#2 +CHECK-NEXT: #2: Register R#8 +CHECK-NEXT: 2 live-outs: [ R#0 (8-bytes) R#7 (8-bytes) ] + +CHECK: Record ID: 11, instruction offset: 4 +CHECK-NEXT: 17 locations: +CHECK-NEXT: #1: Register R#9 +CHECK-NEXT: #2: Indirect [R#6 + 16] +CHECK-NEXT: #3: Indirect [R#6 + 24] +CHECK-NEXT: #4: Indirect [R#6 + 32] +CHECK-NEXT: #5: Indirect [R#6 + 40] +CHECK-NEXT: #6: Indirect [R#6 + 48] +CHECK-NEXT: #7: Indirect [R#6 + 56] +CHECK-NEXT: #8: Indirect [R#6 + 64] +CHECK-NEXT: #9: Indirect [R#6 + 72] +CHECK-NEXT: #10: Indirect [R#6 + 80] +CHECK-NEXT: #11: Indirect [R#6 + 88] +CHECK-NEXT: #12: Indirect [R#6 + 96] +CHECK-NEXT: #13: Indirect [R#6 + 104] +CHECK-NEXT: #14: Indirect [R#6 + 112] +CHECK-NEXT: #15: Indirect [R#6 + 120] +CHECK-NEXT: #16: Indirect [R#6 + 128] +CHECK-NEXT: #17: Indirect [R#6 + 136] +CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] + +CHECK: Record ID: 12, instruction offset: 4 +CHECK-NEXT: 17 locations: +CHECK-NEXT: #1: Register R#0 +CHECK-NEXT: #2: Indirect [R#6 + 16] +CHECK-NEXT: #3: Indirect [R#6 + 24] +CHECK-NEXT: #4: Indirect [R#6 + 32] +CHECK-NEXT: #5: Indirect [R#6 + 40] +CHECK-NEXT: #6: Indirect [R#6 + 48] +CHECK-NEXT: #7: Indirect [R#6 + 56] +CHECK-NEXT: #8: Indirect [R#6 + 64] +CHECK-NEXT: #9: Indirect [R#6 + 72] +CHECK-NEXT: #10: Indirect [R#6 + 80] +CHECK-NEXT: #11: Indirect [R#6 + 88] +CHECK-NEXT: #12: Indirect [R#6 + 96] +CHECK-NEXT: #13: Indirect [R#6 + 104] +CHECK-NEXT: #14: Indirect [R#6 + 112] +CHECK-NEXT: #15: Indirect [R#6 + 120] +CHECK-NEXT: #16: Indirect [R#6 + 128] +CHECK-NEXT: #17: Indirect [R#6 + 136] +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 13, instruction offset: 50 +CHECK-NEXT: 1 locations: +CHECK-NEXT: #1: Indirect [R#6 + -48] +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 14, instruction offset: 24 +CHECK-NEXT: 2 locations: +CHECK-NEXT: #1: Register R#0 +CHECK-NEXT: #2: Register R#3 +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 15, instruction offset: 4 +CHECK-NEXT: 1 locations: +CHECK-NEXT: #1: Constant 33 +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 16, instruction offset: 16 +CHECK-NEXT: 1 locations: +CHECK-NEXT: #1: Direct R#6 + -40 +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 17, instruction offset: 16 +CHECK-NEXT: 2 locations: +CHECK-NEXT: #1: Direct R#6 + -8 +CHECK-NEXT: #2: Direct R#6 + -16 +CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] + +CHECK: Record ID: 4294967295, instruction offset: 4 +CHECK-NEXT: 0 locations: +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 4294967296, instruction offset: 4 +CHECK-NEXT: 0 locations: +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 9223372036854775807, instruction offset: 4 +CHECK-NEXT: 0 locations: +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 18446744073709551615, instruction offset: 4 +CHECK-NEXT: 0 locations: +CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ] + +CHECK: Record ID: 16, instruction offset: 18 +CHECK-NEXT: 1 locations: +CHECK-NEXT: #1: Indirect [R#6 + -44] +CHECK-NEXT: 0 live-outs: [ ] + +CHECK: Record ID: 0, instruction offset: 25 +CHECK-NEXT: 0 locations: +CHECK-NEXT: 0 live-outs: [ ] Index: llvm/tools/llvm-readobj/COFFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/COFFDumper.cpp +++ llvm/tools/llvm-readobj/COFFDumper.cpp @@ -1868,10 +1868,10 @@ if (Obj->isLittleEndian()) prettyPrintStackMap( - W, StackMapV2Parser(StackMapContentsArray)); + W, StackMapV3Parser(StackMapContentsArray)); else prettyPrintStackMap(W, - StackMapV2Parser(StackMapContentsArray)); + StackMapV3Parser(StackMapContentsArray)); } void COFFDumper::printAddrsig() { Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -2397,7 +2397,7 @@ unwrapOrError(Obj->getSectionContents(StackMapSection)); prettyPrintStackMap( - W, StackMapV2Parser(StackMapContentsArray)); + W, StackMapV3Parser(StackMapContentsArray)); } template void ELFDumper::printGroupSections() { Index: llvm/tools/llvm-readobj/MachODumper.cpp =================================================================== --- llvm/tools/llvm-readobj/MachODumper.cpp +++ llvm/tools/llvm-readobj/MachODumper.cpp @@ -667,10 +667,10 @@ if (Obj->isLittleEndian()) prettyPrintStackMap( - W, StackMapV2Parser(StackMapContentsArray)); + W, StackMapV3Parser(StackMapContentsArray)); else prettyPrintStackMap(W, - StackMapV2Parser(StackMapContentsArray)); + StackMapV3Parser(StackMapContentsArray)); } void MachODumper::printNeededLibraries() {