AA metadata refactoring (introduce AAMDNodes)

In order to enable the preservation of noalias function parameter information
after inlining, and the representation of block-level __restrict__ pointer
information (etc.), additional kinds of aliasing metadata will be introduced.
This metadata needs to be carried around in AliasAnalysis::Location objects
(and MMOs at the SDAG level), and so we need to generalize the current scheme
(which is hard-coded to just one TBAA MDNode*).

This commit introduces only the necessary refactoring to allow for the
introduction of other aliasing metadata types, but does not actually introduce
any (that will come in a follow-up commit). What it does introduce is a new
AAMDNodes structure to hold all of the aliasing metadata nodes associated with
a particular memory-accessing instruction, and uses that structure instead of
the raw MDNode* in AliasAnalysis::Location, etc.

No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213859 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Hal Finkel
2014-07-24 12:16:19 +00:00
parent a4abc43a56
commit 2c7c54c86c
50 changed files with 521 additions and 389 deletions

View File

@@ -25,6 +25,7 @@ namespace llvm {
class FastMathFlags;
class LLVMContext;
class MDNode;
struct AAMDNodes;
template<typename ValueSubClass, typename ItemParentClass>
class SymbolTableListTraits;
@@ -168,6 +169,11 @@ public:
getAllMetadataOtherThanDebugLocImpl(MDs);
}
/// getAAMetadata - Fills the AAMDNodes structure with AA metadata from
/// this instruction. When Merge is true, the existing AA metadata is
/// merged with that from this instruction providing the most-general result.
void getAAMetadata(AAMDNodes &N, bool Merge = false) const;
/// setMetadata - Set the metadata of the specified kind to the specified
/// node. This updates/replaces metadata if already present, or removes it if
/// Node is null.
@@ -189,6 +195,10 @@ public:
return dropUnknownMetadata(IDs);
}
/// setAAMetadata - Sets the metadata on this instruction from the
/// AAMDNodes structure.
void setAAMetadata(const AAMDNodes &N);
/// setDebugLoc - Set the debug location information for this instruction.
void setDebugLoc(const DebugLoc &Loc) { DbgLoc = Loc; }

View File

@@ -15,6 +15,7 @@
#ifndef LLVM_IR_MDBUILDER_H
#define LLVM_IR_MDBUILDER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/DataTypes.h"
#include <utility>
@@ -25,7 +26,6 @@ template <typename T> class ArrayRef;
class LLVMContext;
class MDNode;
class MDString;
class StringRef;
class MDBuilder {
LLVMContext &Context;

View File

@@ -17,6 +17,7 @@
#define LLVM_IR_METADATA_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/iterator_range.h"
@@ -66,6 +67,49 @@ public:
}
};
/// AAMDNodes - A collection of metadata nodes that might be associated with a
/// memory access used by the alias-analysis infrastructure.
struct AAMDNodes {
AAMDNodes(MDNode *T = nullptr)
: TBAA(T) {}
bool operator == (const AAMDNodes &A) const {
return equals(A);
}
bool operator != (const AAMDNodes &A) const {
return !equals(A);
}
operator bool() const {
return TBAA;
}
/// TBAA - The tag for type-based alias analysis.
MDNode *TBAA;
protected:
bool equals(const AAMDNodes &A) const {
return TBAA == A.TBAA;
}
};
// Specialize DenseMapInfo for AAMDNodes.
template<>
struct DenseMapInfo<AAMDNodes> {
static inline AAMDNodes getEmptyKey() {
return AAMDNodes(DenseMapInfo<MDNode *>::getEmptyKey());
}
static inline AAMDNodes getTombstoneKey() {
return AAMDNodes(DenseMapInfo<MDNode *>::getTombstoneKey());
}
static unsigned getHashValue(const AAMDNodes &Val) {
return DenseMapInfo<MDNode *>::getHashValue(Val.TBAA);
}
static bool isEqual(const AAMDNodes &LHS, const AAMDNodes &RHS) {
return LHS == RHS;
}
};
class MDNodeOperand;
@@ -171,6 +215,7 @@ public:
/// Methods for metadata merging.
static MDNode *getMostGenericTBAA(MDNode *A, MDNode *B);
static AAMDNodes getMostGenericAA(const AAMDNodes &A, const AAMDNodes &B);
static MDNode *getMostGenericFPMath(MDNode *A, MDNode *B);
static MDNode *getMostGenericRange(MDNode *A, MDNode *B);
private: