diff options
author | Dan Gohman <gohman@apple.com> | 2010-10-21 18:49:12 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-10-21 18:49:12 +0000 |
commit | 5419ce6827c5edfb2c0b5b17fba5cab2b300b5d4 (patch) | |
tree | f8de935aadb5ce1b7bebcfdfc76fa315b0b98af2 /clang/lib/CodeGen/CodeGenTBAA.cpp | |
parent | f4bbe50fc3d9904455900c1c3dd4330fa754c553 (diff) | |
download | bcm5719-llvm-5419ce6827c5edfb2c0b5b17fba5cab2b300b5d4.tar.gz bcm5719-llvm-5419ce6827c5edfb2c0b5b17fba5cab2b300b5d4.zip |
Add some more comments.
llvm-svn: 117043
Diffstat (limited to 'clang/lib/CodeGen/CodeGenTBAA.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenTBAA.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp index f8772674ae0..fb551b9ac6a 100644 --- a/clang/lib/CodeGen/CodeGenTBAA.cpp +++ b/clang/lib/CodeGen/CodeGenTBAA.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This is the code that manages TBAA information. Relevant standards -// text includes: +// This is the code that manages TBAA information and defines the TBAA policy +// for the optimizer to use. Relevant standards text includes: // // C99 6.5p7 // C++ [basic.lval] (p10 in n3126, p15 in some earlier versions) @@ -32,6 +32,8 @@ CodeGenTBAA::CodeGenTBAA(ASTContext &Ctx, llvm::LLVMContext& VMContext, CodeGenTBAA::~CodeGenTBAA() { } +/// getTBAAInfoForNamedType - Create a TBAA tree node with the given string +/// as its identifier, and the given Parent node as its tree parent. llvm::MDNode *CodeGenTBAA::getTBAAInfoForNamedType(llvm::StringRef NameStr, llvm::MDNode *Parent) { llvm::Value *Ops[] = { @@ -49,12 +51,22 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) { if (llvm::MDNode *N = MetadataCache[Ty]) return N; + // If this is our first node, create the initial tree. if (!Root) { + // Define the root of the tree. This identifies the tree, so that + // if our LLVM IR is linked with LLVM IR from a different front-end + // (or a different version of this front-end), their TBAA trees will + // remain distinct, and the optimizer will treat them conservatively. Root = getTBAAInfoForNamedType("Experimental TBAA", 0); + + // Define the root of the tree for user-accessible memory. C and C++ + // give special powers to char and certain similar types. However, + // these special powers only cover user-accessible memory, and doesn't + // include things like vtables. Char = getTBAAInfoForNamedType("omnipotent char", Root); } - // For now, just emit a very minimal tree. + // Handle builtin types. if (const BuiltinType *BTy = dyn_cast<BuiltinType>(Ty)) { switch (BTy->getKind()) { // Character types are special and can alias anything. @@ -89,6 +101,7 @@ CodeGenTBAA::getTBAAInfo(QualType QTy) { } } + // Handle pointers. // TODO: Implement C++'s type "similarity" and consider dis-"similar" // pointers distinct. if (Ty->isPointerType()) |