Bug 55488 - Implement cold calls in tsan run-time
Summary: Implement cold calls in tsan run-time
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-27 13:58 UTC by Konstantin Serebryany
Modified: 2013-01-14 13:20 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Serebryany 2012-11-27 13:58:52 UTC
The hottest functions in tsan run-time make two cold calls: __tsan_report_race and __tsan_trace_switch

If these calls are implemented via regular calling convention,
they ruin the performance since the compiler creates too many spills.
So, we've manually implemented a cold-call calling convention using a separate assembly file, libsanitizer/tsan/tsan_rtl_amd64.S

Currently, this hack is disabled in GCC causing the tsan run-time to be slower than it could be: 

libsanitizer/tsan/tsan_rtl.h: 

#if 0 && TSAN_DEBUG == 0
...
#define HACKY_CALL(f) \


We need to enable building/linking the file libsanitizer/tsan/tsan_rtl_amd64.S and enable the HACKY_CALL in libsanitizer/tsan/tsan_rtl.h. This will eliminate the only difference left between the gcc version and upstream. 

Or maybe gcc has another way to implement a cold call?
Comment 1 wmi 2013-01-10 17:57:40 UTC
Author: wmi
Date: Thu Jan 10 17:57:34 2013
New Revision: 195092

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195092
Log:
2013-01-10  Wei Mi  <wmi@google.com>

libsanitizer/
        PR sanitizer/55488
        * tsan/Makefile.am: Add tsan_rtl_amd64.S.
        * tsan/Makefile.in: Regenerated.
        * tsan/tsan_rtl.h: Enable HACKY_CALL.

Modified:
    trunk/libsanitizer/ChangeLog
    trunk/libsanitizer/tsan/Makefile.am
    trunk/libsanitizer/tsan/Makefile.in
    trunk/libsanitizer/tsan/tsan_rtl.h
Comment 2 Dmitry Vyukov 2013-01-11 19:52:55 UTC
Great, thanks!
I guess we need to close this bug now.
Comment 3 Kostya Serebryany 2013-01-14 13:20:01 UTC
thanks! I confirmed the fix.