mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 18:34:09 +00:00
Write function-local metadata as a metadata subblock of a funciton block
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93339 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ab9cd10721
commit
0c316416bd
@ -499,11 +499,13 @@ static void WriteModuleMetadata(const ValueEnumerator &VE,
|
||||
for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
|
||||
|
||||
if (const MDNode *N = dyn_cast<MDNode>(Vals[i].first)) {
|
||||
if (!StartedMetadataBlock) {
|
||||
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
|
||||
StartedMetadataBlock = true;
|
||||
if (!N->isFunctionLocal()) {
|
||||
if (!StartedMetadataBlock) {
|
||||
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
|
||||
StartedMetadataBlock = true;
|
||||
}
|
||||
WriteMDNode(N, VE, Stream, Record);
|
||||
}
|
||||
WriteMDNode(N, VE, Stream, Record);
|
||||
} else if (const MDString *MDS = dyn_cast<MDString>(Vals[i].first)) {
|
||||
if (!StartedMetadataBlock) {
|
||||
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
|
||||
@ -552,6 +554,35 @@ static void WriteModuleMetadata(const ValueEnumerator &VE,
|
||||
Stream.ExitBlock();
|
||||
}
|
||||
|
||||
static void WriteFunctionLocalMetadata(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()) {
|
||||
if (!StartedMetadataBlock) {
|
||||
Stream.EnterSubblock(bitc::METADATA_BLOCK_ID, 3);
|
||||
StartedMetadataBlock = true;
|
||||
}
|
||||
WriteMDNode(N, VE, Stream, Record);
|
||||
// Remove function-local MD, since it is used outside of function.
|
||||
it = Vals.erase(it);
|
||||
end = Vals.end();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
if (StartedMetadataBlock)
|
||||
Stream.ExitBlock();
|
||||
}
|
||||
|
||||
static void WriteMetadataAttachment(const Function &F,
|
||||
const ValueEnumerator &VE,
|
||||
BitstreamWriter &Stream) {
|
||||
@ -1210,6 +1241,7 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
|
||||
// Emit names for all the instructions etc.
|
||||
WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream);
|
||||
|
||||
WriteFunctionLocalMetadata(VE, Stream);
|
||||
WriteMetadataAttachment(F, VE, Stream);
|
||||
VE.purgeFunction();
|
||||
Stream.ExitBlock();
|
||||
|
Loading…
x
Reference in New Issue
Block a user