Skip to content

Commit 70a75ef

Browse files
Nestedv1 also splits debug_abbrev and debug_info blocks properly
1 parent b4b1103 commit 70a75ef

File tree

6 files changed

+349
-81
lines changed

6 files changed

+349
-81
lines changed

llvm/include/llvm/CASObjectFormats/NestedV1.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,10 @@ class BlockDataRef : public SpecificRef<BlockDataRef> {
273273
uint64_t AlignmentOffset,
274274
ArrayRef<Fixup> Fixups);
275275

276-
static Expected<BlockDataRef> createContent(const ObjectFileSchema &Schema,
277-
StringRef Content,
278-
uint64_t Alignment,
279-
uint64_t AlignmentOffset,
280-
ArrayRef<Fixup> Fixups);
276+
static Expected<BlockDataRef>
277+
createContent(const ObjectFileSchema &Schema, StringRef Content,
278+
uint64_t Alignment, uint64_t AlignmentOffset,
279+
ArrayRef<Fixup> Fixups, bool IsDebugInfoBlock = false);
281280

282281
static Expected<BlockDataRef> create(const ObjectFileSchema &Schema,
283282
const jitlink::Block &Block,
@@ -288,11 +287,10 @@ class BlockDataRef : public SpecificRef<BlockDataRef> {
288287
explicit BlockDataRef(SpecificRefT Ref, data::BlockData Data)
289288
: SpecificRefT(Ref), Data(Data) {}
290289

291-
static Expected<BlockDataRef> createImpl(const ObjectFileSchema &Schema,
292-
Optional<StringRef> Content,
293-
uint64_t Size, uint64_t Alignment,
294-
uint64_t AlignmentOffset,
295-
ArrayRef<Fixup> Fixups);
290+
static Expected<BlockDataRef>
291+
createImpl(const ObjectFileSchema &Schema, Optional<StringRef> Content,
292+
uint64_t Size, uint64_t Alignment, uint64_t AlignmentOffset,
293+
ArrayRef<Fixup> Fixups, bool IsDebugInfoBlock = false);
296294
};
297295

298296
/// A variant of SymbolRef and IndirectSymbolRef. The kind is cached.
@@ -521,7 +519,8 @@ class BlockRef : public SpecificRef<BlockRef> {
521519
static Expected<BlockRef>
522520
create(const ObjectFileSchema &Schema, const jitlink::Block &Block,
523521
function_ref<Expected<Optional<TargetRef>>(const jitlink::Symbol &)>
524-
GetTargetRef);
522+
GetTargetRef,
523+
cas::CASID *AbbrevID = nullptr);
525524

526525
static Expected<BlockRef> create(const ObjectFileSchema &Schema,
527526
SectionRef Section, BlockDataRef Data) {
@@ -535,7 +534,7 @@ class BlockRef : public SpecificRef<BlockRef> {
535534
return createImpl(Schema, Section, Data, TargetInfo, Targets, Fixups);
536535
}
537536

538-
static Expected<BlockRef> get(Expected<ObjectFormatObjectProxy> Ref);
537+
static Expected<BlockRef> get(Expected<ObjectFormatObjectProxy> Ref, bool IsDebugInfoBlock = false);
539538
static Expected<BlockRef> get(const ObjectFileSchema &Schema,
540539
cas::ObjectRef ID) {
541540
return get(Schema.get(ID));
@@ -558,11 +557,11 @@ class BlockRef : public SpecificRef<BlockRef> {
558557

559558
explicit BlockRef(SpecificRefT Ref) : SpecificRefT(Ref) {}
560559

561-
static Expected<BlockRef> createImpl(const ObjectFileSchema &Schema,
562-
SectionRef Section, BlockDataRef Data,
563-
ArrayRef<TargetInfo> TargetInfo,
564-
ArrayRef<TargetRef> Targets,
565-
ArrayRef<Fixup> Fixups);
560+
static Expected<BlockRef>
561+
createImpl(const ObjectFileSchema &Schema, SectionRef Section,
562+
BlockDataRef Data, ArrayRef<TargetInfo> TargetInfo,
563+
ArrayRef<TargetRef> Targets, ArrayRef<Fixup> Fixups,
564+
cas::CASID *AbbrevID = nullptr, bool IsDebugInfoBlock = false);
566565
};
567566

568567
/// A symbol.
@@ -693,7 +692,8 @@ class SymbolRef : public SpecificRef<SymbolRef> {
693692
static Expected<SymbolRef> create(const ObjectFileSchema &Schema,
694693
Optional<NameRef> SymbolName,
695694
SymbolDefinitionRef Definition,
696-
uint64_t Offset, Flags F);
695+
uint64_t Offset, Flags F,
696+
bool IsDebugInfoSymbol = false);
697697

698698
static Expected<SymbolRef>
699699
create(const ObjectFileSchema &Schema, const jitlink::Symbol &S,

llvm/lib/CASObjectFormats/FlatV1.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,12 @@ Expected<BlockRef> BlockRef::create(CompileUnitBuilder &CUB,
327327
if (!B)
328328
return B.takeError();
329329

330-
bool IsDebugInfoBlock = false;
331330
// If we are creating a cas block out of a debug_info jitlink::Block, add the
332331
// debug_abbrev cas block CAS ID as a refrence
333332
if (Block.getSection().getName() == "__DWARF,__debug_info") {
333+
assert(AbbrevID &&
334+
"The CAS ID for the abbrev section shouldn't be nullptr");
334335
B->IDs.push_back(*AbbrevID);
335-
IsDebugInfoBlock = true;
336336
}
337337

338338
// Encode Section.
@@ -376,9 +376,10 @@ Expected<BlockRef> BlockRef::create(CompileUnitBuilder &CUB,
376376
BlockSize = Content->size();
377377
}
378378
SmallString<1024> EncodeContent;
379-
data::BlockData::encode(BlockSize, Block.getAlignment(),
380-
Block.getAlignmentOffset(), Content, Fixups,
381-
EncodeContent, IsDebugInfoBlock);
379+
data::BlockData::encode(
380+
BlockSize, Block.getAlignment(), Block.getAlignmentOffset(), Content,
381+
Fixups, EncodeContent,
382+
Block.getSection().getName() == "__DWARF,__debug_info");
382383

383384
StringRef BlockData(EncodeContent);
384385
// Encode content first with size and data.

0 commit comments

Comments
 (0)