[PATCH] D29110: LangRef: Document the allowed metadata dropping transforms.
Mehdi AMINI via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 21:56:13 PST 2017
mehdi_amini added a comment.
In https://reviews.llvm.org/D29110#655763, @pcc wrote:
> In https://reviews.llvm.org/D29110#655741, @mehdi_amini wrote:
>
> > I believe the implication of this hasn't been considered enough, and ultimately it means that any pass that looks at a global needs to understand the associated metadata.
>
>
> Only passes that rebuild globals without dropping them
What do you mean "without dropping them"? Aren't you making illegal to drop them?
> There is already support for copying metadata when rebuilding globals (see `GlobalObject::copyMetadata`). Look at its callers [0] for how often it is needed. Somehow we've been able to launch features which rely on global-metadata-for-correctness (e.g. CFI and devirtualization on Linux Chrome) with that level of support.
What about merging globals? What about shrinking a global based on the uses? (Int-> bool for example).
> Ultimately I care about keeping things simple.
I'm not convinced simplicity has to go before soundness.
> Should we invent some other way of representing type information? I suppose we could, but that would seem to involve a significant parallel infrastructure to metadata and we wouldn't be in much of a better place to where we started, i.e. we would still need to preserve whatever we replace type metadata with, etc.
Right, the problem is not that you're using metadata, the problem is that you put a burden on the rest of the compiler to understand your construct, that's a flaw in the way the feature itself is designed.
> Perhaps a better way of thinking about whether to keep metadata is by analogy to linkage. We can drop unreferenced globals with internal linkage without breaking semantics, but not external or weak globals. In principle we could add a similar concept for metadata attached to globals, but I don't see a pressing need at this point.
Sorry I don't understand the analogy here. Linkage have a clear semantic and a clear set of rules. Metadata don't.
Dropping them is *not* the only problem, the problem is updating them when mutating the IR and keeping their semantic valid.
https://reviews.llvm.org/D29110
More information about the llvm-commits
mailing list