@@ -320,15 +320,6 @@ static DebugVariable getAggregateVariable(DbgVariableRecord *DVR) {
320320 DVR->getDebugLoc ().getInlinedAt ());
321321}
322322
323- DbgVariableRecord *UnwrapDbgInstPtr (DbgInstPtr P, DbgVariableRecord *Unused) {
324- (void )Unused;
325- return static_cast <DbgVariableRecord *>(cast<DbgRecord *>(P));
326- }
327- DbgAssignIntrinsic *UnwrapDbgInstPtr (DbgInstPtr P, DbgAssignIntrinsic *Unused) {
328- (void )Unused;
329- return static_cast <DbgAssignIntrinsic *>(cast<Instruction *>(P));
330- }
331-
332323// / Find linked dbg.assign and generate a new one with the correct
333324// / FragmentInfo. Link Inst to the new dbg.assign. If Value is nullptr the
334325// / value component is copied from the old dbg.assign to the new.
@@ -348,10 +339,9 @@ static void migrateDebugInfo(AllocaInst *OldAlloca, bool IsSplit,
348339 uint64_t SliceSizeInBits, Instruction *OldInst,
349340 Instruction *Inst, Value *Dest, Value *Value,
350341 const DataLayout &DL) {
351- auto MarkerRange = at::getAssignmentMarkers (OldInst);
352342 auto DVRAssignMarkerRange = at::getDVRAssignmentMarkers (OldInst);
353343 // Nothing to do if OldInst has no linked dbg.assign intrinsics.
354- if (MarkerRange. empty () && DVRAssignMarkerRange.empty ())
344+ if (DVRAssignMarkerRange.empty ())
355345 return ;
356346
357347 LLVM_DEBUG (dbgs () << " migrateDebugInfo\n " );
@@ -435,11 +425,10 @@ static void migrateDebugInfo(AllocaInst *OldAlloca, bool IsSplit,
435425 }
436426
437427 ::Value *NewValue = Value ? Value : DbgAssign->getValue ();
438- auto *NewAssign = UnwrapDbgInstPtr (
428+ DbgVariableRecord *NewAssign = cast<DbgVariableRecord>(cast<DbgRecord *> (
439429 DIB.insertDbgAssign (Inst, NewValue, DbgAssign->getVariable (), Expr,
440430 Dest, DIExpression::get (Expr->getContext (), {}),
441- DbgAssign->getDebugLoc ()),
442- DbgAssign);
431+ DbgAssign->getDebugLoc ())));
443432
444433 // If we've updated the value but the original dbg.assign has an arglist
445434 // then kill it now - we can't use the requested new value.
@@ -3232,8 +3221,7 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
32323221 // In theory we should call migrateDebugInfo here. However, we do not
32333222 // emit dbg.assign intrinsics for mem intrinsics storing through non-
32343223 // constant geps, or storing a variable number of bytes.
3235- assert (at::getAssignmentMarkers (&II).empty () &&
3236- at::getDVRAssignmentMarkers (&II).empty () &&
3224+ assert (at::getDVRAssignmentMarkers (&II).empty () &&
32373225 " AT: Unexpected link to non-const GEP" );
32383226 deleteIfTriviallyDead (OldPtr);
32393227 return false ;
@@ -3382,13 +3370,11 @@ class AllocaSliceRewriter : public InstVisitor<AllocaSliceRewriter, bool> {
33823370 Value *AdjustedPtr = getNewAllocaSlicePtr (IRB, OldPtr->getType ());
33833371 if (IsDest) {
33843372 // Update the address component of linked dbg.assigns.
3385- auto UpdateAssignAddress = [&]( auto *DbgAssign) {
3373+ for (DbgVariableRecord *DbgAssign : at::getDVRAssignmentMarkers (&II) ) {
33863374 if (llvm::is_contained (DbgAssign->location_ops (), II.getDest ()) ||
33873375 DbgAssign->getAddress () == II.getDest ())
33883376 DbgAssign->replaceVariableLocationOp (II.getDest (), AdjustedPtr);
3389- };
3390- for_each (at::getAssignmentMarkers (&II), UpdateAssignAddress);
3391- for_each (at::getDVRAssignmentMarkers (&II), UpdateAssignAddress);
3377+ }
33923378 II.setDest (AdjustedPtr);
33933379 II.setDestAlignment (SliceAlign);
33943380 } else {
@@ -3986,8 +3972,7 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
39863972 Store->getPointerOperand (), Store->getValueOperand (),
39873973 DL);
39883974 } else {
3989- assert (at::getAssignmentMarkers (Store).empty () &&
3990- at::getDVRAssignmentMarkers (Store).empty () &&
3975+ assert (at::getDVRAssignmentMarkers (Store).empty () &&
39913976 " AT: unexpected debug.assign linked to store through "
39923977 " unbounded GEP" );
39933978 }
0 commit comments