[llvm-commits] [llvm] r73230 - in /llvm/trunk: lib/Transforms/IPO/MergeFunctions.cpp test/Transforms/MergeFunc/fold-weak.ll

Nick Lewycky nlewycky at google.com
Fri Jun 12 10:09:14 PDT 2009


2009/6/12 Frits van Bommel <fvbommel at wxs.nl>

> Nick Lewycky wrote:
> > Author: nicholas
> > Date: Fri Jun 12 10:56:56 2009
> > New Revision: 73230
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=73230&view=rev
> > Log:
> > Given two identical weak functions, produce one internal function and two
> weak
> > thunks.
>
> > +    case ExternalWeak: {
> > +      assert(catG == ExternalWeak);
> > +
> > +      // Make them both thunks to the same internal function.
> > +      F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
> > +      Function *H = Function::Create(F->getFunctionType(),
> F->getLinkage(), "",
> > +                                     F->getParent());
> > +      H->copyAttributesFrom(F);
> > +      H->takeName(F);
> > +
> > +      ThunkGToF(F, G);
> > +      ThunkGToF(F, H);
> > +
> > +      F->setLinkage(GlobalValue::InternalLinkage);
> > +    } break;
>
> Here you're basically creating a declaration H with an identical signature
> to F
> just so ThunkGtoF can suck the life out of it, replace it with a thunk, and
> delete it, right?
>
> So shouldn't you also call F->replaceAllUsesWith(H) before doing that?
> Otherwise
> all uses of F would keep using the now-internal version instead of the
> thunk
> created for them...


Oops! Yes, you're exactly right. I'll commit the fix momentarily.

Thanks for doing review!

Nick


>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090612/ff385832/attachment.html>


More information about the llvm-commits mailing list