diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-29 00:03:30 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-05-29 00:03:30 +0000 |
commit | 6b204f796d985a7983f9dd4b37098435814583b9 (patch) | |
tree | 4d779d266d02877f0745ae648992e2b0bc6c2c4e /libgo | |
parent | de8b47de2e5ffc6bdbba5bf14024a843af5d9012 (diff) | |
download | gcc-6b204f796d985a7983f9dd4b37098435814583b9.tar.gz |
runtime: disable split stacks for runtime_printf function under Clang
LLVM's code generator does not currently support split stacks for vararg
functions, so we disable split stacks for the only function that uses this
feature under Clang. This appears to be OK as long as:
- this function only calls non-inlined, internal-linkage (hence no dynamic
loader) functions compiled with split stacks (i.e. go_vprintf), which can
allocate more stack space as required;
- this function itself does not occupy more than BACKOFF bytes of stack space
(see libgcc/config/i386/morestack.S).
These conditions are currently known to be satisfied by Clang on x86-32 and
x86-64. Note that signal handlers receive slightly less stack space than they
would normally do if they happen to be called while this function is being
run. If this turns out to be a problem we could consider increasing BACKOFF.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@211037 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r-- | libgo/runtime/print.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libgo/runtime/print.c b/libgo/runtime/print.c index 1656a998529..ba0b86a2c56 100644 --- a/libgo/runtime/print.c +++ b/libgo/runtime/print.c @@ -11,7 +11,9 @@ //static Lock debuglock; -static void go_vprintf(const char*, va_list); +// Clang requires this function to not be inlined (see below). +static void go_vprintf(const char*, va_list) +__attribute__((noinline)); // write to goroutine-local buffer if diverting output, // or else standard error. @@ -61,6 +63,24 @@ runtime_prints(const char *s) gwrite(s, runtime_findnull((const byte*)s)); } +#if defined (__clang__) && (defined (__i386__) || defined (__x86_64__)) +// LLVM's code generator does not currently support split stacks for vararg +// functions, so we disable the feature for this function under Clang. This +// appears to be OK as long as: +// - this function only calls non-inlined, internal-linkage (hence no dynamic +// loader) functions compiled with split stacks (i.e. go_vprintf), which can +// allocate more stack space as required; +// - this function itself does not occupy more than BACKOFF bytes of stack space +// (see libgcc/config/i386/morestack.S). +// These conditions are currently known to be satisfied by Clang on x86-32 and +// x86-64. Note that signal handlers receive slightly less stack space than they +// would normally do if they happen to be called while this function is being +// run. If this turns out to be a problem we could consider increasing BACKOFF. +void +runtime_printf(const char *s, ...) +__attribute__((no_split_stack)); +#endif + void runtime_printf(const char *s, ...) { |