This is more of an RFC than for committing (hence the post to
llvmdev) but I'd like to have some opinions on these improvements
to IntrinsicLowering before I go ahead and implement the rest of
the intrinsics.
My main motivation for the single-thread lowering is to be able to run
code that uses these intrinsics in the KLEE symbolic execution engine
but I imagine it could have other uses such as a whole-program LTO
that lowers atomic operations to more efficient non-atomic operations
when it is known to be safe to do so.
The LowerIntrinsicCall method would need to be refactored into
multiple methods I think, but I'm not sure about the granularity.
Do we need more than standard and single-thread?
My main motivation for the single-thread lowering is to be able to run
code that uses these intrinsics in the KLEE symbolic execution engine
but I imagine it could have other uses such as a whole-program LTO
that lowers atomic operations to more efficient non-atomic operations
when it is known to be safe to do so.
instead, how about writing an LLVM IR pass that turns atomic intrinsics into
non-atomic equivalent LLVM IR? Finally, I guess even "single threaded" code
may have a use for some atomic operations if it makes use of signal handlers.
> My main motivation for the single-thread lowering is to be able to run
> code that uses these intrinsics in the KLEE symbolic execution engine
> but I imagine it could have other uses such as a whole-program LTO
> that lowers atomic operations to more efficient non-atomic operations
> when it is known to be safe to do so.
instead, how about writing an LLVM IR pass that turns atomic intrinsics into
non-atomic equivalent LLVM IR?
Yes, that seems more sensible. I refactored the lowering into a pass
and added the remaining intrinsics (see attached patch). I'll commit
this if approved.
I wonder if IntrinsicLowering should also be made into a pass, for
consistency with the other lowering passes.
Finally, I guess even "single threaded" code
may have a use for some atomic operations if it makes use of signal handlers.
Yes, good point. Perhaps "non-preemptible" is better terminology
which is what I used in the new patch.