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

Frits van Bommel fvbommel at wxs.nl
Fri Jun 12 09:37:08 PDT 2009


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...



More information about the llvm-commits mailing list