@@ -634,19 +634,12 @@ static void destroyOptimisticNormalEntry(CodeGenFunction &CGF,
634
634
// / Pops a cleanup block. If the block includes a normal cleanup, the
635
635
// / current insertion point is threaded through the cleanup, as are
636
636
// / any branch fixups on the cleanup.
637
- void CodeGenFunction::PopCleanupBlock (bool FallthroughIsBranchThrough,
638
- bool ForDeactivation) {
637
+ void CodeGenFunction::PopCleanupBlock (bool FallthroughIsBranchThrough) {
639
638
assert (!EHStack.empty () && " cleanup stack is empty!" );
640
639
assert (isa<EHCleanupScope>(*EHStack.begin ()) && " top not a cleanup!" );
641
640
EHCleanupScope &Scope = cast<EHCleanupScope>(*EHStack.begin ());
642
641
assert (Scope.getFixupDepth () <= EHStack.getNumBranchFixups ());
643
642
644
- // If we are deactivating a normal cleanup, we need to pretend that the
645
- // fallthrough is unreachable. We restore this IP before returning.
646
- CGBuilderTy::InsertPoint NormalDeactivateOrigIP;
647
- if (ForDeactivation && (Scope.isNormalCleanup () || !getLangOpts ().EHAsynch )) {
648
- NormalDeactivateOrigIP = Builder.saveAndClearIP ();
649
- }
650
643
// Remember activation information.
651
644
bool IsActive = Scope.isActive ();
652
645
Address NormalActiveFlag =
@@ -736,8 +729,6 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough,
736
729
EHStack.popCleanup (); // safe because there are no fixups
737
730
assert (EHStack.getNumBranchFixups () == 0 ||
738
731
EHStack.hasNormalCleanups ());
739
- if (NormalDeactivateOrigIP.isSet ())
740
- Builder.restoreIP (NormalDeactivateOrigIP);
741
732
return ;
742
733
}
743
734
@@ -774,16 +765,9 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough,
774
765
if (!RequiresNormalCleanup) {
775
766
// Mark CPP scope end for passed-by-value Arg temp
776
767
// per Windows ABI which is "normally" Cleanup in callee
777
- if (IsEHa && getInvokeDest ()) {
778
- // If we are deactivating a normal cleanup then we don't have a
779
- // fallthrough. Restore original IP to emit CPP scope ends in the correct
780
- // block.
781
- if (NormalDeactivateOrigIP.isSet ())
782
- Builder.restoreIP (NormalDeactivateOrigIP);
783
- if (Personality.isMSVCXXPersonality () && Builder.GetInsertBlock ())
768
+ if (IsEHa && getInvokeDest () && Builder.GetInsertBlock ()) {
769
+ if (Personality.isMSVCXXPersonality ())
784
770
EmitSehCppScopeEnd ();
785
- if (NormalDeactivateOrigIP.isSet ())
786
- NormalDeactivateOrigIP = Builder.saveAndClearIP ();
787
771
}
788
772
destroyOptimisticNormalEntry (*this , Scope);
789
773
Scope.MarkEmitted ();
@@ -1008,8 +992,6 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough,
1008
992
}
1009
993
}
1010
994
1011
- if (NormalDeactivateOrigIP.isSet ())
1012
- Builder.restoreIP (NormalDeactivateOrigIP);
1013
995
assert (EHStack.hasNormalCleanups () || EHStack.getNumBranchFixups () == 0 );
1014
996
1015
997
// Emit the EH cleanup if required.
@@ -1299,8 +1281,17 @@ void CodeGenFunction::DeactivateCleanupBlock(EHScopeStack::stable_iterator C,
1299
1281
// to the current RunCleanupsScope.
1300
1282
if (C == EHStack.stable_begin () &&
1301
1283
CurrentCleanupScopeDepth.strictlyEncloses (C)) {
1302
- PopCleanupBlock (/* FallthroughIsBranchThrough=*/ false ,
1303
- /* ForDeactivation=*/ true );
1284
+ // Per comment below, checking EHAsynch is not really necessary
1285
+ // it's there to assure zero-impact w/o EHAsynch option
1286
+ if (!Scope.isNormalCleanup () && getLangOpts ().EHAsynch ) {
1287
+ PopCleanupBlock ();
1288
+ } else {
1289
+ // If it's a normal cleanup, we need to pretend that the
1290
+ // fallthrough is unreachable.
1291
+ CGBuilderTy::InsertPoint SavedIP = Builder.saveAndClearIP ();
1292
+ PopCleanupBlock ();
1293
+ Builder.restoreIP (SavedIP);
1294
+ }
1304
1295
return ;
1305
1296
}
1306
1297
0 commit comments