diff options
author | Victor Hernandez <vhernandez@apple.com> | 2010-02-04 01:13:08 +0000 |
---|---|---|
committer | Victor Hernandez <vhernandez@apple.com> | 2010-02-04 01:13:08 +0000 |
commit | af6ce14d679e2a87d2de6a3e26ce6a1f34d1f879 (patch) | |
tree | 27f7c64c1cd8c519da09dcd06f60f02bebfd74d9 /lib/Bitcode/Writer | |
parent | ec5ef6d8b0fcdf7bf9df397a0e3d03e1d57b6fc1 (diff) | |
download | external_llvm-af6ce14d679e2a87d2de6a3e26ce6a1f34d1f879.zip external_llvm-af6ce14d679e2a87d2de6a3e26ce6a1f34d1f879.tar.gz external_llvm-af6ce14d679e2a87d2de6a3e26ce6a1f34d1f879.tar.bz2 |
Fix (and test) function-local metadata that occurs before the instruction that it refers to; fix is to not enumerate operands of function-local metadata until after all instructions have been enumerated
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95269 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Writer')
-rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index c46d735..3eacc5e 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -408,21 +408,25 @@ void ValueEnumerator::incorporateFunction(const Function &F) { FirstInstID = Values.size(); + SmallVector<MDNode *, 8> FunctionLocalMDs; // Add all of the instructions. for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) { for (User::const_op_iterator OI = I->op_begin(), E = I->op_end(); OI != E; ++OI) { if (MDNode *MD = dyn_cast<MDNode>(*OI)) - if (!MD->isFunctionLocal()) - // These were already enumerated during ValueEnumerator creation. - continue; - EnumerateOperandType(*OI); + if (MD->isFunctionLocal()) + // Enumerate metadata after the instructions they might refer to. + FunctionLocalMDs.push_back(MD); } if (!I->getType()->isVoidTy()) EnumerateValue(I); } } + + // Add all of the function-local metadata. + for (unsigned i = 0, e = FunctionLocalMDs.size(); i != e; ++i) + EnumerateOperandType(FunctionLocalMDs[i]); } void ValueEnumerator::purgeFunction() { |