mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-11 00:39:36 +00:00
Avoid modifying ValueEnumerator's MD ValueList by choosing which function-local MD to write based on the function currently being written
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93441 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
09bf003983
commit
3cd7c3db99
@ -554,30 +554,22 @@ static void WriteModuleMetadata(const ValueEnumerator &VE,
|
||||
Stream.ExitBlock();
|
||||
}
|
||||
|
||||
static void WriteFunctionLocalMetadata(const ValueEnumerator &VE,
|
||||
static void WriteFunctionLocalMetadata(const Function &F,
|
||||
const ValueEnumerator &VE,
|
||||
BitstreamWriter &Stream) {
|
||||
bool StartedMetadataBlock = false;
|
||||
SmallVector<uint64_t, 64> Record;
|
||||
ValueEnumerator::ValueList Vals = VE.getMDValues();
|
||||
ValueEnumerator::ValueList::iterator it = Vals.begin();
|
||||
ValueEnumerator::ValueList::iterator end = Vals.end();
|
||||
|
||||
while (it != end) {
|
||||
if (const MDNode *N = dyn_cast<MDNode>((*it).first)) {
|
||||
if (N->isFunctionLocal()) {
|
||||
const ValueEnumerator::ValueList &Vals = VE.getMDValues();
|
||||
|
||||
for (unsigned i = 0, e = Vals.size(); i != e; ++i)
|
||||
if (const MDNode *N = dyn_cast<MDNode>(Vals[i].first))
|
||||
if (N->getFunction() == &F) {
|
||||
if (!StartedMetadataBlock) {
|
||||
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
|
||||
StartedMetadataBlock = true;
|
||||
}
|
||||
WriteMDNode(N, VE, Stream, Record);
|
||||
// Remove function-local MD, since it is not used outside of function.
|
||||
it = Vals.erase(it);
|
||||
end = Vals.end();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
if (StartedMetadataBlock)
|
||||
Stream.ExitBlock();
|
||||
@ -1227,7 +1219,7 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
|
||||
WriteConstants(CstStart, CstEnd, VE, Stream, false);
|
||||
|
||||
// If there is function-local metadata, emit it now.
|
||||
WriteFunctionLocalMetadata(VE, Stream);
|
||||
WriteFunctionLocalMetadata(F, VE, Stream);
|
||||
|
||||
// Keep a running idea of what the instruction ID is.
|
||||
unsigned InstID = CstEnd;
|
||||
|
@ -105,7 +105,6 @@ public:
|
||||
|
||||
const ValueList &getValues() const { return Values; }
|
||||
const ValueList &getMDValues() const { return MDValues; }
|
||||
ValueList getMDValues() { return MDValues; }
|
||||
const TypeList &getTypes() const { return Types; }
|
||||
const std::vector<const BasicBlock*> &getBasicBlocks() const {
|
||||
return BasicBlocks;
|
||||
|
Loading…
x
Reference in New Issue
Block a user