[cfe-dev] [LLVMdev] [RFC] Module Flags Metadata
gohman at apple.com
Thu Jan 26 14:10:31 PST 2012
On Jan 26, 2012, at 12:54 PM, Devang Patel wrote:
> On Jan 26, 2012, at 11:15 AM, Dan Gohman wrote:
>> or what optimizers must do to preserve it.
> The number one reason behind metadata is to have a mechanism to track values while being completely transparent to optimizer. If you want a guarantee from the optimizer to preserve certain semantics about the way metadata is used (e.g. say to describe range of values) then metadata is not appropriate mechanism.
If the optimizer makes no guarantees whatsoever, then metadata is
not appropriate for anything.
For example, the metadata used by TBAA today is not safe. Imagine an
optimization pass which takes two allocas that are used in
non-overlaping regions and rewrites all uses of one to use the other,
to reduce the stack size. By LLVM IR rules alone, this would seem to
be a valid semantics-preserving transformation. But if the loads
and stores for the two allocas have different TBAA type tags, the
tags will say NoAlias for memory references that do in fact alias.
The only reason why TBAA doesn't have a problem with this today is
that LLVM doesn't happen to implement optimizations which break it
yet. But there are no guarantees.
More information about the cfe-dev