llvm.org GIT mirror llvm / 7d99ae5
[ValueTracking] Don't delete assumes of side-effectful instructions ValueTracking has to strike a balance when attempting to propagate information backwards from assumes, because if the information is trivially propagated backwards, it can appear to LLVM that the assumption is known to be true, and therefore can be removed. This is sound (because an assumption has no semantic effect except for causing UB), but prevents the assume from allowing further optimizations. The isEphemeralValueOf check exists to try and prevent this issue by not removing the source of an assumption. This tries to make it a little bit more general to handle the case of side-effectful instructions, such as in %0 = call i1 @get_val() %1 = xor i1 %0, true call void @llvm.assume(i1 %1) Patch by Ariel Ben-Yehuda, thanks! Differential Revision: https://reviews.llvm.org/D36590 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310859 91177308-0d34-0410-b5e6-96231b3b80d8 Hal Finkel 2 years ago
2 changed file(s) with 19 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
383383 if (V == E)
384384 return true;
385385
386 EphValues.insert(V);
387 if (const User *U = dyn_cast(V))
388 for (User::const_op_iterator J = U->op_begin(), JE = U->op_end();
389 J != JE; ++J) {
390 if (isSafeToSpeculativelyExecute(*J))
391 WorkSet.push_back(*J);
392 }
386 if (V == I || isSafeToSpeculativelyExecute(V)) {
387 EphValues.insert(V);
388 if (const User *U = dyn_cast(V))
389 for (User::const_op_iterator J = U->op_begin(), JE = U->op_end();
390 J != JE; ++J)
391 WorkSet.push_back(*J);
392 }
393393 }
394394 }
395395
1717 ret i32 %t3
1818 }
1919
20
21 define void @assume_not() {
22 ; CHECK-LABEL: @assume_not(
23 entry-block:
24 %0 = call i1 @get_val()
25 ; CHECK: call void @llvm.assume
26 %1 = xor i1 %0, true
27 call void @llvm.assume(i1 %1)
28 ret void
29 }
30
31 declare i1 @get_val()
2032 declare void @llvm.assume(i1)
21