diff --git a/stdlib/public/SwiftShims/LibcShims.h b/stdlib/public/SwiftShims/LibcShims.h index 47b78d36ce560..63f8b9ae3f025 100644 --- a/stdlib/public/SwiftShims/LibcShims.h +++ b/stdlib/public/SwiftShims/LibcShims.h @@ -91,30 +91,36 @@ __swift_uint32_t _swift_stdlib_cxx11_mt19937_uniform(__swift_uint32_t upper_bound); // Math library functions -static inline float _swift_stdlib_remainderf(float _self, float _other) { +static inline __attribute__((always_inline)) +float _swift_stdlib_remainderf(float _self, float _other) { return __builtin_remainderf(_self, _other); } -static inline float _swift_stdlib_squareRootf(float _self) { - return __builtin_sqrtf(_self); +static inline __attribute__((always_inline)) +float _swift_stdlib_squareRootf(float _self) { + return __builtin_sqrt(_self); } -static inline double _swift_stdlib_remainder(double _self, double _other) { +static inline __attribute__((always_inline)) +double _swift_stdlib_remainder(double _self, double _other) { return __builtin_remainder(_self, _other); } -static inline double _swift_stdlib_squareRoot(double _self) { +static inline __attribute__((always_inline)) +double _swift_stdlib_squareRoot(double _self) { return __builtin_sqrt(_self); } // TODO: Remove horrible workaround when importer does Float80 <-> long double. #if (defined __i386__ || defined __x86_64__) && !defined _MSC_VER -static inline void _swift_stdlib_remainderl(void *_self, const void *_other) { +static inline __attribute__((always_inline)) +void _swift_stdlib_remainderl(void *_self, const void *_other) { long double *_f80self = (long double *)_self; *_f80self = __builtin_remainderl(*_f80self, *(const long double *)_other); } -static inline void _swift_stdlib_squareRootl(void *_self) { +static inline __attribute__((always_inline)) +void _swift_stdlib_squareRootl(void *_self) { long double *_f80self = (long double *)_self; *_f80self = __builtin_sqrtl(*_f80self); } diff --git a/test/IRGen/builtin_math.swift b/test/IRGen/builtin_math.swift index 7af8060fb7631..43a84b5d88055 100644 --- a/test/IRGen/builtin_math.swift +++ b/test/IRGen/builtin_math.swift @@ -1,6 +1,5 @@ // RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -emit-ir -O %s | %FileCheck %s -// REQUIRES: 30043258 // XFAIL: linux import Darwin @@ -39,6 +38,20 @@ public func test4(f : Float) -> Float { return sqrt(f) } +// CHECK-LABEL: define {{.*}}test3a +// CHECK: call double @remainder + +public func test3a(d : Double) -> Double { + return remainder(1,d) +} + +// CHECK-LABEL: define {{.*}}test4a +// CHECK: call float @remainder + +public func test4a(f : Float) -> Float { + return remainder(1,f) +} + // CHECK-LABEL: define {{.*}}test5 // CHECK: ret float 2