Skip to content

Commit 9ce382d

Browse files
authored
Merge pull request swiftlang#74353 from eeckstein/fix-fixed-abi-runtime-effects-6.0
[6.0] PerformanceDiagnostics: avoid false meta-data alarms for non-loadable types
2 parents bd91438 + 98ba13b commit 9ce382d

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

include/swift/SIL/SILType.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ class SILType {
366366
/// address-only. This is the opposite of isLoadable.
367367
bool isAddressOnly(const SILFunction &F) const;
368368

369+
/// For details see the comment of `IsFixedABI_t`.
370+
bool isFixedABI(const SILFunction &F) const;
371+
369372
/// True if the underlying AST type is trivial, meaning it is loadable and can
370373
/// be trivially copied, moved or destroyed. Returns false for address types
371374
/// even though they are technically trivial.

lib/SIL/IR/SILType.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,11 @@ bool SILType::isAddressOnly(const SILFunction &F) const {
450450
return F.getTypeLowering(contextType).isAddressOnly();
451451
}
452452

453+
bool SILType::isFixedABI(const SILFunction &F) const {
454+
auto contextType = hasTypeParameter() ? F.mapTypeIntoContext(*this) : *this;
455+
return F.getTypeLowering(contextType).isFixedABI();
456+
}
457+
453458
SILType SILType::substGenericArgs(SILModule &M, SubstitutionMap SubMap,
454459
TypeExpansionContext context) const {
455460
auto fnTy = castTo<SILFunctionType>();

lib/SIL/Utils/InstructionUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ RuntimeEffect swift::getRuntimeEffect(SILInstruction *inst, SILType &impactType)
616616
case SILInstructionKind::StructElementAddrInst:
617617
case SILInstructionKind::IndexAddrInst:
618618
// TODO: hasArchetype() ?
619-
if (!inst->getOperand(0)->getType().isLoadable(*inst->getFunction())) {
619+
if (!inst->getOperand(0)->getType().isFixedABI(*inst->getFunction())) {
620620
impactType = inst->getOperand(0)->getType();
621621
return RuntimeEffect::MetaData;
622622
}

test/SILOptimizer/performance-annotations.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -parse-as-library -disable-availability-checking -import-objc-header %S/Inputs/perf-annotations.h -emit-sil %s -o /dev/null -verify
1+
// RUN: %target-swift-frontend -parse-as-library -disable-availability-checking -enable-experimental-feature RawLayout -import-objc-header %S/Inputs/perf-annotations.h -emit-sil %s -o /dev/null -verify
22

33
// REQUIRES: swift_in_compiler
44
// REQUIRES: optimized_stdlib
@@ -542,3 +542,16 @@ extension G where T == Int {
542542
}
543543
}
544544
}
545+
546+
public struct RawLayoutWrapper: ~Copyable {
547+
private let x = RawLayout<Int>()
548+
549+
@_noLocks func testit() {
550+
x.test()
551+
}
552+
}
553+
554+
@_rawLayout(like: T)
555+
public struct RawLayout<T>: ~Copyable {
556+
public func test() {}
557+
}

0 commit comments

Comments
 (0)