runtime: add and switch to SWIFT_NOINLINE (NFC)

This switches the `LLVM_ATTRIBUTE_NOINLINE` to a local copy which is
namespaced in Swift.
This commit is contained in:
Saleem Abdulrasool
2020-05-06 08:27:26 -07:00
parent 923def217f
commit f465ec0345
6 changed files with 33 additions and 24 deletions

View File

@@ -182,8 +182,8 @@ namespace swift {
} }
// FIXME: HACK: copied from HeapObject.cpp // FIXME: HACK: copied from HeapObject.cpp
extern "C" SWIFT_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED extern "C" SWIFT_LIBRARY_VISIBILITY SWIFT_NOINLINE LLVM_ATTRIBUTE_USED void
void _swift_release_dealloc(swift::HeapObject *object); _swift_release_dealloc(swift::HeapObject *object);
namespace swift { namespace swift {
@@ -697,19 +697,19 @@ class RefCounts {
// Out-of-line slow paths. // Out-of-line slow paths.
LLVM_ATTRIBUTE_NOINLINE SWIFT_NOINLINE
void incrementSlow(RefCountBits oldbits, uint32_t inc) SWIFT_CC(PreserveMost); void incrementSlow(RefCountBits oldbits, uint32_t inc) SWIFT_CC(PreserveMost);
LLVM_ATTRIBUTE_NOINLINE SWIFT_NOINLINE
void incrementNonAtomicSlow(RefCountBits oldbits, uint32_t inc); void incrementNonAtomicSlow(RefCountBits oldbits, uint32_t inc);
LLVM_ATTRIBUTE_NOINLINE SWIFT_NOINLINE
bool tryIncrementSlow(RefCountBits oldbits); bool tryIncrementSlow(RefCountBits oldbits);
LLVM_ATTRIBUTE_NOINLINE SWIFT_NOINLINE
bool tryIncrementNonAtomicSlow(RefCountBits oldbits); bool tryIncrementNonAtomicSlow(RefCountBits oldbits);
LLVM_ATTRIBUTE_NOINLINE SWIFT_NOINLINE
void incrementUnownedSlow(uint32_t inc); void incrementUnownedSlow(uint32_t inc);
public: public:

View File

@@ -66,6 +66,12 @@
#define SWIFT_ALWAYS_INLINE #define SWIFT_ALWAYS_INLINE
#endif #endif
#if __has_attribute(noinline)
#define SWIFT_NOINLINE __attribute__((__noinline__))
#else
#define SWIFT_NOINLINE
#endif
#if __has_attribute(unavailable) #if __has_attribute(unavailable)
#define SWIFT_ATTRIBUTE_UNAVAILABLE __attribute__((__unavailable__)) #define SWIFT_ATTRIBUTE_UNAVAILABLE __attribute__((__unavailable__))
#else #else

View File

@@ -248,11 +248,9 @@ swift::swift_getMangledTypeName(const Metadata *type) {
// This is noinline to preserve this frame in stack traces. // This is noinline to preserve this frame in stack traces.
// We want "dynamicCastFailure" to appear in crash logs even we crash // We want "dynamicCastFailure" to appear in crash logs even we crash
// during the diagnostic because some Metadata is invalid. // during the diagnostic because some Metadata is invalid.
LLVM_ATTRIBUTE_NORETURN LLVM_ATTRIBUTE_NORETURN SWIFT_NOINLINE void
LLVM_ATTRIBUTE_NOINLINE swift::swift_dynamicCastFailure(const void *sourceType, const char *sourceName,
void const void *targetType, const char *targetName,
swift::swift_dynamicCastFailure(const void *sourceType, const char *sourceName,
const void *targetType, const char *targetName,
const char *message) { const char *message) {
swift::fatalError(/* flags = */ 0, swift::fatalError(/* flags = */ 0,
"Could not cast value of type '%s' (%p) to '%s' (%p)%s%s\n", "Could not cast value of type '%s' (%p) to '%s' (%p)%s%s\n",

View File

@@ -224,7 +224,7 @@ static _Unwind_Reason_Code SwiftUnwindFrame(struct _Unwind_Context *context, voi
} }
#endif #endif
LLVM_ATTRIBUTE_NOINLINE SWIFT_NOINLINE
void swift::printCurrentBacktrace(unsigned framesToSkip) { void swift::printCurrentBacktrace(unsigned framesToSkip) {
#if SWIFT_SUPPORTS_BACKTRACE_REPORTING #if SWIFT_SUPPORTS_BACKTRACE_REPORTING
constexpr unsigned maxSupportedStackDepth = 128; constexpr unsigned maxSupportedStackDepth = 128;
@@ -320,9 +320,9 @@ reportNow(uint32_t flags, const char *message)
#endif #endif
} }
LLVM_ATTRIBUTE_NOINLINE SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE SWIFT_RUNTIME_EXPORT void
void _swift_runtime_on_report(uintptr_t flags, const char *message, _swift_runtime_on_report(uintptr_t flags, const char *message,
RuntimeErrorDetails *details) { RuntimeErrorDetails *details) {
// Do nothing. This function is meant to be used by the debugger. // Do nothing. This function is meant to be used by the debugger.
// The following is necessary to avoid calls from being optimized out. // The following is necessary to avoid calls from being optimized out.

View File

@@ -327,8 +327,8 @@ HeapObject *swift::swift_allocEmptyBox() {
} }
// Forward-declare this, but define it after swift_release. // Forward-declare this, but define it after swift_release.
extern "C" SWIFT_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED extern "C" SWIFT_LIBRARY_VISIBILITY SWIFT_NOINLINE LLVM_ATTRIBUTE_USED void
void _swift_release_dealloc(HeapObject *object); _swift_release_dealloc(HeapObject *object);
static HeapObject *_swift_retain_(HeapObject *object) { static HeapObject *_swift_retain_(HeapObject *object) {
SWIFT_RT_TRACK_INVOCATION(object, swift_retain); SWIFT_RT_TRACK_INVOCATION(object, swift_retain);

View File

@@ -30,14 +30,19 @@ namespace swift {
struct HeapObject; struct HeapObject;
} }
SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED SWIFT_CC(swift)
SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE LLVM_ATTRIBUTE_USED
void _swift_leaks_startTrackingObjects(const char *); void _swift_leaks_startTrackingObjects(const char *);
SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
SWIFT_CC(swift)
SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE LLVM_ATTRIBUTE_USED
int _swift_leaks_stopTrackingObjects(const char *); int _swift_leaks_stopTrackingObjects(const char *);
SWIFT_RUNTIME_EXPORT LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
void _swift_leaks_startTrackingObject(swift::HeapObject *); SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE LLVM_ATTRIBUTE_USED void
SWIFT_RUNTIME_EXPORT LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED _swift_leaks_startTrackingObject(swift::HeapObject *);
void _swift_leaks_stopTrackingObject(swift::HeapObject *);
SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE LLVM_ATTRIBUTE_USED void
_swift_leaks_stopTrackingObject(swift::HeapObject *);
#define SWIFT_LEAKS_START_TRACKING_OBJECT(obj) \ #define SWIFT_LEAKS_START_TRACKING_OBJECT(obj) \
_swift_leaks_startTrackingObject(obj) _swift_leaks_startTrackingObject(obj)