@@ -99,9 +99,6 @@ namespace llvm {
99
99
extern FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold;
100
100
}
101
101
102
- extern bool WriteNewDbgInfoFormatToBitcode;
103
- extern llvm::cl::opt<bool > UseNewDbgInfoFormat;
104
-
105
102
namespace {
106
103
107
104
// / These are manifest constants used by the bitcode writer. They do not need to
@@ -131,7 +128,6 @@ enum {
131
128
FUNCTION_INST_RET_VAL_ABBREV,
132
129
FUNCTION_INST_UNREACHABLE_ABBREV,
133
130
FUNCTION_INST_GEP_ABBREV,
134
- FUNCTION_DEBUG_RECORD_VALUE_ABBREV,
135
131
};
136
132
137
133
// / Abstract class to manage the bitcode writing, subclassed for each bitcode
@@ -3516,95 +3512,25 @@ void ModuleBitcodeWriter::writeFunction(
3516
3512
NeedsMetadataAttachment |= I.hasMetadataOtherThanDebugLoc ();
3517
3513
3518
3514
// If the instruction has a debug location, emit it.
3519
- if (DILocation *DL = I.getDebugLoc ()) {
3520
- if (DL == LastDL) {
3521
- // Just repeat the same debug loc as last time.
3522
- Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_LOC_AGAIN, Vals);
3523
- } else {
3524
- Vals.push_back (DL->getLine ());
3525
- Vals.push_back (DL->getColumn ());
3526
- Vals.push_back (VE.getMetadataOrNullID (DL->getScope ()));
3527
- Vals.push_back (VE.getMetadataOrNullID (DL->getInlinedAt ()));
3528
- Vals.push_back (DL->isImplicitCode ());
3529
- Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_LOC, Vals);
3530
- Vals.clear ();
3531
- LastDL = DL;
3532
- }
3533
- }
3515
+ DILocation *DL = I.getDebugLoc ();
3516
+ if (!DL)
3517
+ continue ;
3534
3518
3535
- // If the instruction has DbgRecords attached to it, emit them. Note that
3536
- // they come after the instruction so that it's easy to attach them again
3537
- // when reading the bitcode, even though conceptually the debug locations
3538
- // start "before" the instruction.
3539
- if (I.hasDbgRecords () && WriteNewDbgInfoFormatToBitcode) {
3540
- // / Try to push the value only (unwrapped), otherwise push the
3541
- // / metadata wrapped value. Returns true if the value was pushed
3542
- // / without the ValueAsMetadata wrapper.
3543
- auto PushValueOrMetadata = [&Vals, InstID,
3544
- this ](Metadata *RawLocation) {
3545
- assert (RawLocation && " RawLocation unexpectedly null in DPValue" );
3546
- if (ValueAsMetadata *VAM = dyn_cast<ValueAsMetadata>(RawLocation)) {
3547
- SmallVector<unsigned , 2 > ValAndType;
3548
- // If the value is a fwd-ref the type is also pushed. We don't
3549
- // want the type, so fwd-refs are kept wrapped (pushValueAndType
3550
- // returns false if the value is pushed without type).
3551
- if (!pushValueAndType (VAM->getValue (), InstID, ValAndType)) {
3552
- Vals.push_back (ValAndType[0 ]);
3553
- return true ;
3554
- }
3555
- }
3556
- // The metadata is a DIArgList, or ValueAsMetadata wrapping a
3557
- // fwd-ref. Push the metadata ID.
3558
- Vals.push_back (VE.getMetadataID (RawLocation));
3559
- return false ;
3560
- };
3561
-
3562
- // Write out non-instruction debug information attached to this
3563
- // instruction. Write it after the instruction so that it's easy to
3564
- // re-attach to the instruction reading the records in.
3565
- for (DbgRecord &DR : I.DbgMarker ->getDbgRecordRange ()) {
3566
- if (DPLabel *DPL = dyn_cast<DPLabel>(&DR)) {
3567
- Vals.push_back (VE.getMetadataID (&*DPL->getDebugLoc ()));
3568
- Vals.push_back (VE.getMetadataID (DPL->getLabel ()));
3569
- Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_RECORD_LABEL, Vals);
3570
- Vals.clear ();
3571
- continue ;
3572
- }
3573
-
3574
- // First 3 fields are common to all kinds:
3575
- // DILocation, DILocalVariable, DIExpression
3576
- // dbg_value (FUNC_CODE_DEBUG_RECORD_VALUE)
3577
- // ..., LocationMetadata
3578
- // dbg_value (FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE - abbrev'd)
3579
- // ..., Value
3580
- // dbg_declare (FUNC_CODE_DEBUG_RECORD_DECLARE)
3581
- // ..., LocationMetadata
3582
- // dbg_assign (FUNC_CODE_DEBUG_RECORD_ASSIGN)
3583
- // ..., LocationMetadata, DIAssignID, DIExpression, LocationMetadata
3584
- DPValue &DPV = cast<DPValue>(DR);
3585
- Vals.push_back (VE.getMetadataID (&*DPV.getDebugLoc ()));
3586
- Vals.push_back (VE.getMetadataID (DPV.getVariable ()));
3587
- Vals.push_back (VE.getMetadataID (DPV.getExpression ()));
3588
- if (DPV.isDbgValue ()) {
3589
- if (PushValueOrMetadata (DPV.getRawLocation ()))
3590
- Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE, Vals,
3591
- FUNCTION_DEBUG_RECORD_VALUE_ABBREV);
3592
- else
3593
- Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_RECORD_VALUE, Vals);
3594
- } else if (DPV.isDbgDeclare ()) {
3595
- Vals.push_back (VE.getMetadataID (DPV.getRawLocation ()));
3596
- Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_RECORD_DECLARE, Vals);
3597
- } else {
3598
- assert (DPV.isDbgAssign () && " Unexpected DbgRecord kind" );
3599
- Vals.push_back (VE.getMetadataID (DPV.getRawLocation ()));
3600
- Vals.push_back (VE.getMetadataID (DPV.getAssignID ()));
3601
- Vals.push_back (VE.getMetadataID (DPV.getAddressExpression ()));
3602
- Vals.push_back (VE.getMetadataID (DPV.getRawAddress ()));
3603
- Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_RECORD_ASSIGN, Vals);
3604
- }
3605
- Vals.clear ();
3606
- }
3519
+ if (DL == LastDL) {
3520
+ // Just repeat the same debug loc as last time.
3521
+ Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_LOC_AGAIN, Vals);
3522
+ continue ;
3607
3523
}
3524
+
3525
+ Vals.push_back (DL->getLine ());
3526
+ Vals.push_back (DL->getColumn ());
3527
+ Vals.push_back (VE.getMetadataOrNullID (DL->getScope ()));
3528
+ Vals.push_back (VE.getMetadataOrNullID (DL->getInlinedAt ()));
3529
+ Vals.push_back (DL->isImplicitCode ());
3530
+ Stream.EmitRecord (bitc::FUNC_CODE_DEBUG_LOC, Vals);
3531
+ Vals.clear ();
3532
+
3533
+ LastDL = DL;
3608
3534
}
3609
3535
3610
3536
if (BlockAddress *BA = BlockAddress::lookup (&BB)) {
@@ -3845,17 +3771,7 @@ void ModuleBitcodeWriter::writeBlockInfo() {
3845
3771
FUNCTION_INST_GEP_ABBREV)
3846
3772
llvm_unreachable (" Unexpected abbrev ordering!" );
3847
3773
}
3848
- {
3849
- auto Abbv = std::make_shared<BitCodeAbbrev>();
3850
- Abbv->Add (BitCodeAbbrevOp (bitc::FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE));
3851
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 7 )); // dbgloc
3852
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 7 )); // var
3853
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 7 )); // expr
3854
- Abbv->Add (BitCodeAbbrevOp (BitCodeAbbrevOp::VBR, 6 )); // val
3855
- if (Stream.EmitBlockInfoAbbrev (bitc::FUNCTION_BLOCK_ID, Abbv) !=
3856
- FUNCTION_DEBUG_RECORD_VALUE_ABBREV)
3857
- llvm_unreachable (" Unexpected abbrev ordering! 1" );
3858
- }
3774
+
3859
3775
Stream.ExitBlock ();
3860
3776
}
3861
3777
0 commit comments