mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
IR: MDNode => Value: Instruction::getAllMetadataOtherThanDebugLoc()
Change `Instruction::getAllMetadataOtherThanDebugLoc()` from a vector of `MDNode` to one of `Value`. Part of PR21433. llvm-svn: 221167
This commit is contained in:
parent
05675977c5
commit
8f49c8202f
@ -182,8 +182,8 @@ public:
|
||||
|
||||
/// getAllMetadataOtherThanDebugLoc - This does the same thing as
|
||||
/// getAllMetadata, except that it filters out the debug location.
|
||||
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl<std::pair<unsigned,
|
||||
MDNode*> > &MDs) const {
|
||||
void getAllMetadataOtherThanDebugLoc(
|
||||
SmallVectorImpl<std::pair<unsigned, Value *>> &MDs) const {
|
||||
if (hasMetadataOtherThanDebugLoc())
|
||||
getAllMetadataOtherThanDebugLocImpl(MDs);
|
||||
}
|
||||
@ -296,8 +296,8 @@ private:
|
||||
MDNode *getMDNodeImpl(StringRef Kind) const;
|
||||
void
|
||||
getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, Value *>> &) const;
|
||||
void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<unsigned,
|
||||
MDNode*> > &) const;
|
||||
void getAllMetadataOtherThanDebugLocImpl(
|
||||
SmallVectorImpl<std::pair<unsigned, Value *>> &) const;
|
||||
void clearMetadataHashEntries();
|
||||
public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -848,7 +848,7 @@ static void WriteMetadataAttachment(const Function &F,
|
||||
|
||||
// Write metadata attachments
|
||||
// METADATA_ATTACHMENT - [m x [value, [n x [id, mdnode]]]
|
||||
SmallVector<std::pair<unsigned, MDNode*>, 4> MDs;
|
||||
SmallVector<std::pair<unsigned, Value *>, 4> MDs;
|
||||
|
||||
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
||||
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end();
|
||||
|
@ -321,7 +321,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
|
||||
EnumerateValueSymbolTable(M->getValueSymbolTable());
|
||||
EnumerateNamedMetadata(M);
|
||||
|
||||
SmallVector<std::pair<unsigned, MDNode*>, 8> MDs;
|
||||
SmallVector<std::pair<unsigned, Value *>, 8> MDs;
|
||||
|
||||
// Enumerate types used by function bodies and argument lists.
|
||||
for (const Function &F : *M) {
|
||||
@ -347,7 +347,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) {
|
||||
MDs.clear();
|
||||
I.getAllMetadataOtherThanDebugLoc(MDs);
|
||||
for (unsigned i = 0, e = MDs.size(); i != e; ++i)
|
||||
EnumerateMetadata(MDs[i].second);
|
||||
EnumerateMetadata(cast<MDNode>(MDs[i].second));
|
||||
|
||||
if (!I.getDebugLoc().isUnknown()) {
|
||||
MDNode *Scope, *IA;
|
||||
@ -741,10 +741,10 @@ void ValueEnumerator::incorporateFunction(const Function &F) {
|
||||
FnLocalMDVector.push_back(MD);
|
||||
}
|
||||
|
||||
SmallVector<std::pair<unsigned, MDNode*>, 8> MDs;
|
||||
SmallVector<std::pair<unsigned, Value *>, 8> MDs;
|
||||
I->getAllMetadataOtherThanDebugLoc(MDs);
|
||||
for (unsigned i = 0, e = MDs.size(); i != e; ++i) {
|
||||
MDNode *N = MDs[i].second;
|
||||
auto *N = cast<MDNode>(MDs[i].second);
|
||||
if (N->isFunctionLocal() && N->getFunction())
|
||||
FnLocalMDVector.push_back(N);
|
||||
}
|
||||
|
@ -548,7 +548,7 @@ Instruction *Instruction::clone() const {
|
||||
|
||||
// Otherwise, enumerate and copy over metadata from the old instruction to the
|
||||
// new one.
|
||||
SmallVector<std::pair<unsigned, MDNode*>, 4> TheMDs;
|
||||
SmallVector<std::pair<unsigned, Value *>, 4> TheMDs;
|
||||
getAllMetadataOtherThanDebugLoc(TheMDs);
|
||||
for (const auto &MD : TheMDs)
|
||||
New->setMetadata(MD.first, MD.second);
|
||||
|
@ -770,9 +770,8 @@ void Instruction::getAllMetadataImpl(
|
||||
array_pod_sort(Result.begin(), Result.end());
|
||||
}
|
||||
|
||||
void Instruction::
|
||||
getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<unsigned,
|
||||
MDNode*> > &Result) const {
|
||||
void Instruction::getAllMetadataOtherThanDebugLocImpl(
|
||||
SmallVectorImpl<std::pair<unsigned, Value *>> &Result) const {
|
||||
Result.clear();
|
||||
assert(hasMetadataHashEntry() &&
|
||||
getContext().pImpl->MetadataStore.count(this) &&
|
||||
|
@ -40,7 +40,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
|
||||
}
|
||||
|
||||
// Get types from functions.
|
||||
SmallVector<std::pair<unsigned, MDNode*>, 4> MDForInst;
|
||||
SmallVector<std::pair<unsigned, Value *>, 4> MDForInst;
|
||||
for (Module::const_iterator FI = M.begin(), E = M.end(); FI != E; ++FI) {
|
||||
incorporateType(FI->getType());
|
||||
|
||||
@ -71,7 +71,7 @@ void TypeFinder::run(const Module &M, bool onlyNamed) {
|
||||
// Incorporate types hiding in metadata.
|
||||
I.getAllMetadataOtherThanDebugLoc(MDForInst);
|
||||
for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
|
||||
incorporateMDNode(MDForInst[i].second);
|
||||
incorporateMDNode(cast<MDNode>(MDForInst[i].second));
|
||||
|
||||
MDForInst.clear();
|
||||
}
|
||||
|
@ -87,7 +87,8 @@ void SITypeRewriter::visitLoadInst(LoadInst &I) {
|
||||
Value *BitCast = Builder.CreateBitCast(Ptr,
|
||||
PointerType::get(v4i32,PtrTy->getPointerAddressSpace()));
|
||||
LoadInst *Load = Builder.CreateLoad(BitCast);
|
||||
SmallVector <std::pair<unsigned, MDNode*>, 8> MD;
|
||||
// FIXME: Should the DebugLoc really get dropped here?
|
||||
SmallVector<std::pair<unsigned, Value *>, 8> MD;
|
||||
I.getAllMetadataOtherThanDebugLoc(MD);
|
||||
for (unsigned i = 0, e = MD.size(); i != e; ++i) {
|
||||
Load->setMetadata(MD[i].first, MD[i].second);
|
||||
|
@ -327,12 +327,11 @@ bool Scalarizer::canTransferMetadata(unsigned Tag) {
|
||||
// Transfer metadata from Op to the instructions in CV if it is known
|
||||
// to be safe to do so.
|
||||
void Scalarizer::transferMetadata(Instruction *Op, const ValueVector &CV) {
|
||||
SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
|
||||
SmallVector<std::pair<unsigned, Value *>, 4> MDs;
|
||||
Op->getAllMetadataOtherThanDebugLoc(MDs);
|
||||
for (unsigned I = 0, E = CV.size(); I != E; ++I) {
|
||||
if (Instruction *New = dyn_cast<Instruction>(CV[I])) {
|
||||
for (SmallVectorImpl<std::pair<unsigned, MDNode *> >::iterator
|
||||
MI = MDs.begin(), ME = MDs.end(); MI != ME; ++MI)
|
||||
for (auto MI = MDs.begin(), ME = MDs.end(); MI != ME; ++MI)
|
||||
if (canTransferMetadata(MI->first))
|
||||
New->setMetadata(MI->first, MI->second);
|
||||
New->setDebugLoc(Op->getDebugLoc());
|
||||
|
@ -1308,13 +1308,13 @@ bool llvm::removeUnreachableBlocks(Function &F) {
|
||||
}
|
||||
|
||||
void llvm::combineMetadata(Instruction *K, const Instruction *J, ArrayRef<unsigned> KnownIDs) {
|
||||
SmallVector<std::pair<unsigned, MDNode*>, 4> Metadata;
|
||||
SmallVector<std::pair<unsigned, Value *>, 4> Metadata;
|
||||
K->dropUnknownMetadata(KnownIDs);
|
||||
K->getAllMetadataOtherThanDebugLoc(Metadata);
|
||||
for (unsigned i = 0, n = Metadata.size(); i < n; ++i) {
|
||||
unsigned Kind = Metadata[i].first;
|
||||
MDNode *JMD = J->getMDNode(Kind);
|
||||
MDNode *KMD = Metadata[i].second;
|
||||
MDNode *KMD = cast<MDNode>(Metadata[i].second);
|
||||
|
||||
switch (Kind) {
|
||||
default:
|
||||
|
@ -531,7 +531,7 @@ static std::string getDebugLocString(const Loop *L) {
|
||||
|
||||
/// \brief Propagate known metadata from one instruction to another.
|
||||
static void propagateMetadata(Instruction *To, const Instruction *From) {
|
||||
SmallVector<std::pair<unsigned, MDNode *>, 4> Metadata;
|
||||
SmallVector<std::pair<unsigned, Value *>, 4> Metadata;
|
||||
From->getAllMetadataOtherThanDebugLoc(Metadata);
|
||||
|
||||
for (auto M : Metadata) {
|
||||
|
@ -188,12 +188,12 @@ static void propagateIRFlags(Value *I, ArrayRef<Value *> VL) {
|
||||
/// \returns \p I after propagating metadata from \p VL.
|
||||
static Instruction *propagateMetadata(Instruction *I, ArrayRef<Value *> VL) {
|
||||
Instruction *I0 = cast<Instruction>(VL[0]);
|
||||
SmallVector<std::pair<unsigned, MDNode *>, 4> Metadata;
|
||||
SmallVector<std::pair<unsigned, Value *>, 4> Metadata;
|
||||
I0->getAllMetadataOtherThanDebugLoc(Metadata);
|
||||
|
||||
for (unsigned i = 0, n = Metadata.size(); i != n; ++i) {
|
||||
unsigned Kind = Metadata[i].first;
|
||||
MDNode *MD = Metadata[i].second;
|
||||
MDNode *MD = cast_or_null<MDNode>(Metadata[i].second);
|
||||
|
||||
for (int i = 1, e = VL.size(); MD && i != e; i++) {
|
||||
Instruction *I = cast<Instruction>(VL[i]);
|
||||
|
Loading…
Reference in New Issue
Block a user