Help !! Problem about Intrinsic::returnaddress and optimization

Hi all,

I want to add some functionalities to Stack protection of llvm by
modifying the file StackPrtoector.cpp under llvm/src/lib/CodeGen.
However, I encounter some problems here.

Here is my problem:

I want to call the function Intrinsic::returnaddress with the same
parameter twice in a function. However, llvm will optimize this
process automatically by storing the result from the first call in the
local stack, then use this value for the second call instead of
calling the function again. However, I do want this function to be
called twice exactly without being optimized (I do want it behaves
this way even though optimization flags are used during compilation).
Is that possible? How can I do?

Thank you
Best wishes,

Hi Ying,

Have you tried making the variable you're using 'volatile'? (I don't know if this will help, but...)