<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 28, 2015 at 10:51 AM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On 2015-Oct-28, at 08:59, David Majnemer <<a href="mailto:david.majnemer@gmail.com">david.majnemer@gmail.com</a>> wrote:<br>
><br>
> majnemer added inline comments.<br>
><br>
> ================<br>
> Comment at: lib/Transforms/IPO/GlobalOpt.cpp:1747<br>
> @@ +1746,3 @@<br>
> +<br>
> +// main() is known not to be recursive and to only be called once.<br>
> +static bool isFunctionMain(const Function *F) {<br>
> ----------------<br>
> This is not true if the program is not a C++ program.  `main` can be recursively called in C.  Also, the name `main` may be reused for a function other than the entry point if it is not a hosted program which would be important to LTO something like the Linux kernel.<br>
><br>
> At the very least, we should check the functions prototype.<br>
<br>
</span>Note that this "main" shortcut isn't new; that check has been around<br>
for quite some time.<br></blockquote><div><br></div><div>If LLVM's stance is that it believes main cannot be called from within the program, then we should make clang's -Wmain diagnose calls to main in C language mode.  This would do nothing to help us in free-standing mode though.</div><div><br></div><div>It isn't terribly hard for us to fix it the right way.  I would recommend that we have some sort of entry-point attribute which clang would stick on main if we are in C mode and -ffreestanding has not been specified.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
> ================<br>
> Comment at: lib/Transforms/IPO/GlobalOpt.cpp:1786<br>
> @@ +1785,3 @@<br>
> +    // FIXME: Deal with constantexpr bitcasts?<br>
> +    Instruction *I = dyn_cast<Instruction>(U);<br>
> +    if (!I)<br>
> ----------------<br>
> `auto *I`<br>
><br>
> ================<br>
> Comment at: lib/Transforms/IPO/GlobalOpt.cpp:1803<br>
> @@ +1802,3 @@<br>
> +      for (auto *UU : I->users()) {<br>
> +        LoadInst *LI = dyn_cast<LoadInst>(UU);<br>
> +        if (!LI)<br>
> ----------------<br>
> `auto *LI`<br>
><br>
><br>
> Repository:<br>
>  rL LLVM<br>
><br>
> <a href="http://reviews.llvm.org/D14148" rel="noreferrer" target="_blank">http://reviews.llvm.org/D14148</a><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div></div>