On Fri, Oct 6, 2017 at 5:00 AM, Henri Sivonen <hsivo...@hsivonen.fi> wrote:
> Do we already have a C++ analog of Rust's test::black_box() function?

We do not.

> Specifically, this isn't the answer for GCC:
> void* black_box(void* foo) {
>   asm ("":"=r" (foo): "r" (foo):"memory");
>   return foo;
> }

Can you provide a slightly larger example testcase (links to
godbolt.org would be excellent) that actually uses this, so we can see
what the compiler is doing?

I think it's customary to make these sorts of asms `volatile asm` to
tell the compiler to not touch it.  I don't know how to write one for
MSVC, but I think a small variant of the above should work for GCC.

-Nathan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to