intrinsic: Add black_box intrinsic#4456
Conversation
This patch implements the `black_box` intrinsic, which is used to prevent the compiler from optimizing away a piece of code. It maps to an empty volatile inline assembly block with a memory clobber and a general input constraint, matching the behavior expected by the standard library. Addresses Rust-GCC#3372 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (black_box_handler): New handler. gcc/testsuite/ChangeLog: * rust/compile/intrinsic-black-box.rs: New test. * rust/execute/intrinsic-black-box.rs: New test. Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
|
I don't think this was already available with rust 1.49 ? |
|
While This implementation follows the same "infrastructure parity" logic as the existing |
|
I'm not sure I'm following you here, black box was indeed available in 1.49 but what I meant really was "did it exist as an intrinsic yet ?". |
|
yeah , you are right . i just gazed over that file . disregard my comment . |
This patch implements the
black_boxintrinsic, which is used to prevent the compiler from optimizing away a piece of code. It maps to an empty volatile inline assembly block with a memory clobber and a general input constraint, matching the behavior expected by the standard library.Addresses #3372
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog: