<div dir="ltr"><div>Hi, I ran into this exact problem with an out-of-tree backend that will do stuff like that:</div><div><pre style="white-space:pre-wrap;color:rgb(0,0,0)">setOperationAction(ISD::ATOMIC_SWAP,  MVT::i32, Expand);</pre>
</div><div><br></div>It seems -fno-builtin will only disable builtins marked as "f"<div><div><br></div><div>from \include\clang\Basic\Builtins.def</div>
<div>//  f -> this is a libc/libm function without the '__builtin_' prefix. It can</div><div>//       be followed by ':headername:' to state which header this function</div><div>//       comes from.</div>

</div><div><br></div><div>I do not understand the rational for that.</div><div>I tried to disable all builtins when -fno-builtin but this caused about a dozen clang tests to fail</div><div>I didn't investigate further.</div>
<div><br></div><div>I currently get around this problem by using this patch that allows builtins definition if -fno-builtin</div><div><a href="http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130603/081354.html">http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130603/081354.html</a><br>
</div><div>
<br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jul 19, 2013 at 12:04 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Have you tried -fno-builtin?<br>
<span class="HOEnZb"><font color="#888888"><br>
-Chris<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Jul 19, 2013, at 3:04 AM, Emmanuel Blot <<a href="mailto:eblot.ml@gmail.com">eblot.ml@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> clang emits calls to external functions for built-in functions it<br>
> cannot implement, the way GCC does:<br>
><br>
> From GCC doc about built-in functions for memory accesses:<br>
> "Not all operations are supported by all target processors. If a<br>
> particular operation cannot be implemented on the target processor, a<br>
> warning will be generated and a call an external function will be<br>
> generated. The external function will carry the same name as the<br>
> builtin, with an additional suffix `_n' where n is the size of the<br>
> data type."<br>
><br>
> Is is possible to implement those "external" built-in functions and<br>
> compile them with clang? The "problem" is that clang recognizes their<br>
> signature, and emit an error, such as:<br>
><br>
> error: definition of builtin function<br>
>   '__sync_fetch_and_and_4'<br>
><br>
> I'm unable to find a clang front-end option switch to disable this behavior.<br>
> What is the recommended way to compile such a built-in function?<br>
><br>
> I'm looking for a way to compile those functions in a dedicated<br>
> library, outside the clang build tree.<br>
><br>
> Thanks,<br>
> Emmanuel.<br>
> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>