[cfe-dev] Calling main() is ub based optimizations
Eric Fiselier via cfe-dev
cfe-dev at lists.llvm.org
Mon Nov 14 01:43:58 PST 2016
On Sat, Nov 12, 2016 at 11:09 AM, Mehdi Amini via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> main is marked as “norecurse” in C++ and not in C:
>
I would be interested in seeing the standardese associated with each
behavior.
/Eric
>
> $ echo "int main() {}" | clang -x c - -emit-llvm -o - -S | grep recurse
> $ echo "int main() {}" | clang -x c++ - -emit-llvm -o - -S | grep recurse
> ; Function Attrs: norecurse nounwind ssp uwtable
> attributes #0 = { norecurse nounwind ssp uwtable ...
>
> —
> Mehdi
>
> > On Nov 12, 2016, at 1:58 AM, Piotr Padlewski via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> >
> > Hey,
> > I have question. Does clang take advantage of the fact that calling main
> or taking address of main function in C++ is undefined behavior?
> > I've heard that some compilers do so and AFAIRC I've heard that it was
> important to some benchmarks.
> > 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.
> >
> > Is there any optimization that do this in clang?
> >
> > Piotr
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161114/d4d22289/attachment.html>
More information about the cfe-dev
mailing list