Skip to content

Commit 1f394c5

Browse files
committed
Move workaround for swifterror miscompile earlier
Thank you, Arnold for noting this miscompile on x86!
1 parent bc92617 commit 1f394c5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3787,6 +3787,13 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) {
37873787

37883788
// If the error value is non-null, branch to the error destination.
37893789
auto hasError = Builder.CreateICmpNE(errorValue, nullError);
3790+
3791+
// Create a dummy use of 'errorValue' in the catch BB to workaround an
3792+
// LLVM miscompile that ends up taking the wrong branch if there are no
3793+
// uses of 'errorValue' in the catch block.
3794+
// FIXME: Remove this when the following radar is fixed: rdar://116636601
3795+
Builder.CreatePtrToInt(errorValue, IGM.IntPtrTy);
3796+
37903797
Builder.CreateCondBr(hasError,
37913798
typedErrorLoadBB ? typedErrorLoadBB : errorDest.bb,
37923799
normalDest.bb);
@@ -3806,12 +3813,6 @@ void IRGenSILFunction::visitFullApplySite(FullApplySite site) {
38063813
} else {
38073814
Builder.emitBlock(typedErrorLoadBB);
38083815

3809-
// Create a dummy use of 'errorValue' in the catch BB to workaround an
3810-
// LLVM miscompile that ends up taking the wrong branch if there are no
3811-
// uses of 'errorValue' in the catch block.
3812-
// FIXME: Remove this when the following radar is fixed: rdar://116636601
3813-
Builder.CreatePtrToInt(errorValue, IGM.IntPtrTy);
3814-
38153816
auto &ti = cast<LoadableTypeInfo>(IGM.getTypeInfo(errorType));
38163817
Explosion errorValue;
38173818
ti.loadAsTake(*this, getCalleeTypedErrorResultSlot(errorType), errorValue);

0 commit comments

Comments
 (0)