aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Object/StackMapParser.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:50:12 +0000
commite6d1592492a3a379186bfb02bd0f4eda0669c0d5 (patch)
tree599ab169a01f1c86eda9adc774edaedde2f2db5b /include/llvm/Object/StackMapParser.h
parent1a56a5ead7a2e84bee8240f5f6b033b5f1707154 (diff)
Diffstat (limited to 'include/llvm/Object/StackMapParser.h')
-rw-r--r--include/llvm/Object/StackMapParser.h50
1 files changed, 29 insertions, 21 deletions
diff --git a/include/llvm/Object/StackMapParser.h b/include/llvm/Object/StackMapParser.h
index 557db5afa825..ed44efbf80b9 100644
--- a/include/llvm/Object/StackMapParser.h
+++ b/include/llvm/Object/StackMapParser.h
@@ -1,9 +1,8 @@
//===- StackMapParser.h - StackMap Parsing Support --------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,8 +19,9 @@
namespace llvm {
+/// A parser for the latest stackmap format. At the moment, latest=V2.
template <support::endianness Endianness>
-class StackMapV2Parser {
+class StackMapParser {
public:
template <typename AccessorT>
class AccessorIterator {
@@ -50,7 +50,7 @@ public:
/// Accessor for function records.
class FunctionAccessor {
- friend class StackMapV2Parser;
+ friend class StackMapParser;
public:
/// Get the function address.
@@ -82,7 +82,7 @@ public:
/// Accessor for constants.
class ConstantAccessor {
- friend class StackMapV2Parser;
+ friend class StackMapParser;
public:
/// Return the value of this constant.
@@ -106,7 +106,7 @@ public:
/// Accessor for location records.
class LocationAccessor {
- friend class StackMapV2Parser;
+ friend class StackMapParser;
friend class RecordAccessor;
public:
@@ -115,6 +115,12 @@ public:
return LocationKind(P[KindOffset]);
}
+ /// Get the Size for this location.
+ unsigned getSizeInBytes() const {
+ return read<uint16_t>(P + SizeOffset);
+
+ }
+
/// Get the Dwarf register number for this location.
uint16_t getDwarfRegNum() const {
return read<uint16_t>(P + DwarfRegNumOffset);
@@ -149,16 +155,17 @@ public:
}
static const int KindOffset = 0;
- static const int DwarfRegNumOffset = KindOffset + sizeof(uint16_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 StackMapParser;
friend class RecordAccessor;
public:
@@ -189,7 +196,7 @@ public:
/// Accessor for stackmap records.
class RecordAccessor {
- friend class StackMapV2Parser;
+ friend class StackMapParser;
public:
using location_iterator = AccessorIterator<LocationAccessor>;
@@ -264,8 +271,9 @@ public:
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 {
@@ -285,7 +293,7 @@ public:
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;
@@ -293,12 +301,12 @@ public:
/// Construct a parser for a version-2 stackmap. StackMap data will be read
/// from the given array.
- StackMapV2Parser(ArrayRef<uint8_t> StackMapSection)
+ StackMapParser(ArrayRef<uint8_t> StackMapSection)
: StackMapSection(StackMapSection) {
ConstantsListOffset = FunctionListOffset + getNumFunctions() * FunctionSize;
- assert(StackMapSection[0] == 2 &&
- "StackMapV2Parser can only parse version 2 stackmaps");
+ assert(StackMapSection[0] == 3 &&
+ "StackMapParser can only parse version 3 stackmaps");
unsigned CurrentRecordOffset =
ConstantsListOffset + getNumConstants() * ConstantSize;
@@ -314,8 +322,8 @@ public:
using constant_iterator = AccessorIterator<ConstantAccessor>;
using record_iterator = AccessorIterator<RecordAccessor>;
- /// Get the version number of this stackmap. (Always returns 2).
- unsigned getVersion() const { return 2; }
+ /// Get the version number of this stackmap. (Always returns 3).
+ unsigned getVersion() const { return 3; }
/// Get the number of functions in the stack map.
uint32_t getNumFunctions() const {