llvm.org GIT mirror llvm / 408158e
[BDCE] reduce scope of an assert (PR34179) The assert was added with r310779 and is usually correct, but as the test shows, not always. The 'volatile' on the load is needed to expose the faulty path because without it, DemandedBits would return that the load is just dead rather than not demanded, and so we wouldn't hit the bogus assert. Also, since the lambda is just a single-line now, get rid of it and inline the DB.isAllOnesValue() calls. This should fix (prevent execution of a faulty assert): https://bugs.llvm.org/show_bug.cgi?id=34179 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310842 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 2 years ago
2 changed file(s) with 21 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
3939 /// instruction may need to be cleared of assumptions that can no longer be
4040 /// guaranteed correct.
4141 static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB) {
42 // Any value we're trivializing should be an integer value, and moreover,
43 // any conversion between an integer value and a non-integer value should
44 // demand all of the bits. This will cause us to stop looking down the
45 // use/def chain, so we should only see integer-typed instructions here.
46 auto isExternallyVisible = [](Instruction *I, DemandedBits &DB) {
47 assert(I->getType()->isIntegerTy() && "Trivializing a non-integer value?");
48 return DB.getDemandedBits(I).isAllOnesValue();
49 };
42 assert(I->getType()->isIntegerTy() && "Trivializing a non-integer value?");
5043
5144 // Initialize the worklist with eligible direct users.
5245 SmallVector WorkList;
5346 for (User *JU : I->users()) {
47 // If all bits of a user are demanded, then we know that nothing below that
48 // in the def-use chain needs to be changed.
5449 auto *J = dyn_cast(JU);
55 if (J && !isExternallyVisible(J, DB))
50 if (J && !DB.getDemandedBits(J).isAllOnesValue())
5651 WorkList.push_back(J);
5752 }
5853
7166 Visited.insert(J);
7267
7368 for (User *KU : J->users()) {
69 // If all bits of a user are demanded, then we know that nothing below
70 // that in the def-use chain needs to be changed.
7471 auto *K = dyn_cast(KU);
75 if (K && !Visited.count(K) && !isExternallyVisible(K, DB))
72 if (K && !Visited.count(K) && !DB.getDemandedBits(K).isAllOnesValue())
7673 WorkList.push_back(K);
7774 }
7875 }
8383 ret i1 %mul
8484 }
8585
86
87 ; We were asserting that all users of a trivialized integer-type instruction were
88 ; also integer-typed, but that's too strong. The alloca has a pointer-type result.
89
90 define void @PR34179(i32* %a) {
91 ; CHECK-LABEL: @PR34179(
92 ; CHECK-NEXT: [[T0:%.*]] = load volatile i32, i32* %a
93 ; CHECK-NEXT: ret void
94 ;
95 %t0 = load volatile i32, i32* %a
96 %vla = alloca i32, i32 %t0
97 ret void
98 }
99