@@ -4146,7 +4146,10 @@ Explosion NativeConventionSchema::mapFromNative(IRGenModule &IGM,
4146
4146
if (explosionTy != elt->getType ()) {
4147
4147
if (isa<llvm::IntegerType>(explosionTy) &&
4148
4148
isa<llvm::IntegerType>(elt->getType ())) {
4149
- elt = IGF.Builder .CreateTrunc (elt, explosionTy);
4149
+ // [HACK: Atomic-Bool-IRGen] In the case of _Atomic(_Bool), Clang
4150
+ // treats it as i8 whereas Swift works with i1, so we need to zext
4151
+ // in that case.
4152
+ elt = IGF.Builder .CreateZExtOrTrunc (elt, explosionTy);
4150
4153
} else {
4151
4154
elt = IGF.coerceValue (elt, explosionTy, DataLayout);
4152
4155
}
@@ -4278,10 +4281,14 @@ Explosion NativeConventionSchema::mapIntoNative(IRGenModule &IGM,
4278
4281
auto *elt = fromNonNative.claimNext ();
4279
4282
if (nativeTy != elt->getType ()) {
4280
4283
if (isa<llvm::IntegerType>(nativeTy) &&
4281
- isa<llvm::IntegerType>(elt->getType ()))
4282
- elt = IGF.Builder .CreateZExt (elt, nativeTy);
4283
- else
4284
+ isa<llvm::IntegerType>(elt->getType ())) {
4285
+ // [HACK: Atomic-Bool-IRGen] In the case of _Atomic(_Bool), Clang
4286
+ // treats it as i8 whereas Swift works with i1, so we need to trunc
4287
+ // in that case.
4288
+ elt = IGF.Builder .CreateZExtOrTrunc (elt, nativeTy);
4289
+ } else {
4284
4290
elt = IGF.coerceValue (elt, nativeTy, DataLayout);
4291
+ }
4285
4292
}
4286
4293
nativeExplosion.add (elt);
4287
4294
return nativeExplosion;
0 commit comments