[LLVMdev] MallocInst/CallInst bitcast,

srs skaflotten at gmail.com
Fri Oct 16 13:58:21 PDT 2009


Daniel Waterworth skrev:
> Thanks very much. I only have one more question, (hopefully), which 
> is, is there a better way of finding the direction of stack growth 
> other than:
>
> static bool StackCmp(void *ptr) {
>   volatile int a;
>   return (void *)&a > ptr;
> }
>
> bool FindStackDirection() {
>   volatile int a;
>   return StackCmp((void *)&a);
> }
>
> Preferably one which isn't destroyed by optimization.

I suggest you turn the scalars into arrays and make the ptr argument 
volatile as well.

Other ways: If you are careful with tail recursion eliminiation, you can 
compare local var addresses from different recursive calls. I believe 
there are va_arg based approaches as well.

That said, there is no truly portable way.

/Stein Roger



More information about the llvm-dev mailing list