<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Update: VS2019 Update 2 is likely to do this; who do I need to prod such that I get to use these unconditionally in our <atomic> ?
<span id="🙂" title=":slight_smile:">🙂</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span title=":slight_smile:"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span title=":slight_smile:">Billy3</span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Billy O'Neal (VC LIBS)<br>
<b>Sent:</b> Tuesday, March 19, 2019 02:01 PM<br>
<b>To:</b> JF Bastien<br>
<b>Cc:</b> cfe-dev<br>
<b>Subject:</b> Re: [cfe-dev] FYI, Intel folks might be looking to add the __iso_volatile_Xxx family for MSVC STL <atomic> soon</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">></span><span style="color:rgb(33,33,33); font-size:15px">MSVC’s volatiles on x86 were traditionally seq_cst when they could.</span><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt"><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Normal loads are already seq_cst on x86 with no extra work. We still intend to use _InterlockedCompareExchange64 (on x86) or _InterlockedExchange64 (on amd64) to implement store. To be clear, this is in response to a specific customer bug where they want to
 put an atomic<8 bytes> into read only memory, and want load() to not break their program with STATUS_ACCESS_VIOLATION. ( <a href="https://developercommunity.visualstudio.com/content/problem/274938/vs2017-1567158p2-stdatomicload-causes-write-access.html">https://developercommunity.visualstudio.com/content/problem/274938/vs2017-1567158p2-stdatomicload-causes-write-access.html</a>
 )</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
><span style="color:rgb(33,33,33); font-size:15px; background-color:rgb(255,255,255); display:inline!important">I think you should add type-generic versions as well.</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
I don't think C1XX or EDG have the ability to do that form of intrinsics right now, so to implement volatile_load/volatile_store we're going to need library tech that calls the __iso_volatile family.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
><span style="color:rgb(33,33,33); font-size:15px; background-color:rgb(255,255,255); display:inline!important">who doesn’t love C++ library features that require compiler support? Right Billy?</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<span style="font-family:Calibri,Arial,Helvetica,sans-serif; background-color:rgb(255,255,255); display:inline!important">I don't hate things that require compiler support. I hate things that require compiler support of the form nobody has demonstrated to be
 reasonably implementable. Things that can be implemented in terms of traditional builtins or intrinsics (like volatile_load / volatile_store) are fine.</span><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Billy3</div>
