<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 12, 2016 at 11:09 AM, Mehdi Amini via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">main is marked as “norecurse” in C++ and not in C:<br></blockquote><div><br></div><div>I would be interested in seeing the standardese associated with each behavior.</div><div><br></div><div>/Eric</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
$ echo "int main() {}" | clang -x c - -emit-llvm -o - -S | grep recurse<br>
$ echo "int main() {}" | clang -x c++ - -emit-llvm -o - -S | grep recurse<br>
; Function Attrs: norecurse nounwind ssp uwtable<br>
attributes #0 = { norecurse nounwind ssp uwtable ...<br>
<br>
—<br>
Mehdi<br>
<div><div class="h5"><br>
> On Nov 12, 2016, at 1:58 AM, Piotr Padlewski via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Hey,<br>
> I have question. Does clang take advantage of the fact that calling main or taking address of main function in C++ is undefined behavior?<br>
> I've heard that some compilers do so and AFAIRC I've heard that it was important to some benchmarks.<br>
> I guess compiler can assume the values of globals after calling main, because it knows that it is the first function called after initializing them.<br>
><br>
> Is there any optimization that do this in clang?<br>
><br>
> Piotr<br>
</div></div>> ______________________________<wbr>_________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
<br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br></div></div>