[cfe-dev] Does the Integrated Assembler need Output Operands listed as Clobbered?

Jeffrey Walton via cfe-dev cfe-dev at lists.llvm.org
Sat Jan 30 10:48:11 PST 2016


We have a user reporting a crash under Apple's Clang 7.0.2. The code is:

       __asm__ volatile(
#if BOOL_X64 || BOOL_X32
    ".byte 0x48, 0x0f, 0xc7, 0xf0;\n"  // rdrand rax
#else
    ".byte 0x0f, 0xc7, 0xf0;\n"        // rdrand eax
#endif
    "setc %1; "
    : "=a" (val), "=qm" (rc)
    :
    : "cc"
        );

The byte instructions are the op-codes for the 'rdrand' instruction.
Apple Clang was late to provide them, so we have an implementation
regardless of downlevel compilers. They are also available for
downlevel GCC compilers in a hosted environment where the iron
provides a modern CPU.

The same user reports adding EAX or RAX as a clobber clears the issue.
However, when we test the Clang fix, it breaks a GCC compile, so its
not ideal.

Does Clang's Integrated Assembler need Output Operands listed as Clobbered?

Thanks in advance.



More information about the cfe-dev mailing list