[LLVMbugs] [Bug 22514] Wrong transformation due to semantic gap between C11 and LLVM semantics

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 10 02:21:03 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22514

soham <sohachak at mpi-sws.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #4 from soham <sohachak at mpi-sws.org> ---
Reference
----------
ISO/IEC 14882:2011 Programming Language C++
Link: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf

> The R_sc(X,1) in readA() reads-from W_sc(X,1) in writeA() which results in
> synchronization

 >> That is not correct; no synchronization happens here.

 29.3 page - 1116
>From 1.
"memory_order_release, memory_order_acq_rel, and memory_order_seq_cst: a store
operation performs
a release operation on the affected memory location."

>From 2.
"An atomic operation A that performs a release operation on an atomic object M
synchronizes with an atomic
operation B that performs an acquire operation on M and takes its value from
any side effect in the release
sequence headed by A."

Considering these the R_sc(x,1) in readA() reads-from W_sc(x,1) in writeA()
which results in synchronization.


> and W_na(a,42) happens-before R_na(a,42)

>> No, there is no happens-before relation here.


1.10 [intro.multithreaded] page 13-14

"
11 An evaluation A inter-thread happens before an evaluation B if
— A synchronizes with B, or
— A is dependency-ordered before B, or
— for some evaluation X
— A synchronizes with X and X is sequenced before B, or
— A is sequenced before X and X inter-thread happens before B, or
— A inter-thread happens before X and X inter-thread happens before B.
"
"
12 An evaluation A happens before an evaluation B if:
— A is sequenced before B, or
— A inter-thread happens before B
"

In our example x=1 and x==1 synchronizes(sw); hence x=1 happens-before(hb)
x==1. 

Also a=42; is sequenced before(sb) x=1 in writeA() and in readA() x==1 is
sequenced before r1=a.

Hence a=42 ->(sb) x=1 ->(sw) x==1 ->(sb) r1=a which means a=42 ->(hb) r1=a and
the program is not racy.  

If you reopen this again, please provide an explanation of why you think there
is a happens-before relation here, referencing the rules in [intro.multithread]
in the C++ standard to justify the steps in your explanation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150210/d254af0f/attachment.html>


More information about the llvm-bugs mailing list