Skip to content

Commit 9843a75

Browse files
authored
Merge pull request #80548 from swiftlang/revert-80077-integer-conversion-transparent-6.1
2 parents 954c668 + 7ba73a7 commit 9843a75

File tree

7 files changed

+20
-45
lines changed

7 files changed

+20
-45
lines changed

lib/SILOptimizer/Mandatory/OSLogOptimization.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -938,16 +938,6 @@ static void substituteConstants(FoldState &foldState) {
938938
for (SILValue constantSILValue : foldState.getConstantSILValues()) {
939939
SymbolicValue constantSymbolicVal =
940940
evaluator.lookupConstValue(constantSILValue).value();
941-
CanType instType = constantSILValue->getType().getASTType();
942-
943-
// If the SymbolicValue is a string but the instruction that is folded is
944-
// not String typed, we are tracking a StaticString which is represented as
945-
// a raw pointer. Skip folding StaticString as they are already efficiently
946-
// represented.
947-
if (constantSymbolicVal.getKind() == SymbolicValue::String &&
948-
!instType->isString())
949-
continue;
950-
951941
// Make sure that the symbolic value tracked in the foldState is a constant.
952942
// In the case of ArraySymbolicValue, the array storage could be a non-constant
953943
// if some instruction in the array initialization sequence was not evaluated
@@ -986,6 +976,7 @@ static void substituteConstants(FoldState &foldState) {
986976

987977
SILBuilderWithScope builder(insertionPoint);
988978
SILLocation loc = insertionPoint->getLoc();
979+
CanType instType = constantSILValue->getType().getASTType();
989980
SILValue foldedSILVal = emitCodeForSymbolicValue(
990981
constantSymbolicVal, instType, builder, loc, foldState.stringInfo);
991982

stdlib/public/core/Integers.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,7 +3040,8 @@ extension UnsignedInteger where Self: FixedWidthInteger {
30403040
/// - Parameter source: A value to convert to this type of integer. The value
30413041
/// passed as `source` must be representable in this type.
30423042
@_semantics("optimize.sil.specialize.generic.partial.never")
3043-
@_transparent
3043+
@inlinable // FIXME(inline-always)
3044+
@inline(__always)
30443045
public init<T: BinaryInteger>(_ source: T) {
30453046
// This check is potentially removable by the optimizer
30463047
if T.isSigned {
@@ -3055,7 +3056,8 @@ extension UnsignedInteger where Self: FixedWidthInteger {
30553056
}
30563057

30573058
@_semantics("optimize.sil.specialize.generic.partial.never")
3058-
@_transparent
3059+
@inlinable // FIXME(inline-always)
3060+
@inline(__always)
30593061
public init?<T: BinaryInteger>(exactly source: T) {
30603062
// This check is potentially removable by the optimizer
30613063
if T.isSigned && source < (0 as T) {
@@ -3253,7 +3255,8 @@ extension SignedInteger where Self: FixedWidthInteger {
32533255
/// - Parameter source: A value to convert to this type of integer. The value
32543256
/// passed as `source` must be representable in this type.
32553257
@_semantics("optimize.sil.specialize.generic.partial.never")
3256-
@_transparent
3258+
@inlinable // FIXME(inline-always)
3259+
@inline(__always)
32573260
public init<T: BinaryInteger>(_ source: T) {
32583261
// This check is potentially removable by the optimizer
32593262
if T.isSigned && source.bitWidth > Self.bitWidth {
@@ -3270,7 +3273,8 @@ extension SignedInteger where Self: FixedWidthInteger {
32703273
}
32713274

32723275
@_semantics("optimize.sil.specialize.generic.partial.never")
3273-
@_transparent
3276+
@inlinable // FIXME(inline-always)
3277+
@inline(__always)
32743278
public init?<T: BinaryInteger>(exactly source: T) {
32753279
// This check is potentially removable by the optimizer
32763280
if T.isSigned && source.bitWidth > Self.bitWidth && source < Self.min {

test/IRGen/integer_conversion.swift

Lines changed: 0 additions & 26 deletions
This file was deleted.

test/Interop/Cxx/templates/function-template-silgen.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ import FunctionTemplates
1616
// CHECK: [[ADD_TWO_FN:%.*]] = function_ref @{{_Z18addMixedTypeParamsIiiET_S0_T0_|\?\?\$addMixedTypeParams@HH@@YAHHH@Z}} : $@convention(c) (Int32, Int32) -> Int32
1717
// CHECK: [[C:%.*]] = apply [[ADD_TWO_FN]]([[A]], [[B]]) : $@convention(c) (Int32, Int32) -> Int32
1818

19+
// CHECK: [[C_32_ADDR:%.*]] = alloc_stack $Int32
20+
// CHECK: [[C_32:%.*]] = load [[C_32_ADDR]] : $*Int32
1921
// CHECK: [[ADD_FN:%.*]] = function_ref @{{_Z17addSameTypeParamsIiET_S0_S0_|\?\?\$addSameTypeParams@H@@YAHHH@Z}} : $@convention(c) (Int32, Int32) -> Int32
20-
// CHECK: [[OUT:%.*]] = apply [[ADD_FN]]([[B]], [[C_32:%.*]]) : $@convention(c) (Int32, Int32) -> Int32
22+
// CHECK: [[OUT:%.*]] = apply [[ADD_FN]]([[B]], [[C_32]]) : $@convention(c) (Int32, Int32) -> Int32
2123
// CHECK: return [[OUT]] : $Int32
2224

2325
// CHECK-LABEL: end sil function '$s4main4test1xs5Int32VAE_tF'

test/SILOptimizer/Inputs/constant_evaluable.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ internal func interpretIntTruncations() -> Int8 {
174174
internal func testInvalidIntTruncations(a: Int32) -> Int8 {
175175
return Int8(a)
176176
// CHECK: note: {{.*}}: Not enough bits to represent the passed value
177-
// CHECK: note: operation traps
177+
// CHECK: note: operation performed during this call traps
178+
// CHECK: function_ref @$sSZss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufC
178179
}
179180

180181
@_semantics("test_driver")
@@ -219,7 +220,8 @@ internal func interpretSingedUnsignedConversions() -> UInt32 {
219220
internal func testInvalidSingedUnsignedConversions(a: Int64) -> UInt64 {
220221
return UInt64(a)
221222
// CHECK: note: {{.*}}: Negative value is not representable
222-
// CHECK: note: operation traps
223+
// CHECK: note: operation performed during this call traps
224+
// CHECK: function_ref @$sSUss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufC
223225
}
224226

225227
@_semantics("test_driver")

test/SILOptimizer/constant_evaluable_subset_test_arch64.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ internal func interpretIntTruncations() -> Int16 {
7171
internal func testInvalidIntTruncations(a: Int64) -> Int8 {
7272
return Int8(a)
7373
// CHECK: note: {{.*}} Not enough bits to represent the passed value
74-
// CHECK: note: operation traps
74+
// CHECK: note: operation performed during this call traps
75+
// CHECK: function_ref @$sSZss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufC
7576
}
7677

7778
@_semantics("test_driver")

test/SILOptimizer/diagnostic_constant_propagation.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func testArithmeticOverflow() {
3434
xu8_3 += 40 // expected-error {{arithmetic operation '240 + 40' (on type 'UInt8') results in an overflow}}
3535
var _ : UInt8 = 240 + 5 + 15 // expected-error {{arithmetic operation '245 + 15' (on type 'UInt8') results in an overflow}}
3636

37-
var _ = Int8(126) + Int8(1+1) // expected-error{{arithmetic operation '126 + 2' (on type 'Int8') results in an overflow}}
37+
var _ = Int8(126) + Int8(1+1) // FIXME: false negative: overflow that is not
38+
// caught by diagnostics (see also <rdar://problem/39120081>).
3839

3940
var _: Int8 = (1 << 7) - 1 // FIXME: false negative: should expect an error
4041
// like {{arithmetic operation '-128 - 1' (on type 'Int8') results in an overflow}}

0 commit comments

Comments
 (0)