[llvm-dev] setjmp/longjmp and volatile stores, but non-volatile loads
Reid Kleckner via llvm-dev
llvm-dev at lists.llvm.org
Fri Sep 16 10:26:10 PDT 2016
On Fri, Sep 16, 2016 at 10:13 AM, Jonas Maebe via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> In our (non-C) compiler we use setjmp/longjmp to implement exception
> handling. For the initial implementation LLVM backend, I'm keeping that
> model. In order to ensure that changes performed in a try/setjmp==0
> block survive the longjmp, the changes must be done via volatile
> operations.
>
If you want to observe those volatile store updates, you're really going to
need to volatilize the load operations. In your example, LLVM does not
model the CFG edge from the longjmp to the setjmp. This leads LLVM to
conclude that the only reaching definition of 'loops' at the point of the
load in the else block is 'loops = 0'.
Volatilizing all operations on local variables is going to kill your
performance, obviously. You should really emit invoke instructions in your
frontend. You can either use your own EH personality, or the existing SjLj
EH personality, which will optimize on a correct CFG and then volatilize
all values live across exceptional edges. Then the LLVM CFG will be
correct, and you'll get pretty good code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160916/c13d1713/attachment.html>
More information about the llvm-dev
mailing list