@@ -4158,7 +4158,10 @@ Explosion NativeConventionSchema::mapFromNative(IRGenModule &IGM,
4158
4158
if (explosionTy != elt->getType ()) {
4159
4159
if (isa<llvm::IntegerType>(explosionTy) &&
4160
4160
isa<llvm::IntegerType>(elt->getType ())) {
4161
- elt = IGF.Builder .CreateTrunc (elt, explosionTy);
4161
+ // [HACK: Atomic-Bool-IRGen] In the case of _Atomic(_Bool), Clang
4162
+ // treats it as i8 whereas Swift works with i1, so we need to zext
4163
+ // in that case.
4164
+ elt = IGF.Builder .CreateZExtOrTrunc (elt, explosionTy);
4162
4165
} else {
4163
4166
elt = IGF.coerceValue (elt, explosionTy, DataLayout);
4164
4167
}
@@ -4290,10 +4293,14 @@ Explosion NativeConventionSchema::mapIntoNative(IRGenModule &IGM,
4290
4293
auto *elt = fromNonNative.claimNext ();
4291
4294
if (nativeTy != elt->getType ()) {
4292
4295
if (isa<llvm::IntegerType>(nativeTy) &&
4293
- isa<llvm::IntegerType>(elt->getType ()))
4294
- elt = IGF.Builder .CreateZExt (elt, nativeTy);
4295
- else
4296
+ isa<llvm::IntegerType>(elt->getType ())) {
4297
+ // [HACK: Atomic-Bool-IRGen] In the case of _Atomic(_Bool), Clang
4298
+ // treats it as i8 whereas Swift works with i1, so we need to trunc
4299
+ // in that case.
4300
+ elt = IGF.Builder .CreateZExtOrTrunc (elt, nativeTy);
4301
+ } else {
4296
4302
elt = IGF.coerceValue (elt, nativeTy, DataLayout);
4303
+ }
4297
4304
}
4298
4305
nativeExplosion.add (elt);
4299
4306
return nativeExplosion;
0 commit comments