Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AddressOfReturnAddress-like intrinsic #60854

Closed
MauriceKayser opened this issue May 15, 2019 · 2 comments
Closed

Add AddressOfReturnAddress-like intrinsic #60854

MauriceKayser opened this issue May 15, 2019 · 2 comments

Comments

@MauriceKayser
Copy link

Would it be possible to add an intrinsic that provides the address of the memory location that holds the return address of the current function? Microsoft has one for C/C++ _AddressOfReturnAddress.

I could really use it for low level matters, but do not know enough about the compiler intrinsics to add a pull request myself.

@nagisa
Copy link
Member

nagisa commented May 15, 2019

I don’t think that is feasible – the return address location is not addressable on all targets rust supports. However if you only support x86 and aarch64 targets, you can link to the llvm.addressofreturnaddress intrinsic directly without necessarily needing support from rustc.

@MauriceKayser
Copy link
Author

MauriceKayser commented May 16, 2019

That sounds reasonable. I found this pull request that temporarily added the return_address intrinsic, but I can not see any connection to the llvm.returnaddress intrinsic in the added lines. @nagisa could you lead me to an example how I could use the llvm.addressofreturnaddress intrinsic in my code without modifying rustc? I also don't really understand this out pointer restriction, but maybe I will if I look at the resulting assembly output..

edit: I found this example that seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants