[PATCH] D11212: [SCEV] Apply NSW and NUW flags via poison value analysis

hfinkel at anl.gov hfinkel at anl.gov
Wed Jul 15 19:14:46 PDT 2015


hfinkel added a subscriber: hfinkel.
hfinkel added a comment.

In http://reviews.llvm.org/D11212#206104, @broune wrote:

> Added and used isGuaranteedToTransferExecutionToSuccessor (is there a better name?). Also slight improvement to comments.
>
> I checked all the instructions in the langref to see if any others might also not terminate. All I found is that while the langref doesn't explicitly say so, some atomics like atomicrmw do not necessarily terminate if another thread keeps interfering. Looking at the C++14 standard, some thread is guaranteed to make progress but I could not find a statement that any given thread is guaranteed to make progress, so I made isGuaranteedToTransferExecutionToSuccessor conservative on that point.


I think we'll end up needing some additional attribute to let us get the C++ semantics at the IR level, and we do want them, but we also need to support languages like Java where infinite loops are (sadly) well defined. Regarding C++, 1.10p27 says:

  The implementation may assume that any thread will eventually do one of the following:
    terminate
    make a call to a library I/O function
    access or modify a volatile object, or
    perform a synchronization operation or an atomic operation
  
   [Note: This is intended to allow compiler transformations such as removal of empty loops, even
    when termination cannot be proven. — end note ]

And, thus, when we can assume C++ semantics, any thread is guaranteed to make progress, or call some external function, or access a volatile/atomic variable.


http://reviews.llvm.org/D11212







More information about the llvm-commits mailing list