Skip to content

Commit 417f1f1

Browse files
authored
Merge pull request swiftlang#31599 from compnerd/there-is-no-line
runtime: add and switch to `SWIFT_NOINLINE` (NFC)
2 parents 923def2 + f465ec0 commit 417f1f1

File tree

6 files changed

+33
-24
lines changed

6 files changed

+33
-24
lines changed

stdlib/public/SwiftShims/RefCount.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ namespace swift {
182182
}
183183

184184
// FIXME: HACK: copied from HeapObject.cpp
185-
extern "C" SWIFT_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
186-
void _swift_release_dealloc(swift::HeapObject *object);
185+
extern "C" SWIFT_LIBRARY_VISIBILITY SWIFT_NOINLINE LLVM_ATTRIBUTE_USED void
186+
_swift_release_dealloc(swift::HeapObject *object);
187187

188188
namespace swift {
189189

@@ -697,19 +697,19 @@ class RefCounts {
697697

698698
// Out-of-line slow paths.
699699

700-
LLVM_ATTRIBUTE_NOINLINE
700+
SWIFT_NOINLINE
701701
void incrementSlow(RefCountBits oldbits, uint32_t inc) SWIFT_CC(PreserveMost);
702702

703-
LLVM_ATTRIBUTE_NOINLINE
703+
SWIFT_NOINLINE
704704
void incrementNonAtomicSlow(RefCountBits oldbits, uint32_t inc);
705705

706-
LLVM_ATTRIBUTE_NOINLINE
706+
SWIFT_NOINLINE
707707
bool tryIncrementSlow(RefCountBits oldbits);
708708

709-
LLVM_ATTRIBUTE_NOINLINE
709+
SWIFT_NOINLINE
710710
bool tryIncrementNonAtomicSlow(RefCountBits oldbits);
711711

712-
LLVM_ATTRIBUTE_NOINLINE
712+
SWIFT_NOINLINE
713713
void incrementUnownedSlow(uint32_t inc);
714714

715715
public:

stdlib/public/SwiftShims/Visibility.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
#define SWIFT_ALWAYS_INLINE
6767
#endif
6868

69+
#if __has_attribute(noinline)
70+
#define SWIFT_NOINLINE __attribute__((__noinline__))
71+
#else
72+
#define SWIFT_NOINLINE
73+
#endif
74+
6975
#if __has_attribute(unavailable)
7076
#define SWIFT_ATTRIBUTE_UNAVAILABLE __attribute__((__unavailable__))
7177
#else

stdlib/public/runtime/Casting.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,9 @@ swift::swift_getMangledTypeName(const Metadata *type) {
248248
// This is noinline to preserve this frame in stack traces.
249249
// We want "dynamicCastFailure" to appear in crash logs even we crash
250250
// during the diagnostic because some Metadata is invalid.
251-
LLVM_ATTRIBUTE_NORETURN
252-
LLVM_ATTRIBUTE_NOINLINE
253-
void
254-
swift::swift_dynamicCastFailure(const void *sourceType, const char *sourceName,
255-
const void *targetType, const char *targetName,
251+
LLVM_ATTRIBUTE_NORETURN SWIFT_NOINLINE void
252+
swift::swift_dynamicCastFailure(const void *sourceType, const char *sourceName,
253+
const void *targetType, const char *targetName,
256254
const char *message) {
257255
swift::fatalError(/* flags = */ 0,
258256
"Could not cast value of type '%s' (%p) to '%s' (%p)%s%s\n",

stdlib/public/runtime/Errors.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static _Unwind_Reason_Code SwiftUnwindFrame(struct _Unwind_Context *context, voi
224224
}
225225
#endif
226226

227-
LLVM_ATTRIBUTE_NOINLINE
227+
SWIFT_NOINLINE
228228
void swift::printCurrentBacktrace(unsigned framesToSkip) {
229229
#if SWIFT_SUPPORTS_BACKTRACE_REPORTING
230230
constexpr unsigned maxSupportedStackDepth = 128;
@@ -320,9 +320,9 @@ reportNow(uint32_t flags, const char *message)
320320
#endif
321321
}
322322

323-
LLVM_ATTRIBUTE_NOINLINE SWIFT_RUNTIME_EXPORT
324-
void _swift_runtime_on_report(uintptr_t flags, const char *message,
325-
RuntimeErrorDetails *details) {
323+
SWIFT_NOINLINE SWIFT_RUNTIME_EXPORT void
324+
_swift_runtime_on_report(uintptr_t flags, const char *message,
325+
RuntimeErrorDetails *details) {
326326
// Do nothing. This function is meant to be used by the debugger.
327327

328328
// The following is necessary to avoid calls from being optimized out.

stdlib/public/runtime/HeapObject.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ HeapObject *swift::swift_allocEmptyBox() {
327327
}
328328

329329
// Forward-declare this, but define it after swift_release.
330-
extern "C" SWIFT_LIBRARY_VISIBILITY LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
331-
void _swift_release_dealloc(HeapObject *object);
330+
extern "C" SWIFT_LIBRARY_VISIBILITY SWIFT_NOINLINE LLVM_ATTRIBUTE_USED void
331+
_swift_release_dealloc(HeapObject *object);
332332

333333
static HeapObject *_swift_retain_(HeapObject *object) {
334334
SWIFT_RT_TRACK_INVOCATION(object, swift_retain);

stdlib/public/runtime/Leaks.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,19 @@ namespace swift {
3030
struct HeapObject;
3131
}
3232

33-
SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
33+
SWIFT_CC(swift)
34+
SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE LLVM_ATTRIBUTE_USED
3435
void _swift_leaks_startTrackingObjects(const char *);
35-
SWIFT_CC(swift) SWIFT_RUNTIME_EXPORT LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
36+
37+
SWIFT_CC(swift)
38+
SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE LLVM_ATTRIBUTE_USED
3639
int _swift_leaks_stopTrackingObjects(const char *);
37-
SWIFT_RUNTIME_EXPORT LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
38-
void _swift_leaks_startTrackingObject(swift::HeapObject *);
39-
SWIFT_RUNTIME_EXPORT LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
40-
void _swift_leaks_stopTrackingObject(swift::HeapObject *);
40+
41+
SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE LLVM_ATTRIBUTE_USED void
42+
_swift_leaks_startTrackingObject(swift::HeapObject *);
43+
44+
SWIFT_RUNTIME_EXPORT SWIFT_NOINLINE LLVM_ATTRIBUTE_USED void
45+
_swift_leaks_stopTrackingObject(swift::HeapObject *);
4146

4247
#define SWIFT_LEAKS_START_TRACKING_OBJECT(obj) \
4348
_swift_leaks_startTrackingObject(obj)

0 commit comments

Comments
 (0)