[PATCH] D38336: Add an @llvm.sideeffect intrinsic

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 08:15:27 PDT 2017


sunfish updated this revision to Diff 117135.
sunfish added a comment.

This update revises the documentation to clarify that the intrinsic doesn't inherently prevent loops from being optimized away.

In https://reviews.llvm.org/D38336#884104, @dberlin wrote:

> In https://reviews.llvm.org/D38336#882970, @sunfish wrote:
>
> > If it supports C++, ADCE needs to preserve calls to a library I/O functions, volatile operations, thread synchronizations, and atomic operations, and calls to functions which may perform any of these. Whatever it does to handle those should handle llvm.sideeffect as well.
>
>
> This seems pretty incongruous to me with your answers to my earlier questions, so i feel like i'm missing something.


The basic idea of llvm.sideeffect is to just be a thing that gets treated like it has side effects. It's just like a volatile store through a non-escaped memory address.

I may have been unclear when you asked <https://reviews.llvm.org/D38336#882813>

> Do you expect it to keep provably finite loops that have it alive.
>  IE a loop where we can prove the backedge is not taken?

and I said <https://reviews.llvm.org/D38336#882864>

> No; a backedge can still be folded away in the normal ways. The llvm.sideeffect call would remain, no longer needed, but not invalid. If it were important, we could add code to remove it in that case, but the patch here doesn't have that.

I interpreted your question to be just about loops where we can prove the backedge is not taken. llvm.sideeffect does keep finite loops alive under the same conditions that other operations with side effects would.

In the future, we may want to optimize away redundant llvm.sideeffect calls, and an advanced form of this could allow optimizing away provably-finite loops containing llvm.sideeffect, however, the current patch doesn't depend on this.


Repository:
  rL LLVM

https://reviews.llvm.org/D38336

Files:
  docs/LangRef.rst
  include/llvm/Analysis/TargetTransformInfoImpl.h
  include/llvm/CodeGen/BasicTTIImpl.h
  include/llvm/IR/Intrinsics.td
  lib/Analysis/AliasSetTracker.cpp
  lib/Analysis/ValueTracking.cpp
  lib/Analysis/VectorUtils.cpp
  lib/CodeGen/SelectionDAG/FastISel.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/Transforms/Scalar/EarlyCSE.cpp
  lib/Transforms/Scalar/GVNHoist.cpp
  lib/Transforms/Utils/Evaluator.cpp
  lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
  lib/Transforms/Vectorize/LoopVectorize.cpp
  lib/Transforms/Vectorize/SLPVectorizer.cpp
  test/CodeGen/Generic/intrinsics.ll
  test/Transforms/DCE/int_sideeffect.ll
  test/Transforms/DeadStoreElimination/int_sideeffect.ll
  test/Transforms/EarlyCSE/int_sideeffect.ll
  test/Transforms/FunctionAttrs/int_sideeffect.ll
  test/Transforms/GVN/int_sideeffect.ll
  test/Transforms/GVNHoist/int_sideeffect.ll
  test/Transforms/GVNSink/int_sideeffect.ll
  test/Transforms/GlobalOpt/int_sideeffect.ll
  test/Transforms/InstCombine/int_sideeffect.ll
  test/Transforms/LICM/int_sideeffect.ll
  test/Transforms/LoadStoreVectorizer/int_sideeffect.ll
  test/Transforms/LoopIdiom/int_sideeffect.ll
  test/Transforms/LoopVectorize/int_sideeffect.ll
  test/Transforms/NewGVN/int_sideeffect.ll
  test/Transforms/SLPVectorizer/int_sideeffect.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38336.117135.patch
Type: text/x-patch
Size: 22130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170929/ff5144f7/attachment.bin>


More information about the llvm-commits mailing list