Skip to content

Commit 5591bd2

Browse files
committed
py/nlrthumb: Do not mark nlr_push as not returning anything.
By adding __builtin_unreachable() at the end of nlr_push, we're essentially telling the compiler that this function will never return. When GCC LTO is in use, this means that any time nlr_push() is called (which is often), the compiler thinks this function will never return and thus eliminates all code following the call. Note: I've added a 'return 0' for older GCC versions like 4.6 which complain about not returning anything (which doesn't make sense in a naked function). Newer GCC versions (tested 4.8, 5.4 and some others) don't complain about this.
1 parent 60c6b88 commit 5591bd2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

py/nlrthumb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ __attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) {
7676
#endif
7777
);
7878

79-
#if defined(__GNUC__)
79+
#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
8080
// Older versions of gcc give an error when naked functions don't return a value
81-
__builtin_unreachable();
81+
return 0;
8282
#endif
8383
}
8484

0 commit comments

Comments
 (0)