Skip to content

Commit 0268423

Browse files
Merge pull request #2550 from swiftwasm/release/5.4
[pull] swiftwasm-release/5.4 from release/5.4
2 parents fc53822 + 73b291b commit 0268423

File tree

7 files changed

+43
-9
lines changed

7 files changed

+43
-9
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,7 +4146,10 @@ Explosion NativeConventionSchema::mapFromNative(IRGenModule &IGM,
41464146
if (explosionTy != elt->getType()) {
41474147
if (isa<llvm::IntegerType>(explosionTy) &&
41484148
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);
41504153
} else {
41514154
elt = IGF.coerceValue(elt, explosionTy, DataLayout);
41524155
}
@@ -4278,10 +4281,14 @@ Explosion NativeConventionSchema::mapIntoNative(IRGenModule &IGM,
42784281
auto *elt = fromNonNative.claimNext();
42794282
if (nativeTy != elt->getType()) {
42804283
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 {
42844290
elt = IGF.coerceValue(elt, nativeTy, DataLayout);
4291+
}
42854292
}
42864293
nativeExplosion.add(elt);
42874294
return nativeExplosion;

lib/IRGen/GenType.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,8 +1420,9 @@ TypeConverter::TypeConverter(IRGenModule &IGM)
14201420
}
14211421

14221422
bool error = readLegacyTypeInfo(*fs, path);
1423-
if (error)
1424-
llvm::report_fatal_error("Cannot read '" + path + "'");
1423+
if (error) {
1424+
IGM.error(SourceLoc(), "Cannot read legacy layout file at '" + path + "'");
1425+
}
14251426
}
14261427

14271428
TypeConverter::~TypeConverter() {

lib/Sema/CSSimplify.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7472,11 +7472,11 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
74727472
if (!paramDecl)
74737473
continue;
74747474

7475-
auto descriptor = UnqualifiedLookupDescriptor(
7475+
auto descriptor = UnqualifiedLookupDescriptor{
74767476
DeclNameRef(param->getName()),
7477-
paramDecl->getDeclContext()->getParentSourceFile(),
7477+
paramDecl->getDeclContext()->getModuleScopeContext(),
74787478
SourceLoc(),
7479-
UnqualifiedLookupFlags::TypeLookup);
7479+
UnqualifiedLookupFlags::TypeLookup};
74807480
auto lookup = evaluateOrDefault(
74817481
Context.evaluator, UnqualifiedLookupRequest{descriptor}, {});
74827482
for (auto &result : lookup) {

test/IRGen/Inputs/atomic_bool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
typedef struct { _Atomic(_Bool) value; } MyAtomicBool;

test/IRGen/Inputs/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ module AutolinkElfCPragmaTransitive {
2121
module AutolinkModuleMapLink {
2222
link "autolink-module-map-link"
2323
}
24+
25+
module AtomicBoolModule {
26+
header "atomic_bool.h"
27+
export *
28+
}

test/IRGen/atomic_bool.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Check that IRGen doesn't crash. rdar://72999296
2+
// RUN: %target-swift-emit-ir %s -I %S/Inputs
3+
4+
import AtomicBoolModule
5+
6+
public func f() -> MyAtomicBool {
7+
return MyAtomicBool()
8+
}
9+
10+
public func g(_ b: MyAtomicBool) {
11+
let _ = b
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: not %target-swift-frontend -typecheck %s
2+
3+
typealias IndexResult = Result<Bol, Error>
4+
extension IndexResult {
5+
func perfect() -> Self {
6+
Success(true)
7+
}
8+
}

0 commit comments

Comments
 (0)