[llvm] r190216 - TBAA: add isTBAAVtableAccess to MDNode so clients can call the function

Duncan Sands duncan.sands at gmail.com
Tue Sep 10 07:17:01 PDT 2013


Hi Manman,

On 07/09/13 00:47, Manman Ren wrote:
> Author: mren
> Date: Fri Sep  6 17:47:05 2013
> New Revision: 190216
...
> --- llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp (original)
> +++ llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp Fri Sep  6 17:47:05 2013
> @@ -458,6 +458,25 @@ TypeBasedAliasAnalysis::getModRefInfo(Im
>     return AliasAnalysis::getModRefInfo(CS1, CS2);
>   }
>
> +bool MDNode::isTBAAVtableAccess() const {
> +  if (!EnableStructPathTBAA) {
> +    if (getNumOperands() < 1) return false;
> +    if (MDString *Tag1 = dyn_cast<MDString>(getOperand(0))) {
> +      if (Tag1->getString() == "vtable pointer") return true;

using magic names like this seems pretty naughty to me (especially
when they don't seem to be documented).  Before your patch this hack
was restricted to ThreadSanitizer.cpp, but now you've pretty much
made it official it by pulling it into the core.  If you need to
add extra information to a TBAA mdnode, adding an extra flag seems
like a cleaner way to go.

Ciao, Duncan.

> +    }
> +    return false;
> +  }
> +
> +  // For struct-path aware TBAA, we use the access type of the tag.
> +  if (getNumOperands() < 2) return false;
> +  MDNode *Tag = cast_or_null<MDNode>(getOperand(1));
> +  if (!Tag) return false;
> +  if (MDString *Tag1 = dyn_cast<MDString>(Tag->getOperand(0))) {
> +    if (Tag1->getString() == "vtable pointer") return true;
> +  }
> +  return false;
> +}
> +
>   MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
>     if (!A || !B)
>       return NULL;
>




More information about the llvm-commits mailing list