[cfe-dev] TBAA metadata

Marianne Mailhot-Sarrasin via cfe-dev cfe-dev at lists.llvm.org
Fri Apr 27 06:47:50 PDT 2018


Hi,

I am looking at the Type Based Alias Analysis and I am trying to understand why, from what I see, pointsToConstantMemory() never returns true.

It seems that this information should come from the TBAA metadata, in which the Access Tag has an optional 4th field to specify this information.

"Access tags are represented as MDNode s with either 3 or 4 operands. The first operand is an MDNode pointing to the node representing the base type. The second operand is an MDNode pointing to the node representing the access type. The third operand is a ConstantInt that states the offset of the access. If a fourth field is present, it must be a ConstantInt valued at 0 or 1. If it is 1 then the access tag states that the location being accessed is "constant" (meaningpointsToConstantMemory should return true; see other useful AliasAnalysis methods<https://llvm.org/docs/AliasAnalysis.html#OtherItfs>). The TBAA root of the access type and the base type of an access tag must be the same, and that is the TBAA root of the access tag." (https://llvm.org/docs/LangRef.html#tbaa-metadata)

But, from what I see, the CodeGenTBAA pass never sets this field. CodeGenTBAA::getAccessTagInfo() calls createTBAAStructTagNode() to create the access tag, but it does not pass the IsConstant parameter.

  /// \brief Return metadata for a TBAA tag node with the given
  /// base type, access type and offset relative to the base type.
  MDNode *createTBAAStructTagNode(MDNode *BaseType, MDNode *AccessType,
                                  uint64_t Offset, bool IsConstant = false);

So my questions are:


-           Is there any reason IsConstant is never set ?

-           Would it be valid to set this information according to the const-qualifier of the data accessed, maybe by getting it from QualType::isConstQualified()somehow ?

Thanks,
Marianne

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180427/c2e836f5/attachment-0001.html>


More information about the cfe-dev mailing list