[PATCH] D64233: Prepare for making SwitchInstProfUpdateWrapper strict.
Yevgeny Rouban via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 4 21:10:10 PDT 2019
yrouban created this revision.
yrouban added a reviewer: davidxl.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
This patch allows us to make the patch D64061 <https://reviews.llvm.org/D64061> a one-liner that is need to revert it easily if any failure will arise.
Basically this patch removes the test part that relates to non-strict behavior and changes the assertion to llvm_unreachable() to allow the check in release builds.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64233
Files:
llvm/lib/IR/Instructions.cpp
llvm/unittests/IR/InstructionsTest.cpp
Index: llvm/unittests/IR/InstructionsTest.cpp
===================================================================
--- llvm/unittests/IR/InstructionsTest.cpp
+++ llvm/unittests/IR/InstructionsTest.cpp
@@ -792,44 +792,6 @@
EXPECT_EQ(*SIW.getSuccessorWeight(1), 11u);
EXPECT_EQ(*SIW.getSuccessorWeight(2), 22u);
}
-
- // Make prof data invalid by adding one extra weight.
- SI->setMetadata(LLVMContext::MD_prof, MDBuilder(C).createBranchWeights(
- { 99, 11, 22, 33 })); // extra
- { // Invalid prof data makes wrapper act as if there were no prof data.
- SwitchInstProfUpdateWrapper SIW(*SI);
- ASSERT_FALSE(SIW.getSuccessorWeight(0).hasValue());
- ASSERT_FALSE(SIW.getSuccessorWeight(1).hasValue());
- ASSERT_FALSE(SIW.getSuccessorWeight(2).hasValue());
- SIW.addCase(ConstantInt::get(Int32Ty, 3), BB3.get(), 39);
- ASSERT_FALSE(SIW.getSuccessorWeight(3).hasValue()); // did not add weight 39
- }
-
- { // With added 3rd case the prof data become consistent with num of cases.
- SwitchInstProfUpdateWrapper SIW(*SI);
- EXPECT_EQ(*SIW.getSuccessorWeight(0), 99u);
- EXPECT_EQ(*SIW.getSuccessorWeight(1), 11u);
- EXPECT_EQ(*SIW.getSuccessorWeight(2), 22u);
- EXPECT_EQ(*SIW.getSuccessorWeight(3), 33u);
- }
-
- // Make prof data invalid by removing one extra weight.
- SI->setMetadata(LLVMContext::MD_prof,
- MDBuilder(C).createBranchWeights({ 99, 11, 22 })); // shorter
- { // Invalid prof data makes wrapper act as if there were no prof data.
- SwitchInstProfUpdateWrapper SIW(*SI);
- ASSERT_FALSE(SIW.getSuccessorWeight(0).hasValue());
- ASSERT_FALSE(SIW.getSuccessorWeight(1).hasValue());
- ASSERT_FALSE(SIW.getSuccessorWeight(2).hasValue());
- SIW.removeCase(SwitchInst::CaseIt(SI, 2));
- }
-
- { // With removed 3rd case the prof data become consistent with num of cases.
- SwitchInstProfUpdateWrapper SIW(*SI);
- EXPECT_EQ(*SIW.getSuccessorWeight(0), 99u);
- EXPECT_EQ(*SIW.getSuccessorWeight(1), 11u);
- EXPECT_EQ(*SIW.getSuccessorWeight(2), 22u);
- }
}
TEST(InstructionsTest, CommuteShuffleMask) {
Index: llvm/lib/IR/Instructions.cpp
===================================================================
--- llvm/lib/IR/Instructions.cpp
+++ llvm/lib/IR/Instructions.cpp
@@ -3913,9 +3913,8 @@
if (ProfileData->getNumOperands() != SI.getNumSuccessors() + 1) {
State = Invalid;
if (SwitchInstProfUpdateWrapperStrict)
- assert(false &&
- "number of prof branch_weights metadata operands corresponds to"
- " number of succesors");
+ llvm_unreachable("number of prof branch_weights metadata operands does "
+ "not correspond to number of succesors");
return;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64233.208109.patch
Type: text/x-patch
Size: 2786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190705/b35db202/attachment.bin>
More information about the llvm-commits
mailing list