[all-commits] [llvm/llvm-project] 05f0e5: [LangRef] Clarify the semantics of branch on undef

Juneyoung Lee via All-commits all-commits at lists.llvm.org
Sun Mar 29 19:41:53 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 05f0e598ab265a80fedb23225cde4176f11774ac
      https://github.com/llvm/llvm-project/commit/05f0e598ab265a80fedb23225cde4176f11774ac
  Author: Juneyoung Lee <aqjune at gmail.com>
  Date:   2020-03-30 (Mon, 30 Mar 2020)

  Changed paths:
    M llvm/docs/LangRef.rst

  Log Message:
  -----------
  [LangRef] Clarify the semantics of branch on undef

Summary:
This patch clarifies the semantics of branching on undef value.

Defining `br undef` as undefined behavior explains optimizations that use branch conditions, such as CVP (D76931) and GVN (propagateEquality).

For `switch cond`, it is defined to raise UB if cond is an expression containing undef && cond is not frozen &&
it may yield different values.
This allows that at the destination block the branch condition can be assumed to be frozen already (otherwise UB was already triggered).
This condition is slightly stricter than MemorySanitizer, which allows undef-y condition if it always leads to the same destination,
but it does not break MemorySanitizer because we are giving stricter constraint.

Reviewers: efriedma, fhahn, nikic, spatel, jdoerfert, nlopes

Reviewed By: nlopes

Subscribers: regehr, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76973




More information about the All-commits mailing list