Upgrade TBAA *before* upgrading intrinsics

Summary: If TBAA is on an intrinsic and it gets upgraded and drops the TBAA we hit an odd assert. We should just upgrade the TBAA first because it doesn't have side-effects.

Reviewers: reames, apilipenko, manmanren

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D18229

llvm-svn: 263673
This commit is contained in:
Chris Bieneman
2016-03-16 23:17:54 +00:00
parent 43e33d61c6
commit 671d0dda7d
3 changed files with 12 additions and 6 deletions

View File

@@ -5334,6 +5334,11 @@ 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
@@ -5349,9 +5354,6 @@ std::error_code BitcodeReader::materializeModule() {
}
UpgradedIntrinsics.clear();
for (unsigned I = 0, E = InstsWithTBAATag.size(); I < E; I++)
UpgradeInstWithTBAATag(InstsWithTBAATag[I]);
UpgradeDebugInfo(*TheModule);
return std::error_code();
}