[PATCH] D49434: Put "built-in" function definitions in global Used list, for LTO. (fix bug 34169)

Steven Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 18 10:15:41 PDT 2018


steven_wu added a comment.

In https://reviews.llvm.org/D49434#1165761, @tejohnson wrote:

> In https://reviews.llvm.org/D49434#1165612, @pcc wrote:
>
> > You wouldn't be making changes to the IR, only the summary. I was thinking that you might add code to http://llvm-cs.pcc.me.uk/lib/Analysis/ModuleSummaryAnalysis.cpp#534 that would effectively do:
> >
> >   if (ValueInfo VI = Index.getValueInfo(GlobalValue::getGUID("memcpy")))
> >       for (auto &Summary : VI.getSummaryList())
> >         Summary->setLive(true);
> >   if (ValueInfo VI = Index.getValueInfo(GlobalValue::getGUID("memmove")))
> >       for (auto &Summary : VI.getSummaryList())
> >         Summary->setLive(true);
> >   // etc.
> >
>
>
> If I recall correctly it wasn't the LTO dead code elimination that was removing them. Caroline, I forget what was happening in the original case - were they being internalized by LTO and then eliminated by GlobalDCE? If so, then Peter's approach should fix the issue by preventing them from being internalized (at least by ThinLTO, not sure about regular LTO).


The legacy LTOCodeGenerator has a preserve list which you can declare symbols to preserve (which is essentially the same mechanism as this implementation). Not sure what is the equivalent for the C++ API but I guess you can just reuse that?


https://reviews.llvm.org/D49434





More information about the llvm-commits mailing list