From b6bde406c36e93ba83f23ccb5048663fff9a4585 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Wed, 16 Mar 2016 23:17:54 +0000 Subject: [PATCH] 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 --- lib/Bitcode/Reader/BitcodeReader.cpp | 8 +++++--- test/Assembler/auto_upgrade_intrinsics.ll | 10 +++++++--- test/Bitcode/auto_upgrade_intrinsics.bc | Bin 0 -> 1672 bytes 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 test/Bitcode/auto_upgrade_intrinsics.bc diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 8d749c29108..fd9a5e5c5ef 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -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(); } diff --git a/test/Assembler/auto_upgrade_intrinsics.ll b/test/Assembler/auto_upgrade_intrinsics.ll index 43fe7e2d460..ed2f6402f60 100644 --- a/test/Assembler/auto_upgrade_intrinsics.ll +++ b/test/Assembler/auto_upgrade_intrinsics.ll @@ -63,7 +63,7 @@ declare <2 x double> @llvm.masked.load.v2f64(<2 x double>* %ptrs, i32, <2 x i1> define <2 x double> @tests.masked.load(<2 x double>* %ptr, <2 x i1> %mask, <2 x double> %passthru) { ; CHECK-LABEL: @tests.masked.load( ; CHECK: @llvm.masked.load.v2f64.p0v2f64 - %res = call <2 x double> @llvm.masked.load.v2f64(<2 x double>* %ptr, i32 1, <2 x i1> %mask, <2 x double> %passthru) + %res = call <2 x double> @llvm.masked.load.v2f64(<2 x double>* %ptr, i32 1, <2 x i1> %mask, <2 x double> %passthru), !tbaa !0 ret <2 x double> %res } @@ -72,6 +72,10 @@ declare void @llvm.masked.store.v2f64(<2 x double> %val, <2 x double>* %ptrs, i3 define void @tests.masked.store(<2 x double>* %ptr, <2 x i1> %mask, <2 x double> %val) { ; CHECK-LABEL: @tests.masked.store( ; CHECK: @llvm.masked.store.v2f64.p0v2f64 - call void @llvm.masked.store.v2f64(<2 x double> %val, <2 x double>* %ptr, i32 3, <2 x i1> %mask) + call void @llvm.masked.store.v2f64(<2 x double> %val, <2 x double>* %ptr, i32 3, <2 x i1> %mask), !tbaa !0 ret void -} \ No newline at end of file +} + +!0 = !{!"omnipotent char", !1} +!1 = !{!"Simple C/C++ TBAA"} +!2 = !{!"double", !0} diff --git a/test/Bitcode/auto_upgrade_intrinsics.bc b/test/Bitcode/auto_upgrade_intrinsics.bc new file mode 100644 index 0000000000000000000000000000000000000000..9205c8ae4d3a33667bed6a04c3e90a8362797b0d GIT binary patch literal 1672 zcma)6e`phD82*x6a%UPZcTF6LO|rYD7M*pyq|P>NBDq`}qt-3ju2Z&Q5^7PdI;F3GtuO{l0!;*f;}ifd!@adMzJh8! zhG@*gF=*yuDM4G@m`D`G(v5^LW{~vTfxH2L)$`a;saCE(jQG3=l4?EST=~IBMVer? z5QCBqQ^XCn(GvN&o6XYLw{*ylW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