LLVM  14.0.0git
SymbolSerializer.cpp
Go to the documentation of this file.
1 //===- SymbolSerializer.cpp -----------------------------------------------===//
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 
10 #include "llvm/ADT/ArrayRef.h"
12 #include "llvm/Support/Endian.h"
13 #include "llvm/Support/Error.h"
14 #include <cassert>
15 #include <cstdint>
16 #include <cstring>
17 
18 using namespace llvm;
19 using namespace llvm::codeview;
20 
22  CodeViewContainer Container)
23  : Storage(Allocator), Stream(RecordBuffer, support::little), Writer(Stream),
24  Mapping(Writer, Container) {}
25 
27  assert(!CurrentSymbol.hasValue() && "Already in a symbol mapping!");
28 
29  Writer.setOffset(0);
30 
31  if (auto EC = writeRecordPrefix(Record.kind()))
32  return EC;
33 
34  CurrentSymbol = Record.kind();
35  if (auto EC = Mapping.visitSymbolBegin(Record))
36  return EC;
37 
38  return Error::success();
39 }
40 
42  assert(CurrentSymbol.hasValue() && "Not in a symbol mapping!");
43 
44  if (auto EC = Mapping.visitSymbolEnd(Record))
45  return EC;
46 
47  uint32_t RecordEnd = Writer.getOffset();
48  uint16_t Length = RecordEnd - 2;
49  Writer.setOffset(0);
50  if (auto EC = Writer.writeInteger(Length))
51  return EC;
52 
53  uint8_t *StableStorage = Storage.Allocate<uint8_t>(RecordEnd);
54  ::memcpy(StableStorage, &RecordBuffer[0], RecordEnd);
55  Record.RecordData = ArrayRef<uint8_t>(StableStorage, RecordEnd);
56  CurrentSymbol.reset();
57 
58  return Error::success();
59 }
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::BinaryStreamWriter::writeInteger
Error writeInteger(T Value)
Write the integer Value to the underlying stream in the specified endianness.
Definition: BinaryStreamWriter.h:64
SymbolRecord.h
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
Error.h
llvm::BinaryStreamWriter::setOffset
void setOffset(uint64_t Off)
Definition: BinaryStreamWriter.h:183
llvm::codeview::SymbolSerializer::visitSymbolBegin
Error visitSymbolBegin(CVSymbol &Record) override
Definition: SymbolSerializer.cpp:26
llvm::Optional::hasValue
constexpr bool hasValue() const
Definition: Optional.h:288
llvm::BumpPtrAllocatorImpl::Allocate
LLVM_ATTRIBUTE_RETURNS_NONNULL LLVM_ATTRIBUTE_RETURNS_NOALIAS void * Allocate(size_t Size, Align Alignment)
Allocate space at the specified alignment.
Definition: Allocator.h:145
llvm::support::little
@ little
Definition: Endian.h:27
llvm::codeview::SymbolSerializer::visitSymbolEnd
Error visitSymbolEnd(CVSymbol &Record) override
Definition: SymbolSerializer.cpp:41
llvm::codeview::SymbolRecordMapping::visitSymbolEnd
Error visitSymbolEnd(CVSymbol &Record) override
Definition: SymbolRecordMapping.cpp:41
llvm::codeview::SymbolSerializer::SymbolSerializer
SymbolSerializer(BumpPtrAllocator &Storage, CodeViewContainer Container)
Definition: SymbolSerializer.cpp:21
llvm::Optional::reset
void reset()
Definition: Optional.h:278
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
ArrayRef.h
llvm::BinaryStreamWriter::getOffset
uint64_t getOffset() const
Definition: BinaryStreamWriter.h:184
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::codeview::CompileSym2Flags::EC
@ EC
SymbolSerializer.h
llvm::Record
Definition: Record.h:1472
llvm::codeview::SymbolRecordMapping::visitSymbolBegin
Error visitSymbolBegin(CVSymbol &Record) override
Definition: SymbolRecordMapping.cpp:36
llvm::ArrayRef< uint8_t >
llvm::codeview::CVRecord
CVRecord is a fat pointer (base + size pair) to a symbol or type record.
Definition: CVRecord.h:30
uint32_t
uint16_t
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::codeview
Definition: AppendingTypeTableBuilder.h:22
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:146
llvm::codeview::CodeViewContainer
CodeViewContainer
Definition: CodeView.h:607
support
Reimplement select in terms of SEL *We would really like to support but we need to prove that the add doesn t need to overflow between the two bit chunks *Implement pre post increment support(e.g. PR935) *Implement smarter const ant generation for binops with large immediates. A few ARMv6T2 ops should be pattern matched
Definition: README.txt:10
Endian.h