<div id="x_appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> jfbastien@apple.com <jfbastien@apple.com> on behalf of JF Bastien <jfbastien@apple.com><br>
<b>Sent:</b> Tuesday, March 19, 2019 01:52 PM<br>
<b>To:</b> Billy O'Neal (VC LIBS)<br>
<b>Cc:</b> cfe-dev<br>
<b>Subject:</b> Re: [cfe-dev] FYI, Intel folks might be looking to add the __iso_volatile_Xxx family for MSVC STL <atomic> soon</font>
<div> </div>
</div>
<div class="" style="word-wrap:break-word; line-break:after-white-space">
<div class="">These? <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fcpp%2Fintrinsics%2Farm-intrinsics%3Fview%3Dvs-2017%23IsoVolatileLoadStore&data=02%7C01%7Cbion%40microsoft.com%7C9e4e63a643884977521e08d6acacc3e2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636886255355080579&sdata=zfDNjIZrzKkc3RvHQSGdUadTzJytsmU5vmBbwyk%2FJW0%3D&reserved=0" originalsrc="https://docs.microsoft.com/en-us/cpp/intrinsics/arm-intrinsics?view=vs-2017#IsoVolatileLoadStore" shash="ZhaLVkNZwZOpIqT4j7SS/VDCBoBLjbcdxs2ZTGfYTpzJmls4KQZ+c6LIkec7AKs+wtYCqbRo8nl9DlvLma1doMrSqVWGsMzXB1lnhbu+DAYE2rEzGhuN3YZbWMUUGosuSXqfrUJGqIF4MSOuQmf76PElSaYhpQcnKfEDi5l/Miw=" class="">https://docs.microsoft.com/en-us/cpp/intrinsics/arm-intrinsics?view=vs-2017#IsoVolatileLoadStore</a></div>
<div class=""><br class="">
<blockquote class="" style="margin:0 0 0 40px; border:none; padding:0px">
<div class="">
<div class=""><font face="Courier" class="">__int16 __iso_volatile_load16(const volatile __int16 * Location)</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class="">__int32 __iso_volatile_load32(const volatile __int32 * Location)</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class="">__int64 __iso_volatile_load64(const volatile __int64 * Location)</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class="">__int8 __iso_volatile_load8(const volatile __int8 * Location)</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class=""><br class="">
</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class="">void __iso_volatile_store16(volatile __int16 * Location, __int16 Value)</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class="">void __iso_volatile_store32(volatile __int32 * Location, __int32 Value)</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class="">void __iso_volatile_store64(volatile __int64 * Location, __int64 Value)</font></div>
</div>
<div class="">
<div class=""><font face="Courier" class="">void __iso_volatile_store8(volatile __int8 * Location, __int8 Value)</font></div>
</div>
</blockquote>
<div class="">
<div class=""><br class="">
</div>
<div class="">Seems fine, given how MSVC’s volatiles on x86 were traditionally seq_cst when they could. I think the above match the LLVM IR semantics precisely.</div>
<div class=""><br class="">
</div>
<div class="">I think you should add type-generic versions as well. Then you’ve got a nice builtin for <a href="https://nam06.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwg21.link%2FP1382&data=02%7C01%7Cbion%40microsoft.com%7C9e4e63a643884977521e08d6acacc3e2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636886255355080579&sdata=H8iAKCg12tAuAqfupoU0MMPFYGrMxDc%2F3QxkPkbdRDE%3D&reserved=0" originalsrc="http://wg21.link/P1382" shash="h4NFTdR6B59jFZ89nMq27orCtUZ5SzS6KgzVPmGFWDyJZX6aRwkSAjk3L1Maisqstlv+K403TV01fHi98K7TWhYOi7Lelq/fjFVbMPpWgNI6PS1NaH6+21ZPzajM9oCfpsLqd5hO9dfo37FXgVLW83RmxqQ0SKDnJaDzOiLvwPQ=" class="">volatile_load<T>
 / volatile_store<T></a>, and who doesn’t love C++ library features that require compiler support? Right Billy? 😁</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Mar 19, 2019, at 1:32 PM, Billy O'Neal (VC LIBS) via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div>
<br class="x_x_Apple-interchange-newline">
<div class="">
<div class="" style="font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">
I think Clang has those already implemented for ARM (since our <atomic> compiles there) but we are looking to use them instead of cmpxchg8b to implement load of atomic<8 bytes> on x86 soon.</div>
<div class="" style="font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">
<br class="">
</div>
<div class="" style="font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">
Billy3</div>
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; float:none; display:inline!important">_______________________________________________</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none; float:none; display:inline!important">cfe-dev
 mailing list</span><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<a href="mailto:cfe-dev@lists.llvm.org" class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">cfe-dev@lists.llvm.org</a><br class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fcfe-dev&data=02%7C01%7Cbion%40microsoft.com%7C9e4e63a643884977521e08d6acacc3e2%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636886255355090573&sdata=amedPfjk4WtXDfRgivT9m3clPmrOQGfrl377SJOs7d8%3D&reserved=0" originalsrc="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" shash="WEWsRXy7N9OKHj8Ih/zHN3NEF/ykValCUr28+kBT3EbfhaKu4/Po1Ga6wa8YxuLvsrVPN5g7dUGgrtHEX5WpEIYmCsi7q0IpMTK8gFlm5YgccgAI3gVFZ0mxvqD3vb+L6KMQLy7FhmWgHG3YdcJoKrm1PYnb2pnW4hae/EAKjTc=" class="" style="font-family:Helvetica; font-size:12px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a></div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</div>
</body>
</html>