@@ -373,12 +373,12 @@ void BinaryFunction::updateEHRanges() {
373373 const MCSymbol *StartRange = nullptr ;
374374
375375 for (BinaryBasicBlock *const BB : FF) {
376- for (auto II = BB-> begin (); II != BB-> end (); ++II ) {
377- if (!BC.MIB ->isCall (*II ))
376+ for (MCInst &Instr : *BB ) {
377+ if (!BC.MIB ->isCall (Instr ))
378378 continue ;
379379
380380 // Instruction can throw an exception that should be handled.
381- const bool Throws = BC.MIB ->isInvoke (*II );
381+ const bool Throws = BC.MIB ->isInvoke (Instr );
382382
383383 // Ignore the call if it's a continuation of a no-throw gap.
384384 if (!Throws && !StartRange)
@@ -388,7 +388,7 @@ void BinaryFunction::updateEHRanges() {
388388 const MCSymbol *LP = nullptr ;
389389 uint64_t Action = 0 ;
390390 if (const std::optional<MCPlus::MCLandingPad> EHInfo =
391- BC.MIB ->getEHInfo (*II ))
391+ BC.MIB ->getEHInfo (Instr ))
392392 std::tie (LP, Action) = *EHInfo;
393393
394394 // No action if the exception handler has not changed.
@@ -397,16 +397,15 @@ void BinaryFunction::updateEHRanges() {
397397 continue ;
398398
399399 // Same symbol is used for the beginning and the end of the range.
400- const MCSymbol *EHSymbol;
401- MCInst EHLabel;
402- {
400+ MCSymbol *EHSymbol;
401+ if (auto InstrLabel = BC.MIB ->getLabel (Instr)) {
402+ EHSymbol = *InstrLabel;
403+ } else {
403404 std::unique_lock<llvm::sys::RWMutex> Lock (BC.CtxMutex );
404405 EHSymbol = BC.Ctx ->createNamedTempSymbol (" EH" );
405- BC.MIB ->createEHLabel (EHLabel , EHSymbol, BC. Ctx . get () );
406+ BC.MIB ->setLabel (Instr , EHSymbol);
406407 }
407408
408- II = std::next (BB->insertPseudoInstr (II, EHLabel));
409-
410409 // At this point we could be in one of the following states:
411410 //
412411 // I. Exception handler has changed and we need to close previous range
0 commit comments