diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-07-08 01:13:41 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-07-08 01:13:41 +0000 |
commit | a5cbf4351eaed9643ad254f674d325f581204ab2 (patch) | |
tree | 5ed7761a760f3e13fdbc36e15b68b5a84469e07c /llvm/lib/Bitcode/Writer/ValueEnumerator.cpp | |
parent | a74374a86b7948b5c772d5aa761cb24c8568b024 (diff) | |
download | bcm5719-llvm-a5cbf4351eaed9643ad254f674d325f581204ab2.tar.gz bcm5719-llvm-a5cbf4351eaed9643ad254f674d325f581204ab2.zip |
Add an assertion for the value enumerator (bitcode writer) NFC
I have an LTO snapshot (for which I don't have sources) that can't
be read back by LLVM. It seems the writer emitted broken bitcode
and this assertions aims at catching such cases.
llvm-svn: 274819
Diffstat (limited to 'llvm/lib/Bitcode/Writer/ValueEnumerator.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/ValueEnumerator.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp index 398f7d7d00a..5d5bfab58b8 100644 --- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -957,8 +957,13 @@ void ValueEnumerator::incorporateFunction(const Function &F) { } // Add all of the function-local metadata. - for (unsigned i = 0, e = FnLocalMDVector.size(); i != e; ++i) + for (unsigned i = 0, e = FnLocalMDVector.size(); i != e; ++i) { + // At this point, every local values have been incorporated, we shouldn't + // have a metadata operand that references a value that hasn't been seen. + assert(ValueMap.count(FnLocalMDVector[i]->getValue()) && + "Missing value for metadata operand"); EnumerateFunctionLocalMetadata(F, FnLocalMDVector[i]); + } } void ValueEnumerator::purgeFunction() { |