[PATCH] D18514: [SystemZ] Support llvm.frameaddress/llvm.returnaddress intrinsics

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 29 10:42:12 PDT 2016


uweigand added a comment.

This implementation of `-mattr=backchain` is not quite compatible to GCC's `-mbackchain` flag: with GCC, if a function does not need any stack frame, `-mbackchain` by itself does *not* force allocation of a frame, as your patch does.  `-mbackchain` only says that *if* a frame is allocated, then the frame's back chain slot is always kept valid.  In addition, GCC keeps the back chain slot valid across `alloca` calls and other dynamic stack allocations, which your current implementation does not.  (This latter is actually a bug, not just an incompatibility.)

(Note that if a function calls `__builtin_frame_address` or `__builtin_return_address` with a nonzero frame count, then GCC does force allocation of a stack frame.  This in in turn is independent of `-mbackchain`, however.)

Now, if we actually implement `-mattr=backchain`, we should do it in a way compatible with GCC, and also enable it in clang via a `-mbackchain` command line option.  However, I'm somewhat sceptical that this is really useful.  (Note that for `__builtin_frame_address` and `__builtin_return_address` to be actually safe with larger count values, **all** of the program needs to be built with` -mbackchain` --- but this is not the case for any system-installed libraries on any current Linux distribution ...)


http://reviews.llvm.org/D18514





More information about the llvm-commits mailing list