[prev in list] [next in list] [prev in thread] [next in thread]
List: cfe-dev
Subject: [cfe-dev] Size suffix ignored in atomic builtins?
From: Mikhail Zolotukhin via cfe-dev <cfe-dev () lists ! llvm ! org>
Date: 2015-08-24 19:52:48
Message-ID: 0129EF0C-8A29-4F23-8697-FA31C1DD8D4B () apple ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi,
Currently atomic intrinsics are overloaded by the datatype. That allow us to use a \
non-suffixed version for any data-type, like this: signed char sc;
void foo(void) {
(void) __sync_fetch_and_add(&sc, 1);
}
instead of explicitly specifying data-type, as here:
signed char sc;
void foo(void) {
(void) __sync_fetch_and_add_1(&sc, 1);
}
For both of these examples clang generates
%0 = atomicrmw add i8* @sc, i8 1 seq_cst
However, it looks like due to this overloading, we completely ignore the size suffix. \
For instance, for signed char sc;
void foo(void) {
(void) __sync_fetch_and_add_4(&sc, 1);
}
clang will generate the same IR with i8:
%0 = atomicrmw add i8* @sc, i8 1 seq_cst ; << i8, instead of i32
Is it an expected behavior, or a bug?
Thanks,
Michael
[Attachment #5 (unknown)]
<html><head><meta http-equiv="Content-Type" content="text/html \
charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: \
space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br \
class=""></div><div class="">Currently atomic intrinsics are overloaded by the \
datatype. That allow us to use a non-suffixed version for any data-type, like \
this:</div><div class=""><div class=""><font face="Menlo" class=""> signed char \
sc;</font></div><div class=""><font face="Menlo" class=""> void foo(void) \
{</font></div><div class=""><font face="Menlo" class=""> (void) \
__sync_fetch_and_add(&sc, 1);</font></div><div class=""><font face="Menlo" \
class=""> }</font></div></div><div class="">instead of explicitly specifying \
data-type, as here:</div><div class=""><div class=""><div class=""><font face="Menlo" \
class=""> signed char sc;</font></div><div class=""><font face="Menlo" \
class=""> void foo(void) {</font></div><div class=""><font face="Menlo" \
class=""> (void) __sync_fetch_and_add_1(&sc, 1);</font></div><div \
class=""><font face="Menlo" class=""> }</font></div></div></div><div \
class=""><font face="Menlo" class=""><br class=""></font></div><div class="">For both \
of these examples clang generates</div><div class=""><font face="Menlo" \
class=""> %0 = atomicrmw add i8* @sc, i8 1 seq_cst</font></div><div \
class=""><br class=""></div><div class="">However, it looks like due to this \
overloading, we completely ignore the size suffix. For instance, for </div><div \
class=""><div class=""><font face="Menlo" class=""> signed char \
sc;</font></div><div class=""><font face="Menlo" class=""> void foo(void) \
{</font></div><div class=""><font face="Menlo" class=""> (void) \
__sync_fetch_and_add_4(&sc, 1);</font></div><div class=""><font face="Menlo" \
class=""> }</font></div></div><div class=""><br class=""></div><div \
class="">clang will generate the same IR with i8:</div><div class=""><div \
class=""><font face="Menlo" class=""> %0 = atomicrmw add i8* @sc, i8 1 seq_cst \
; << i8, instead of i32</font></div></div><div class=""><br class=""></div><div \
class=""><br class=""></div><div class="">Is it an expected behavior, or a \
bug?</div><div class=""><br class=""></div><div class="">Thanks,</div><div \
class="">Michael</div></body></html>
[Attachment #6 (text/plain)]
_______________________________________________
cfe-dev mailing list
cfe-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic