Skip to content

Commit

Permalink
[StackMaps] Add location size to llvm-readobj -stackmap output
Browse files Browse the repository at this point in the history
The size field of a location can be different for each entry, so it is useful to have this displayed in the output of llvm-readobj -stackmap. Below is an example of how the output would look:

Record ID: 2882400000, instruction offset: 16
   3 locations:
     #1: Constant 1, size: 8
     #2: Constant 2, size: 8
     #3: Constant 3, size: 8
   0 live-outs: [ ]

Patch By: [email protected] (with heavy modification by me)
Differential Revision: https://reviews.llvm.org/D59169

llvm-svn: 358324
  • Loading branch information
preames committed Apr 13, 2019
1 parent f7acef9 commit eea989a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 73 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Object/StackMapParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class StackMapParser {
}

/// Get the Size for this location.
uint8_t getSize() const {
unsigned getSizeInBytes() const {
return read<uint8_t>(P + SizeOffset);

}
Expand Down
132 changes: 66 additions & 66 deletions llvm/test/Object/stackmap-dump.test
Original file line number Diff line number Diff line change
Expand Up @@ -29,123 +29,123 @@ 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: Constant 4294967295, size: 8
CHECK-NEXT: #2: Constant 4294967295, size: 8
CHECK-NEXT: #3: Constant 65536, size: 8
CHECK-NEXT: #4: Constant 2000000000, size: 8
CHECK-NEXT: #5: Constant 2147483647, size: 8
CHECK-NEXT: #6: Constant 4294967295, size: 8
CHECK-NEXT: #7: Constant 4294967295, size: 8
CHECK-NEXT: #8: Constant 0, size: 8
CHECK-NEXT: #9: ConstantIndex #0 (2147483648), size: 8
CHECK-NEXT: #10: ConstantIndex #1 (4294967295), size: 8
CHECK-NEXT: #11: ConstantIndex #2 (4294967296), size: 8
CHECK-NEXT: #12: Constant 4294967295, size: 8
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: #1: Register R#3, size: 8
CHECK-NEXT: #2: Register R#14, size: 8
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: #1: Register R#5, size: 8
CHECK-NEXT: #2: Register R#4, size: 8
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: #1: Register R#0, size: 8
CHECK-NEXT: #2: Register R#5, size: 8
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: Register R#4, size: 8
CHECK-NEXT: #2: Register R#2, size: 8
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: Register R#2, size: 8
CHECK-NEXT: #2: Register R#8, size: 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: #1: Register R#2, size: 8
CHECK-NEXT: #2: Register R#8, size: 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: Register R#9, size: 8
CHECK-NEXT: #2: Register R#14, size: 8
CHECK-NEXT: #3: Register R#10, size: 8
CHECK-NEXT: #4: Register R#3, size: 8
CHECK-NEXT: #5: Register R#0, size: 8
CHECK-NEXT: #6: Register R#13, size: 8
CHECK-NEXT: #7: Register R#12, size: 8
CHECK-NEXT: #8: Register R#15, size: 8
CHECK-NEXT: #9: Indirect [R#6 + 72], size: 8
CHECK-NEXT: #10: Indirect [R#6 + 80], size: 8
CHECK-NEXT: #11: Indirect [R#6 + 88], size: 8
CHECK-NEXT: #12: Indirect [R#6 + 96], size: 8
CHECK-NEXT: #13: Indirect [R#6 + 104], size: 8
CHECK-NEXT: #14: Indirect [R#6 + 112], size: 8
CHECK-NEXT: #15: Indirect [R#6 + 120], size: 8
CHECK-NEXT: #16: Indirect [R#6 + 128], size: 8
CHECK-NEXT: #17: Indirect [R#6 + 136], size: 8
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: #1: Register R#0, size: 8
CHECK-NEXT: #2: Register R#14, size: 8
CHECK-NEXT: #3: Register R#10, size: 8
CHECK-NEXT: #4: Register R#9, size: 8
CHECK-NEXT: #5: Register R#8, size: 8
CHECK-NEXT: #6: Register R#4, size: 8
CHECK-NEXT: #7: Register R#1, size: 8
CHECK-NEXT: #8: Register R#2, size: 8
CHECK-NEXT: #9: Register R#5, size: 8
CHECK-NEXT: #10: Register R#3, size: 8
CHECK-NEXT: #11: Register R#13, size: 8
CHECK-NEXT: #12: Register R#12, size: 8
CHECK-NEXT: #13: Register R#15, size: 8
CHECK-NEXT: #14: Indirect [R#6 + 112], size: 8
CHECK-NEXT: #15: Indirect [R#6 + 120], size: 8
CHECK-NEXT: #16: Indirect [R#6 + 128], size: 8
CHECK-NEXT: #17: Indirect [R#6 + 136], size: 8
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: #1: Indirect [R#6 + -48], size: 4
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: #1: Register R#0, size: 1
CHECK-NEXT: #2: Register R#3, size: 1
CHECK-NEXT: 0 live-outs: [ ]

CHECK: Record ID: 15, instruction offset: 4
CHECK-NEXT: 1 locations:
CHECK-NEXT: #1: Constant 33
CHECK-NEXT: #1: Constant 33, size: 8
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: #1: Direct R#6 + -32, size: 8
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: Direct R#6 + -8, size: 8
CHECK-NEXT: #2: Direct R#6 + -40, size: 8
CHECK-NEXT: 1 live-outs: [ R#7 (8-bytes) ]

CHECK: Record ID: 4294967295, instruction offset: 4
Expand All @@ -166,7 +166,7 @@ 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: #1: Indirect [R#6 + -44], size: 4
CHECK-NEXT: 0 live-outs: [ ]

CHECK: Record ID: 0, instruction offset: 26
Expand Down
12 changes: 6 additions & 6 deletions llvm/tools/llvm-readobj/StackMapPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@ void prettyPrintStackMap(ScopedPrinter &W, const StackMapParserT &SMP) {
OS << " #" << ++LocationIndex << ": ";
switch (Loc.getKind()) {
case StackMapParserT::LocationKind::Register:
OS << "Register R#" << Loc.getDwarfRegNum() << "\n";
OS << "Register R#" << Loc.getDwarfRegNum();
break;
case StackMapParserT::LocationKind::Direct:
OS << "Direct R#" << Loc.getDwarfRegNum() << " + " << Loc.getOffset()
<< "\n";
OS << "Direct R#" << Loc.getDwarfRegNum() << " + " << Loc.getOffset();
break;
case StackMapParserT::LocationKind::Indirect:
OS << "Indirect [R#" << Loc.getDwarfRegNum() << " + " << Loc.getOffset()
<< "]\n";
<< "]";
break;
case StackMapParserT::LocationKind::Constant:
OS << "Constant " << Loc.getSmallConstant() << "\n";
OS << "Constant " << Loc.getSmallConstant();
break;
case StackMapParserT::LocationKind::ConstantIndex:
OS << "ConstantIndex #" << Loc.getConstantIndex() << " ("
<< SMP.getConstant(Loc.getConstantIndex()).getValue() << ")\n";
<< SMP.getConstant(Loc.getConstantIndex()).getValue() << ")";
break;
}
OS << ", size: " << Loc.getSizeInBytes() << "\n";
}

raw_ostream &OS = W.startLine();
Expand Down

0 comments on commit eea989a

Please sign in to comment.