diff --git a/lib/SILOptimizer/Mandatory/OSLogOptimization.cpp b/lib/SILOptimizer/Mandatory/OSLogOptimization.cpp index 69cd337c2a6cc..ca6b3e2fbe89e 100644 --- a/lib/SILOptimizer/Mandatory/OSLogOptimization.cpp +++ b/lib/SILOptimizer/Mandatory/OSLogOptimization.cpp @@ -938,16 +938,6 @@ static void substituteConstants(FoldState &foldState) { for (SILValue constantSILValue : foldState.getConstantSILValues()) { SymbolicValue constantSymbolicVal = evaluator.lookupConstValue(constantSILValue).value(); - CanType instType = constantSILValue->getType().getASTType(); - - // If the SymbolicValue is a string but the instruction that is folded is - // not String typed, we are tracking a StaticString which is represented as - // a raw pointer. Skip folding StaticString as they are already efficiently - // represented. - if (constantSymbolicVal.getKind() == SymbolicValue::String && - !instType->isString()) - continue; - // Make sure that the symbolic value tracked in the foldState is a constant. // In the case of ArraySymbolicValue, the array storage could be a non-constant // if some instruction in the array initialization sequence was not evaluated @@ -986,6 +976,7 @@ static void substituteConstants(FoldState &foldState) { SILBuilderWithScope builder(insertionPoint); SILLocation loc = insertionPoint->getLoc(); + CanType instType = constantSILValue->getType().getASTType(); SILValue foldedSILVal = emitCodeForSymbolicValue( constantSymbolicVal, instType, builder, loc, foldState.stringInfo); diff --git a/stdlib/public/core/Integers.swift b/stdlib/public/core/Integers.swift index 8f5653262fcd9..870d69023b819 100644 --- a/stdlib/public/core/Integers.swift +++ b/stdlib/public/core/Integers.swift @@ -3041,7 +3041,8 @@ extension UnsignedInteger where Self: FixedWidthInteger { /// - Parameter source: A value to convert to this type of integer. The value /// passed as `source` must be representable in this type. @_semantics("optimize.sil.specialize.generic.partial.never") - @_transparent + @inlinable // FIXME(inline-always) + @inline(__always) public init(_ source: T) { // This check is potentially removable by the optimizer if T.isSigned { @@ -3056,7 +3057,8 @@ extension UnsignedInteger where Self: FixedWidthInteger { } @_semantics("optimize.sil.specialize.generic.partial.never") - @_transparent + @inlinable // FIXME(inline-always) + @inline(__always) public init?(exactly source: T) { // This check is potentially removable by the optimizer if T.isSigned && source < (0 as T) { @@ -3254,7 +3256,8 @@ extension SignedInteger where Self: FixedWidthInteger { /// - Parameter source: A value to convert to this type of integer. The value /// passed as `source` must be representable in this type. @_semantics("optimize.sil.specialize.generic.partial.never") - @_transparent + @inlinable // FIXME(inline-always) + @inline(__always) public init(_ source: T) { // This check is potentially removable by the optimizer if T.isSigned && source.bitWidth > Self.bitWidth { @@ -3271,7 +3274,8 @@ extension SignedInteger where Self: FixedWidthInteger { } @_semantics("optimize.sil.specialize.generic.partial.never") - @_transparent + @inlinable // FIXME(inline-always) + @inline(__always) public init?(exactly source: T) { // This check is potentially removable by the optimizer if T.isSigned && source.bitWidth > Self.bitWidth && source < Self.min { diff --git a/test/IRGen/integer_conversion.swift b/test/IRGen/integer_conversion.swift deleted file mode 100644 index 9d671a8207423..0000000000000 --- a/test/IRGen/integer_conversion.swift +++ /dev/null @@ -1,26 +0,0 @@ -// RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s -// RUN: %target-swift-frontend -primary-file %s -O -emit-ir | %FileCheck %s -// REQUIRES: CPU=x86_64 || CPU=arm64 - -// https://github.com/swiftlang/swift/issues/78501 -public struct PcgRandom { - private var state: UInt64 = 0; - - // CHECK-LABEL: define{{.*}}swiftcc i32 @"$s18integer_conversion9PcgRandomV6next32s6UInt32VyF" - public mutating func next32() -> UInt32 { - // CHECK-NOT: sSUss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufC - // CHECK-NOT: sSZss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufC - // CHECK: ret i32 - let oldstate : UInt64 = state - state = oldstate &* 6364136223846793005 &+ 1; - let shifted = oldstate >> 18 - let xor = shifted ^ oldstate - let xorshifted64 = xor >> 27 - let xorshifted = UInt32((xorshifted64 << 32) >> 32) - let rot : UInt32 = UInt32(oldstate >> 59) - let nrot : UInt32 = UInt32(bitPattern: -Int32(rot)) - return (xorshifted >> rot) | (xorshifted << (nrot & 31)) - } - - init() {} -} diff --git a/test/Interop/Cxx/templates/function-template-silgen.swift b/test/Interop/Cxx/templates/function-template-silgen.swift index 5a0a93f63b6a8..9b93e7b62124a 100644 --- a/test/Interop/Cxx/templates/function-template-silgen.swift +++ b/test/Interop/Cxx/templates/function-template-silgen.swift @@ -16,8 +16,10 @@ import FunctionTemplates // CHECK: [[ADD_TWO_FN:%.*]] = function_ref @{{_Z18addMixedTypeParamsIiiET_S0_T0_|\?\?\$addMixedTypeParams@HH@@YAHHH@Z}} : $@convention(c) (Int32, Int32) -> Int32 // CHECK: [[C:%.*]] = apply [[ADD_TWO_FN]]([[A]], [[B]]) : $@convention(c) (Int32, Int32) -> Int32 +// CHECK: [[C_32_ADDR:%.*]] = alloc_stack $Int32 +// CHECK: [[C_32:%.*]] = load [[C_32_ADDR]] : $*Int32 // CHECK: [[ADD_FN:%.*]] = function_ref @{{_Z17addSameTypeParamsIiET_S0_S0_|\?\?\$addSameTypeParams@H@@YAHHH@Z}} : $@convention(c) (Int32, Int32) -> Int32 -// CHECK: [[OUT:%.*]] = apply [[ADD_FN]]([[B]], [[C_32:%.*]]) : $@convention(c) (Int32, Int32) -> Int32 +// CHECK: [[OUT:%.*]] = apply [[ADD_FN]]([[B]], [[C_32]]) : $@convention(c) (Int32, Int32) -> Int32 // CHECK: return [[OUT]] : $Int32 // CHECK-LABEL: end sil function '$s4main4test1xs5Int32VAE_tF' diff --git a/test/SILOptimizer/Inputs/constant_evaluable.swift b/test/SILOptimizer/Inputs/constant_evaluable.swift index d5a7a5d7aa097..a9755a5668373 100644 --- a/test/SILOptimizer/Inputs/constant_evaluable.swift +++ b/test/SILOptimizer/Inputs/constant_evaluable.swift @@ -174,7 +174,8 @@ internal func interpretIntTruncations() -> Int8 { internal func testInvalidIntTruncations(a: Int32) -> Int8 { return Int8(a) // CHECK: note: {{.*}}: Not enough bits to represent the passed value - // CHECK: note: operation traps + // CHECK: note: operation performed during this call traps + // CHECK: function_ref @$sSZss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufC } @_semantics("test_driver") @@ -219,7 +220,8 @@ internal func interpretSingedUnsignedConversions() -> UInt32 { internal func testInvalidSingedUnsignedConversions(a: Int64) -> UInt64 { return UInt64(a) // CHECK: note: {{.*}}: Negative value is not representable - // CHECK: note: operation traps + // CHECK: note: operation performed during this call traps + // CHECK: function_ref @$sSUss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufC } @_semantics("test_driver") diff --git a/test/SILOptimizer/constant_evaluable_subset_test_arch64.swift b/test/SILOptimizer/constant_evaluable_subset_test_arch64.swift index 03dd91cbf35cb..bd53c23a60c3c 100644 --- a/test/SILOptimizer/constant_evaluable_subset_test_arch64.swift +++ b/test/SILOptimizer/constant_evaluable_subset_test_arch64.swift @@ -71,7 +71,8 @@ internal func interpretIntTruncations() -> Int16 { internal func testInvalidIntTruncations(a: Int64) -> Int8 { return Int8(a) // CHECK: note: {{.*}} Not enough bits to represent the passed value - // CHECK: note: operation traps + // CHECK: note: operation performed during this call traps + // CHECK: function_ref @$sSZss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufC } @_semantics("test_driver")