[llvm-dev] setjmp in llvm

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Fri Jun 2 19:21:33 PDT 2017

(Adding the list back in, especially as other people have taken an
interest in really immobile intrinsics before).

On 2 June 2017 at 18:33, Wael Yehia <wmyehia2001 at yahoo.com> wrote:
> Thank you Tim. The C spec never stops enlightening me with new quirks.
> Out of curiousity, did you know about this or grep'ed the spec for setjmp?

I've got a standing interest in both threading (a canonical place
where volatile is definitely not what you want) and OS programming
(the extra 0.5 where it is, for memory mapped I/O) so I've read lots
and lots about it. The final standards-blessed use is for reading
variables in a signal handler.

> BTW, how confident are you about the statement you made:
>  "This is pretty much impossible in LLVM if you mean instructions LLVM
>    considers side-effect free (e.g. a simple "add")."
> Because I was tempted for a while to just ask the community about it, after having
> spent few weeks experimenting, with a hope that there's a way to actually prevent
> all instructions (including the side-effect free ones) from moving across calls.

Pretty sure, I'm afraid. Even the strongest property, HasSideEffects
which is basically a "this does stuff you don't understand"
instruction to LLVM doesn't prevent that kind of code motion. Because
even though the intrinsic might do things LLVM doesn't understand,
"add" doesn't.



More information about the llvm-dev mailing list