From: Dan Gohman Date: Thu, 21 Oct 2010 21:55:35 +0000 (+0000) Subject: Add some more documentation. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=ee135131b16390177c09c1620e322bcf38a78e0a Add some more documentation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117070 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/TypeBasedAliasAnalysis.cpp b/lib/Analysis/TypeBasedAliasAnalysis.cpp index 38f3a11372d..65ab70f0b84 100644 --- a/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -12,27 +12,33 @@ // // In LLVM IR, memory does not have types, so LLVM's own type system is not // suitable for doing TBAA. Instead, metadata is added to the IR to describe -// a type system of a higher level language. +// a type system of a higher level language. This can be used to implement +// typical C/C++ TBAA, but it can also be used to implement custom alias +// analysis behavior for other languages. // -// This pass is language-independent. The type system is encoded in -// metadata. This allows this pass to support typical C and C++ TBAA, but -// it can also support custom aliasing behavior for other languages. +// The current metadata format is very simple. TBAA MDNodes have up to +// three fields, e.g.: +// !0 = metadata !{ metadata !"an example type tree" } +// !1 = metadata !{ metadata !"int", metadata !0 } +// !2 = metadata !{ metadata !"float", metadata !0 } +// !3 = metadata !{ metadata !"const float", metadata !2, i64 1 } // -// This is a work-in-progress. It doesn't work yet, and the metadata -// format isn't stable. +// The first field is an identity field. It can be any value, usually +// an MDString, which uniquely identifies the type. The most important +// name in the tree is the name of the root node. Two trees with +// different root node names are entirely disjoint, even if they +// have leaves with common names. +// +// The second field identifies the type's parent node in the tree, or +// is null or omitted for a root node. A type is considered to alias +// all of its decendents and all of its ancestors in the tree. // -// The current metadata format is very simple. MDNodes have up to three -// fields, e.g.: -// !0 = metadata !{ !"name", !1, 0 } -// The first field is an identity field. It can be any MDString which -// uniquely identifies the type. The second field identifies the type's -// parent node in the tree, or is null or omitted for a root node. // If the third field is present, it's an integer which if equal to 1 -// indicates that the type is "constant" (meaning -// pointsToConstantMemory should return true; see +// indicates that the type is "constant" (meaning pointsToConstantMemory +// should return true; see // http://llvm.org/docs/AliasAnalysis.html#OtherItfs). // -// TODO: The current metadata encoding scheme doesn't support struct +// TODO: The current metadata format doesn't support struct // fields. For example: // struct X { // double d;