@@ -511,7 +511,7 @@ DbgVariableRecordsRemoveRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) {
511
511
continue ;
512
512
DebugVariable Key (DVR.getVariable (), std::nullopt,
513
513
DVR.getDebugLoc ()->getInlinedAt ());
514
- auto VMI = VariableMap.find (Key);
514
+ auto [ VMI, Inserted] = VariableMap.try_emplace (Key);
515
515
// A dbg.assign with no linked instructions can be treated like a
516
516
// dbg.value (i.e. can be deleted).
517
517
bool IsDbgValueKind =
@@ -520,12 +520,12 @@ DbgVariableRecordsRemoveRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) {
520
520
// Update the map if we found a new value/expression describing the
521
521
// variable, or if the variable wasn't mapped already.
522
522
SmallVector<Value *, 4 > Values (DVR.location_ops ());
523
- if (VMI == VariableMap. end () || VMI->second .first != Values ||
523
+ if (Inserted || VMI->second .first != Values ||
524
524
VMI->second .second != DVR.getExpression ()) {
525
525
if (IsDbgValueKind)
526
- VariableMap[Key] = {Values, DVR.getExpression ()};
526
+ VMI-> second = {Values, DVR.getExpression ()};
527
527
else
528
- VariableMap[Key] = {Values, nullptr };
528
+ VMI-> second = {Values, nullptr };
529
529
continue ;
530
530
}
531
531
// Don't delete dbg.assign intrinsics that are linked to instructions.
@@ -591,7 +591,7 @@ static bool removeRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) {
591
591
if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(&I)) {
592
592
DebugVariable Key (DVI->getVariable (), std::nullopt,
593
593
DVI->getDebugLoc ()->getInlinedAt ());
594
- auto VMI = VariableMap.find (Key);
594
+ auto [ VMI, Inserted] = VariableMap.try_emplace (Key);
595
595
auto *DAI = dyn_cast<DbgAssignIntrinsic>(DVI);
596
596
// A dbg.assign with no linked instructions can be treated like a
597
597
// dbg.value (i.e. can be deleted).
@@ -600,15 +600,15 @@ static bool removeRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) {
600
600
// Update the map if we found a new value/expression describing the
601
601
// variable, or if the variable wasn't mapped already.
602
602
SmallVector<Value *, 4 > Values (DVI->getValues ());
603
- if (VMI == VariableMap. end () || VMI->second .first != Values ||
603
+ if (Inserted || VMI->second .first != Values ||
604
604
VMI->second .second != DVI->getExpression ()) {
605
605
// Use a sentinel value (nullptr) for the DIExpression when we see a
606
606
// linked dbg.assign so that the next debug intrinsic will never match
607
607
// it (i.e. always treat linked dbg.assigns as if they're unique).
608
608
if (IsDbgValueKind)
609
- VariableMap[Key] = {Values, DVI->getExpression ()};
609
+ VMI-> second = {Values, DVI->getExpression ()};
610
610
else
611
- VariableMap[Key] = {Values, nullptr };
611
+ VMI-> second = {Values, nullptr };
612
612
continue ;
613
613
}
614
614
0 commit comments