Displaying 2 results from an estimated 2 matches for "stack_direct".
2019 Jun 25
2
Optimised stack direction?
Why does LLVM struggle to optimize the following stack direction check?
#include <stdint.h>
inline int stack_direction() {
int x = 0;
int y = 0;
return uintptr_t(&x) < uintptr_t(&y);
}
int main(int argc, const char * argv[]) {
return stack_direction();
}
It generates the following assembly:
main: # @main
lea rcx, [rsp - 8]
lea rdx, [rsp - 4]
xor eax, eax
cmp rdx, rcx
setb al...
2019 Jun 25
3
Optimised stack direction?
On Tue, 25 Jun 2019 at 13:22, Tim Northover <t.p.northover at gmail.com> wrote:
> The only way I can think of to reliably detect the direction is using
> an __attribute__((noinline)) function to compare locals from two
> different, nested frames (even that's iffy though on a semantic
> level). If there turned out to be a compelling enough use-case, an
> intrinsic could be