LLVM 20.0.0git
MergedFunctionsInfo.cpp
Go to the documentation of this file.
1//===- MergedFunctionsInfo.cpp ----------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
13
14using namespace llvm;
15using namespace gsym;
16
18
20 Out.writeU32(MergedFunctions.size());
21 for (const auto &F : MergedFunctions) {
22 Out.writeU32(0);
23 const auto StartOffset = Out.tell();
24 // Encode the FunctionInfo with no padding so later we can just read them
25 // one after the other without knowing the offset in the stream for each.
26 llvm::Expected<uint64_t> result = F.encode(Out, /*NoPadding =*/true);
27 if (!result)
28 return result.takeError();
29 const auto Length = Out.tell() - StartOffset;
30 Out.fixup32(static_cast<uint32_t>(Length), StartOffset - 4);
31 }
32 return Error::success();
33}
34
38 uint64_t Offset = 0;
39 uint32_t Count = Data.getU32(&Offset);
40
41 for (uint32_t i = 0; i < Count; ++i) {
42 uint32_t FnSize = Data.getU32(&Offset);
43 DataExtractor FnData(Data.getData().substr(Offset, FnSize),
44 Data.isLittleEndian(), Data.getAddressSize());
46 FunctionInfo::decode(FnData, BaseAddr + Offset);
47 if (!FI)
48 return FI.takeError();
49 MFI.MergedFunctions.push_back(std::move(*FI));
50 Offset += FnSize;
51 }
52
53 return MFI;
54}
55
57 const MergedFunctionsInfo &RHS) {
58 return LHS.MergedFunctions == RHS.MergedFunctions;
59}
#define F(x, y, z)
Definition: MD5.cpp:55
Value * RHS
Value * LHS
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
Tagged union holding either a T or a Error.
Definition: Error.h:481
Error takeError()
Take ownership of the stored error.
Definition: Error.h:608
A simplified binary data writer class that doesn't require targets, target definitions,...
Definition: FileWriter.h:29
uint64_t tell()
Return the current offset within the file.
Definition: FileWriter.cpp:66
void fixup32(uint32_t Value, uint64_t Offset)
Fixup a uint32_t value at the specified offset in the stream.
Definition: FileWriter.cpp:52
void writeU32(uint32_t Value)
Write a single uint32_t value into the stream at the current file position.
Definition: FileWriter.cpp:42
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
@ Length
Definition: DWP.cpp:480
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
static llvm::Expected< FunctionInfo > decode(DataExtractor &Data, uint64_t BaseAddr)
Decode an object from a binary data stream.
static llvm::Expected< MergedFunctionsInfo > decode(DataExtractor &Data, uint64_t BaseAddr)
Decode an MergedFunctionsInfo object from a binary data stream.
llvm::Error encode(FileWriter &O) const
Encode this MergedFunctionsInfo object into FileWriter stream.
std::vector< FunctionInfo > MergedFunctions