mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[debug-info] refactor emitDwarfUnitLength
remove `Hi` `Lo` argument from `emitDwarfUnitLength`, so we can make caller of emitDwarfUnitLength easier. Reviewed By: MaskRay, dblaikie, ikudrin Differential Revision: https://reviews.llvm.org/D96409
This commit is contained in:
parent
e6224a7a0c
commit
28da0778f7
@ -645,7 +645,8 @@ public:
|
|||||||
|
|
||||||
/// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
|
/// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
|
||||||
/// according to the settings.
|
/// according to the settings.
|
||||||
void emitDwarfUnitLength(const MCSymbol *Hi, const MCSymbol *Lo,
|
/// Return the end symbol generated inside, the caller needs to emit it.
|
||||||
|
MCSymbol *emitDwarfUnitLength(const Twine &Prefix,
|
||||||
const Twine &Comment) const;
|
const Twine &Comment) const;
|
||||||
|
|
||||||
/// Emit reference to a call site with a specified encoding
|
/// Emit reference to a call site with a specified encoding
|
||||||
|
@ -1089,7 +1089,8 @@ public:
|
|||||||
|
|
||||||
/// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
|
/// Emit a unit length field. The actual format, DWARF32 or DWARF64, is chosen
|
||||||
/// according to the settings.
|
/// according to the settings.
|
||||||
virtual void emitDwarfUnitLength(const MCSymbol *Hi, const MCSymbol *Lo,
|
/// Return the end symbol generated inside, the caller needs to emit it.
|
||||||
|
virtual MCSymbol *emitDwarfUnitLength(const Twine &Prefix,
|
||||||
const Twine &Comment);
|
const Twine &Comment);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
|
|||||||
: CompUnitCount(CompUnitCount), BucketCount(BucketCount),
|
: CompUnitCount(CompUnitCount), BucketCount(BucketCount),
|
||||||
NameCount(NameCount) {}
|
NameCount(NameCount) {}
|
||||||
|
|
||||||
void emit(const Dwarf5AccelTableWriter &Ctx) const;
|
void emit(Dwarf5AccelTableWriter &Ctx);
|
||||||
};
|
};
|
||||||
struct AttributeEncoding {
|
struct AttributeEncoding {
|
||||||
dwarf::Index Index;
|
dwarf::Index Index;
|
||||||
@ -216,8 +216,7 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
|
|||||||
DenseMap<uint32_t, SmallVector<AttributeEncoding, 2>> Abbreviations;
|
DenseMap<uint32_t, SmallVector<AttributeEncoding, 2>> Abbreviations;
|
||||||
ArrayRef<MCSymbol *> CompUnits;
|
ArrayRef<MCSymbol *> CompUnits;
|
||||||
llvm::function_ref<unsigned(const DataT &)> getCUIndexForEntry;
|
llvm::function_ref<unsigned(const DataT &)> getCUIndexForEntry;
|
||||||
MCSymbol *ContributionStart = Asm->createTempSymbol("names_start");
|
MCSymbol *ContributionEnd = nullptr;
|
||||||
MCSymbol *ContributionEnd = Asm->createTempSymbol("names_end");
|
|
||||||
MCSymbol *AbbrevStart = Asm->createTempSymbol("names_abbrev_start");
|
MCSymbol *AbbrevStart = Asm->createTempSymbol("names_abbrev_start");
|
||||||
MCSymbol *AbbrevEnd = Asm->createTempSymbol("names_abbrev_end");
|
MCSymbol *AbbrevEnd = Asm->createTempSymbol("names_abbrev_end");
|
||||||
MCSymbol *EntryPool = Asm->createTempSymbol("names_entries");
|
MCSymbol *EntryPool = Asm->createTempSymbol("names_entries");
|
||||||
@ -240,7 +239,7 @@ public:
|
|||||||
ArrayRef<MCSymbol *> CompUnits,
|
ArrayRef<MCSymbol *> CompUnits,
|
||||||
llvm::function_ref<unsigned(const DataT &)> GetCUIndexForEntry);
|
llvm::function_ref<unsigned(const DataT &)> GetCUIndexForEntry);
|
||||||
|
|
||||||
void emit() const;
|
void emit();
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -361,14 +360,12 @@ void AppleAccelTableWriter::emit() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename DataT>
|
template <typename DataT>
|
||||||
void Dwarf5AccelTableWriter<DataT>::Header::emit(
|
void Dwarf5AccelTableWriter<DataT>::Header::emit(Dwarf5AccelTableWriter &Ctx) {
|
||||||
const Dwarf5AccelTableWriter &Ctx) const {
|
|
||||||
assert(CompUnitCount > 0 && "Index must have at least one CU.");
|
assert(CompUnitCount > 0 && "Index must have at least one CU.");
|
||||||
|
|
||||||
AsmPrinter *Asm = Ctx.Asm;
|
AsmPrinter *Asm = Ctx.Asm;
|
||||||
Asm->emitDwarfUnitLength(Ctx.ContributionEnd, Ctx.ContributionStart,
|
Ctx.ContributionEnd =
|
||||||
"Header: unit length");
|
Asm->emitDwarfUnitLength("names", "Header: unit length");
|
||||||
Asm->OutStreamer->emitLabel(Ctx.ContributionStart);
|
|
||||||
Asm->OutStreamer->AddComment("Header: version");
|
Asm->OutStreamer->AddComment("Header: version");
|
||||||
Asm->emitInt16(Version);
|
Asm->emitInt16(Version);
|
||||||
Asm->OutStreamer->AddComment("Header: padding");
|
Asm->OutStreamer->AddComment("Header: padding");
|
||||||
@ -526,7 +523,7 @@ Dwarf5AccelTableWriter<DataT>::Dwarf5AccelTableWriter(
|
|||||||
Abbreviations.try_emplace(Tag, UniformAttributes);
|
Abbreviations.try_emplace(Tag, UniformAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emit() const {
|
template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emit() {
|
||||||
Header.emit(*this);
|
Header.emit(*this);
|
||||||
emitCUList();
|
emitCUList();
|
||||||
emitBuckets();
|
emitBuckets();
|
||||||
|
@ -25,12 +25,9 @@ unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
|
|||||||
|
|
||||||
MCSymbol *AddressPool::emitHeader(AsmPrinter &Asm, MCSection *Section) {
|
MCSymbol *AddressPool::emitHeader(AsmPrinter &Asm, MCSection *Section) {
|
||||||
static const uint8_t AddrSize = Asm.getDataLayout().getPointerSize();
|
static const uint8_t AddrSize = Asm.getDataLayout().getPointerSize();
|
||||||
StringRef Prefix = "debug_addr_";
|
|
||||||
MCSymbol *BeginLabel = Asm.createTempSymbol(Prefix + "start");
|
|
||||||
MCSymbol *EndLabel = Asm.createTempSymbol(Prefix + "end");
|
|
||||||
|
|
||||||
Asm.emitDwarfUnitLength(EndLabel, BeginLabel, "Length of contribution");
|
MCSymbol *EndLabel =
|
||||||
Asm.OutStreamer->emitLabel(BeginLabel);
|
Asm.emitDwarfUnitLength("debug_addr", "Length of contribution");
|
||||||
Asm.OutStreamer->AddComment("DWARF version number");
|
Asm.OutStreamer->AddComment("DWARF version number");
|
||||||
Asm.emitInt16(Asm.getDwarfVersion());
|
Asm.emitInt16(Asm.getDwarfVersion());
|
||||||
Asm.OutStreamer->AddComment("Address size");
|
Asm.OutStreamer->AddComment("Address size");
|
||||||
|
@ -203,9 +203,9 @@ void AsmPrinter::emitDwarfUnitLength(uint64_t Length,
|
|||||||
OutStreamer->emitDwarfUnitLength(Length, Comment);
|
OutStreamer->emitDwarfUnitLength(Length, Comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::emitDwarfUnitLength(const MCSymbol *Hi, const MCSymbol *Lo,
|
MCSymbol *AsmPrinter::emitDwarfUnitLength(const Twine &Prefix,
|
||||||
const Twine &Comment) const {
|
const Twine &Comment) const {
|
||||||
OutStreamer->emitDwarfUnitLength(Hi, Lo, Comment);
|
return OutStreamer->emitDwarfUnitLength(Prefix, Comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo,
|
void AsmPrinter::emitCallSiteOffset(const MCSymbol *Hi, const MCSymbol *Lo,
|
||||||
|
@ -2374,12 +2374,8 @@ void DwarfDebug::emitDebugPubSection(bool GnuStyle, StringRef Name,
|
|||||||
TheU = Skeleton;
|
TheU = Skeleton;
|
||||||
|
|
||||||
// Emit the header.
|
// Emit the header.
|
||||||
MCSymbol *BeginLabel = Asm->createTempSymbol("pub" + Name + "_begin");
|
MCSymbol *EndLabel = Asm->emitDwarfUnitLength(
|
||||||
MCSymbol *EndLabel = Asm->createTempSymbol("pub" + Name + "_end");
|
"pub" + Name, "Length of Public " + Name + " Info");
|
||||||
Asm->emitDwarfUnitLength(EndLabel, BeginLabel,
|
|
||||||
"Length of Public " + Name + " Info");
|
|
||||||
|
|
||||||
Asm->OutStreamer->emitLabel(BeginLabel);
|
|
||||||
|
|
||||||
Asm->OutStreamer->AddComment("DWARF Version");
|
Asm->OutStreamer->AddComment("DWARF Version");
|
||||||
Asm->emitInt16(dwarf::DW_PUBNAMES_VERSION);
|
Asm->emitInt16(dwarf::DW_PUBNAMES_VERSION);
|
||||||
|
@ -1701,13 +1701,10 @@ DIE *DwarfUnit::getOrCreateStaticMemberDIE(const DIDerivedType *DT) {
|
|||||||
|
|
||||||
void DwarfUnit::emitCommonHeader(bool UseOffsets, dwarf::UnitType UT) {
|
void DwarfUnit::emitCommonHeader(bool UseOffsets, dwarf::UnitType UT) {
|
||||||
// Emit size of content not including length itself
|
// Emit size of content not including length itself
|
||||||
if (!DD->useSectionsAsReferences()) {
|
if (!DD->useSectionsAsReferences())
|
||||||
StringRef Prefix = isDwoUnit() ? "debug_info_dwo_" : "debug_info_";
|
EndLabel = Asm->emitDwarfUnitLength(
|
||||||
MCSymbol *BeginLabel = Asm->createTempSymbol(Prefix + "start");
|
isDwoUnit() ? "debug_info_dwo" : "debug_info", "Length of Unit");
|
||||||
EndLabel = Asm->createTempSymbol(Prefix + "end");
|
else
|
||||||
Asm->emitDwarfUnitLength(EndLabel, BeginLabel, "Length of Unit");
|
|
||||||
Asm->OutStreamer->emitLabel(BeginLabel);
|
|
||||||
} else
|
|
||||||
Asm->emitDwarfUnitLength(getHeaderSize() + getUnitDie().getSize(),
|
Asm->emitDwarfUnitLength(getHeaderSize() + getUnitDie().getSize(),
|
||||||
"Length of Unit");
|
"Length of Unit");
|
||||||
|
|
||||||
|
@ -1006,12 +1006,19 @@ void MCStreamer::emitDwarfUnitLength(uint64_t Length, const Twine &Comment) {
|
|||||||
emitIntValue(Length, dwarf::getDwarfOffsetByteSize(Context.getDwarfFormat()));
|
emitIntValue(Length, dwarf::getDwarfOffsetByteSize(Context.getDwarfFormat()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::emitDwarfUnitLength(const MCSymbol *Hi, const MCSymbol *Lo,
|
MCSymbol *MCStreamer::emitDwarfUnitLength(const Twine &Prefix,
|
||||||
const Twine &Comment) {
|
const Twine &Comment) {
|
||||||
maybeEmitDwarf64Mark();
|
maybeEmitDwarf64Mark();
|
||||||
AddComment(Comment);
|
AddComment(Comment);
|
||||||
|
MCSymbol *Lo = Context.createTempSymbol(Prefix + "_start");
|
||||||
|
MCSymbol *Hi = Context.createTempSymbol(Prefix + "_end");
|
||||||
|
|
||||||
emitAbsoluteSymbolDiff(
|
emitAbsoluteSymbolDiff(
|
||||||
Hi, Lo, dwarf::getDwarfOffsetByteSize(Context.getDwarfFormat()));
|
Hi, Lo, dwarf::getDwarfOffsetByteSize(Context.getDwarfFormat()));
|
||||||
|
// emit the begin symbol after we generate the length field.
|
||||||
|
emitLabel(Lo);
|
||||||
|
// Return the Hi symbol to the caller.
|
||||||
|
return Hi;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
|
void MCStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
; Check that we get a symbol off of the debug_info section when using split dwarf and pubnames.
|
; Check that we get a symbol off of the debug_info section when using split dwarf and pubnames.
|
||||||
|
|
||||||
; CHECK: .LpubTypes_begin0:
|
; CHECK: .LpubTypes_start0:
|
||||||
; CHECK-NEXT: .short 2 # DWARF Version
|
; CHECK-NEXT: .short 2 # DWARF Version
|
||||||
; CHECK-NEXT: .long .Lcu_begin0 # Offset of Compilation Unit Info
|
; CHECK-NEXT: .long .Lcu_begin0 # Offset of Compilation Unit Info
|
||||||
|
|
||||||
|
@ -50,19 +50,21 @@ protected:
|
|||||||
if (!AsmPrinterFixtureBase::init(TripleStr, DwarfVersion, DwarfFormat))
|
if (!AsmPrinterFixtureBase::init(TripleStr, DwarfVersion, DwarfFormat))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create a symbol which will be emitted in the tests and associate it
|
// AsmPrinter::emitDwarfSymbolReference(Label, true) gets the associated
|
||||||
// with a section because that is required in some code paths.
|
// section from `Label` to find its BeginSymbol.
|
||||||
|
// Prepare the test symbol `Val` accordingly.
|
||||||
|
|
||||||
Val = TestPrinter->getCtx().createTempSymbol();
|
Val = TestPrinter->getCtx().createTempSymbol();
|
||||||
Sec = TestPrinter->getCtx().getELFSection(".tst", ELF::SHT_PROGBITS, 0);
|
MCSection *Sec =
|
||||||
|
TestPrinter->getCtx().getELFSection(".tst", ELF::SHT_PROGBITS, 0);
|
||||||
SecBeginSymbol = Sec->getBeginSymbol();
|
SecBeginSymbol = Sec->getBeginSymbol();
|
||||||
TestPrinter->getMS().SwitchSection(Sec);
|
TestPrinter->getMS().SwitchSection(Sec);
|
||||||
TestPrinter->getMS().emitLabel(Val);
|
Val->setFragment(&Sec->getDummyFragment());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *Val = nullptr;
|
MCSymbol *Val = nullptr;
|
||||||
MCSection *Sec = nullptr;
|
|
||||||
MCSymbol *SecBeginSymbol = nullptr;
|
MCSymbol *SecBeginSymbol = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -326,21 +328,28 @@ protected:
|
|||||||
if (!AsmPrinterFixtureBase::init(TripleStr, DwarfVersion, DwarfFormat))
|
if (!AsmPrinterFixtureBase::init(TripleStr, DwarfVersion, DwarfFormat))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Hi = TestPrinter->getCtx().createTempSymbol();
|
|
||||||
Lo = TestPrinter->getCtx().createTempSymbol();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCSymbol *Hi = nullptr;
|
|
||||||
MCSymbol *Lo = nullptr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(AsmPrinterEmitDwarfUnitLengthAsHiLoDiffTest, DWARF32) {
|
TEST_F(AsmPrinterEmitDwarfUnitLengthAsHiLoDiffTest, DWARF32) {
|
||||||
if (!init("x86_64-pc-linux", /*DwarfVersion=*/4, dwarf::DWARF32))
|
if (!init("x86_64-pc-linux", /*DwarfVersion=*/4, dwarf::DWARF32))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
EXPECT_CALL(TestPrinter->getMS(), emitAbsoluteSymbolDiff(Hi, Lo, 4));
|
InSequence S;
|
||||||
TestPrinter->getAP()->emitDwarfUnitLength(Hi, Lo, "");
|
const MCSymbol *Hi = nullptr;
|
||||||
|
const MCSymbol *Lo = nullptr;
|
||||||
|
EXPECT_CALL(TestPrinter->getMS(), emitAbsoluteSymbolDiff(_, _, 4))
|
||||||
|
.WillOnce(DoAll(SaveArg<0>(&Hi), SaveArg<1>(&Lo)));
|
||||||
|
MCSymbol *LTmp = nullptr;
|
||||||
|
EXPECT_CALL(TestPrinter->getMS(), emitLabel(_, _))
|
||||||
|
.WillOnce(SaveArg<0>(<mp));
|
||||||
|
|
||||||
|
MCSymbol *HTmp = TestPrinter->getAP()->emitDwarfUnitLength("", "");
|
||||||
|
EXPECT_NE(Lo, nullptr);
|
||||||
|
EXPECT_EQ(Lo, LTmp);
|
||||||
|
EXPECT_NE(Hi, nullptr);
|
||||||
|
EXPECT_EQ(Hi, HTmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(AsmPrinterEmitDwarfUnitLengthAsHiLoDiffTest, DWARF64) {
|
TEST_F(AsmPrinterEmitDwarfUnitLengthAsHiLoDiffTest, DWARF64) {
|
||||||
@ -348,10 +357,20 @@ TEST_F(AsmPrinterEmitDwarfUnitLengthAsHiLoDiffTest, DWARF64) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
InSequence S;
|
InSequence S;
|
||||||
|
const MCSymbol *Hi = nullptr;
|
||||||
|
const MCSymbol *Lo = nullptr;
|
||||||
EXPECT_CALL(TestPrinter->getMS(), emitIntValue(dwarf::DW_LENGTH_DWARF64, 4));
|
EXPECT_CALL(TestPrinter->getMS(), emitIntValue(dwarf::DW_LENGTH_DWARF64, 4));
|
||||||
EXPECT_CALL(TestPrinter->getMS(), emitAbsoluteSymbolDiff(Hi, Lo, 8));
|
EXPECT_CALL(TestPrinter->getMS(), emitAbsoluteSymbolDiff(_, _, 8))
|
||||||
|
.WillOnce(DoAll(SaveArg<0>(&Hi), SaveArg<1>(&Lo)));
|
||||||
|
MCSymbol *LTmp = nullptr;
|
||||||
|
EXPECT_CALL(TestPrinter->getMS(), emitLabel(_, _))
|
||||||
|
.WillOnce(SaveArg<0>(<mp));
|
||||||
|
|
||||||
TestPrinter->getAP()->emitDwarfUnitLength(Hi, Lo, "");
|
MCSymbol *HTmp = TestPrinter->getAP()->emitDwarfUnitLength("", "");
|
||||||
|
EXPECT_NE(Lo, nullptr);
|
||||||
|
EXPECT_EQ(Lo, LTmp);
|
||||||
|
EXPECT_NE(Hi, nullptr);
|
||||||
|
EXPECT_EQ(Hi, HTmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsmPrinterHandlerTest : public AsmPrinterFixtureBase {
|
class AsmPrinterHandlerTest : public AsmPrinterFixtureBase {
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
|
|
||||||
// The following are mock methods to be used in tests.
|
// The following are mock methods to be used in tests.
|
||||||
|
|
||||||
|
MOCK_METHOD2(emitLabel, void(MCSymbol *Symbol, SMLoc Loc));
|
||||||
MOCK_METHOD2(emitIntValue, void(uint64_t Value, unsigned Size));
|
MOCK_METHOD2(emitIntValue, void(uint64_t Value, unsigned Size));
|
||||||
MOCK_METHOD3(emitValueImpl,
|
MOCK_METHOD3(emitValueImpl,
|
||||||
void(const MCExpr *Value, unsigned Size, SMLoc Loc));
|
void(const MCExpr *Value, unsigned Size, SMLoc Loc));
|
||||||
|
Loading…
Reference in New Issue
Block a user