summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-09-14 22:29:59 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-09-14 22:29:59 +0000
commite470927187f6a3848613a41ba98a21471800ed0d (patch)
tree26099177f5b181840636de331551ea23b975c1fb /llvm/lib/AsmParser/LLParser.cpp
parent8d22e6c27ba54e9eba3fa0294f08bbced7447b3f (diff)
downloadbcm5719-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/AsmParser/LLParser.cpp')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 15327a1d065..0e154b26578 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -222,8 +222,13 @@ bool LLParser::ValidateEndOfModule() {
N.second->resolveCycles();
}
- for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
- UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
+ for (auto *Inst : InstsWithTBAATag) {
+ MDNode *MD = Inst->getMetadata(LLVMContext::MD_tbaa);
+ assert(MD && "UpgradeInstWithTBAATag should have a TBAA tag");
+ auto *UpgradedMD = UpgradeTBAANode(*MD);
+ if (MD != UpgradedMD)
+ Inst->setMetadata(LLVMContext::MD_tbaa, UpgradedMD);
+ }
// Look for intrinsic functions and CallInst that need to be upgraded
for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; )
OpenPOWER on IntegriCloud