[Metadata] Fix layer violation in D91576

There is a library layering issue. LLVMAnalysis provides llvm/Analysis/ScopedNoAliasAA.h and depends on LLVMCore.

LLVMCore provides llvm/IR/Metadata.cpp and it should not include a header file in LLVMAnalysis
This commit is contained in:
Fangrui Song
2020-12-03 10:58:46 -08:00
parent e312b388eb
commit 756fa8b9be
3 changed files with 21 additions and 22 deletions

View File

@@ -25,27 +25,6 @@ class Function;
class MDNode;
class MemoryLocation;
/// This is a simple wrapper around an MDNode which provides a higher-level
/// interface by hiding the details of how alias analysis information is encoded
/// in its operands.
class AliasScopeNode {
const MDNode *Node = nullptr;
public:
AliasScopeNode() = default;
explicit AliasScopeNode(const MDNode *N) : Node(N) {}
/// Get the MDNode for this AliasScopeNode.
const MDNode *getNode() const { return Node; }
/// Get the MDNode for this AliasScopeNode's domain.
const MDNode *getDomain() const {
if (Node->getNumOperands() < 2)
return nullptr;
return dyn_cast_or_null<MDNode>(Node->getOperand(1));
}
};
/// A simple AA result which uses scoped-noalias metadata to answer queries.
class ScopedNoAliasAAResult : public AAResultBase<ScopedNoAliasAAResult> {
friend AAResultBase<ScopedNoAliasAAResult>;

View File

@@ -1190,6 +1190,27 @@ void TempMDNodeDeleter::operator()(MDNode *Node) const {
MDNode::deleteTemporary(Node);
}
/// This is a simple wrapper around an MDNode which provides a higher-level
/// interface by hiding the details of how alias analysis information is encoded
/// in its operands.
class AliasScopeNode {
const MDNode *Node = nullptr;
public:
AliasScopeNode() = default;
explicit AliasScopeNode(const MDNode *N) : Node(N) {}
/// Get the MDNode for this AliasScopeNode.
const MDNode *getNode() const { return Node; }
/// Get the MDNode for this AliasScopeNode's domain.
const MDNode *getDomain() const {
if (Node->getNumOperands() < 2)
return nullptr;
return dyn_cast_or_null<MDNode>(Node->getOperand(1));
}
};
/// Typed iterator through MDNode operands.
///
/// An iterator that transforms an \a MDNode::iterator into an iterator over a

View File

@@ -27,7 +27,6 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Analysis/ScopedNoAliasAA.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"