@@ -861,7 +861,7 @@ class SlotTracker : public AbstractSlotTrackerStorage {
861
861
// / Add all of the metadata from an instruction.
862
862
void processInstructionMetadata (const Instruction &I);
863
863
864
- // / Add all of the metadata from a DbgRecord .
864
+ // / Add all of the metadata from an instruction .
865
865
void processDbgRecordMetadata (const DbgRecord &DPV);
866
866
};
867
867
@@ -1140,9 +1140,6 @@ void SlotTracker::processFunctionMetadata(const Function &F) {
1140
1140
1141
1141
void SlotTracker::processDbgRecordMetadata (const DbgRecord &DR) {
1142
1142
if (const DPValue *DPV = dyn_cast<const DPValue>(&DR)) {
1143
- // Process metadata used by DbgRecords; we only specifically care about the
1144
- // DILocalVariable, DILocation, and DIAssignID fields, as the Value and
1145
- // Expression fields should only be printed inline and so do not use a slot.
1146
1143
CreateMetadataSlot (DPV->getVariable ());
1147
1144
if (DPV->isDbgAssign ())
1148
1145
CreateMetadataSlot (DPV->getAssignID ());
@@ -2706,7 +2703,6 @@ class AssemblyWriter {
2706
2703
void printDPValue (const DPValue &DPI);
2707
2704
void printDPLabel (const DPLabel &DPL);
2708
2705
void printDbgRecord (const DbgRecord &DPI);
2709
- void printDbgRecordLine (const DbgRecord &DPI);
2710
2706
2711
2707
void printUseListOrder (const Value *V, const std::vector<unsigned > &Shuffle);
2712
2708
void printUseLists (const Function *F);
@@ -3889,6 +3885,9 @@ void AssemblyWriter::printTypeIdentities() {
3889
3885
3890
3886
// / printFunction - Print all aspects of a function.
3891
3887
void AssemblyWriter::printFunction (const Function *F) {
3888
+ bool ConvertBack = F->IsNewDbgInfoFormat ;
3889
+ if (ConvertBack)
3890
+ const_cast <Function *>(F)->convertFromNewDbgValues ();
3892
3891
if (AnnotationWriter) AnnotationWriter->emitFunctionAnnot (F, Out);
3893
3892
3894
3893
if (F->isMaterializable ())
@@ -4031,6 +4030,8 @@ void AssemblyWriter::printFunction(const Function *F) {
4031
4030
Out << " }\n " ;
4032
4031
}
4033
4032
4033
+ if (ConvertBack)
4034
+ const_cast <Function *>(F)->convertToNewDbgValues ();
4034
4035
Machine.purgeFunction ();
4035
4036
}
4036
4037
@@ -4097,8 +4098,6 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
4097
4098
4098
4099
// Output all of the instructions in the basic block...
4099
4100
for (const Instruction &I : *BB) {
4100
- for (const DbgRecord &DR : I.getDbgValueRange ())
4101
- printDbgRecordLine (DR);
4102
4101
printInstructionLine (I);
4103
4102
}
4104
4103
@@ -4612,10 +4611,12 @@ void AssemblyWriter::printDbgRecord(const DbgRecord &DR) {
4612
4611
llvm_unreachable (" Unexpected DbgRecord kind" );
4613
4612
}
4614
4613
4615
- void AssemblyWriter::printDPValue (const DPValue &DPV) {
4616
- auto WriterCtx = getContext ();
4617
- Out << " #dbg_" ;
4618
- switch (DPV.getType ()) {
4614
+ void AssemblyWriter::printDPValue (const DPValue &Value) {
4615
+ // There's no formal representation of a DPValue -- print purely as a
4616
+ // debugging aid.
4617
+ Out << " DPValue " ;
4618
+
4619
+ switch (Value.getType ()) {
4619
4620
case DPValue::LocationType::Value:
4620
4621
Out << " value" ;
4621
4622
break ;
@@ -4628,39 +4629,35 @@ void AssemblyWriter::printDPValue(const DPValue &DPV) {
4628
4629
default :
4629
4630
llvm_unreachable (" Tried to print a DPValue with an invalid LocationType!" );
4630
4631
}
4631
- Out << " (" ;
4632
- WriteAsOperandInternal (Out, DPV.getRawLocation (), WriterCtx, true );
4632
+ Out << " { " ;
4633
+ auto WriterCtx = getContext ();
4634
+ WriteAsOperandInternal (Out, Value.getRawLocation (), WriterCtx, true );
4633
4635
Out << " , " ;
4634
- WriteAsOperandInternal (Out, DPV .getVariable (), WriterCtx, true );
4636
+ WriteAsOperandInternal (Out, Value .getVariable (), WriterCtx, true );
4635
4637
Out << " , " ;
4636
- WriteAsOperandInternal (Out, DPV .getExpression (), WriterCtx, true );
4638
+ WriteAsOperandInternal (Out, Value .getExpression (), WriterCtx, true );
4637
4639
Out << " , " ;
4638
- if (DPV .isDbgAssign ()) {
4639
- WriteAsOperandInternal (Out, DPV .getAssignID (), WriterCtx, true );
4640
+ if (Value .isDbgAssign ()) {
4641
+ WriteAsOperandInternal (Out, Value .getAssignID (), WriterCtx, true );
4640
4642
Out << " , " ;
4641
- WriteAsOperandInternal (Out, DPV .getRawAddress (), WriterCtx, true );
4643
+ WriteAsOperandInternal (Out, Value .getRawAddress (), WriterCtx, true );
4642
4644
Out << " , " ;
4643
- WriteAsOperandInternal (Out, DPV .getAddressExpression (), WriterCtx, true );
4645
+ WriteAsOperandInternal (Out, Value .getAddressExpression (), WriterCtx, true );
4644
4646
Out << " , " ;
4645
4647
}
4646
- WriteAsOperandInternal (Out, DPV.getDebugLoc ().getAsMDNode (), WriterCtx, true );
4647
- Out << " )" ;
4648
- }
4649
-
4650
- // / printDbgRecordLine - Print a DbgRecord with indentation and a newline
4651
- // / character.
4652
- void AssemblyWriter::printDbgRecordLine (const DbgRecord &DR) {
4653
- // Print lengthier indentation to bring out-of-line with instructions.
4654
- Out << " " ;
4655
- printDbgRecord (DR);
4656
- Out << ' \n ' ;
4648
+ WriteAsOperandInternal (Out, Value.getDebugLoc ().get (), WriterCtx, true );
4649
+ Out << " marker @" << Value.getMarker ();
4650
+ Out << " }" ;
4657
4651
}
4658
4652
4659
4653
void AssemblyWriter::printDPLabel (const DPLabel &Label) {
4654
+ // There's no formal representation of a DPLabel -- print purely as
4655
+ // a debugging aid.
4656
+ Out << " DPLabel { " ;
4660
4657
auto WriterCtx = getContext ();
4661
- Out << " #dbg_label(" ;
4662
4658
WriteAsOperandInternal (Out, Label.getLabel (), WriterCtx, true );
4663
- Out << " )" ;
4659
+ Out << " marker @" << Label.getMarker ();
4660
+ Out << " }" ;
4664
4661
}
4665
4662
4666
4663
void AssemblyWriter::printMetadataAttachments (
@@ -4808,11 +4805,19 @@ void BasicBlock::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW,
4808
4805
4809
4806
void Module::print (raw_ostream &ROS, AssemblyAnnotationWriter *AAW,
4810
4807
bool ShouldPreserveUseListOrder, bool IsForDebug) const {
4808
+ // RemoveDIs: always print with debug-info in intrinsic format.
4809
+ bool ConvertAfter = IsNewDbgInfoFormat;
4810
+ if (IsNewDbgInfoFormat)
4811
+ const_cast <Module *>(this )->convertFromNewDbgValues ();
4812
+
4811
4813
SlotTracker SlotTable (this );
4812
4814
formatted_raw_ostream OS (ROS);
4813
4815
AssemblyWriter W (OS, SlotTable, this , AAW, IsForDebug,
4814
4816
ShouldPreserveUseListOrder);
4815
4817
W.printModule (this );
4818
+
4819
+ if (ConvertAfter)
4820
+ const_cast <Module *>(this )->convertToNewDbgValues ();
4816
4821
}
4817
4822
4818
4823
void NamedMDNode::print (raw_ostream &ROS, bool IsForDebug) const {
@@ -4903,6 +4908,8 @@ void DPValue::print(raw_ostream &ROS, bool IsForDebug) const {
4903
4908
4904
4909
void DPMarker::print (raw_ostream &ROS, ModuleSlotTracker &MST,
4905
4910
bool IsForDebug) const {
4911
+ // There's no formal representation of a DPMarker -- print purely as a
4912
+ // debugging aid.
4906
4913
formatted_raw_ostream OS (ROS);
4907
4914
SlotTracker EmptySlotTable (static_cast <const Module *>(nullptr ));
4908
4915
SlotTracker &SlotTable =
@@ -4924,6 +4931,8 @@ void DPLabel::print(raw_ostream &ROS, bool IsForDebug) const {
4924
4931
4925
4932
void DPValue::print (raw_ostream &ROS, ModuleSlotTracker &MST,
4926
4933
bool IsForDebug) const {
4934
+ // There's no formal representation of a DPValue -- print purely as a
4935
+ // debugging aid.
4927
4936
formatted_raw_ostream OS (ROS);
4928
4937
SlotTracker EmptySlotTable (static_cast <const Module *>(nullptr ));
4929
4938
SlotTracker &SlotTable =
@@ -4941,6 +4950,8 @@ void DPValue::print(raw_ostream &ROS, ModuleSlotTracker &MST,
4941
4950
4942
4951
void DPLabel::print (raw_ostream &ROS, ModuleSlotTracker &MST,
4943
4952
bool IsForDebug) const {
4953
+ // There's no formal representation of a DbgLabelRecord -- print purely as
4954
+ // a debugging aid.
4944
4955
formatted_raw_ostream OS (ROS);
4945
4956
SlotTracker EmptySlotTable (static_cast <const Module *>(nullptr ));
4946
4957
SlotTracker &SlotTable =
0 commit comments