Free memory used by initializers of global variables, created during linking

Rafael EspĂ­ndola rafael.espindola at
Fri Jan 16 18:17:58 PST 2015

> A 20% slowdown seems excessive.  Do I understand correctly that if you
> don't delete unused `ConstantExpr`s there's no real slowdown?
> Realistically I don't expect `ModuleLinking` to create many surplus
> `ConstantExpr`s.  Those referencing `GlobalValue`s from deleted modules
> get destroyed when the `GlobalValue`s die, and otherwise most constants
> probably get merged in anyway.  I'd prefer to leave that out and avoid
> the slowdown.
> (I'm tempted even to narrow the scope just to `ConstantArray`s, since the
> only quadratic memory explosion is on arrays with appending linkage.)
> Rafael, what do you think?

Yes, that is probably fine. Sorry for leading you down this path. Just
include a comment about the cost and your remark about the quadratic

Once we change constant ownership we can refactor the linker to not
copy dead constants and keep track of any constants it might delete on
the target.


More information about the llvm-commits mailing list