diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2025-04-30 11:53:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-30 11:53:38 +0800 |
commit | 830cf36bd4c491ef28d9bba74737e324639bb4cd (patch) | |
tree | 17fecbe6ab0f5223fb572a9a243b2ecbd22666e2 /llvm/lib/Analysis/LazyValueInfo.cpp | |
parent | 4075a3698a3fdda3a77ce2456e3bfefbc0f0c56e (diff) | |
download | llvm-830cf36bd4c491ef28d9bba74737e324639bb4cd.zip llvm-830cf36bd4c491ef28d9bba74737e324639bb4cd.tar.gz llvm-830cf36bd4c491ef28d9bba74737e324639bb4cd.tar.bz2 |
[LVI][ValueTracking] Take UB-implying attributes into account in `isSafeToSpeculativelyExecute` (#137604)
Closes https://github.com/llvm/llvm-project/issues/137582.
In the original case, LVI uses the edge information in `%entry ->
%if.end` to get a more precise result. However, since the call to `smin`
has an `noundef` return attribute, an immediate UB will be triggered
after optimization.
Currently, `isSafeToSpeculativelyExecuteWithOpcode(%min)` returns true
because
https://github.com/llvm/llvm-project/commit/6a288c1e32351d4be3b7630841af078fa1c3bb8b
only checks whether the function is speculatable. However, it is not
enough in this case.
This patch takes UB-implying attributes into account if
`IgnoreUBImplyingAttrs` is set to false. If it is set to true, the
caller is responsible for correctly propagating UB-implying attributes.
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/LazyValueInfo.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index e49e004..2a56248 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -1701,7 +1701,8 @@ ValueLatticeElement LazyValueInfoImpl::getValueAtUse(const Use &U) { // of a cycle, we might end up reasoning about values from different cycle // iterations (PR60629). if (!CurrI->hasOneUse() || - !isSafeToSpeculativelyExecuteWithVariableReplaced(CurrI)) + !isSafeToSpeculativelyExecuteWithVariableReplaced( + CurrI, /*IgnoreUBImplyingAttrs=*/false)) break; CurrU = &*CurrI->use_begin(); } |