[all-commits] [llvm/llvm-project] 830cf3: [LVI][ValueTracking] Take UB-implying attributes i...

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Tue Apr 29 20:53:59 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 830cf36bd4c491ef28d9bba74737e324639bb4cd
      https://github.com/llvm/llvm-project/commit/830cf36bd4c491ef28d9bba74737e324639bb4cd
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2025-04-30 (Wed, 30 Apr 2025)

  Changed paths:
    M llvm/include/llvm/Analysis/ValueTracking.h
    M llvm/include/llvm/IR/Instruction.h
    M llvm/lib/Analysis/LazyValueInfo.cpp
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/lib/IR/Instruction.cpp
    A llvm/test/Transforms/CorrelatedValuePropagation/pr137582.ll

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list