[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.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 22130 bytes
Desc: not available
More information about the llvm-commits