Index: llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp =================================================================== --- llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp +++ llvm/unittests/Analysis/AssumeBundleQueriesTest.cpp @@ -35,8 +35,11 @@ LLVMContext C; SMDiagnostic Err; std::unique_ptr Mod = parseAssemblyString(IR, Err, C); - if (!Mod) + if (!Mod) { Err.print("AssumeQueryAPI", errs()); + ADD_FAILURE() << "Unable to parse the assembly string"; + continue; + } Elem.second(&*(Mod->getFunction("test")->begin()->begin())); } } @@ -399,8 +402,11 @@ Attribute::EndAttrKinds - 1); std::unique_ptr Mod = std::make_unique("AssumeQueryAPI", C); - if (!Mod) + if (!Mod) { Err.print("AssumeQueryAPI", errs()); + ADD_FAILURE() << "Unable to create Module"; + return; + } std::vector TypeArgs; for (int i = 0; i < (Size * 2); i++) @@ -496,8 +502,10 @@ "\"dereferenceable\"(i32* %P, i32 4)]\n" "ret void\n}\n", Err, C); - if (!Mod) + if (!Mod) { Err.print("AssumeQueryAPI", errs()); + FAIL() << "Unable to parse the assembly string"; + } Function *F = Mod->getFunction("test"); BasicBlock::iterator First = F->begin()->begin(); BasicBlock::iterator Second = F->begin()->begin(); @@ -559,8 +567,10 @@ "call void @llvm.assume(i1 true) [\"align\"(i32* %P2, i32 16, i32 8)]\n" "ret void\n}\n", Err, C); - if (!Mod) + if (!Mod) { Err.print("AssumeQueryAPI", errs()); + FAIL() << "Unable to parse the assembly string"; + } Function *F = Mod->getFunction("test"); BasicBlock::iterator Start = F->begin()->begin(); Index: llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp =================================================================== --- llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp +++ llvm/unittests/Analysis/FunctionPropertiesAnalysisTest.cpp @@ -65,6 +65,7 @@ ret i32 %2 } )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; Function *BranchesFunction = M->getFunction("branches"); FunctionPropertiesInfo BranchesFeatures = buildFPI(*BranchesFunction); Index: llvm/unittests/Analysis/IVDescriptorsTest.cpp =================================================================== --- llvm/unittests/Analysis/IVDescriptorsTest.cpp +++ llvm/unittests/Analysis/IVDescriptorsTest.cpp @@ -70,6 +70,7 @@ ret void })" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithLoopInfoAndSE( *M, "foo", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) { @@ -147,6 +148,7 @@ bb34: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithLoopInfoAndSE( *M, "barney", [&](Function &F, LoopInfo &LI, ScalarEvolution &SE) { Index: llvm/unittests/Analysis/LoadsTest.cpp =================================================================== --- llvm/unittests/Analysis/LoadsTest.cpp +++ llvm/unittests/Analysis/LoadsTest.cpp @@ -41,6 +41,7 @@ ret i32 %v } )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); auto *F = dyn_cast(GV); @@ -75,6 +76,7 @@ ret void } )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; const auto &DL = M->getDataLayout(); auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); Index: llvm/unittests/Analysis/ValueTrackingTest.cpp =================================================================== --- llvm/unittests/Analysis/ValueTrackingTest.cpp +++ llvm/unittests/Analysis/ValueTrackingTest.cpp @@ -48,25 +48,28 @@ SMDiagnostic Error; std::unique_ptr M = parseAssemblyString(Assembly, Error, Context); - std::string errMsg; - raw_string_ostream os(errMsg); - Error.print("", os); - EXPECT_TRUE(M) << os.str(); + if (!M) + Error.print("", errs()); return M; } void parseAssembly(StringRef Assembly) { M = parseModule(Assembly); - ASSERT_TRUE(M); + if (!M) + return; F = M->getFunction("test"); - ASSERT_TRUE(F) << "Test must have a function @test"; - if (!F) + if (!F) { + errs() << "Test must have a function @test\n"; return; + } A = findInstructionByNameOrNull(F, "A"); - ASSERT_TRUE(A) << "@test must have an instruction %A"; + if (!A) { + errs() << "@test must have an instruction %A\n"; + return; + } CxtI = findInstructionByNameOrNull(F, "CxtI"); CxtI2 = findInstructionByNameOrNull(F, "CxtI2"); @@ -113,6 +116,7 @@ " %A = select i1 %1, float %a, float 5.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_FMINNUM, SPNB_RETURNS_NAN, false}); } @@ -123,6 +127,7 @@ " %A = select i1 %1, float %a, float 5.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_FMAXNUM, SPNB_RETURNS_OTHER, true}); } @@ -133,6 +138,7 @@ " %A = select i1 %1, float %a, float 5.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_FMAXNUM, SPNB_RETURNS_OTHER, false}); } @@ -143,6 +149,7 @@ " %A = select i1 %1, float 5.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_FMAXNUM, SPNB_RETURNS_NAN, false}); } @@ -153,6 +160,7 @@ " %A = select i1 %1, float 5.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_FMAXNUM, SPNB_RETURNS_OTHER, true}); } @@ -163,6 +171,7 @@ " %A = select i1 %1, float %a, float 5.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_FMINNUM, SPNB_RETURNS_ANY, false}); } @@ -173,6 +182,7 @@ " %A = select i1 %1, float %a, float 0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // This shouldn't be matched, as %a could be -0.0. expectPattern({SPF_UNKNOWN, SPNB_NA, false}); } @@ -184,6 +194,7 @@ " %A = select i1 %1, float %a, float 0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // But this should be, because we've ignored signed zeroes. expectPattern({SPF_FMINNUM, SPNB_RETURNS_OTHER, true}); } @@ -195,6 +206,7 @@ " %A = select i1 %1, float 0.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMINNUM, SPNB_RETURNS_NAN, true}); } @@ -206,6 +218,7 @@ " %A = select i1 %1, float 0.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMINNUM, SPNB_RETURNS_NAN, false}); } @@ -217,6 +230,7 @@ " %A = select i1 %1, float -0.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMINNUM, SPNB_RETURNS_NAN, true}); } @@ -228,6 +242,7 @@ " %A = select i1 %1, float -0.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMINNUM, SPNB_RETURNS_NAN, false}); } @@ -239,6 +254,7 @@ " %A = select i1 %1, float %a, float 0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMINNUM, SPNB_RETURNS_OTHER, false}); } @@ -250,6 +266,7 @@ " %A = select i1 %1, float %a, float 0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMINNUM, SPNB_RETURNS_OTHER, true}); } @@ -261,6 +278,7 @@ " %A = select i1 %1, float %a, float -0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMINNUM, SPNB_RETURNS_OTHER, false}); } @@ -272,6 +290,7 @@ " %A = select i1 %1, float %a, float -0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMINNUM, SPNB_RETURNS_OTHER, true}); } @@ -283,6 +302,7 @@ " %A = select i1 %1, float 0.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMAXNUM, SPNB_RETURNS_NAN, true}); } @@ -294,6 +314,7 @@ " %A = select i1 %1, float 0.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMAXNUM, SPNB_RETURNS_NAN, false}); } @@ -305,6 +326,7 @@ " %A = select i1 %1, float -0.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMAXNUM, SPNB_RETURNS_NAN, true}); } @@ -316,6 +338,7 @@ " %A = select i1 %1, float -0.0, float %a\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMAXNUM, SPNB_RETURNS_NAN, false}); } @@ -327,6 +350,7 @@ " %A = select i1 %1, float %a, float 0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMAXNUM, SPNB_RETURNS_OTHER, false}); } @@ -338,6 +362,7 @@ " %A = select i1 %1, float %a, float 0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMAXNUM, SPNB_RETURNS_OTHER, true}); } @@ -349,6 +374,7 @@ " %A = select i1 %1, float %a, float -0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMAXNUM, SPNB_RETURNS_OTHER, false}); } @@ -360,6 +386,7 @@ " %A = select i1 %1, float %a, float -0.0\n" " ret float %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The sign of zero doesn't matter in fcmp. expectPattern({SPF_FMAXNUM, SPNB_RETURNS_OTHER, true}); } @@ -371,6 +398,7 @@ " %A = select <2 x i1> %1, <2 x float> , <2 x float> %a\n" " ret <2 x float> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // An undef in a vector constant can not be back-propagated for this analysis. expectPattern({SPF_UNKNOWN, SPNB_NA, false}); } @@ -382,6 +410,7 @@ " %A = select <2 x i1> %1, <2 x float> %a, <2 x float> \n" " ret <2 x float> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // An undef in a vector constant can not be back-propagated for this analysis. expectPattern({SPF_UNKNOWN, SPNB_NA, false}); } @@ -395,6 +424,7 @@ " <4 x float> \n" " ret <4 x float> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // Check that pattern matching works on vectors where each lane has the same // unordered pattern. expectPattern({SPF_FMINNUM, SPNB_RETURNS_NAN, false}); @@ -409,6 +439,7 @@ " <4 x float> \n" " ret <4 x float> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // Check that pattern matching works on vectors where each lane has the same // ordered pattern. expectPattern({SPF_FMINNUM, SPNB_RETURNS_OTHER, true}); @@ -424,6 +455,7 @@ "5.0>\n" " ret <4 x float> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The lane that contains a NaN (0x7ff80...) behaves like a // non-NaN-propagating min and the other lines behave like a NaN-propagating // min, so check that neither is returned. @@ -439,6 +471,7 @@ " <4 x float> \n" " ret <4 x float> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // Always selects the second lane of %a if it is positive or negative zero, so // this is stricter than a min. expectPattern({SPF_UNKNOWN, SPNB_NA, false}); @@ -453,6 +486,7 @@ " %A = select i1 %1, i32 %2, i32 %3\n" " ret i32 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // We should be able to look through the situation where we cast both operands // to the select. expectPattern({SPF_UMIN, SPNB_NA, false}); @@ -467,6 +501,7 @@ " %A = select i1 %1, i32 %2, i32 %3\n" " ret i32 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // We should be able to look through the situation where we cast both operands // to the select. expectPattern({SPF_SMIN, SPNB_NA, false}); @@ -481,6 +516,7 @@ " %A = select i1 %1, i32 %2, i32 %3\n" " ret i32 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // The cast types here aren't the same, so we cannot match an UMIN. expectPattern({SPF_UNKNOWN, SPNB_NA, false}); } @@ -494,6 +530,7 @@ " %A = select i1 %cmp, i8 %an, i8 %bn\n" " ret i8 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_SMIN, SPNB_NA, false}); } @@ -506,6 +543,7 @@ " %A = select <2 x i1> %cmp, <2 x i8> %bn, <2 x i8> %an\n" " ret <2 x i8> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_SMIN, SPNB_NA, false}); } @@ -518,6 +556,7 @@ " %A = select i1 %cmp, i8 %an, i8 %bn\n" " ret i8 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_SMAX, SPNB_NA, false}); } @@ -530,6 +569,7 @@ " %A = select <2 x i1> %cmp, <2 x i8> %bn, <2 x i8> %an\n" " ret <2 x i8> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_SMAX, SPNB_NA, false}); } @@ -542,6 +582,7 @@ " %A = select <2 x i1> %cmp, <2 x i8> %an, <2 x i8> %bn\n" " ret <2 x i8> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_UMIN, SPNB_NA, false}); } @@ -554,6 +595,7 @@ " %A = select i1 %cmp, i8 %bn, i8 %an\n" " ret i8 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_UMIN, SPNB_NA, false}); } @@ -566,6 +608,7 @@ " %A = select <2 x i1> %cmp, <2 x i8> %an, <2 x i8> %bn\n" " ret <2 x i8> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_UMAX, SPNB_NA, false}); } @@ -578,6 +621,7 @@ " %A = select i1 %cmp, i8 %bn, i8 %an\n" " ret i8 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_UMAX, SPNB_NA, false}); } @@ -590,6 +634,7 @@ " %A = select i1 %cmp, i8 %bn, i8 %an\n" " ret i8 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_UNKNOWN, SPNB_NA, false}); } @@ -602,6 +647,7 @@ " %A = select i1 %cmp, i8 %bn, i8 %an\n" " ret i8 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectPattern({SPF_UNKNOWN, SPNB_NA, false}); } @@ -631,10 +677,10 @@ LLVMContext Context; SMDiagnostic Error; auto M = parseAssemblyString(Assembly, Error, Context); - assert(M && "Bad assembly?"); + ASSERT_TRUE(M) << "Bad assembly?"; auto *F = M->getFunction("f"); - assert(F && "Bad assembly?"); + ASSERT_TRUE(F) << "Bad assembly?"; auto &BB = F->getEntryBlock(); bool ExpectedAnswers[] = { @@ -665,6 +711,7 @@ " %A = ashr i32 %a, -1\n" " ret i32 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; EXPECT_EQ(ComputeNumSignBits(A, M->getDataLayout()), 1u); } @@ -675,6 +722,7 @@ " %A = shufflevector <2 x i32> undef, <2 x i32> undef, <2 x i32> \n" " ret <2 x i32> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; EXPECT_EQ(ComputeNumSignBits(A, M->getDataLayout()), 1u); } @@ -687,6 +735,7 @@ " %A = shufflevector <2 x i32> %sext, <2 x i32> undef, <2 x i32> \n" " ret <2 x i32> %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; EXPECT_EQ(ComputeNumSignBits(A, M->getDataLayout()), 1u); } @@ -722,10 +771,10 @@ LLVMContext Context; SMDiagnostic Error; auto M = parseAssemblyString(AssemblyStr, Error, Context); - assert(M && "Bad assembly?"); + ASSERT_TRUE(M) << "Bad assembly?"; auto *F = M->getFunction("f"); - assert(F && "Bad assembly?"); + ASSERT_TRUE(F) << "Bad assembly?"; auto &BB = F->getEntryBlock(); @@ -747,6 +796,7 @@ " udiv i32 1, %B" " ret void\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // If %A was poison, udiv raises UB regardless of %mask's value EXPECT_EQ(programUndefinedIfPoison(A), true); } @@ -759,6 +809,7 @@ " udiv i32 1, %B" " ret void\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; // If %A was undef and %mask was 1, udiv does not raise UB EXPECT_EQ(programUndefinedIfUndefOrPoison(A), false); } @@ -774,6 +825,7 @@ "BB2:\n" " ret void\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; DominatorTree DT(*F); for (auto &BB : *F) { if (&BB == &F->getEntryBlock()) @@ -800,6 +852,7 @@ "EXIT:\n" " ret void\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; DominatorTree DT(*F); for (auto &BB : *F) { if (BB.getName() == "LOOP") { @@ -816,6 +869,7 @@ " call void @f(i32 noundef %x)\n" " ret void\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; EXPECT_EQ(isGuaranteedNotToBeUndefOrPoison(A), true); } @@ -839,6 +893,7 @@ "EXIT:\n" " ret void\n" "}"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); DominatorTree DT(*F); EXPECT_FALSE(isGuaranteedNotToBeUndefOrPoison(A, &AC, CxtI, &DT)); @@ -916,10 +971,10 @@ LLVMContext Context; SMDiagnostic Error; auto M = parseAssemblyString(AssemblyStr, Error, Context); - assert(M && "Bad assembly?"); + ASSERT_TRUE(M) << "Bad assembly?"; auto *F = M->getFunction("f"); - assert(F && "Bad assembly?"); + ASSERT_TRUE(F) << "Bad assembly?"; auto &BB = F->getEntryBlock(); @@ -959,6 +1014,7 @@ "EXIT:\n" " ret void\n" "}"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); DominatorTree DT(*F); DataLayout DL = M->getDataLayout(); @@ -979,6 +1035,7 @@ " %A = mul i32 %aan, %ban\n" " ret i32 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 4278190085u, /*one*/ 10u); } @@ -992,6 +1049,7 @@ " %A = mul i32 %aaa, %bbb\n" " ret i32 %A\n" "}\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 95u, /*one*/ 32u); } @@ -1005,6 +1063,7 @@ " ret i8 %A\n" "}\n" "!0 = !{ i8 1, i8 5 }\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 1u, /*one*/ 0u); } @@ -1021,6 +1080,7 @@ " ret i16 %A\n" "}\n" "declare i16 @llvm.fshl.i16(i16, i16, i16)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 1008u, /*one*/ 49155u); } @@ -1037,6 +1097,7 @@ " ret i16 %A\n" "}\n" "declare i16 @llvm.fshr.i16(i16, i16, i16)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 1008u, /*one*/ 49155u); } @@ -1053,6 +1114,7 @@ " ret i16 %A\n" "}\n" "declare i16 @llvm.fshl.i16(i16, i16, i16)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 15u, /*one*/ 3840u); } @@ -1066,6 +1128,7 @@ " ret i8 %A\n" "}\n" "declare i8 @llvm.uadd.sat.i8(i8, i8)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 0u, /*one*/ 240u); } @@ -1082,6 +1145,7 @@ " ret i8 %A\n" "}\n" "declare i8 @llvm.uadd.sat.i8(i8, i8)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 0u, /*one*/ 1u); } @@ -1095,6 +1159,7 @@ " ret i8 %A\n" "}\n" "declare i8 @llvm.usub.sat.i8(i8, i8)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 240u, /*one*/ 0u); } @@ -1108,6 +1173,7 @@ " ret i8 %A\n" "}\n" "declare i8 @llvm.usub.sat.i8(i8, i8)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 240u, /*one*/ 0u); } @@ -1124,6 +1190,7 @@ " ret i8 %A\n" "}\n" "declare i8 @llvm.usub.sat.i8(i8, i8)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; expectKnownBits(/*zero*/ 2u, /*one*/ 0u); } @@ -1139,6 +1206,7 @@ " ret void\n" "}\n" "declare void @llvm.assume(i1)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); KnownBits Known = computeKnownBits( A, M->getDataLayout(), /* Depth */ 0, &AC, F->front().getTerminator()); @@ -1158,6 +1226,7 @@ " ret void\n" "}\n" "declare void @llvm.assume(i1)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); KnownBits Known = computeKnownBits( A, M->getDataLayout(), /* Depth */ 0, &AC, F->front().getTerminator()); @@ -1176,6 +1245,7 @@ "}\n" "declare void @llvm.assume(i1)\n" "declare i32 @any_num()\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); KnownBits Known = computeKnownBits(A, M->getDataLayout(), /* Depth */ 0, &AC, F->front().getTerminator()); @@ -1192,6 +1262,7 @@ " ret void\n" "}\n" "declare void @llvm.assume(i1)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); KnownBits Known = computeKnownBits(A, M->getDataLayout(), /* Depth */ 0, &AC, F->front().getTerminator()); @@ -1221,6 +1292,7 @@ " ret void\n" "}\n" "declare void @llvm.assume(i1)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); KnownBits Known = computeKnownBits(A, M->getDataLayout(), /* Depth */ 0, &AC, F->front().getTerminator()); @@ -1248,6 +1320,7 @@ " ret void\n" "}\n" "declare void @llvm.assume(i1)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); KnownBits Known = computeKnownBits(A, M->getDataLayout(), /* Depth */ 0, &AC, F->front().getTerminator()); @@ -1281,6 +1354,7 @@ " ret void\n" "}\n" "declare void @llvm.assume(i1)\n"); + ASSERT_TRUE(M && F && A) << "Bad assmply string?"; AssumptionCache AC(*F); KnownBits Known = computeKnownBits(A, M->getDataLayout(), /* Depth */ 0, &AC, F->front().getTerminator()); @@ -1541,6 +1615,7 @@ TEST_P(IsBytewiseValueTest, IsBytewiseValue) { auto M = parseModule(std::string("@test = global ") + GetParam().second); + ASSERT_TRUE(M) << "Bad module assembly?"; GlobalVariable *GV = dyn_cast(M->getNamedValue("test")); Value *Actual = isBytewiseValue(GV->getInitializer(), M->getDataLayout()); std::string Buff; @@ -1568,6 +1643,7 @@ %stride.plus.one = add nsw nuw i32 %stride, 1 ret i32 %stride.plus.one })"); + ASSERT_TRUE(M) << "Bad module assembly?"; Function *F = M->getFunction("test"); AssumptionCache AC(*F); @@ -1601,6 +1677,7 @@ %stride.plus.one = add nsw nuw i32 %stride, 1 ret i32 %stride.plus.one })"); + ASSERT_TRUE(M) << "Bad module assembly?"; Function *F = M->getFunction("test"); AssumptionCache AC(*F); @@ -1639,6 +1716,7 @@ bb2: ret i32 0 })"); + ASSERT_TRUE(M) << "Bad module assembly?"; Function *F = M->getFunction("test"); AssumptionCache AC(*F); @@ -1671,6 +1749,7 @@ %stride.plus.one = add nsw nuw i32 %stride, 1 ret i32 %stride.plus.one })"); + ASSERT_TRUE(M) << "Bad module assembly?"; Function *F = M->getFunction("test"); AssumptionCache AC(*F); @@ -1698,6 +1777,7 @@ %stride.plus.one = add nsw nuw i32 %x.1, 1 ret i32 %stride.plus.one })"); + ASSERT_TRUE(M) << "Bad module assembly?"; Function *F = M->getFunction("test"); AssumptionCache AC(*F); @@ -1845,6 +1925,7 @@ TEST_P(FindAllocaForValueTest, findAllocaForValue) { auto M = parseModule(GetParam().IR); + ASSERT_TRUE(M) << "Bad module assembly?"; Function *F = M->getFunction("test"); Instruction *I = &findInstructionByName(F, "r"); const AllocaInst *AI = findAllocaForValue(I); @@ -1853,6 +1934,7 @@ TEST_P(FindAllocaForValueTest, findAllocaForValueZeroOffset) { auto M = parseModule(GetParam().IR); + ASSERT_TRUE(M) << "Bad module assembly?"; Function *F = M->getFunction("test"); Instruction *I = &findInstructionByName(F, "r"); const AllocaInst *AI = findAllocaForValue(I, true); Index: llvm/unittests/Analysis/VectorFunctionABITest.cpp =================================================================== --- llvm/unittests/Analysis/VectorFunctionABITest.cpp +++ llvm/unittests/Analysis/VectorFunctionABITest.cpp @@ -22,15 +22,15 @@ // Reset the data needed for the test. void reset(const StringRef Name, const StringRef IRType) { M = parseAssemblyString("declare void @dummy()", Err, Ctx); - EXPECT_NE(M.get(), nullptr) << "Loading an invalid module.\n " + ASSERT_NE(M.get(), nullptr) << "Loading an invalid module.\n " << Err.getMessage() << "\n"; Type *Ty = parseType(IRType, Err, *(M.get())); FunctionType *FTy = dyn_cast(Ty); - EXPECT_NE(FTy, nullptr) << "Invalid function type string: " << IRType + ASSERT_NE(FTy, nullptr) << "Invalid function type string: " << IRType << "\n" << Err.getMessage() << "\n"; FunctionCallee F = M->getOrInsertFunction(Name, FTy); - EXPECT_NE(F.getCallee(), nullptr) + ASSERT_NE(F.getCallee(), nullptr) << "The function must be present in the module\n"; // Reset the VFInfo Info = VFInfo(); @@ -555,6 +555,7 @@ M = parseAssemblyString(IR, Err, Ctx); // Get the only call instruction in the block, which is the first // instruction. + ASSERT_TRUE(M) << "Unable to parse the assembly string"; CI = dyn_cast(&*(instructions(M->getFunction("f")).begin())); } const char *IR = "define i32 @f(i32 %a) {\n" @@ -636,6 +637,7 @@ ret void } )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto F = dyn_cast_or_null(M->getNamedValue("call")); ASSERT_TRUE(F); auto CI = dyn_cast(&F->front().front()); Index: llvm/unittests/IR/DebugInfoTest.cpp =================================================================== --- llvm/unittests/IR/DebugInfoTest.cpp +++ llvm/unittests/IR/DebugInfoTest.cpp @@ -120,6 +120,7 @@ !10 = !DILocation(line: 1, column: 1, scope: !5) !11 = distinct !{!11, !10, !10} )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; // Look up the debug info emission kind for the CU via the loop metadata // attached to the terminator. If, when stripping non-line table debug info, @@ -173,6 +174,7 @@ !10 = !DIBasicType(name: "ty16", size: 16, encoding: DW_ATE_unsigned) !11 = !DILocation(line: 1, column: 1, scope: !6) )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; // Find %b = add ... Instruction &I = *M->getFunction("f")->getEntryBlock().getFirstNonPHI(); @@ -219,7 +221,8 @@ DataLocation, Associated, Allocated, Rank); - EXPECT_TRUE(isa_and_nonnull(ArrayType)); + ASSERT_TRUE(ArrayType); + EXPECT_TRUE(isa(ArrayType)); EXPECT_EQ(ArrayType->getRawDataLocation(), DataLocation); EXPECT_EQ(ArrayType->getRawAssociated(), Associated); EXPECT_EQ(ArrayType->getRawAllocated(), Allocated); Index: llvm/unittests/IR/InstructionsTest.cpp =================================================================== --- llvm/unittests/IR/InstructionsTest.cpp +++ llvm/unittests/IR/InstructionsTest.cpp @@ -1260,6 +1260,7 @@ ret void } )"); + ASSERT_TRUE(M); Function *Foo = M->getFunction("foo"); auto BBs = Foo->getBasicBlockList().begin(); CallBrInst &CBI = cast(BBs->front()); Index: llvm/unittests/IR/LegacyPassManagerTest.cpp =================================================================== --- llvm/unittests/IR/LegacyPassManagerTest.cpp +++ llvm/unittests/IR/LegacyPassManagerTest.cpp @@ -772,8 +772,10 @@ SMDiagnostic Err; std::unique_ptr M = parseAssemblyString(IR, Err, Context); - if (!M) + if (!M) { Err.print("LegacyPassManagerTest", errs()); + FAIL() << "Unable to parse the assembly string"; + } CallbackCallsModifierPass *P = new CallbackCallsModifierPass(); legacy::PassManager Passes; Index: llvm/unittests/InterfaceStub/ELFYAMLTest.cpp =================================================================== --- llvm/unittests/InterfaceStub/ELFYAMLTest.cpp +++ llvm/unittests/InterfaceStub/ELFYAMLTest.cpp @@ -44,7 +44,7 @@ Expected> StubOrErr = readTBEFromBuffer(Data); ASSERT_THAT_ERROR(StubOrErr.takeError(), Succeeded()); std::unique_ptr Stub = std::move(StubOrErr.get()); - EXPECT_NE(Stub.get(), nullptr); + ASSERT_NE(Stub.get(), nullptr); EXPECT_FALSE(Stub->SoName.hasValue()); EXPECT_EQ(Stub->Arch, (uint16_t)llvm::ELF::EM_X86_64); EXPECT_EQ(Stub->NeededLibs.size(), 3u); @@ -69,7 +69,7 @@ Expected> StubOrErr = readTBEFromBuffer(Data); ASSERT_THAT_ERROR(StubOrErr.takeError(), Succeeded()); std::unique_ptr Stub = std::move(StubOrErr.get()); - EXPECT_NE(Stub.get(), nullptr); + ASSERT_NE(Stub.get(), nullptr); EXPECT_TRUE(Stub->SoName.hasValue()); EXPECT_STREQ(Stub->SoName->c_str(), "test.so"); EXPECT_EQ(Stub->Symbols.size(), 5u); @@ -128,7 +128,7 @@ Expected> StubOrErr = readTBEFromBuffer(Data); ASSERT_THAT_ERROR(StubOrErr.takeError(), Succeeded()); std::unique_ptr Stub = std::move(StubOrErr.get()); - EXPECT_NE(Stub.get(), nullptr); + ASSERT_NE(Stub.get(), nullptr); EXPECT_EQ(0u, Stub->Symbols.size()); } Index: llvm/unittests/MC/DwarfLineTables.cpp =================================================================== --- llvm/unittests/MC/DwarfLineTables.cpp +++ llvm/unittests/MC/DwarfLineTables.cpp @@ -37,9 +37,15 @@ if (!TheTarget) return; + setContext(TheTarget); + } + + void setContext(const Target *TheTarget) { MRI.reset(TheTarget->createMCRegInfo(Triple)); + ASSERT_TRUE(MRI) << "Unable to create reg info"; MCTargetOptions MCOptions; MAI.reset(TheTarget->createMCAsmInfo(*MRI, Triple, MCOptions)); + ASSERT_TRUE(MAI) << "Unable to create asm info"; Ctx = std::make_unique(MAI.get(), MRI.get(), nullptr); } Index: llvm/unittests/MC/MCInstPrinter.cpp =================================================================== --- llvm/unittests/MC/MCInstPrinter.cpp +++ llvm/unittests/MC/MCInstPrinter.cpp @@ -40,12 +40,18 @@ if (!TheTarget) return; - MRI.reset(TheTarget->createMCRegInfo(TripleName)); - MCTargetOptions MCOptions; - MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions)); - MII.reset(TheTarget->createMCInstrInfo()); - Printer.reset(TheTarget->createMCInstPrinter( - Triple(TripleName), MAI->getAssemblerDialect(), *MAI, *MII, *MRI)); + [&]() { + MRI.reset(TheTarget->createMCRegInfo(TripleName)); + ASSERT_TRUE(MRI) << "Unable to create reg info"; + MCTargetOptions MCOptions; + MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions)); + ASSERT_TRUE(MAI) << "Unable to create asm info"; + MII.reset(TheTarget->createMCInstrInfo()); + ASSERT_TRUE(MII) << "Unable to create instruction info"; + Printer.reset(TheTarget->createMCInstPrinter( + Triple(TripleName), MAI->getAssemblerDialect(), *MAI, *MII, *MRI)); + ASSERT_TRUE(Printer) << "Unable to create instruction printer"; + }(); } template std::string formatHex(T i) { Index: llvm/unittests/Remarks/BitstreamRemarksParsingTest.cpp =================================================================== --- llvm/unittests/Remarks/BitstreamRemarksParsingTest.cpp +++ llvm/unittests/Remarks/BitstreamRemarksParsingTest.cpp @@ -28,13 +28,13 @@ Expected> MaybeParser = remarks::createRemarkParser(remarks::Format::YAML, {Buf, N - 1}); EXPECT_FALSE(errorToBool(MaybeParser.takeError())); - EXPECT_TRUE(*MaybeParser != nullptr); + ASSERT_TRUE(*MaybeParser != nullptr); std::unique_ptr FromYAMLRemark = nullptr; remarks::RemarkParser &Parser = **MaybeParser; Expected> Remark = Parser.next(); EXPECT_FALSE(errorToBool(Remark.takeError())); // Check for parsing errors. - EXPECT_TRUE(*Remark != nullptr); // At least one remark. + ASSERT_TRUE(*Remark != nullptr); // At least one remark. // Keep the previous remark around. FromYAMLRemark = std::move(*Remark); Remark = Parser.next(); @@ -58,13 +58,13 @@ Expected> MaybeBSParser = remarks::createRemarkParser(remarks::Format::Bitstream, BSStream.str()); EXPECT_FALSE(errorToBool(MaybeBSParser.takeError())); - EXPECT_TRUE(*MaybeBSParser != nullptr); + ASSERT_TRUE(*MaybeBSParser != nullptr); std::unique_ptr FromBSRemark = nullptr; remarks::RemarkParser &BSParser = **MaybeBSParser; Expected> BSRemark = BSParser.next(); EXPECT_FALSE(errorToBool(BSRemark.takeError())); // Check for parsing errors. - EXPECT_TRUE(*BSRemark != nullptr); // At least one remark. + ASSERT_TRUE(*BSRemark != nullptr); // At least one remark. // Keep the previous remark around. FromBSRemark = std::move(*BSRemark); BSRemark = BSParser.next(); @@ -159,25 +159,25 @@ Expected> MaybeParser = remarks::createRemarkParser(remarks::Format::YAML, Buf); EXPECT_FALSE(errorToBool(MaybeParser.takeError())); - EXPECT_TRUE(*MaybeParser != nullptr); + ASSERT_TRUE(*MaybeParser != nullptr); remarks::RemarkParser &Parser = **MaybeParser; Expected> MaybeRemark = Parser.next(); EXPECT_FALSE( errorToBool(MaybeRemark.takeError())); // Check for parsing errors. - EXPECT_TRUE(*MaybeRemark != nullptr); // At least one remark. + ASSERT_TRUE(*MaybeRemark != nullptr); // At least one remark. const remarks::Remark &Remark = **MaybeRemark; EXPECT_EQ(Remark.RemarkType, remarks::Type::Missed); EXPECT_EQ(checkStr(Remark.PassName, 6), "inline"); EXPECT_EQ(checkStr(Remark.RemarkName, 12), "NoDefinition"); EXPECT_EQ(checkStr(Remark.FunctionName, 3), "foo"); - EXPECT_TRUE(Remark.Loc); + ASSERT_TRUE(Remark.Loc); const remarks::RemarkLocation &RL = *Remark.Loc; EXPECT_EQ(checkStr(RL.SourceFilePath, 6), "file.c"); EXPECT_EQ(RL.SourceLine, 3U); EXPECT_EQ(RL.SourceColumn, 12U); - EXPECT_TRUE(Remark.Hotness); + ASSERT_TRUE(Remark.Hotness); EXPECT_EQ(*Remark.Hotness, 4U); EXPECT_EQ(Remark.Args.size(), 4U); @@ -197,7 +197,7 @@ case 2: { EXPECT_EQ(checkStr(Arg.Key, 6), "Caller"); EXPECT_EQ(checkStr(Arg.Val, 3), "foo"); - EXPECT_TRUE(Arg.Loc); + ASSERT_TRUE(Arg.Loc); const remarks::RemarkLocation &RL = *Arg.Loc; EXPECT_EQ(checkStr(RL.SourceFilePath, 6), "file.c"); EXPECT_EQ(RL.SourceLine, 2U); @@ -326,7 +326,7 @@ Expected> MaybeBSParser = remarks::createRemarkParser(remarks::Format::Bitstream, Input); EXPECT_FALSE(errorToBool(MaybeBSParser.takeError())); - EXPECT_TRUE(*MaybeBSParser != nullptr); + ASSERT_TRUE(*MaybeBSParser != nullptr); remarks::RemarkParser &BSParser = **MaybeBSParser; Expected> BSRemark = BSParser.next(); Index: llvm/unittests/Remarks/YAMLRemarksParsingTest.cpp =================================================================== --- llvm/unittests/Remarks/YAMLRemarksParsingTest.cpp +++ llvm/unittests/Remarks/YAMLRemarksParsingTest.cpp @@ -17,7 +17,7 @@ Expected> MaybeParser = remarks::createRemarkParser(remarks::Format::YAML, {Buf, N - 1}); EXPECT_FALSE(errorToBool(MaybeParser.takeError())); - EXPECT_TRUE(*MaybeParser != nullptr); + ASSERT_TRUE(*MaybeParser != nullptr); remarks::RemarkParser &Parser = **MaybeParser; Expected> Remark = Parser.next(); @@ -33,7 +33,7 @@ Expected> MaybeParser = remarks::createRemarkParserFromMeta(remarks::Format::YAML, Buf); EXPECT_FALSE(errorToBool(MaybeParser.takeError())); - EXPECT_TRUE(*MaybeParser != nullptr); + ASSERT_TRUE(*MaybeParser != nullptr); remarks::RemarkParser &Parser = **MaybeParser; Expected> Remark = Parser.next(); @@ -51,6 +51,8 @@ remarks::createRemarkParser(remarks::Format::YAML, {Buf, N - 1}); EXPECT_FALSE(errorToBool(MaybeParser.takeError())); EXPECT_TRUE(*MaybeParser != nullptr); + if (!*MaybeParser) + return false; remarks::RemarkParser &Parser = **MaybeParser; Expected> Remark = Parser.next(); @@ -401,13 +403,13 @@ Expected> MaybeParser = remarks::createRemarkParser(remarks::Format::YAML, Buf); EXPECT_FALSE(errorToBool(MaybeParser.takeError())); - EXPECT_TRUE(*MaybeParser != nullptr); + ASSERT_TRUE(*MaybeParser != nullptr); remarks::RemarkParser &Parser = **MaybeParser; Expected> MaybeRemark = Parser.next(); EXPECT_FALSE( errorToBool(MaybeRemark.takeError())); // Check for parsing errors. - EXPECT_TRUE(*MaybeRemark != nullptr); // At least one remark. + ASSERT_TRUE(*MaybeRemark != nullptr); // At least one remark. const remarks::Remark &Remark = **MaybeRemark; EXPECT_EQ(Remark.RemarkType, remarks::Type::Missed); @@ -573,13 +575,13 @@ remarks::createRemarkParser(remarks::Format::YAMLStrTab, Buf, std::move(StrTab)); EXPECT_FALSE(errorToBool(MaybeParser.takeError())); - EXPECT_TRUE(*MaybeParser != nullptr); + ASSERT_TRUE(*MaybeParser != nullptr); remarks::RemarkParser &Parser = **MaybeParser; Expected> MaybeRemark = Parser.next(); EXPECT_FALSE( errorToBool(MaybeRemark.takeError())); // Check for parsing errors. - EXPECT_TRUE(*MaybeRemark != nullptr); // At least one remark. + ASSERT_TRUE(*MaybeRemark != nullptr); // At least one remark. const remarks::Remark &Remark = **MaybeRemark; EXPECT_EQ(Remark.RemarkType, remarks::Type::Missed); @@ -649,7 +651,7 @@ remarks::createRemarkParser(remarks::Format::YAMLStrTab, Buf, std::move(StrTab)); EXPECT_FALSE(errorToBool(MaybeParser.takeError())); - EXPECT_TRUE(*MaybeParser != nullptr); + ASSERT_TRUE(*MaybeParser != nullptr); remarks::RemarkParser &Parser = **MaybeParser; Expected> MaybeRemark = Parser.next(); Index: llvm/unittests/Support/MemoryBufferTest.cpp =================================================================== --- llvm/unittests/Support/MemoryBufferTest.cpp +++ llvm/unittests/Support/MemoryBufferTest.cpp @@ -74,15 +74,15 @@ TEST_F(MemoryBufferTest, get) { // Default name and null-terminator flag OwningBuffer MB1(MemoryBuffer::getMemBuffer(data)); - EXPECT_TRUE(nullptr != MB1.get()); + ASSERT_TRUE(nullptr != MB1.get()); // RequiresNullTerminator = false OwningBuffer MB2(MemoryBuffer::getMemBuffer(data, "one", false)); - EXPECT_TRUE(nullptr != MB2.get()); + ASSERT_TRUE(nullptr != MB2.get()); // RequiresNullTerminator = true OwningBuffer MB3(MemoryBuffer::getMemBuffer(data, "two", true)); - EXPECT_TRUE(nullptr != MB3.get()); + ASSERT_TRUE(nullptr != MB3.get()); // verify all 3 buffers point to the same address EXPECT_EQ(MB1->getBufferStart(), MB2->getBufferStart()); @@ -152,11 +152,11 @@ TEST_F(MemoryBufferTest, copy) { // copy with no name OwningBuffer MBC1(MemoryBuffer::getMemBufferCopy(data)); - EXPECT_TRUE(nullptr != MBC1.get()); + ASSERT_TRUE(nullptr != MBC1.get()); // copy with a name OwningBuffer MBC2(MemoryBuffer::getMemBufferCopy(data, "copy")); - EXPECT_TRUE(nullptr != MBC2.get()); + ASSERT_TRUE(nullptr != MBC2.get()); // verify the two copies do not point to the same place EXPECT_NE(MBC1->getBufferStart(), MBC2->getBufferStart()); @@ -209,13 +209,13 @@ // 0-initialized buffer with no name OwningBuffer Three(WritableMemoryBuffer::getNewMemBuffer(321, data)); - EXPECT_TRUE(nullptr != Three.get()); + ASSERT_TRUE(nullptr != Three.get()); for (size_t i = 0; i < 321; ++i) EXPECT_EQ(0, Three->getBufferStart()[0]); // 0-initialized buffer with name OwningBuffer Four(WritableMemoryBuffer::getNewMemBuffer(123, "zeros")); - EXPECT_TRUE(nullptr != Four.get()); + ASSERT_TRUE(nullptr != Four.get()); for (size_t i = 0; i < 123; ++i) EXPECT_EQ(0, Four->getBufferStart()[0]); } Index: llvm/unittests/Target/ARM/MachineInstrTest.cpp =================================================================== --- llvm/unittests/Target/ARM/MachineInstrTest.cpp +++ llvm/unittests/Target/ARM/MachineInstrTest.cpp @@ -87,6 +87,7 @@ static_cast( T->createTargetMachine(TT, "generic", "", Options, None, None, CodeGenOpt::Default))); + ASSERT_TRUE(TM) << "Unable to create target machine"; ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -244,6 +245,7 @@ static_cast( T->createTargetMachine(TT, "generic", "", Options, None, None, CodeGenOpt::Default))); + ASSERT_TRUE(TM) << "Unable to create target machine"; ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -344,6 +346,7 @@ static_cast( T->createTargetMachine(TT, "generic", "", Options, None, None, CodeGenOpt::Default))); + ASSERT_TRUE(TM) << "Unable to create target machine"; ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -1037,6 +1040,7 @@ static_cast( T->createTargetMachine(TT, "generic", "", Options, None, None, CodeGenOpt::Default))); + ASSERT_TRUE(TM) << "Unable to create target machine"; ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); @@ -1178,6 +1182,7 @@ auto TM = std::unique_ptr( static_cast(T->createTargetMachine( TT, "generic", "", Options, None, None, CodeGenOpt::Default))); + ASSERT_TRUE(TM) << "Unable to create target machine"; ARMSubtarget ST(TM->getTargetTriple(), std::string(TM->getTargetCPU()), std::string(TM->getTargetFeatureString()), *static_cast(TM.get()), false); Index: llvm/unittests/Transforms/IPO/AttributorTestBase.h =================================================================== --- llvm/unittests/Transforms/IPO/AttributorTestBase.h +++ llvm/unittests/Transforms/IPO/AttributorTestBase.h @@ -36,9 +36,11 @@ AttributorTestBase() : Ctx(new LLVMContext) {} Module &parseModule(const char *ModuleString) { - SMDiagnostic Err; - M = parseAssemblyString(ModuleString, Err, *Ctx); - EXPECT_TRUE(M); + [&]() { + SMDiagnostic Err; + M = parseAssemblyString(ModuleString, Err, *Ctx); + ASSERT_TRUE(M); + }(); return *M; } }; Index: llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp =================================================================== --- llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp +++ llvm/unittests/Transforms/Utils/BasicBlockUtilsTest.cpp @@ -46,6 +46,7 @@ "}\n" "\n" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("has_unreachable"); DominatorTree DT(*F); @@ -74,6 +75,7 @@ "}\n" "\n" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("no_unreachable"); DominatorTree DT(*F); @@ -102,6 +104,7 @@ "}\n" "\n" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("basic_func"); DominatorTree DT(*F); @@ -129,6 +132,7 @@ "}\n" "\n" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("crit_edge"); DominatorTree DT(*F); @@ -157,6 +161,7 @@ "bb3:\n" " ret void\n" "}\n"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("crit_edge"); DominatorTree DT(*F); @@ -255,6 +260,7 @@ "L19:\n" " ret void\n" "}\n"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("edge_probability"); DominatorTree DT(*F); Index: llvm/unittests/Transforms/Utils/CallPromotionUtilsTest.cpp =================================================================== --- llvm/unittests/Transforms/Utils/CallPromotionUtilsTest.cpp +++ llvm/unittests/Transforms/Utils/CallPromotionUtilsTest.cpp @@ -50,6 +50,7 @@ declare void @_ZN4Impl3RunEv(%class.Impl* %this) )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); @@ -83,6 +84,7 @@ ret void } )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); @@ -110,6 +112,7 @@ ret void } )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); @@ -145,6 +148,7 @@ declare void @_ZN4Impl3RunEv(%class.Impl* %this) )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); @@ -184,6 +188,7 @@ declare void @_ZN4Impl3RunEv(%class.Impl* %this) )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); @@ -226,6 +231,7 @@ declare void @_ZN4Impl3RunEv(%class.Impl* %this) )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); @@ -285,6 +291,7 @@ declare i32 @_ZN1A3vf1Ev(%struct.A* %this) declare i32 @_ZN1A3vf2Ev(%struct.A* %this) )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("_Z2g1v"); ASSERT_TRUE(GV); @@ -353,6 +360,7 @@ declare %struct2 @_ZN4Impl3RunEv(%class.Impl* %this) )IR"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); Index: llvm/unittests/Transforms/Utils/CloningTest.cpp =================================================================== --- llvm/unittests/Transforms/Utils/CloningTest.cpp +++ llvm/unittests/Transforms/Utils/CloningTest.cpp @@ -415,6 +415,7 @@ ret void })" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithLoopInfoAndDominatorTree( *M, "foo", [&](Function &F, LoopInfo &LI, DominatorTree &DT) { @@ -672,11 +673,11 @@ SMDiagnostic Error; auto ImplModule = parseAssemblyString(ImplAssembly, Error, Context); - EXPECT_TRUE(ImplModule != nullptr); + ASSERT_TRUE(ImplModule != nullptr); auto *ImplFunction = ImplModule->getFunction("foo"); - EXPECT_TRUE(ImplFunction != nullptr); + ASSERT_TRUE(ImplFunction != nullptr); auto *DeclFunction = ImplModule->getFunction("bar"); - EXPECT_TRUE(DeclFunction != nullptr); + ASSERT_TRUE(DeclFunction != nullptr); ValueToValueMapTy VMap; SmallVector Returns; @@ -703,11 +704,11 @@ SMDiagnostic Error; auto ImplModule = parseAssemblyString(ImplAssembly, Error, Context); - EXPECT_TRUE(ImplModule != nullptr); + ASSERT_TRUE(ImplModule != nullptr); auto *ImplFunction = ImplModule->getFunction("foo"); - EXPECT_TRUE(ImplFunction != nullptr); + ASSERT_TRUE(ImplFunction != nullptr); auto *DeclFunction = ImplModule->getFunction("bar"); - EXPECT_TRUE(DeclFunction != nullptr); + ASSERT_TRUE(DeclFunction != nullptr); ValueToValueMapTy VMap; SmallVector Returns; @@ -752,11 +753,11 @@ SMDiagnostic Error; auto ImplModule = parseAssemblyString(ImplAssembly, Error, Context); - EXPECT_TRUE(ImplModule != nullptr); + ASSERT_TRUE(ImplModule != nullptr); auto *OldFunc = ImplModule->getFunction("test"); - EXPECT_TRUE(OldFunc != nullptr); + ASSERT_TRUE(OldFunc != nullptr); auto *NewFunc = ImplModule->getFunction("cloned"); - EXPECT_TRUE(NewFunc != nullptr); + ASSERT_TRUE(NewFunc != nullptr); ValueToValueMapTy VMap; SmallVector Returns; @@ -792,18 +793,18 @@ SMDiagnostic Error; auto ImplModule = parseAssemblyString(ImplAssembly, Error, Context); - EXPECT_TRUE(ImplModule != nullptr); + ASSERT_TRUE(ImplModule != nullptr); // DICompileUnits: !2, !6. Only !2 is reachable from @foo(). EXPECT_TRUE(GetDICompileUnitCount(*ImplModule) == 2); auto* ImplFunction = ImplModule->getFunction("foo"); - EXPECT_TRUE(ImplFunction != nullptr); + ASSERT_TRUE(ImplFunction != nullptr); auto DeclModule = parseAssemblyString(DeclAssembly, Error, Context); - EXPECT_TRUE(DeclModule != nullptr); + ASSERT_TRUE(DeclModule != nullptr); // No DICompileUnits defined here. EXPECT_TRUE(GetDICompileUnitCount(*DeclModule) == 0); auto* DeclFunction = DeclModule->getFunction("foo"); - EXPECT_TRUE(DeclFunction != nullptr); + ASSERT_TRUE(DeclFunction != nullptr); ValueToValueMapTy VMap; VMap[ImplFunction] = DeclFunction; Index: llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp =================================================================== --- llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp +++ llvm/unittests/Transforms/Utils/CodeMoverUtilsTest.cpp @@ -92,6 +92,7 @@ if.third.end: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, DependenceInfo &DI) { @@ -183,6 +184,7 @@ if.sixth.end: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, DependenceInfo &DI) { @@ -243,6 +245,7 @@ if.second.end: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, DependenceInfo &DI) { @@ -313,6 +316,7 @@ if.fourth.end: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, DependenceInfo &DI) { @@ -367,6 +371,7 @@ if.third.end: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, DependenceInfo &DI) { @@ -417,6 +422,7 @@ bb: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, DependenceInfo &DI) { @@ -480,6 +486,7 @@ declare void @safecall() nounwind nosync willreturn declare void @unsafecall1() declare void @unsafecall2())"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, @@ -572,6 +579,7 @@ if.end.second: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, @@ -604,6 +612,7 @@ for.end: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, @@ -637,6 +646,7 @@ if.end.second: ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, @@ -672,6 +682,7 @@ %tmp5 = load i32, i32* %B, align 4 ; loadB3 ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "dependence", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, @@ -793,6 +804,7 @@ %tmp5 = load i32, i32* %B, align 4 ; loadB3 ret void })"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "dependence", [&](Function &F, DominatorTree &DT, PostDominatorTree &PDT, DependenceInfo &DI) { Index: llvm/unittests/Transforms/Utils/LocalTest.cpp =================================================================== --- llvm/unittests/Transforms/Utils/LocalTest.cpp +++ llvm/unittests/Transforms/Utils/LocalTest.cpp @@ -141,6 +141,7 @@ !13 = !DILocation(line: 2, column: 7, scope: !8) !14 = !DILocation(line: 3, column: 1, scope: !8) )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); auto *F = dyn_cast(GV); @@ -232,6 +233,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Eager UpdateStrategy with // both DT and PDT. resetIR(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); DomTreeUpdater DTU(*DT, PDT, DomTreeUpdater::UpdateStrategy::Eager); @@ -241,6 +243,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Eager UpdateStrategy with // DT. resetIR(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { DomTreeUpdater DTU(*DT, DomTreeUpdater::UpdateStrategy::Eager); Test(F, DTU); @@ -249,6 +252,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Eager UpdateStrategy with // PDT. resetIR(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); DomTreeUpdater DTU(PDT, DomTreeUpdater::UpdateStrategy::Eager); @@ -258,6 +262,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Lazy UpdateStrategy with // both DT and PDT. resetIR(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); DomTreeUpdater DTU(*DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy); @@ -267,6 +272,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Lazy UpdateStrategy with // PDT. resetIR(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); DomTreeUpdater DTU(PDT, DomTreeUpdater::UpdateStrategy::Lazy); @@ -275,6 +281,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Lazy UpdateStrategy with DT. resetIR(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { DomTreeUpdater DTU(*DT, DomTreeUpdater::UpdateStrategy::Lazy); Test(F, DTU); @@ -283,6 +290,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Eager UpdateStrategy with // both DT and PDT. resetIRReplaceEntry(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); DomTreeUpdater DTU(*DT, PDT, DomTreeUpdater::UpdateStrategy::Eager); @@ -292,6 +300,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Eager UpdateStrategy with // DT. resetIRReplaceEntry(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { DomTreeUpdater DTU(*DT, DomTreeUpdater::UpdateStrategy::Eager); Test(F, DTU); @@ -300,6 +309,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Eager UpdateStrategy with // PDT. resetIRReplaceEntry(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); DomTreeUpdater DTU(PDT, DomTreeUpdater::UpdateStrategy::Eager); @@ -309,6 +319,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Lazy UpdateStrategy with // both DT and PDT. resetIRReplaceEntry(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); DomTreeUpdater DTU(*DT, PDT, DomTreeUpdater::UpdateStrategy::Lazy); @@ -318,6 +329,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Lazy UpdateStrategy with // PDT. resetIRReplaceEntry(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); DomTreeUpdater DTU(PDT, DomTreeUpdater::UpdateStrategy::Lazy); @@ -326,6 +338,7 @@ // Test MergeBasicBlockIntoOnlyPred working under Lazy UpdateStrategy with DT. resetIRReplaceEntry(); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; runWithDomTree(*M, "f", [&](Function &F, DominatorTree *DT) { DomTreeUpdater DTU(*DT, DomTreeUpdater::UpdateStrategy::Lazy); Test(F, DTU); @@ -432,6 +445,7 @@ ret void } )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto CFAllTerminatorsEager = [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); @@ -516,6 +530,7 @@ !13 = !DILocation(line: 2, column: 7, scope: !8) !14 = !DILocation(line: 3, column: 1, scope: !8) )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *GV = M->getNamedValue("f"); ASSERT_TRUE(GV); @@ -606,6 +621,7 @@ !7 = !DISubroutineType(types: !2) !8 = !DILocation(line: 1, column: 1, scope: !6) )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; bool BrokenDebugInfo = true; verifyModule(*M, &errs(), &BrokenDebugInfo); @@ -702,6 +718,7 @@ !19 = !DILocation(line: 5, column: 1, scope: !6) !20 = !DILocalVariable(name: "5", scope: !6, file: !1, line: 5, type: !10) )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; bool BrokenDebugInfo = true; verifyModule(*M, &errs(), &BrokenDebugInfo); @@ -902,6 +919,7 @@ declare i1 @invokable() )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto runEager = [&](Function &F, DominatorTree *DT) { PostDominatorTree PDT = PostDominatorTree(F); @@ -942,6 +960,7 @@ ret void } )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto checkRUBlocksRetVal = [&](Function &F, DominatorTree *DT) { DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy); @@ -981,6 +1000,7 @@ ret i32 0 } )"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; Function &F = *cast(M->getNamedValue("foo")); TargetTransformInfo TTI(M->getDataLayout()); Index: llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp =================================================================== --- llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp +++ llvm/unittests/Transforms/Utils/LoopRotationUtilsTest.cpp @@ -72,6 +72,7 @@ ret i32 %deopt.val })" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("test"); DominatorTree DT(*F); @@ -143,6 +144,7 @@ ret i32 %deopt.val })" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("test_nondup"); DominatorTree DT(*F); Index: llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp =================================================================== --- llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp +++ llvm/unittests/Transforms/Utils/LoopUtilsTest.cpp @@ -68,6 +68,7 @@ "for.end:\n" " ret void\n" "}\n"); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; run(*M, "foo", [&](Function &F, DominatorTree &DT, ScalarEvolution &SE, LoopInfo &LI) { Index: llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp =================================================================== --- llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp +++ llvm/unittests/Transforms/Utils/UnrollLoopTest.cpp @@ -57,6 +57,7 @@ ret i32 0 })" ); + ASSERT_TRUE(M) << "Unable to parse the assembly string"; auto *F = M->getFunction("test"); DominatorTree DT(*F); Index: llvm/unittests/tools/llvm-exegesis/PowerPC/AnalysisTest.cpp =================================================================== --- llvm/unittests/tools/llvm-exegesis/PowerPC/AnalysisTest.cpp +++ llvm/unittests/tools/llvm-exegesis/PowerPC/AnalysisTest.cpp @@ -33,7 +33,12 @@ errs() << error << "\n"; return; } - STI.reset(TheTarget->createMCSubtargetInfo(TT, "pwr9", "")); + [&]() { + STI.reset(TheTarget->createMCSubtargetInfo(TT, "pwr9", "")); + ASSERT_TRUE(STI) << "Unable to create subtarget info"; + }(); + if (!STI) + return; // Compute the ProxResIdx of ports uses in tests. const auto &SM = STI->getSchedModel(); Index: llvm/unittests/tools/llvm-exegesis/PowerPC/TargetTest.cpp =================================================================== --- llvm/unittests/tools/llvm-exegesis/PowerPC/TargetTest.cpp +++ llvm/unittests/tools/llvm-exegesis/PowerPC/TargetTest.cpp @@ -34,10 +34,12 @@ protected: PowerPCTargetTest() : ExegesisTarget_(ExegesisTarget::lookup(Triple(kTriple))) { - EXPECT_THAT(ExegesisTarget_, NotNull()); - std::string error; - Target_ = TargetRegistry::lookupTarget(kTriple, error); - EXPECT_THAT(Target_, NotNull()); + [&]() { + ASSERT_THAT(ExegesisTarget_, NotNull()); + std::string error; + Target_ = TargetRegistry::lookupTarget(kTriple, error); + ASSERT_THAT(Target_, NotNull()); + }(); } static void SetUpTestCase() { LLVMInitializePowerPCTargetInfo(); @@ -53,6 +55,7 @@ TEST_F(PowerPCTargetTest, SetRegToConstant) { const std::unique_ptr STI( Target_->createMCSubtargetInfo(kTriple, "generic", "")); + ASSERT_TRUE(STI) << "Unable to create subtarget info"; const auto Insts = ExegesisTarget_->setRegTo(*STI, PPC::X0, APInt()); EXPECT_THAT(Insts, Not(IsEmpty())); }