@@ -179,19 +179,11 @@ class RegReloadCache {
179179public:
180180 RegReloadCache () = default ;
181181
182- // Record reload of Reg from FI in block MBB
183- void recordReload (Register Reg, int FI, const MachineBasicBlock *MBB) {
182+ // Record reload of Reg from FI in block MBB if not present yet.
183+ // Return true if the reload is successfully recorded.
184+ bool tryRecordReload (Register Reg, int FI, const MachineBasicBlock *MBB) {
184185 RegSlotPair RSP (Reg, FI);
185- auto Res = Reloads[MBB].insert (RSP);
186- (void )Res;
187- assert (Res.second && " reload already exists" );
188- }
189-
190- // Does basic block MBB contains reload of Reg from FI?
191- bool hasReload (Register Reg, int FI, const MachineBasicBlock *MBB) {
192- RegSlotPair RSP (Reg, FI);
193- auto It = Reloads.find (MBB);
194- return It != Reloads.end () && It->second .count (RSP);
186+ return Reloads[MBB].insert (RSP).second ;
195187 }
196188};
197189
@@ -459,8 +451,7 @@ class StatepointState {
459451 LLVM_DEBUG (dbgs () << " Reloading " << printReg (Reg, &TRI) << " from FI "
460452 << RegToSlotIdx[Reg] << " after statepoint\n " );
461453
462- if (EHPad && !RC.hasReload (Reg, RegToSlotIdx[Reg], EHPad)) {
463- RC.recordReload (Reg, RegToSlotIdx[Reg], EHPad);
454+ if (EHPad && RC.tryRecordReload (Reg, RegToSlotIdx[Reg], EHPad)) {
464455 auto EHPadInsertPoint =
465456 EHPad->SkipPHIsLabelsAndDebug (EHPad->begin (), Reg);
466457 insertReloadBefore (Reg, EHPadInsertPoint, EHPad);
0 commit comments