-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RemoveDIs][NFC] Add DPLabel class [2/3] #82376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -292,8 +292,8 @@ static const Module *getModuleFromDPI(const DPMarker *Marker) { | |
return M ? M->getParent() : nullptr; | ||
} | ||
|
||
static const Module *getModuleFromDPI(const DPValue *DPV) { | ||
return DPV->getMarker() ? getModuleFromDPI(DPV->getMarker()) : nullptr; | ||
static const Module *getModuleFromDPI(const DbgRecord *DR) { | ||
return DR->getMarker() ? getModuleFromDPI(DR->getMarker()) : nullptr; | ||
} | ||
|
||
static void PrintCallingConv(unsigned cc, raw_ostream &Out) { | ||
|
@@ -2676,6 +2676,7 @@ class AssemblyWriter { | |
void printInstruction(const Instruction &I); | ||
void printDPMarker(const DPMarker &DPI); | ||
void printDPValue(const DPValue &DPI); | ||
void printDPLabel(const DPLabel &DPL); | ||
void printDbgRecord(const DbgRecord &DPI); | ||
|
||
void printUseListOrder(const Value *V, const std::vector<unsigned> &Shuffle); | ||
|
@@ -4580,7 +4581,7 @@ void AssemblyWriter::printDbgRecord(const DbgRecord &DR) { | |
if (auto *DPV = dyn_cast<DPValue>(&DR)) | ||
printDPValue(*DPV); | ||
else | ||
llvm_unreachable("unsupported dbg record"); | ||
printDPLabel(cast<DPLabel>(DR)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the risk of being a pain, should we make this an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cast would catch that, but I can do so if you'd prefer. The unreachable has a nicer error message than cast failure (and is what I've done elsewhere). Wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd prefer the unreachable, since it's clearer and more consistent with the approach elsewhere - imo at least. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I said I'd done the unreachable approach elsewhere, but I've actually done a mix (in future patches) of whatever looks right at the site. I'll go with unreachable here as there's not much in it, but I might push back against this pattern in the next patches - in some cases it's much cleaner to just cast (imo), but we can discuss that in those patches! |
||
} | ||
|
||
void AssemblyWriter::printDPValue(const DPValue &Value) { | ||
|
@@ -4622,6 +4623,16 @@ void AssemblyWriter::printDPValue(const DPValue &Value) { | |
Out << " }"; | ||
} | ||
|
||
void AssemblyWriter::printDPLabel(const DPLabel &Label) { | ||
// There's no formal representation of a DPLabel -- print purely as | ||
// a debugging aid. | ||
Out << " DPLabel { "; | ||
auto WriterCtx = getContext(); | ||
WriteAsOperandInternal(Out, Label.getLabel(), WriterCtx, true); | ||
Out << " marker @" << Label.getMarker(); | ||
Out << " }"; | ||
} | ||
|
||
void AssemblyWriter::printMetadataAttachments( | ||
const SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs, | ||
StringRef Separator) { | ||
|
@@ -4885,6 +4896,12 @@ void DPMarker::print(raw_ostream &ROS, ModuleSlotTracker &MST, | |
W.printDPMarker(*this); | ||
} | ||
|
||
void DPLabel::print(raw_ostream &ROS, bool IsForDebug) const { | ||
|
||
ModuleSlotTracker MST(getModuleFromDPI(this), true); | ||
print(ROS, MST, IsForDebug); | ||
} | ||
|
||
void DPValue::print(raw_ostream &ROS, ModuleSlotTracker &MST, | ||
bool IsForDebug) const { | ||
// There's no formal representation of a DPValue -- print purely as a | ||
|
@@ -4904,6 +4921,24 @@ void DPValue::print(raw_ostream &ROS, ModuleSlotTracker &MST, | |
W.printDPValue(*this); | ||
} | ||
|
||
void DPLabel::print(raw_ostream &ROS, ModuleSlotTracker &MST, | ||
bool IsForDebug) const { | ||
// There's no formal representation of a DbgLabelRecord -- print purely as | ||
// a debugging aid. | ||
formatted_raw_ostream OS(ROS); | ||
SlotTracker EmptySlotTable(static_cast<const Module *>(nullptr)); | ||
SlotTracker &SlotTable = | ||
MST.getMachine() ? *MST.getMachine() : EmptySlotTable; | ||
auto incorporateFunction = [&](const Function *F) { | ||
if (F) | ||
MST.incorporateFunction(*F); | ||
}; | ||
incorporateFunction(Marker->getParent() ? Marker->getParent()->getParent() | ||
: nullptr); | ||
AssemblyWriter W(OS, SlotTable, getModuleFromDPI(this), nullptr, IsForDebug); | ||
W.printDPLabel(*this); | ||
} | ||
|
||
void Value::print(raw_ostream &ROS, bool IsForDebug) const { | ||
bool ShouldInitializeAllMetadata = false; | ||
if (auto *I = dyn_cast<Instruction>(this)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
printDbgRecord
should be updated to call through toprintDPLabel
, right?