Implement core::arch::return_address and tests#154972
Implement core::arch::return_address and tests#154972chorman0773 wants to merge 3 commits intorust-lang:mainfrom
core::arch::return_address and tests#154972Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
| let ty = self.type_ix(32); | ||
| let val = self.const_int(ty, 0); | ||
| self.call_intrinsic("llvm.returnaddress", &[], &[val]) | ||
| } |
There was a problem hiding this comment.
This can be implemented in cg_clif using fx.bcx.ins().get_return_address(fx.pointer_type).
| /// Other forms of the corresponding gcc or llvm intrinsic (which can have wildly unpredictable results or even crash at runtime) are not exposed. | ||
| #[rustc_intrinsic] | ||
| #[rustc_nounwind] | ||
| pub fn return_address<T>() -> *const T { |
There was a problem hiding this comment.
It seems the only user hard-codes T to be (). Why make it generic?
There was a problem hiding this comment.
This is to handle later switches to use Code if that's ultimately desirable later (only the use site would need to change).
There was a problem hiding this comment.
Given that this intrinsic is an implementation detail, I don't think it is worth preparing it for hypothetical future changes. It just causes unnecessary confusion now.
Wording/docs changes. Co-authored-by: Ralf Jung <post@ralfj.de>
Tracking issue: #154966
Implements libs-team#768