[all-commits] [llvm/llvm-project] 331468: [IR] Consider non-willreturn as side effect (PR50511)

Nikita Popov via All-commits all-commits at lists.llvm.org
Mon Jul 26 07:35:36 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 33146857e9840a92840d48bbc3483e34ea545fc7
      https://github.com/llvm/llvm-project/commit/33146857e9840a92840d48bbc3483e34ea545fc7
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-07-26 (Mon, 26 Jul 2021)

  Changed paths:
    M llvm/include/llvm/IR/Instruction.h
    M llvm/lib/Analysis/DemandedBits.cpp
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/lib/IR/Instruction.cpp
    M llvm/lib/Transforms/Scalar/ADCE.cpp
    M llvm/test/Transforms/LICM/sinking.ll
    M llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll
    M llvm/test/Transforms/SCCP/calltest.ll

  Log Message:
  -----------
  [IR] Consider non-willreturn as side effect (PR50511)

This adjusts mayHaveSideEffect() to return true for !willReturn()
instructions. Just like other side-effects, non-willreturn calls
(aka "divergence") cannot be removed and cannot be reordered relative
to other side effects. This fixes a number of bugs where
non-willreturn calls are either incorrectly dropped or moved. In
particular, it also fixes the last open problem in
https://bugs.llvm.org/show_bug.cgi?id=50511.

I performed a cursory review of all current mayHaveSideEffect()
uses, which convinced me that these are indeed the desired default
semantics. Places that do not want to consider non-willreturn as a
sideeffect generally do not want mayHaveSideEffect() semantics at
all. I identified two such cases, which are addressed by D106591
and D106742. Finally, there is a use in SCEV for which we don't
really have an appropriate API right now -- what it wants is
basically "would this be considered forward progress". I've just
spelled out the previous semantics there.

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




More information about the All-commits mailing list