Skip to content

Commit 7e8a251

Browse files
authored
Revert "[Object] Parsing and dumping of SFrame Frame Row Entries" (#152650)
Reverts #151301 - build breakage on multiple bots.
1 parent 7074471 commit 7e8a251

File tree

7 files changed

+7
-508
lines changed

7 files changed

+7
-508
lines changed

llvm/include/llvm/BinaryFormat/SFrame.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ LLVM_ABI ArrayRef<EnumEntry<FREType>> getFRETypes();
169169
LLVM_ABI ArrayRef<EnumEntry<FDEType>> getFDETypes();
170170
LLVM_ABI ArrayRef<EnumEntry<AArch64PAuthKey>> getAArch64PAuthKeys();
171171
LLVM_ABI ArrayRef<EnumEntry<FREOffset>> getFREOffsets();
172-
LLVM_ABI ArrayRef<EnumEntry<BaseReg>> getBaseRegisters();
173172

174173
} // namespace sframe
175174
} // namespace llvm

llvm/include/llvm/Object/SFrameParser.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define LLVM_OBJECT_SFRAME_H
1111

1212
#include "llvm/ADT/ArrayRef.h"
13-
#include "llvm/ADT/fallible_iterator.h"
1413
#include "llvm/BinaryFormat/SFrame.h"
1514
#include "llvm/Support/Compiler.h"
1615
#include "llvm/Support/Error.h"
@@ -20,8 +19,6 @@ namespace llvm {
2019
namespace object {
2120

2221
template <endianness E> class SFrameParser {
23-
class FallibleFREIterator;
24-
2522
public:
2623
static Expected<SFrameParser> create(ArrayRef<uint8_t> Contents,
2724
uint64_t SectionAddress);
@@ -45,21 +42,6 @@ template <endianness E> class SFrameParser {
4542
// objects returned by the `fdes()` function.
4643
uint64_t getAbsoluteStartAddress(typename FDERange::iterator FDE) const;
4744

48-
struct FrameRowEntry {
49-
uint32_t StartAddress;
50-
sframe::FREInfo<endianness::native> Info;
51-
SmallVector<int32_t, 3> Offsets;
52-
};
53-
54-
using fre_iterator = fallible_iterator<FallibleFREIterator>;
55-
iterator_range<fre_iterator> fres(const sframe::FuncDescEntry<E> &FDE,
56-
Error &Err) const;
57-
58-
std::optional<int32_t> getCFAOffset(const FrameRowEntry &FRE) const;
59-
std::optional<int32_t> getRAOffset(const FrameRowEntry &FRE) const;
60-
std::optional<int32_t> getFPOffset(const FrameRowEntry &FRE) const;
61-
ArrayRef<int32_t> getExtraOffsets(const FrameRowEntry &FRE) const;
62-
6345
private:
6446
ArrayRef<uint8_t> Data;
6547
uint64_t SectionAddress;
@@ -72,39 +54,6 @@ template <endianness E> class SFrameParser {
7254
uint64_t getFDEBase() const {
7355
return sizeof(Header) + Header.AuxHdrLen + Header.FDEOff;
7456
}
75-
76-
uint64_t getFREBase() const {
77-
return getFDEBase() + Header.NumFDEs * sizeof(sframe::FuncDescEntry<E>);
78-
}
79-
};
80-
81-
template <endianness E> class SFrameParser<E>::FallibleFREIterator {
82-
public:
83-
// NB: This iterator starts out in the before_begin() state. It must be
84-
// ++'ed to reach the first element.
85-
FallibleFREIterator(ArrayRef<uint8_t> Data, sframe::FREType FREType,
86-
uint32_t Idx, uint32_t Size, uint64_t Offset)
87-
: Data(Data), FREType(FREType), Idx(Idx), Size(Size), Offset(Offset) {}
88-
89-
Error inc();
90-
const FrameRowEntry &operator*() const { return FRE; }
91-
92-
friend bool operator==(const FallibleFREIterator &LHS,
93-
const FallibleFREIterator &RHS) {
94-
assert(LHS.Data.data() == RHS.Data.data());
95-
assert(LHS.Data.size() == RHS.Data.size());
96-
assert(LHS.FREType == RHS.FREType);
97-
assert(LHS.Size == RHS.Size);
98-
return LHS.Idx == RHS.Idx;
99-
}
100-
101-
private:
102-
ArrayRef<uint8_t> Data;
103-
sframe::FREType FREType;
104-
uint32_t Idx;
105-
uint32_t Size;
106-
uint64_t Offset;
107-
FrameRowEntry FRE;
10857
};
10958

11059
extern template class LLVM_TEMPLATE_ABI SFrameParser<endianness::big>;

llvm/lib/BinaryFormat/SFrame.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,3 @@ ArrayRef<EnumEntry<sframe::FREOffset>> sframe::getFREOffsets() {
6868
};
6969
return ArrayRef(FREOffsets);
7070
}
71-
72-
ArrayRef<EnumEntry<sframe::BaseReg>> sframe::getBaseRegisters() {
73-
static constexpr EnumEntry<sframe::BaseReg> BaseRegs[] = {
74-
{"FP", sframe::BaseReg::FP},
75-
{"SP", sframe::BaseReg::SP},
76-
};
77-
return ArrayRef(BaseRegs);
78-
}

llvm/lib/Object/SFrameParser.cpp

Lines changed: 4 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,14 @@ getDataSlice(ArrayRef<uint8_t> Data, uint64_t Offset, uint64_t Size) {
3232
}
3333

3434
template <typename T>
35-
static Expected<ArrayRef<T>>
36-
getDataSliceAsArrayOf(ArrayRef<uint8_t> Data, uint64_t Offset, uint64_t Count) {
35+
static Expected<const T &> getDataSliceAs(ArrayRef<uint8_t> Data,
36+
uint64_t Offset) {
3737
static_assert(std::is_trivial_v<T>);
38-
Expected<ArrayRef<uint8_t>> Slice =
39-
getDataSlice(Data, Offset, sizeof(T) * Count);
38+
Expected<ArrayRef<uint8_t>> Slice = getDataSlice(Data, Offset, sizeof(T));
4039
if (!Slice)
4140
return Slice.takeError();
4241

43-
return ArrayRef(reinterpret_cast<const T *>(Slice->data()), Count);
44-
}
45-
46-
template <typename T>
47-
static Expected<const T &> getDataSliceAs(ArrayRef<uint8_t> Data,
48-
uint64_t Offset) {
49-
Expected<ArrayRef<T>> Array = getDataSliceAsArrayOf<T>(Data, Offset, 1);
50-
if (!Array)
51-
return Array.takeError();
52-
53-
return Array->front();
42+
return *reinterpret_cast<const T *>(Slice->data());
5443
}
5544

5645
template <endianness E>
@@ -111,119 +100,6 @@ uint64_t SFrameParser<E>::getAbsoluteStartAddress(
111100
return Result;
112101
}
113102

114-
template <typename EndianT>
115-
static Error readArray(ArrayRef<uint8_t> Data, uint64_t Count, uint64_t &Offset,
116-
SmallVectorImpl<int32_t> &Vec) {
117-
Expected<ArrayRef<EndianT>> RawArray =
118-
getDataSliceAsArrayOf<EndianT>(Data, Offset, Count);
119-
if (!RawArray)
120-
return RawArray.takeError();
121-
Offset += Count * sizeof(EndianT);
122-
Vec.resize(Count);
123-
llvm::copy(*RawArray, Vec.begin());
124-
return Error::success();
125-
}
126-
127-
template <typename T, endianness E>
128-
static Error readFRE(ArrayRef<uint8_t> Data, uint64_t &Offset,
129-
typename SFrameParser<E>::FrameRowEntry &FRE) {
130-
Expected<sframe::FrameRowEntry<T, E>> RawFRE =
131-
getDataSliceAs<sframe::FrameRowEntry<T, E>>(Data, Offset);
132-
if (!RawFRE)
133-
return RawFRE.takeError();
134-
135-
Offset += sizeof(*RawFRE);
136-
FRE.StartAddress = RawFRE->StartAddress;
137-
FRE.Info.Info = RawFRE->Info.Info;
138-
139-
switch (FRE.Info.getOffsetSize()) {
140-
case sframe::FREOffset::B1:
141-
return readArray<sframe::detail::packed<int8_t, E>>(
142-
Data, FRE.Info.getOffsetCount(), Offset, FRE.Offsets);
143-
case sframe::FREOffset::B2:
144-
return readArray<sframe::detail::packed<int16_t, E>>(
145-
Data, FRE.Info.getOffsetCount(), Offset, FRE.Offsets);
146-
case sframe::FREOffset::B4:
147-
return readArray<sframe::detail::packed<int32_t, E>>(
148-
Data, FRE.Info.getOffsetCount(), Offset, FRE.Offsets);
149-
default:
150-
return createError("unsupported/unknown offset size");
151-
}
152-
}
153-
154-
template <endianness E> Error SFrameParser<E>::FallibleFREIterator::inc() {
155-
if (++Idx == Size)
156-
return Error::success();
157-
158-
switch (FREType) {
159-
case sframe::FREType::Addr1:
160-
return readFRE<uint8_t, E>(Data, Offset, FRE);
161-
case sframe::FREType::Addr2:
162-
return readFRE<uint16_t, E>(Data, Offset, FRE);
163-
case sframe::FREType::Addr4:
164-
return readFRE<uint32_t, E>(Data, Offset, FRE);
165-
default:
166-
return createError("invalid/unsupported FRE type");
167-
}
168-
}
169-
170-
template <endianness E>
171-
iterator_range<typename SFrameParser<E>::fre_iterator>
172-
SFrameParser<E>::fres(const sframe::FuncDescEntry<E> &FDE, Error &Err) const {
173-
uint64_t Offset = getFREBase() + FDE.StartFREOff;
174-
fre_iterator BeforeBegin = make_fallible_itr(
175-
FallibleFREIterator(Data, FDE.getFREType(), -1, FDE.NumFREs, Offset),
176-
Err);
177-
fre_iterator End = make_fallible_end(
178-
FallibleFREIterator(Data, FDE.getFREType(), FDE.NumFREs, FDE.NumFREs,
179-
/*Offset=*/0));
180-
return {++BeforeBegin, End};
181-
}
182-
183-
static std::optional<int32_t> getOffset(ArrayRef<int32_t> Offsets, size_t Idx) {
184-
if (Offsets.size() > Idx)
185-
return Offsets[Idx];
186-
return std::nullopt;
187-
}
188-
189-
// The interpretation of offsets is ABI-specific. The implementation of this and
190-
// the following functions may need to be adjusted when adding support for a new
191-
// ABI.
192-
template <endianness E>
193-
std::optional<int32_t>
194-
SFrameParser<E>::getCFAOffset(const FrameRowEntry &FRE) const {
195-
return getOffset(FRE.Offsets, 0);
196-
}
197-
198-
template <endianness E>
199-
std::optional<int32_t>
200-
SFrameParser<E>::getRAOffset(const FrameRowEntry &FRE) const {
201-
if (usesFixedRAOffset())
202-
return Header.CFAFixedRAOffset;
203-
return getOffset(FRE.Offsets, 1);
204-
}
205-
206-
template <endianness E>
207-
std::optional<int32_t>
208-
SFrameParser<E>::getFPOffset(const FrameRowEntry &FRE) const {
209-
if (usesFixedFPOffset())
210-
return Header.CFAFixedFPOffset;
211-
return getOffset(FRE.Offsets, usesFixedRAOffset() ? 1 : 2);
212-
}
213-
214-
template <endianness E>
215-
ArrayRef<int32_t>
216-
SFrameParser<E>::getExtraOffsets(const FrameRowEntry &FRE) const {
217-
size_t UsedOffsets = 1; // CFA
218-
if (!usesFixedRAOffset())
219-
++UsedOffsets;
220-
if (!usesFixedFPOffset())
221-
++UsedOffsets;
222-
if (FRE.Offsets.size() > UsedOffsets)
223-
return ArrayRef(FRE.Offsets).drop_front(UsedOffsets);
224-
return {};
225-
}
226-
227103
template class LLVM_EXPORT_TEMPLATE llvm::object::SFrameParser<endianness::big>;
228104
template class LLVM_EXPORT_TEMPLATE
229105
llvm::object::SFrameParser<endianness::little>;

llvm/test/tools/llvm-readobj/ELF/sframe-fde.test

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ Sections:
108108
# CASE1-NEXT: }
109109
# CASE1-NEXT: Repetitive block size: 0xDE
110110
# CASE1-NEXT: Padding2: 0xAD
111-
# CASE1-NEXT: FREs [
112-
# CASE1-NEXT: ]
113111
# CASE1-NEXT: }
114112
# CASE1-NEXT: ]
115113
# CASE1-NEXT:}
@@ -171,8 +169,6 @@ Sections:
171169
# CASE1-NEXT: }
172170
# CASE1-NEXT: Repetitive block size (unused): 0xDE
173171
# CASE1-NEXT: Padding2: 0xAD
174-
# CASE1-NEXT: FREs [
175-
# CASE1-NEXT: ]
176172
# CASE1-NEXT: }
177173
# CASE1-NEXT: ]
178174
# CASE1-NEXT:}
@@ -200,7 +196,7 @@ Sections:
200196
0x00, 0xde, 0xad, 0x00, # Start Address
201197
0x00, 0x00, 0x01, 0xbe, # Size
202198
0x00, 0x00, 0x00, 0x10, # Start FRE Offset
203-
0x00, 0x00, 0x00, 0x00, # Number of FREs
199+
0x00, 0x00, 0x00, 0x10, # Number of FREs
204200
0x02, 0xde, 0xad, 0x00, # Info, RepSize, Padding2
205201
]
206202
# CASE2-LABEL:SFrame section '.sframe' {
@@ -227,7 +223,7 @@ Sections:
227223
# CASE2-NEXT: PC: 0xDEAD1C
228224
# CASE2-NEXT: Size: 0x1BE
229225
# CASE2-NEXT: Start FRE Offset: 0x10
230-
# CASE2-NEXT: Num FREs: 0
226+
# CASE2-NEXT: Num FREs: 16
231227
# CASE2-NEXT: Info {
232228
# CASE2-NEXT: FRE Type: Addr4 (0x2)
233229
# CASE2-NEXT: FDE Type: PCInc (0x0)
@@ -236,8 +232,6 @@ Sections:
236232
# CASE2-NEXT: }
237233
# CASE2-NEXT: Repetitive block size (unused): 0xDE
238234
# CASE2-NEXT: Padding2: 0xAD00
239-
# CASE2-NEXT: FREs [
240-
# CASE2-NEXT: ]
241235
# CASE2-NEXT: }
242236
# CASE2-NEXT: ]
243237
# CASE2-NEXT:}

0 commit comments

Comments
 (0)