chanyancheung / data-race-test

Automatically exported from code.google.com/p/data-race-test
0 stars 1 forks source link

tsanv2: instrumentation of i++ #95

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This ought to be a single memory access:

void foobar(int *p) {
  p[0]++;
}

0000000000002430 <foobar>:
void foobar(int *p) {
    2430:       55                      push   %rbp
    2431:       53                      push   %rbx
    2432:       50                      push   %rax
    2433:       48 89 fb                mov    %rdi,%rbx
    2436:       48 8b 7c 24 18          mov    0x18(%rsp),%rdi
    243b:       e8 50 03 00 00          callq  2790 <__tsan_func_entry>
  p[0]++;
    2440:       48 89 df                mov    %rbx,%rdi
    2443:       e8 68 85 00 00          callq  a9b0 <__tsan_read4>
    2448:       8b 2b                   mov    (%rbx),%ebp
    244a:       48 89 df                mov    %rbx,%rdi
    244d:       e8 1e 67 00 00          callq  8b70 <__tsan_write4>
    2452:       ff c5                   inc    %ebp
    2454:       89 2b                   mov    %ebp,(%rbx)
}
    2456:       e8 75 02 00 00          callq  26d0 <__tsan_func_exit>
    245b:       48 83 c4 08             add    $0x8,%rsp
    245f:       5b                      pop    %rbx
    2460:       5d                      pop    %rbp
    2461:       c3                      retq   

Original issue reported on code.google.com by dvyu...@google.com on 2 Apr 2012 at 11:29

GoogleCodeExporter commented 9 years ago
This should be fixed by LLVM r154418.
On Spec CPU2006 this optimization saves roughly 4% of instrumented reads
(which is 3% of all instrumented accesses):
Writes            : 161216
Reads             : 446458
Reads-before-write: 18295

Original comment by konstant...@gmail.com on 10 Apr 2012 at 6:21

GoogleCodeExporter commented 9 years ago
Nice!
You seem to be measuring the number of "static" mops in the compiler, right?
You may try to measure (at least in future) the number of "dynamic"
accesses with "make CFLAGS=-DTSAN_COLLECT_STATS". I think it's more
representative number.

Original comment by dvyu...@google.com on 10 Apr 2012 at 6:31

GoogleCodeExporter commented 9 years ago
Oh, sure, that's static numbers. 

Original comment by konstant...@gmail.com on 10 Apr 2012 at 6:33