diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-09-14 22:29:59 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-09-14 22:29:59 +0000 |
commit | e470927187f6a3848613a41ba98a21471800ed0d (patch) | |
tree | 26099177f5b181840636de331551ea23b975c1fb /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 8d22e6c27ba54e9eba3fa0294f08bbced7447b3f (diff) | |
download | bcm5719-llvm-e470927187f6a3848613a41ba98a21471800ed0d.tar.gz bcm5719-llvm-e470927187f6a3848613a41ba98a21471800ed0d.zip |
Fix auto-upgrade of TBAA tags in Bitcode Reader
If TBAA is on an intrinsic and it gets upgraded, it'll delete the call
instruction that we collected in a vector. Even if we were to use
WeakVH, it'll drop the TBAA and we'll hit the assert on the upgrade
path.
r263673 gave a shot to make sure the TBAA upgrade happens before
intrinsics upgrade, but failed to account for all cases.
Instead of collecting instructions in a vector, this patch makes it
just upgrade the TBAA on the fly, because metadata are always
already loaded at this point.
Differential Revision: https://reviews.llvm.org/D24533
llvm-svn: 281549
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 2504ce78cc6..33f1a7e454e 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -257,8 +257,6 @@ class BitcodeReader : public GVMaterializer { std::vector<std::pair<Function*, unsigned> > FunctionPrologues; std::vector<std::pair<Function*, unsigned> > FunctionPersonalityFns; - SmallVector<Instruction*, 64> InstsWithTBAATag; - bool HasSeenOldLoopTags = false; /// The set of attributes by index. Index zero in the file is for null, and @@ -4425,11 +4423,11 @@ std::error_code BitcodeReader::parseMetadataAttachment(Function &F) { if (HasSeenOldLoopTags && I->second == LLVMContext::MD_loop) MD = upgradeInstructionLoopAttachment(*MD); - Inst->setMetadata(I->second, MD); if (I->second == LLVMContext::MD_tbaa) { - InstsWithTBAATag.push_back(Inst); - continue; + assert(!MD->isTemporary() && "should load MDs before attachments"); + MD = UpgradeTBAANode(*MD); } + Inst->setMetadata(I->second, MD); } break; } @@ -5842,11 +5840,6 @@ std::error_code BitcodeReader::materializeModule() { if (!BasicBlockFwdRefs.empty()) return error("Never resolved function from blockaddress"); - // Upgrading intrinsic calls before TBAA can cause TBAA metadata to be lost, - // to prevent this instructions with TBAA tags should be upgraded first. - for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++) - UpgradeInstWithTBAATag(InstsWithTBAATag[I]); - // Upgrade any intrinsic calls that slipped through (should not happen!) and // delete the old functions to clean up. We can't do this unless the entire // module is materialized because there could always be another function body |