mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-07-21 02:29:22 +00:00
IR: MDNode => Value: Instruction::getAllMetadata()
Change `Instruction::getAllMetadata()` to modify a vector of `Value` instead of `MDNode` and update call sites. This is part of PR21433. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221027 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3a84a6377c
commit
b2187ede9e
@ -174,7 +174,8 @@ public:
|
|||||||
/// getAllMetadata - Get all metadata attached to this Instruction. The first
|
/// getAllMetadata - Get all metadata attached to this Instruction. The first
|
||||||
/// element of each pair returned is the KindID, the second element is the
|
/// element of each pair returned is the KindID, the second element is the
|
||||||
/// metadata value. This list is returned sorted by the KindID.
|
/// metadata value. This list is returned sorted by the KindID.
|
||||||
void getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode*> > &MDs)const{
|
void
|
||||||
|
getAllMetadata(SmallVectorImpl<std::pair<unsigned, Value *>> &MDs) const {
|
||||||
if (hasMetadata())
|
if (hasMetadata())
|
||||||
getAllMetadataImpl(MDs);
|
getAllMetadataImpl(MDs);
|
||||||
}
|
}
|
||||||
@ -293,7 +294,8 @@ private:
|
|||||||
Value *getMetadataImpl(StringRef Kind) const;
|
Value *getMetadataImpl(StringRef Kind) const;
|
||||||
MDNode *getMDNodeImpl(unsigned KindID) const;
|
MDNode *getMDNodeImpl(unsigned KindID) const;
|
||||||
MDNode *getMDNodeImpl(StringRef Kind) const;
|
MDNode *getMDNodeImpl(StringRef Kind) const;
|
||||||
void getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,MDNode*> > &)const;
|
void
|
||||||
|
getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned, Value *>> &) const;
|
||||||
void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<unsigned,
|
void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl<std::pair<unsigned,
|
||||||
MDNode*> > &) const;
|
MDNode*> > &) const;
|
||||||
void clearMetadataHashEntries();
|
void clearMetadataHashEntries();
|
||||||
|
@ -718,7 +718,7 @@ void SlotTracker::processFunction() {
|
|||||||
|
|
||||||
ST_DEBUG("Inserting Instructions:\n");
|
ST_DEBUG("Inserting Instructions:\n");
|
||||||
|
|
||||||
SmallVector<std::pair<unsigned, MDNode*>, 4> MDForInst;
|
SmallVector<std::pair<unsigned, Value *>, 4> MDForInst;
|
||||||
|
|
||||||
// Add all of the basic blocks and instructions with no names.
|
// Add all of the basic blocks and instructions with no names.
|
||||||
for (Function::const_iterator BB = TheFunction->begin(),
|
for (Function::const_iterator BB = TheFunction->begin(),
|
||||||
@ -755,7 +755,7 @@ void SlotTracker::processFunction() {
|
|||||||
// Process metadata attached with this instruction.
|
// Process metadata attached with this instruction.
|
||||||
I->getAllMetadata(MDForInst);
|
I->getAllMetadata(MDForInst);
|
||||||
for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
|
for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
|
||||||
CreateMetadataSlot(MDForInst[i].second);
|
CreateMetadataSlot(cast<MDNode>(MDForInst[i].second));
|
||||||
MDForInst.clear();
|
MDForInst.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2315,7 +2315,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print Metadata info.
|
// Print Metadata info.
|
||||||
SmallVector<std::pair<unsigned, MDNode*>, 4> InstMD;
|
SmallVector<std::pair<unsigned, Value *>, 4> InstMD;
|
||||||
I.getAllMetadata(InstMD);
|
I.getAllMetadata(InstMD);
|
||||||
if (!InstMD.empty()) {
|
if (!InstMD.empty()) {
|
||||||
SmallVector<StringRef, 8> MDNames;
|
SmallVector<StringRef, 8> MDNames;
|
||||||
@ -2328,8 +2328,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
|||||||
Out << ", !<unknown kind #" << Kind << ">";
|
Out << ", !<unknown kind #" << Kind << ">";
|
||||||
}
|
}
|
||||||
Out << ' ';
|
Out << ' ';
|
||||||
WriteAsOperandInternal(Out, InstMD[i].second, &TypePrinter, &Machine,
|
WriteAsOperandInternal(Out, cast<MDNode>(InstMD[i].second), &TypePrinter,
|
||||||
TheModule);
|
&Machine, TheModule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printInfoComment(I);
|
printInfoComment(I);
|
||||||
|
@ -745,8 +745,8 @@ Value *Instruction::getMetadataImpl(unsigned KindID) const {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instruction::getAllMetadataImpl(SmallVectorImpl<std::pair<unsigned,
|
void Instruction::getAllMetadataImpl(
|
||||||
MDNode*> > &Result) const {
|
SmallVectorImpl<std::pair<unsigned, Value *>> &Result) const {
|
||||||
Result.clear();
|
Result.clear();
|
||||||
|
|
||||||
// Handle 'dbg' as a special case since it is not stored in the hash table.
|
// Handle 'dbg' as a special case since it is not stored in the hash table.
|
||||||
|
@ -304,7 +304,7 @@ Instruction *InstCombiner::visitAllocaInst(AllocaInst &AI) {
|
|||||||
static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewTy) {
|
static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewTy) {
|
||||||
Value *Ptr = LI.getPointerOperand();
|
Value *Ptr = LI.getPointerOperand();
|
||||||
unsigned AS = LI.getPointerAddressSpace();
|
unsigned AS = LI.getPointerAddressSpace();
|
||||||
SmallVector<std::pair<unsigned, MDNode *>, 8> MD;
|
SmallVector<std::pair<unsigned, Value *>, 8> MD;
|
||||||
LI.getAllMetadata(MD);
|
LI.getAllMetadata(MD);
|
||||||
|
|
||||||
LoadInst *NewLoad = IC.Builder->CreateAlignedLoad(
|
LoadInst *NewLoad = IC.Builder->CreateAlignedLoad(
|
||||||
@ -312,7 +312,7 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT
|
|||||||
LI.getAlignment(), LI.getName());
|
LI.getAlignment(), LI.getName());
|
||||||
for (const auto &MDPair : MD) {
|
for (const auto &MDPair : MD) {
|
||||||
unsigned ID = MDPair.first;
|
unsigned ID = MDPair.first;
|
||||||
MDNode *N = MDPair.second;
|
Value *N = MDPair.second;
|
||||||
// Note, essentially every kind of metadata should be preserved here! This
|
// Note, essentially every kind of metadata should be preserved here! This
|
||||||
// routine is supposed to clone a load instruction changing *only its type*.
|
// routine is supposed to clone a load instruction changing *only its type*.
|
||||||
// The only metadata it makes sense to drop is metadata which is invalidated
|
// The only metadata it makes sense to drop is metadata which is invalidated
|
||||||
|
@ -208,12 +208,11 @@ void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remap attached metadata.
|
// Remap attached metadata.
|
||||||
SmallVector<std::pair<unsigned, MDNode *>, 4> MDs;
|
SmallVector<std::pair<unsigned, Value *>, 4> MDs;
|
||||||
I->getAllMetadata(MDs);
|
I->getAllMetadata(MDs);
|
||||||
for (SmallVectorImpl<std::pair<unsigned, MDNode *> >::iterator
|
for (auto MI = MDs.begin(), ME = MDs.end(); MI != ME; ++MI) {
|
||||||
MI = MDs.begin(), ME = MDs.end(); MI != ME; ++MI) {
|
Value *Old = MI->second;
|
||||||
MDNode *Old = MI->second;
|
Value *New = MapValue(Old, VMap, Flags, TypeMapper, Materializer);
|
||||||
MDNode *New = MapValue(Old, VMap, Flags, TypeMapper, Materializer);
|
|
||||||
if (New != Old)
|
if (New != Old)
|
||||||
I->setMetadata(MI->first, New);
|
I->setMetadata(MI->first, New);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user